ReactOS 0.4.16-dev-289-g096a551
main.c File Reference
#include "rosdraw.h"
Include dependency graph for main.c:

Go to the source code of this file.

Classes

struct  DirectDrawEnumerateProcData
 

Functions

BOOL CALLBACK TranslateCallbackA (GUID *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
 
HRESULT WINAPI DirectDrawCreateClipper (DWORD dwFlags, LPDIRECTDRAWCLIPPER *lplpDDClipper, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI DirectDrawCreate (LPGUID lpGUID, LPDIRECTDRAW *lplpDD, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI DirectDrawCreateEx (LPGUID lpGUID, LPVOID *lplpDD, REFIID id, LPUNKNOWN pUnkOuter)
 
HRESULT WINAPI DirectDrawEnumerateA (LPDDENUMCALLBACKA lpCallback, LPVOID lpContext)
 
HRESULT WINAPI DirectDrawEnumerateExA (LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
 
HRESULT WINAPI DirectDrawEnumerateW (LPDDENUMCALLBACKW lpCallback, LPVOID lpContext)
 
HRESULT WINAPI DirectDrawEnumerateExW (LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags)
 
HRESULT WINAPI D3DParseUnknownCommand (LPVOID lpCmd, LPVOID *lpRetCmd)
 
VOID WINAPI AcquireDDThreadLock ()
 
VOID WINAPI ReleaseDDThreadLock ()
 
BOOL APIENTRY DllMain (HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
 

Variables

HMODULE hDllModule = 0
 
CRITICAL_SECTION ddcs
 

Function Documentation

◆ AcquireDDThreadLock()

VOID WINAPI AcquireDDThreadLock ( )

Definition at line 412 of file main.c.

413{
415
417}
CRITICAL_SECTION ddcs
Definition: main.c:14
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)

Referenced by DirectDrawPalette_Release(), Main_DDrawSurface_Release(), Main_DirectDraw_AddRef(), Main_DirectDraw_Compact(), and Main_DirectDraw_Release().

◆ D3DParseUnknownCommand()

HRESULT WINAPI D3DParseUnknownCommand ( LPVOID  lpCmd,
LPVOID lpRetCmd 
)

Definition at line 357 of file main.c.

359{
360 DWORD retCode = DD_OK;
361 LPD3DHAL_DP2COMMAND dp2command = lpCmd;
362
364
365 /* prevent it crash if null pointer are being sent */
366 if ( (lpCmd == NULL) || (lpRetCmd == NULL) )
367 {
368 return E_FAIL;
369 }
370
371 *lpRetCmd = lpCmd;
372
373 switch (dp2command->bCommand)
374 {
375 /* check for valid command, only 3 commands are valid */
377 *(PBYTE)lpRetCmd += ((dp2command->wStateCount * sizeof(D3DHAL_DP2VIEWPORTINFO)) + sizeof(D3DHAL_DP2COMMAND));
378 break;
379
380 case D3DDP2OP_WINFO:
381 *(PBYTE)lpRetCmd += (dp2command->wStateCount * sizeof(D3DHAL_DP2WINFO)) + sizeof(D3DHAL_DP2COMMAND);
382 break;
383
384 case 0x0d: /* Undocumented in MSDN */
385 *(PBYTE)lpRetCmd += ((dp2command->wStateCount * dp2command->bReserved) + sizeof(D3DHAL_DP2COMMAND));
386 break;
387
388
389 /* set the error code */
390 default:
391
392 if ( (dp2command->bCommand <= D3DDP2OP_INDEXEDTRIANGLELIST) || // dp2command->bCommand <= with 0 to 3
393 (dp2command->bCommand == D3DDP2OP_RENDERSTATE) || // dp2command->bCommand == with 8
394 (dp2command->bCommand >= D3DDP2OP_LINELIST) ) // dp2command->bCommand >= with 15 to 255
395 {
396 /* set error code for command 0 to 3, 8 and 15 to 255 */
397 retCode = DDERR_INVALIDPARAMS;
398 }
399 else
400 { /* set error code for 4 - 7, 9 - 12, 14 */
401 retCode = D3DERR_COMMAND_UNPARSED;
402 }
403
404 }
405
406 return retCode;
407}
#define D3DERR_COMMAND_UNPARSED
Definition: d3dhal.h:49
struct _D3DHAL_DP2COMMAND D3DHAL_DP2COMMAND
@ D3DDP2OP_WINFO
Definition: d3dhal.h:350
@ D3DDP2OP_RENDERSTATE
Definition: d3dhal.h:335
@ D3DDP2OP_INDEXEDTRIANGLELIST
Definition: d3dhal.h:334
@ D3DDP2OP_LINELIST
Definition: d3dhal.h:336
@ D3DDP2OP_VIEWPORTINFO
Definition: d3dhal.h:349
#define E_FAIL
Definition: ddrawi.h:102
#define NULL
Definition: types.h:112
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE * PBYTE
Definition: pedump.c:66
#define DD_OK
Definition: ddraw.h:186
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

Referenced by BuildReturnCode().

◆ DirectDrawCreate()

HRESULT WINAPI DirectDrawCreate ( LPGUID  lpGUID,
LPDIRECTDRAW lplpDD,
LPUNKNOWN  pUnkOuter 
)

Definition at line 86 of file main.c.

89{
90 HRESULT retVal = DDERR_GENERIC;
91 /*
92 remove this when UML diagram is in place
93 this api is finished and is working as it should
94 */
95
98 {
99 /* check if pUnkOuter is null or not */
100 if (pUnkOuter)
101 {
102 retVal = CLASS_E_NOAGGREGATION;
103 }
104 else
105 {
106 retVal = Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, &IID_IDirectDraw, FALSE);
107 }
108 }
110 {
111 }
112 _SEH2_END;
113
114 return retVal;
115}
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
HRESULT WINAPI Create_DirectDraw(LPGUID pGUID, LPDIRECTDRAW *pIface, REFIID id, BOOL ex)
Definition: startup.c:20
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
#define DDERR_GENERIC
Definition: ddraw.h:72
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662

Referenced by create_directdraw(), d3drm1_CreateDeviceFromClipper(), d3drm3_CreateDeviceFromClipper(), DDOffscreenBufferTest(), DDPrimarySurfaceTest(), test_create_device_from_clipper1(), test_create_device_from_clipper2(), test_create_device_from_clipper3(), test_create_device_from_d3d1(), test_create_device_from_d3d2(), test_create_device_from_d3d3(), test_create_device_from_surface1(), test_create_device_from_surface2(), test_create_device_from_surface3(), test_create_texture_from_surface(), Test_CreateDDraw(), test_viewport_clear1(), and test_viewport_clear2().

◆ DirectDrawCreateClipper()

HRESULT WINAPI DirectDrawCreateClipper ( DWORD  dwFlags,
LPDIRECTDRAWCLIPPER lplpDDClipper,
LPUNKNOWN  pUnkOuter 
)

Definition at line 55 of file main.c.

57{
59
60 return Main_DirectDraw_CreateClipper(NULL, dwFlags, lplpDDClipper, pUnkOuter);
61}
HRESULT WINAPI Main_DirectDraw_CreateClipper(LPDDRAWI_DIRECTDRAW_INT This, DWORD dwFlags, LPDIRECTDRAWCLIPPER *ppClipper, IUnknown *pUnkOuter)
Definition: ddraw_stubs.c:17
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176

Referenced by CF_CreateDirectDrawClipper(), test_create_device_from_clipper1(), test_create_device_from_clipper2(), test_create_device_from_clipper3(), test_Device(), test_device_qi(), test_Viewport(), and test_viewport_qi().

◆ DirectDrawCreateEx()

HRESULT WINAPI DirectDrawCreateEx ( LPGUID  lpGUID,
LPVOID lplpDD,
REFIID  id,
LPUNKNOWN  pUnkOuter 
)

Definition at line 139 of file main.c.

143{
144 HRESULT retVal = DDERR_GENERIC;
145 /*
146 remove this when UML diagram is in place
147 this api is finished and is working as it should
148 */
150
152 {
153 /* check see if pUnkOuter is null or not */
154 if (pUnkOuter)
155 {
156 /* we are using same error code as MS*/
157 retVal = CLASS_E_NOAGGREGATION;
158 }/* Is it a DirectDraw 7 Request or not */
159 else if (!IsEqualGUID(id, &IID_IDirectDraw7))
160 {
161 retVal = DDERR_INVALIDPARAMS;
162 }
163 else
164 {
165 retVal = Create_DirectDraw (lpGUID, (LPDIRECTDRAW*)lplpDD, id, FALSE);
166 }
167
168 /* Create our DirectDraw interface */
169 }
171 {
172 }
173 _SEH2_END;
174
175 return retVal;
176}
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147

Referenced by CreateSurface(), DirectDrawMediaStreamImpl_IDirectDrawMediaStream_GetDirectDraw(), fill_display_information_fallback(), get_texture_memory(), Test_CreateDDraw(), Test_CreateSurface(), Test_DisplayModes(), Test_GetAvailableVidMem(), Test_GetDeviceIdentifier(), Test_GetFourCCCodes(), Test_GetMonitorFrequency(), and Test_SetCooperativeLevel().

◆ DirectDrawEnumerateA()

HRESULT WINAPI DirectDrawEnumerateA ( LPDDENUMCALLBACKA  lpCallback,
LPVOID  lpContext 
)

Definition at line 180 of file main.c.

182{
183 HRESULT retValue;
185
187
188 epd.lpCallback = (LPVOID) lpCallback;
189 epd.lpContext = lpContext;
190
191 if (!IsBadCodePtr((LPVOID)lpCallback))
192 {
193 return DirectDrawEnumerateExA((LPDDENUMCALLBACKEXA)TranslateCallbackA, &epd, DDENUM_NONDISPLAYDEVICES);
194 }
195 else
196 {
197 retValue = DDERR_INVALIDPARAMS;
198 }
199 return retValue;
200}
BOOL CALLBACK TranslateCallbackA(GUID *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
Definition: main.c:26
HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
Definition: main.c:208
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:872
#define LPVOID
Definition: nt_native.h:45
#define DDENUM_NONDISPLAYDEVICES
Definition: ddraw.h:193

◆ DirectDrawEnumerateExA()

HRESULT WINAPI DirectDrawEnumerateExA ( LPDDENUMCALLBACKEXA  lpCallback,
LPVOID  lpContext,
DWORD  dwFlags 
)

Definition at line 208 of file main.c.

211{
212 HKEY hKey;
213 DWORD cbData = 0;
214 DWORD Value = 0;
215 LONG rc;
216 BOOL EnumerateAttachedSecondaries = FALSE;
217 DWORD privateDWFlags = 0;
218 CHAR strMsg[RC_STRING_MAX_SIZE];
220
222
223 if ((IsBadCodePtr((LPVOID)lpCallback) == 0) &&
227 {
229
231 if (rc == ERROR_SUCCESS)
232 {
233 /* Enumerate Attached Secondaries */
234 cbData = sizeof(DWORD);
235 rc = RegQueryValueExA(hKey, "EnumerateAttachedSecondaries", NULL, NULL, (LPBYTE)&Value, &cbData);
236 if (rc == ERROR_SUCCESS)
237 {
238 if (Value != 0)
239 {
240 EnumerateAttachedSecondaries = TRUE;
241 privateDWFlags = DDENUM_ATTACHEDSECONDARYDEVICES;
242 }
243 }
245 }
246
247 /* Call the user supplied callback function */
248 rc = lpCallback(NULL, strMsg, "display", lpContext, NULL);
249
250 /* If the callback function returns DDENUMRET_CANCEL, we will stop enumerating devices */
251 if(rc == DDENUMRET_CANCEL)
252 {
253 retVal = DD_OK;
254 }
255 else
256 {
257 // not finished
258 retVal = DDERR_UNSUPPORTED;
259 }
260 }
261
262 return retVal;
263}
#define RC_STRING_MAX_SIZE
Definition: resource.h:3
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
HMODULE hDllModule
Definition: main.c:12
#define STR_PRIMARY_DISPLAY
Definition: resource.h:5
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3234
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4009
unsigned int BOOL
Definition: ntddk_ex.h:94
FxAutoRegKey hKey
#define DWORD
Definition: nt_native.h:44
long LONG
Definition: pedump.c:60
#define REGSTR_PATH_DDHW
Definition: ddraw.h:197
#define DDENUMRET_CANCEL
Definition: ddraw.h:188
#define DDENUM_ATTACHEDSECONDARYDEVICES
Definition: ddraw.h:191
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDENUM_DETACHEDSECONDARYDEVICES
Definition: ddraw.h:192
unsigned char * LPBYTE
Definition: typedefs.h:53
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Definition: wdfregistry.h:413
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
char * LPSTR
Definition: xmlstorage.h:182
char CHAR
Definition: xmlstorage.h:175

Referenced by DirectDrawEnumerateA().

◆ DirectDrawEnumerateExW()

HRESULT WINAPI DirectDrawEnumerateExW ( LPDDENUMCALLBACKEXW  lpCallback,
LPVOID  lpContext,
DWORD  dwFlags 
)

Definition at line 277 of file main.c.

280{
282
283 return DDERR_UNSUPPORTED;
284}

◆ DirectDrawEnumerateW()

HRESULT WINAPI DirectDrawEnumerateW ( LPDDENUMCALLBACKW  lpCallback,
LPVOID  lpContext 
)

Definition at line 267 of file main.c.

269{
271
272 return DDERR_UNSUPPORTED;
273}

◆ DllMain()

BOOL APIENTRY DllMain ( HMODULE  hModule,
DWORD  ul_reason_for_call,
LPVOID  lpReserved 
)

Definition at line 430 of file main.c.

431{
432
434
436
437
438 switch(ul_reason_for_call)
439 {
442 break;
443
449 break;
450
451 default:
452 break;
453 }
454
455 return TRUE;
456}
HMODULE hModule
Definition: animate.c:44
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)

◆ ReleaseDDThreadLock()

◆ TranslateCallbackA()

BOOL CALLBACK TranslateCallbackA ( GUID lpGUID,
LPSTR  lpDriverDescription,
LPSTR  lpDriverName,
LPVOID  lpContext,
HMONITOR  hm 
)

Definition at line 26 of file main.c.

31{
33 return ((LPDDENUMCALLBACKA) pEPD->lpCallback)(lpGUID, lpDriverDescription, lpDriverName, pEPD->lpContext);
34}

Referenced by DirectDrawEnumerateA().

Variable Documentation

◆ ddcs

◆ hDllModule

HMODULE hDllModule = 0

Definition at line 12 of file main.c.

Referenced by DirectDrawEnumerateExA(), and DllMain().