ReactOS  0.4.14-dev-317-g96040ec
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 {
414  DX_WINDBG_trace();
415 
417 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
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 
363  DX_WINDBG_trace();
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 DX_WINDBG_trace()
Definition: rosdraw.h:262
struct _D3DHAL_DP2COMMAND D3DHAL_DP2COMMAND
#define E_FAIL
Definition: ddrawi.h:102
#define DD_OK
Definition: ddraw.h:186
smooth NULL
Definition: ftsmooth.c:416
#define D3DERR_COMMAND_UNPARSED
Definition: d3dhal.h:49
unsigned long DWORD
Definition: ntddk_ex.h:95
BYTE * PBYTE
Definition: pedump.c:66
#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 
97  _SEH2_TRY
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 DX_WINDBG_trace()
Definition: rosdraw.h:262
_SEH2_TRY
Definition: create.c:4250
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HRESULT WINAPI Create_DirectDraw(LPGUID pGUID, LPDIRECTDRAW *pIface, REFIID id, BOOL ex)
Definition: startup.c:20
#define DDERR_GENERIC
Definition: ddraw.h:72
LONG HRESULT
Definition: typedefs.h:77
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
_SEH2_END
Definition: create.c:4424
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6

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 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
smooth NULL
Definition: ftsmooth.c:416
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:1175

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  */
149  DX_WINDBG_trace();
150 
151  _SEH2_TRY
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 DX_WINDBG_trace()
Definition: rosdraw.h:262
_SEH2_TRY
Definition: create.c:4250
struct IDirectDraw * LPDIRECTDRAW
Definition: ddraw.h:710
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
HRESULT WINAPI Create_DirectDraw(LPGUID pGUID, LPDIRECTDRAW *pIface, REFIID id, BOOL ex)
Definition: startup.c:20
#define DDERR_GENERIC
Definition: ddraw.h:72
LONG HRESULT
Definition: typedefs.h:77
#define CLASS_E_NOAGGREGATION
Definition: winerror.h:2662
_SEH2_END
Definition: create.c:4424
BOOL WINAPI IsEqualGUID(REFGUID rguid1, REFGUID rguid2)
Definition: compobj.c:4112
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

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 
186  DX_WINDBG_trace();
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 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDENUM_NONDISPLAYDEVICES
Definition: ddraw.h:193
BOOL CALLBACK TranslateCallbackA(GUID *lpGUID, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hm)
Definition: main.c:26
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:874
LONG HRESULT
Definition: typedefs.h:77
#define LPVOID
Definition: nt_native.h:45
HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
Definition: main.c:208
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79

◆ 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];
219  HRESULT retVal = DDERR_INVALIDPARAMS;
220 
221  DX_WINDBG_trace();
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  }
244  RegCloseKey(hKey);
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 }
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDENUM_NONDISPLAYDEVICES
Definition: ddraw.h:193
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
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:4023
#define STR_PRIMARY_DISPLAY
Definition: resource.h:5
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127
#define DDENUMRET_CANCEL
Definition: ddraw.h:188
char CHAR
Definition: xmlstorage.h:175
int WINAPI LoadStringA(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPSTR lpBuffer, _In_ int cchBufferMax)
#define DDENUM_DETACHEDSECONDARYDEVICES
Definition: ddraw.h:192
char * LPSTR
Definition: xmlstorage.h:182
#define DWORD
Definition: nt_native.h:44
BOOL NTAPI IsBadCodePtr(FARPROC lpfn)
Definition: except.c:874
#define DD_OK
Definition: ddraw.h:186
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
HMODULE hDllModule
Definition: main.c:12
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
#define REGSTR_PATH_DDHW
Definition: ddraw.h:197
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1175
#define DDENUM_ATTACHEDSECONDARYDEVICES
Definition: ddraw.h:191
#define DDERR_INVALIDPARAMS
Definition: ddraw.h:79
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define RC_STRING_MAX_SIZE
Definition: resource.h:3

Referenced by DirectDrawEnumerateA().

◆ DirectDrawEnumerateExW()

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

Definition at line 277 of file main.c.

280 {
281  DX_WINDBG_trace();
282 
283  return DDERR_UNSUPPORTED;
284 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127

◆ DirectDrawEnumerateW()

HRESULT WINAPI DirectDrawEnumerateW ( LPDDENUMCALLBACKW  lpCallback,
LPVOID  lpContext 
)

Definition at line 267 of file main.c.

269 {
270  DX_WINDBG_trace();
271 
272  return DDERR_UNSUPPORTED;
273 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
#define DDERR_UNSUPPORTED
Definition: ddraw.h:127

◆ DllMain()

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

Definition at line 430 of file main.c.

431 {
432 
434 
435  DX_WINDBG_trace();
436 
437 
438  switch(ul_reason_for_call)
439  {
440  case DLL_PROCESS_DETACH:
442  break;
443 
444  case DLL_PROCESS_ATTACH:
449  break;
450 
451  default:
452  break;
453  }
454 
455  return TRUE;
456 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
#define DLL_PROCESS_ATTACH
Definition: compat.h:120
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
VOID WINAPI InitializeCriticalSection(OUT LPCRITICAL_SECTION lpCriticalSection)
Definition: synch.c:751
HMODULE hDllModule
Definition: main.c:12
#define DLL_PROCESS_DETACH
Definition: compat.h:119
void WINAPI DeleteCriticalSection(PCRITICAL_SECTION)
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
HMODULE hModule
Definition: animate.c:44

◆ ReleaseDDThreadLock()

VOID WINAPI ReleaseDDThreadLock ( )

Definition at line 421 of file main.c.

422 {
423  DX_WINDBG_trace();
424 
426 }
#define DX_WINDBG_trace()
Definition: rosdraw.h:262
CRITICAL_SECTION ddcs
Definition: main.c:14
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)

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

◆ 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().