Index: ddraw/common.h |
— | — | @@ -104,5 +104,7 @@ |
105 | 105 | #define NextMultipleOfWord NextMultipleOf4
|
106 | 106 | #endif
|
107 | 107 |
|
| 108 | +#include "trace.h"
|
| 109 | +
|
108 | 110 | #include "../cfgmgr/cfgmgr.h"
|
109 | 111 | #endif //_COMMON_H
|
Index: ddraw/ddraw.cpp |
— | — | @@ -49,15 +49,25 @@ |
50 | 50 | */
|
51 | 51 | bool IsBadReadPointer(void *ptr)
|
52 | 52 | {
|
| 53 | + TRACE_ENTER("IsBadReadPointer",1,14,ptr);
|
53 | 54 | char a;
|
54 | 55 | try
|
55 | 56 | {
|
56 | 57 | a = *(char*)ptr;
|
57 | | - if(a == *(char*)ptr) return false;
|
58 | | - else return true;
|
| 58 | + if(a == *(char*)ptr)
|
| 59 | + {
|
| 60 | + TRACE_EXIT("IsBadReadPointer",21,0);
|
| 61 | + return false;
|
| 62 | + }
|
| 63 | + else
|
| 64 | + {
|
| 65 | + TRACE_EXIT("IsBadReadPointer",21,(void*)1);
|
| 66 | + return true;
|
| 67 | + }
|
59 | 68 | }
|
60 | 69 | catch(...)
|
61 | 70 | {
|
| 71 | + TRACE_EXIT("IsBadReadPointer",21,(void*)1);
|
62 | 72 | return true;
|
63 | 73 | }
|
64 | 74 | }
|
— | — | @@ -64,53 +74,69 @@ |
65 | 75 |
|
66 | 76 | void InitGL(int width, int height, int bpp, bool fullscreen, HWND hWnd, glDirectDraw7 *glDD7)
|
67 | 77 | {
|
| 78 | + TRACE_ENTER("InitGL",6,11,width,11,height,11,bpp,21,fullscreen,13,hWnd,14,glDD7);
|
68 | 79 | if(!renderer) renderer = new glRenderer(width,height,bpp,fullscreen,hWnd,glDD7);
|
69 | 80 | else renderer->SetWnd(width,height,bpp,fullscreen,hWnd);
|
| 81 | + TRACE_EXIT("InitGL",0,0);
|
70 | 82 | }
|
71 | 83 |
|
72 | 84 | /// Stub for function found in system ddraw.dll
|
73 | 85 | DDRAW_API void WINAPI AcquireDDThreadLock()
|
74 | 86 | {
|
| 87 | + TRACE_ENTER("AcquireDDThreadLock",0);
|
75 | 88 | // FIXME: Add thread lock
|
76 | 89 | FIXME("AcquireDDThreadLock: stub\n");
|
| 90 | + TRACE_EXIT("AcquireDDThreadLock",0,0);
|
77 | 91 | }
|
78 | 92 |
|
79 | 93 | /// Stub for function found in system ddraw.dll
|
80 | 94 | DDRAW_API void WINAPI CompleteCreateSystemSurface()
|
81 | 95 | {
|
| 96 | + TRACE_ENTER("CompleteCreateSystemSurface",0);
|
82 | 97 | FIXME("CompleteCreateSystemSurface: stub\n");
|
| 98 | + TRACE_EXIT("CompleteCreateSystemSurface",0,0);
|
83 | 99 | }
|
84 | 100 |
|
85 | 101 | /// Stub for function found in system ddraw.dll
|
86 | 102 | DDRAW_API void WINAPI D3DParseUnknownCommand()
|
87 | 103 | {
|
| 104 | + TRACE_ENTER("D3DParseUnknownCommand",0);
|
88 | 105 | FIXME("D3DParseUnknownCommand: stub\n");
|
| 106 | + TRACE_EXIT("D3DParseUnknownCommand",0,0);
|
89 | 107 | }
|
90 | 108 |
|
91 | 109 | /// Stub for function found in system ddraw.dll
|
92 | 110 | DDRAW_API void WINAPI DDGetAttachedSurfaceLcl()
|
93 | 111 | {
|
| 112 | + TRACE_ENTER("DDGetAttachedSurfaceLcl",0);
|
94 | 113 | FIXME("DDGetAttachedSurfaceLcl: stub\n");
|
| 114 | + TRACE_EXIT("DDGetAttachedSurfaceLcl",0,0);
|
95 | 115 | }
|
96 | 116 |
|
97 | 117 | /// Stub for function found in system ddraw.dll
|
98 | 118 | DDRAW_API void WINAPI DDInternalLock()
|
99 | 119 | {
|
| 120 | + TRACE_ENTER("DDInternalLock",0);
|
100 | 121 | //FIXME: Add locking code
|
101 | 122 | FIXME("DDInternalLock: stub\n");
|
| 123 | + TRACE_EXIT("DDInternalLock",0,0);
|
102 | 124 | }
|
103 | 125 |
|
104 | 126 | /// Stub for function found in system ddraw.dll
|
105 | 127 | DDRAW_API void WINAPI DDInternalUnlock()
|
106 | 128 | {
|
| 129 | + TRACE_ENTER("DDInternalUnlock",0);
|
107 | 130 | //FIXME: Add unlocking code
|
108 | 131 | FIXME("DDInternalUnlock: stub\n");
|
| 132 | + TRACE_EXIT("DDInternalUnlock",0,0);
|
109 | 133 | }
|
110 | 134 |
|
111 | 135 | /// Stub for function found in system ddraw.dll
|
112 | 136 | DDRAW_API void WINAPI DSoundHelp()
|
113 | 137 | {
|
| 138 | + TRACE_ENTER("DSoundHelp",0);
|
114 | 139 | FIXME("DSoundHelp: stub\n");
|
| 140 | + TRACE_EXIT("DSoundHelp",0,0);
|
115 | 141 | }
|
116 | 142 |
|
117 | 143 | /**
|
— | — | @@ -124,8 +150,9 @@ |
125 | 151 | * @return
|
126 | 152 | * Returns nonzero if the address points to opengl32.dll, otherwise returns zero.
|
127 | 153 | */
|
128 | | -int IsCallerOpenGL(void *returnaddress)
|
| 154 | +BOOL IsCallerOpenGL(void *returnaddress)
|
129 | 155 | {
|
| 156 | + TRACE_ENTER("IsCallerOpenGL",1,14,returnaddress);
|
130 | 157 | int isgl = 0;
|
131 | 158 | MODULEENTRY32 modentry = {0};
|
132 | 159 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
|
— | — | @@ -141,6 +168,7 @@ |
142 | 169 | }
|
143 | 170 | } while(Module32Next(hSnapshot,&modentry));
|
144 | 171 | CloseHandle(hSnapshot);
|
| 172 | + TRACE_EXIT("IsCallerOpenGL",22,(void*)isgl);
|
145 | 173 | return isgl;
|
146 | 174 | }
|
147 | 175 |
|
— | — | @@ -161,6 +189,8 @@ |
162 | 190 | */
|
163 | 191 | HRESULT WINAPI DirectDrawCreate(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter)
|
164 | 192 | {
|
| 193 | + TRACE_ENTER("DirectDrawCreate",3,24,lpGUID,14,lplpDD,14,pUnkOuter);
|
| 194 | + HRESULT ret;
|
165 | 195 | if(gllock || IsCallerOpenGL(_ReturnAddress()))
|
166 | 196 | {
|
167 | 197 | if(!sysddraw)
|
— | — | @@ -169,16 +199,31 @@ |
170 | 200 | GetSystemDirectoryA(buffer,MAX_PATH);
|
171 | 201 | strcat(buffer,"\\ddraw.dll");
|
172 | 202 | sysddraw = LoadLibraryA(buffer);
|
173 | | - if(!sysddraw) ERR(DDERR_GENERIC);
|
| 203 | + if(!sysddraw)
|
| 204 | + {
|
| 205 | + TRACE_EXIT("DirectDrawCreate",23,(void*)DDERR_GENERIC);
|
| 206 | + ERR(DDERR_GENERIC);
|
| 207 | + }
|
174 | 208 | }
|
175 | 209 | if(!sysddrawcreate)
|
176 | 210 | {
|
177 | 211 | sysddrawcreate = (HRESULT(WINAPI *)(GUID FAR*,LPDIRECTDRAW FAR*, IUnknown FAR*))GetProcAddress(sysddraw,"DirectDrawCreate");
|
178 | | - if(!sysddrawcreate) ERR(DDERR_GENERIC);
|
| 212 | + if(!sysddrawcreate)
|
| 213 | + {
|
| 214 | + TRACE_EXIT("DirectDrawCreate",23,(void*)DDERR_GENERIC);
|
| 215 | + ERR(DDERR_GENERIC);
|
| 216 | + }
|
179 | 217 | }
|
180 | | - return sysddrawcreate(lpGUID,lplpDD,pUnkOuter);
|
| 218 | + ret = sysddrawcreate(lpGUID,lplpDD,pUnkOuter);
|
| 219 | + TRACE_VAR("DirectDrawCreate","lplpDD",14,*lplpDD);
|
| 220 | + TRACE_EXIT("DirectDrawCreate",23,(void*)ret);
|
| 221 | + return ret;
|
181 | 222 | }
|
182 | | - if(dxglinterface) return DDERR_DIRECTDRAWALREADYCREATED;
|
| 223 | + if(dxglinterface)
|
| 224 | + {
|
| 225 | + TRACE_EXIT("DirectDrawCreate",23,(void*)DDERR_DIRECTDRAWALREADYCREATED);
|
| 226 | + return DDERR_DIRECTDRAWALREADYCREATED;
|
| 227 | + }
|
183 | 228 | GetCurrentConfig(&dxglcfg);
|
184 | 229 | glDirectDraw7 *myddraw7;
|
185 | 230 | glDirectDraw1 *myddraw;
|
— | — | @@ -188,11 +233,14 @@ |
189 | 234 | if(error != DD_OK)
|
190 | 235 | {
|
191 | 236 | delete myddraw7;
|
| 237 | + TRACE_EXIT("DirectDrawCreate",23,(void*)error);
|
192 | 238 | return error;
|
193 | 239 | }
|
194 | 240 | myddraw7->QueryInterface(IID_IDirectDraw,(VOID**)&myddraw);
|
195 | 241 | myddraw7->Release();
|
196 | 242 | *lplpDD = (LPDIRECTDRAW)myddraw;
|
| 243 | + TRACE_VAR("DirectDrawCreate","*lplpDD",14,*lplpDD);
|
| 244 | + TRACE_EXIT("DirectDrawCreate",23,(void*)error);
|
197 | 245 | return error;
|
198 | 246 | }
|
199 | 247 |
|
— | — | @@ -211,7 +259,15 @@ |
212 | 260 | */
|
213 | 261 | HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
|
214 | 262 | {
|
| 263 | + TRACE_ENTER("DirectDrawCreateClipper",3,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
|
215 | 264 | *lplpDDClipper = new glDirectDrawClipper(dwFlags,NULL);
|
| 265 | + if(!lplpDDClipper)
|
| 266 | + {
|
| 267 | + TRACE_EXIT("DirectDrawCreateClipper",23,(void*)DDERR_OUTOFMEMORY);
|
| 268 | + return DDERR_OUTOFMEMORY;
|
| 269 | + }
|
| 270 | + TRACE_VAR("DirectDrawCreateClipper","*lplpDDClipper",14,*lplpDDClipper);
|
| 271 | + TRACE_EXIT("DirectDrawCreateClipper",23,(void*)DD_OK);
|
216 | 272 | return DD_OK;
|
217 | 273 | }
|
218 | 274 |
|
— | — | @@ -234,19 +290,31 @@ |
235 | 291 | */
|
236 | 292 | HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)
|
237 | 293 | {
|
238 | | - if(dxglinterface) return DDERR_DIRECTDRAWALREADYCREATED;
|
| 294 | + TRACE_ENTER("DirectDrawCreateEx",4,24,lpGUID,14,lplpDD,24,&iid,14,pUnkOuter);
|
| 295 | + if(dxglinterface)
|
| 296 | + {
|
| 297 | + TRACE_EXIT("DirectDrawCreateEx",23,(void*)DDERR_DIRECTDRAWALREADYCREATED);
|
| 298 | + return DDERR_DIRECTDRAWALREADYCREATED;
|
| 299 | + }
|
239 | 300 | GetCurrentConfig(&dxglcfg);
|
240 | 301 | glDirectDraw7 *myddraw;
|
241 | 302 | HRESULT error;
|
242 | | - if(iid != IID_IDirectDraw7) ERR(DDERR_INVALIDPARAMS);
|
| 303 | + if(iid != IID_IDirectDraw7)
|
| 304 | + {
|
| 305 | + TRACE_EXIT("DirectDrawCreateEx",23,(void*)DDERR_INVALIDPARAMS);
|
| 306 | + return DDERR_INVALIDPARAMS;
|
| 307 | + }
|
243 | 308 | myddraw = new glDirectDraw7(lpGUID,pUnkOuter);
|
244 | 309 | error = myddraw->err();
|
245 | 310 | if(error != DD_OK)
|
246 | 311 | {
|
247 | 312 | delete myddraw;
|
| 313 | + TRACE_EXIT("DirectDrawCreateEx",23,(void*)error);
|
248 | 314 | return error;
|
249 | 315 | }
|
250 | 316 | *lplpDD = (LPDIRECTDRAW7)myddraw;
|
| 317 | + TRACE_VAR("DirectDrawCreateEx","*lplpDD",14,*lplpDD);
|
| 318 | + TRACE_EXIT("DirectDrawCreateEx",23,(void*)error);
|
251 | 319 | return error;
|
252 | 320 | }
|
253 | 321 |
|
— | — | @@ -253,9 +321,12 @@ |
254 | 322 | /// Callback wrapper for DirectDrawEnumerateA
|
255 | 323 | BOOL WINAPI DDEnumA(GUID FAR *guid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
|
256 | 324 | {
|
| 325 | + TRACE_ENTER("DDEnumA",5,24,guid,15,lpDriverDescription,15,lpDriverName,14,lpContext,13,hMonitor);
|
257 | 326 | int *context = (int *)lpContext;
|
258 | 327 | LPDDENUMCALLBACKA callback = (LPDDENUMCALLBACKA)context[0];
|
259 | | - return callback(guid,lpDriverDescription,lpDriverName,(LPVOID)context[1]);
|
| 328 | + BOOL ret = callback(guid,lpDriverDescription,lpDriverName,(LPVOID)context[1]);
|
| 329 | + TRACE_EXIT("DDEnumA",22,(void*)ret);
|
| 330 | + return ret;
|
260 | 331 | }
|
261 | 332 |
|
262 | 333 | /**
|
— | — | @@ -271,19 +342,29 @@ |
272 | 343 | */
|
273 | 344 | HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext)
|
274 | 345 | {
|
275 | | - if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 346 | + TRACE_ENTER("DirectDrawEnumerateA",2,14,lpCallback,14,lpContext);
|
| 347 | + if(IsBadReadPointer(lpCallback))
|
| 348 | + {
|
| 349 | + TRACE_EXIT("DirectDrawEnumerateA",23,(void*)DDERR_INVALIDPARAMS);
|
| 350 | + return DDERR_INVALIDPARAMS;
|
| 351 | + }
|
276 | 352 | LPVOID context[2];
|
277 | 353 | context[0] = (LPVOID) lpCallback;
|
278 | 354 | context[1] = lpContext;
|
279 | | - return DirectDrawEnumerateExA(DDEnumA,&context,0);
|
| 355 | + HRESULT ret = DirectDrawEnumerateExA(DDEnumA,&context,0);
|
| 356 | + TRACE_EXIT("DirectDrawEnumerateA",23,(void*)ret);
|
| 357 | + return ret;
|
280 | 358 | }
|
281 | 359 |
|
282 | 360 | /// Callback wrapper for DirectDrawEnumerateW
|
283 | 361 | BOOL WINAPI DDEnumW(GUID FAR *guid, LPWSTR lpDriverDescription, LPWSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
|
284 | 362 | {
|
| 363 | + TRACE_ENTER("DDEnumW",5,24,guid,16,lpDriverDescription,16,lpDriverName,14,lpContext,13,hMonitor);
|
285 | 364 | int *context = (int *)lpContext;
|
286 | 365 | LPDDENUMCALLBACKW callback = (LPDDENUMCALLBACKW)context[0];
|
287 | | - return callback(guid,lpDriverDescription,lpDriverName,(LPVOID)context[1]);
|
| 366 | + BOOL ret = callback(guid,lpDriverDescription,lpDriverName,(LPVOID)context[1]);
|
| 367 | + TRACE_EXIT("DDEnumW",22,(void*)ret);
|
| 368 | + return ret;
|
288 | 369 | }
|
289 | 370 |
|
290 | 371 | /**
|
— | — | @@ -299,11 +380,18 @@ |
300 | 381 | */
|
301 | 382 | HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW lpCallback, LPVOID lpContext)
|
302 | 383 | {
|
303 | | - if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 384 | + TRACE_ENTER("DirectDrawEnumerateW",2,14,lpCallback,14,lpContext);
|
| 385 | + if(IsBadReadPointer(lpCallback))
|
| 386 | + {
|
| 387 | + TRACE_EXIT("DirectDrawEnumerateW",23,(void*)DDERR_INVALIDPARAMS);
|
| 388 | + return DDERR_INVALIDPARAMS;
|
| 389 | + }
|
304 | 390 | LPVOID context[2];
|
305 | 391 | context[0] = (LPVOID) lpCallback;
|
306 | 392 | context[1] = lpContext;
|
307 | | - return DirectDrawEnumerateExW(DDEnumW,&context,0);
|
| 393 | + HRESULT ret = DirectDrawEnumerateExW(DDEnumW,&context,0);
|
| 394 | + TRACE_EXIT("DirectDrawEnumerateW",23,(void*)ret);
|
| 395 | + return ret;
|
308 | 396 | }
|
309 | 397 |
|
310 | 398 | /// Callback wrapper for DirectDrawEnumerateExA
|
— | — | @@ -310,6 +398,7 @@ |
311 | 399 | /// Converts Unicode strings to ANSI.
|
312 | 400 | BOOL WINAPI DDEnumExA(GUID FAR *guid, LPWSTR lpDriverDescription, LPWSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
|
313 | 401 | {
|
| 402 | + TRACE_ENTER("DDEnumExA",5,24,guid,16,lpDriverDescription,16,lpDriverName,14,lpContext,13,hMonitor);
|
314 | 403 | int *context = (int *)lpContext;
|
315 | 404 | LPDDENUMCALLBACKEXA callback = (LPDDENUMCALLBACKEXA)context[0];
|
316 | 405 | CHAR desc[MAX_PATH];
|
— | — | @@ -316,7 +405,9 @@ |
317 | 406 | CHAR driver[MAX_PATH];
|
318 | 407 | WideCharToMultiByte(CP_ACP,0,lpDriverDescription,-1,desc,MAX_PATH,NULL,NULL);
|
319 | 408 | WideCharToMultiByte(CP_ACP,0,lpDriverName,-1,driver,MAX_PATH,NULL,NULL);
|
320 | | - return callback(guid,desc,driver,(LPVOID)context[1],hMonitor);
|
| 409 | + BOOL ret = callback(guid,desc,driver,(LPVOID)context[1],hMonitor);
|
| 410 | + TRACE_EXIT("DDEnumExA",22,(void*)ret);
|
| 411 | + return ret;
|
321 | 412 | }
|
322 | 413 |
|
323 | 414 | /**
|
— | — | @@ -335,11 +426,18 @@ |
336 | 427 | */
|
337 | 428 | HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
|
338 | 429 | {
|
339 | | - if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 430 | + TRACE_ENTER("DirectDrawEnumerateExA",3,14,lpCallback,14,lpContext,9,dwFlags);
|
| 431 | + if(IsBadReadPointer(lpCallback))
|
| 432 | + {
|
| 433 | + TRACE_EXIT("DirectDrawEnumerateExA",23,(void*)DDERR_INVALIDPARAMS);
|
| 434 | + return DDERR_INVALIDPARAMS;
|
| 435 | + }
|
340 | 436 | LPVOID context[2];
|
341 | 437 | context[0] = (LPVOID) lpCallback;
|
342 | 438 | context[1] = lpContext;
|
343 | | - return DirectDrawEnumerateExW(DDEnumExA,&context,dwFlags);
|
| 439 | + HRESULT ret = DirectDrawEnumerateExW(DDEnumExA,&context,dwFlags);
|
| 440 | + TRACE_EXIT("DirectDrawEnumerateExA",23,(void*)ret);
|
| 441 | + return ret;
|
344 | 442 | }
|
345 | 443 |
|
346 | 444 | /**
|
— | — | @@ -352,18 +450,25 @@ |
353 | 451 | */
|
354 | 452 | BOOL CALLBACK MonitorEnum(HMONITOR hMonitor, HDC unused, LPRECT unused2, LPARAM ptr)
|
355 | 453 | {
|
| 454 | + TRACE_ENTER("MonitorEnum",4,13,hMonitor,13,unused,26,unused2,13,ptr);
|
356 | 455 | int * monitors = *(int**)ptr;
|
357 | 456 | if(!monitors)
|
358 | 457 | {
|
359 | 458 | monitors = (int*)malloc(256*sizeof(int));
|
360 | | - if(!monitors) return FALSE;
|
| 459 | + if(!monitors)
|
| 460 | + {
|
| 461 | + TRACE_EXIT("MonitorEnum",22,(void*)FALSE);
|
| 462 | + return FALSE;
|
| 463 | + }
|
361 | 464 | monitors[0] = 1;
|
362 | 465 | }
|
363 | 466 | else monitors[0]++;
|
364 | 467 | monitors[monitors[0]] = (int)hMonitor;
|
365 | 468 | *(int**)ptr = monitors;
|
366 | | - if(monitors[0] == 255) return FALSE;
|
367 | | - return TRUE;
|
| 469 | + BOOL ret;
|
| 470 | + if(monitors[0] == 255) ret = FALSE;
|
| 471 | + else ret = TRUE;
|
| 472 | + TRACE_EXIT("MonitorEnum",22,(void*)ret);
|
368 | 473 | }
|
369 | 474 |
|
370 | 475 | /**
|
— | — | @@ -381,7 +486,12 @@ |
382 | 487 | */
|
383 | 488 | HRESULT WINAPI DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags)
|
384 | 489 | {
|
385 | | - if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 490 | + TRACE_ENTER("DirectDrawEnumerateExW",3,14,lpCallback,14,lpContext,9,dwFlags);
|
| 491 | + if(IsBadReadPointer(lpCallback))
|
| 492 | + {
|
| 493 | + TRACE_EXIT("DirectDrawEnumerateExW",23,(void*)DDERR_GENERIC);
|
| 494 | + return DDERR_INVALIDPARAMS;
|
| 495 | + }
|
386 | 496 | int *monitors = NULL;
|
387 | 497 | GUID guid;
|
388 | 498 | MONITORINFOEXW monitorinfo;
|
— | — | @@ -392,7 +502,11 @@ |
393 | 503 | if(dwFlags & DDENUM_ATTACHEDSECONDARYDEVICES)
|
394 | 504 | {
|
395 | 505 | EnumDisplayMonitors(NULL,NULL,MonitorEnum,(LPARAM)&monitors);
|
396 | | - if(!monitors) return DDERR_OUTOFMEMORY;
|
| 506 | + if(!monitors)
|
| 507 | + {
|
| 508 | + TRACE_EXIT("DirectDrawEnumerateExW",23,(void*)DDERR_OUTOFMEMORY);
|
| 509 | + return DDERR_OUTOFMEMORY;
|
| 510 | + }
|
397 | 511 | for(int i = 1; i < monitors[0]; i++)
|
398 | 512 | {
|
399 | 513 | guid = device_template;
|
— | — | @@ -403,6 +517,7 @@ |
404 | 518 | }
|
405 | 519 | free(monitors);
|
406 | 520 | }
|
| 521 | + TRACE_EXIT("DirectDrawEnumerateExW",23,(void*)DDERR_OUTOFMEMORY);
|
407 | 522 | return DD_OK;
|
408 | 523 | }
|
409 | 524 |
|
— | — | @@ -414,6 +529,8 @@ |
415 | 530 | */
|
416 | 531 | HRESULT WINAPI DllCanUnloadNow()
|
417 | 532 | {
|
| 533 | + TRACE_ENTER("DllCanUnloadNow",0);
|
| 534 | + TRACE_EXIT("DllCanUnloadNow",23,(void*)S_FALSE);
|
418 | 535 | return S_FALSE;
|
419 | 536 | }
|
420 | 537 |
|
— | — | @@ -431,13 +548,24 @@ |
432 | 549 | */
|
433 | 550 | HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
|
434 | 551 | {
|
| 552 | + TRACE_ENTER("DllGetClassObject",3,24,&rclsid,24,&riid,14,ppv);
|
435 | 553 | if((rclsid != CLSID_DirectDraw) && (rclsid != CLSID_DirectDraw7) &&
|
436 | | - (rclsid != CLSID_DirectDrawClipper)) return CLASS_E_CLASSNOTAVAILABLE;
|
| 554 | + (rclsid != CLSID_DirectDrawClipper))
|
| 555 | + {
|
| 556 | + TRACE_EXIT("DllGetClassObject",23,(void*)CLASS_E_CLASSNOTAVAILABLE);
|
| 557 | + return CLASS_E_CLASSNOTAVAILABLE;
|
| 558 | + }
|
437 | 559 | GetCurrentConfig(&dxglcfg);
|
438 | 560 | glClassFactory *factory = new glClassFactory;
|
439 | | - if(factory == NULL) return E_OUTOFMEMORY;
|
| 561 | + if(factory == NULL)
|
| 562 | + {
|
| 563 | + TRACE_EXIT("DllGetClassObject",23,(void*)E_OUTOFMEMORY);
|
| 564 | + return E_OUTOFMEMORY;
|
| 565 | + }
|
440 | 566 | HRESULT result = factory->QueryInterface(riid,ppv);
|
| 567 | + TRACE_VAR("DllGetClassObject","*ppv",14,*ppv);
|
441 | 568 | factory->Release();
|
| 569 | + TRACE_EXIT("DllGetClassObject",23,(void*)result);
|
442 | 570 | return result;
|
443 | 571 | }
|
444 | 572 |
|
— | — | @@ -444,6 +572,8 @@ |
445 | 573 | /// Stub for function found in system ddraw.dll
|
446 | 574 | DDRAW_API void WINAPI GetDDSurfaceLocal()
|
447 | 575 | {
|
| 576 | + TRACE_ENTER("GetDDSurfaceLocal",0);
|
| 577 | + TRACE_EXIT("GetDDSurfaceLocal",0,0);
|
448 | 578 | FIXME("GetDDSurfaceLocal: stub\n");
|
449 | 579 | }
|
450 | 580 |
|
— | — | @@ -451,6 +581,8 @@ |
452 | 582 | /// This function gets called by the fnddraw.exe test application.
|
453 | 583 | DDRAW_API HANDLE WINAPI GetOLEThunkData(int i1)
|
454 | 584 | {
|
| 585 | + TRACE_ENTER("GetOLEThunkData",1,9,i1);
|
| 586 | + TRACE_EXIT("GetOleThunkData",14,NULL);
|
455 | 587 | DEBUG("GetOleThunkData: stub\n");
|
456 | 588 | return 0;
|
457 | 589 | }
|
— | — | @@ -459,26 +591,36 @@ |
460 | 592 | /// Function import is GetSurfaceFromDC
|
461 | 593 | DDRAW_API HRESULT WINAPI GlobalGetSurfaceFromDC(LPDIRECTDRAW7 lpDD, HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS)
|
462 | 594 | {
|
| 595 | + TRACE_ENTER("GetSurfaceFromDC",3,14,lpDD,9,hdc,14,lpDDS);
|
463 | 596 | FIXME("GetSurfaceFromDC: Verify proper referencing for LPDIRECTDRAW7\n");
|
464 | | - return lpDD->GetSurfaceFromDC(hdc,lpDDS);
|
| 597 | + HRESULT ret = lpDD->GetSurfaceFromDC(hdc,lpDDS);
|
| 598 | + TRACE_VAR("GetSurfaceFromDC","*lpDDS",14,*lpDDS);
|
| 599 | + TRACE_EXIT("GetSurfaceFromDC",23,(void*)ret);
|
| 600 | + return ret;
|
465 | 601 | }
|
466 | 602 |
|
467 | 603 | /// Stub for function found in system ddraw.dll
|
468 | 604 | DDRAW_API void WINAPI RegisterSpecialCase()
|
469 | 605 | {
|
| 606 | + TRACE_ENTER("RegisterSpecialCase",0);
|
470 | 607 | FIXME("RegisterSpecialCase: stub\n");
|
| 608 | + TRACE_EXIT("RegisterSpecialCase",0,0);
|
471 | 609 | }
|
472 | 610 |
|
473 | 611 | /// Stub for function found in system ddraw.dll
|
474 | 612 | DDRAW_API void WINAPI ReleaseDDThreadLock()
|
475 | 613 | {
|
| 614 | + TRACE_ENTER("ReleaseDDThreadLock",0);
|
476 | 615 | FIXME("ReleaseDDThreadLock: stub\n");
|
| 616 | + TRACE_EXIT("ReleaseDDThreadLock",0,0);
|
477 | 617 | }
|
478 | 618 |
|
479 | 619 | /// Stub for function found in system ddraw.dll
|
480 | 620 | DDRAW_API void WINAPI SetAppCompatData()
|
481 | 621 | {
|
| 622 | + TRACE_ENTER("SetAppCompatData",0);
|
482 | 623 | FIXME("SetAppCompatData: stub\n");
|
| 624 | + TRACE_EXIT("SetAppCompatData",0,0);
|
483 | 625 | }
|
484 | 626 |
|
485 | 627 | /**
|
— | — | @@ -494,5 +636,7 @@ |
495 | 637 |
|
496 | 638 | DDRAW_API BOOL IsDXGLDDraw()
|
497 | 639 | {
|
| 640 | + TRACE_ENTER("IsDXGLDDraw",0);
|
| 641 | + TRACE_EXIT("IsDXGLDDraw",0,0);
|
498 | 642 | return TRUE;
|
499 | 643 | }
|
Index: ddraw/trace.cpp |
— | — | @@ -16,17 +16,510 @@ |
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
19 | 19 | #include "common.h"
|
20 | | -#include "trace.h"
|
21 | 20 |
|
| 21 | +/* Data types:
|
| 22 | +0 - void
|
| 23 | +1 - 8-bit signed
|
| 24 | +2 - 8-bit unsigned
|
| 25 | +3 - 8-bit hex
|
| 26 | +4 - 16 bit signed
|
| 27 | +5 - 16 bit unsigned
|
| 28 | +6 - 16 bit hex
|
| 29 | +7 - 32 bit signed
|
| 30 | +8 - 32 bit unsigned
|
| 31 | +9 - 32 bit hex
|
| 32 | +10 - pointer to 64 bit hex
|
| 33 | +11 - native signed
|
| 34 | +12 - native unsigned
|
| 35 | +13 - native hex
|
| 36 | +14 - generic pointer
|
| 37 | +15 - ASCII string
|
| 38 | +16 - Unicode string
|
| 39 | +17 - TCHAR string
|
| 40 | +18 - ASCII character
|
| 41 | +19 - pointer to 32 bit float
|
| 42 | +20 - pointer to 64 bit float
|
| 43 | +21 - c++ bool
|
| 44 | +22 - int BOOL
|
| 45 | +23 - HRESULT
|
| 46 | +24 - GUID pointer
|
| 47 | +25 -
|
| 48 | +26 - RECT pointer
|
| 49 | +*/
|
| 50 | +
|
22 | 51 | #ifdef _TRACE
|
23 | | -HANDLE outfile = INVALID_HANDLE_VALUE;
|
24 | | -void TRACE_ENTER(const char *function, int argtype, void *arg, int end)
|
| 52 | +static CRITICAL_SECTION trace_cs;
|
| 53 | +static bool trace_ready = false;
|
| 54 | +static bool trace_fail = false;
|
| 55 | +static HANDLE outfile = INVALID_HANDLE_VALUE;
|
| 56 | +unsigned int trace_depth = 0;
|
| 57 | +static void trace_decode_hresult(HRESULT hr)
|
25 | 58 | {
|
| 59 | + DWORD byteswritten;
|
| 60 | + char str[64];
|
| 61 | + switch(hr)
|
| 62 | + {
|
| 63 | + case DD_OK:
|
| 64 | + strcpy(str,"DD_OK");
|
| 65 | + break;
|
| 66 | + case DD_FALSE:
|
| 67 | + strcpy(str,"DD_FALSE");
|
| 68 | + break;
|
| 69 | + case DDERR_ALREADYINITIALIZED:
|
| 70 | + strcpy(str,"DDERR_ALREADYINITIALIZED");
|
| 71 | + break;
|
| 72 | + case DDERR_CANNOTATTACHSURFACE:
|
| 73 | + strcpy(str,"DDERR_CANNOTATTACHSURFACE");
|
| 74 | + break;
|
| 75 | + case DDERR_CANNOTDETACHSURFACE:
|
| 76 | + strcpy(str,"DDERR_CANNOTDETACHSURFACE");
|
| 77 | + break;
|
| 78 | + case DDERR_CURRENTLYNOTAVAIL:
|
| 79 | + strcpy(str,"DDERR_CURRENTLYNOTAVAIL");
|
| 80 | + break;
|
| 81 | + case DDERR_EXCEPTION:
|
| 82 | + strcpy(str,"DDERR_EXCEPTION");
|
| 83 | + break;
|
| 84 | + case DDERR_GENERIC:
|
| 85 | + strcpy(str,"DDERR_GENERIC");
|
| 86 | + break;
|
| 87 | + case DDERR_INCOMPATIBLEPRIMARY:
|
| 88 | + strcpy(str,"DDERR_INCOMPATIBLEPRIMARY");
|
| 89 | + break;
|
| 90 | + case DDERR_INVALIDCAPS:
|
| 91 | + strcpy(str,"DDERR_INVALIDCAPS");
|
| 92 | + break;
|
| 93 | + case DDERR_INVALIDCLIPLIST:
|
| 94 | + strcpy(str,"DDERR_INVALIDCLIPLIST");
|
| 95 | + break;
|
| 96 | + case DDERR_INVALIDMODE:
|
| 97 | + strcpy(str,"DDERR_INVALIDMODE");
|
| 98 | + break;
|
| 99 | + case DDERR_INVALIDPARAMS:
|
| 100 | + strcpy(str,"DDERR_INVALIDPARAMS");
|
| 101 | + break;
|
| 102 | + case DDERR_INVALIDPIXELFORMAT:
|
| 103 | + strcpy(str,"DDERR_INVALIDPIXELFORMAT");
|
| 104 | + break;
|
| 105 | + case DDERR_INVALIDRECT:
|
| 106 | + strcpy(str,"DDERR_INVALIDRECT");
|
| 107 | + break;
|
| 108 | + case DDERR_NOTFOUND:
|
| 109 | + strcpy(str,"DDERR_NOTFOUND");
|
| 110 | + break;
|
| 111 | + case DDERR_OUTOFMEMORY:
|
| 112 | + strcpy(str,"DDERR_OUTOFMEMORY");
|
| 113 | + break;
|
| 114 | + case DDERR_OUTOFVIDEOMEMORY:
|
| 115 | + strcpy(str,"DDERR_OUTOFVIDEOMEMORY");
|
| 116 | + break;
|
| 117 | + case DDERR_SURFACEALREADYATTACHED:
|
| 118 | + strcpy(str,"DDERR_SURFACEALREADYATTACHED");
|
| 119 | + break;
|
| 120 | + case DDERR_SURFACEBUSY:
|
| 121 | + strcpy(str,"DDERR_SURFACEBUSY");
|
| 122 | + break;
|
| 123 | + case DDERR_CANTLOCKSURFACE:
|
| 124 | + strcpy(str,"DDERR_CANTLOCKSURFACE");
|
| 125 | + break;
|
| 126 | + case DDERR_SURFACELOST:
|
| 127 | + strcpy(str,"DDERR_SURFACELOST");
|
| 128 | + break;
|
| 129 | + case DDERR_SURFACENOTATTACHED:
|
| 130 | + strcpy(str,"DDERR_SURFACENOTATTACHED");
|
| 131 | + break;
|
| 132 | + case DDERR_UNSUPPORTED:
|
| 133 | + strcpy(str,"DDERR_UNSUPPORTED");
|
| 134 | + break;
|
| 135 | + case DDERR_UNSUPPORTEDFORMAT:
|
| 136 | + strcpy(str,"DDERR_UNSUPPORTEDFORMAT");
|
| 137 | + break;
|
| 138 | + case DDERR_UNSUPPORTEDMASK:
|
| 139 | + strcpy(str,"DDERR_UNSUPPORTEDMASK");
|
| 140 | + break;
|
| 141 | + case DDERR_WASSTILLDRAWING:
|
| 142 | + strcpy(str,"DDERR_WASSTILLDRAWING");
|
| 143 | + break;
|
| 144 | + case DDERR_INVALIDDIRECTDRAWGUID:
|
| 145 | + strcpy(str,"DDERR_INVALIDDIRECTDRAWGUID");
|
| 146 | + break;
|
| 147 | + case DDERR_DIRECTDRAWALREADYCREATED:
|
| 148 | + strcpy(str,"DDERR_DIRECTDRAWALREADYCREATED");
|
| 149 | + break;
|
| 150 | + case DDERR_NODIRECTDRAWHW:
|
| 151 | + strcpy(str,"DDERR_NODIRECTDRAWHW");
|
| 152 | + break;
|
| 153 | + case DDERR_PRIMARYSURFACEALREADYEXISTS:
|
| 154 | + strcpy(str,"DDERR_PRIMARYSURFACEALREADYEXISTS");
|
| 155 | + break;
|
| 156 | + case DDERR_CLIPPERISUSINGHWND:
|
| 157 | + strcpy(str,"DDERR_CLIPPERISUSINGHWND");
|
| 158 | + break;
|
| 159 | + case DDERR_NOCLIPPERATTACHED:
|
| 160 | + strcpy(str,"DDERR_NOCLIPPERATTACHED");
|
| 161 | + break;
|
| 162 | + case DDERR_NOHWND:
|
| 163 | + strcpy(str,"DDERR_NOHWND");
|
| 164 | + break;
|
| 165 | + case DDERR_HWNDSUBCLASSED:
|
| 166 | + strcpy(str,"DDERR_HWNDSUBCLASSED");
|
| 167 | + break;
|
| 168 | + case DDERR_HWNDALREADYSET:
|
| 169 | + strcpy(str,"DDERR_HWNDALREADYSET");
|
| 170 | + break;
|
| 171 | + case DDERR_NOPALETTEATTACHED:
|
| 172 | + strcpy(str,"DDERR_NOPALETTEATTACHED");
|
| 173 | + break;
|
| 174 | + case DDERR_NOPALETTEHW:
|
| 175 | + strcpy(str,"DDERR_NOPALETTEHW");
|
| 176 | + break;
|
| 177 | + case DDERR_BLTFASTCANTCLIP:
|
| 178 | + strcpy(str,"DDERR_BLTFASTCANTCLIP");
|
| 179 | + break;
|
| 180 | + case DDERR_OVERLAYNOTVISIBLE:
|
| 181 | + strcpy(str,"DDERR_OVERLAYNOTVISIBLE");
|
| 182 | + break;
|
| 183 | + case DDERR_NOOVERLAYDEST:
|
| 184 | + strcpy(str,"DDERR_NOOVERLAYDEST");
|
| 185 | + break;
|
| 186 | + case DDERR_EXCLUSIVEMODEALREADYSET:
|
| 187 | + strcpy(str,"DDERR_EXCLUSIVEMODEALREADYSET");
|
| 188 | + break;
|
| 189 | + case DDERR_NOTFLIPPABLE:
|
| 190 | + strcpy(str,"DDERR_NOTFLIPPABLE");
|
| 191 | + break;
|
| 192 | + case DDERR_CANTDUPLICATE:
|
| 193 | + strcpy(str,"DDERR_CANTDUPLICATE");
|
| 194 | + break;
|
| 195 | + case DDERR_NOTLOCKED:
|
| 196 | + strcpy(str,"DDERR_NOTLOCKED");
|
| 197 | + break;
|
| 198 | + case DDERR_CANTCREATEDC:
|
| 199 | + strcpy(str,"DDERR_CANTCREATEDC");
|
| 200 | + break;
|
| 201 | + case DDERR_NODC:
|
| 202 | + strcpy(str,"DDERR_NODC");
|
| 203 | + break;
|
| 204 | + case DDERR_WRONGMODE:
|
| 205 | + strcpy(str,"DDERR_WRONGMODE");
|
| 206 | + break;
|
| 207 | + case DDERR_IMPLICITLYCREATED:
|
| 208 | + strcpy(str,"DDERR_IMPLICITLYCREATED");
|
| 209 | + break;
|
| 210 | + case DDERR_NOTPALETTIZED:
|
| 211 | + strcpy(str,"DDERR_NOTPALETTIZED");
|
| 212 | + break;
|
| 213 | + case DDERR_UNSUPPORTEDMODE:
|
| 214 | + strcpy(str,"DDERR_UNSUPPORTEDMODE");
|
| 215 | + break;
|
| 216 | + case DDERR_INVALIDSURFACETYPE:
|
| 217 | + strcpy(str,"DDERR_INVALIDSURFACETYPE");
|
| 218 | + break;
|
| 219 | + case DDERR_NOTONMIPMAPSUBLEVEL:
|
| 220 | + strcpy(str,"DDERR_NOTONMIPMAPSUBLEVEL");
|
| 221 | + break;
|
| 222 | + case DDERR_DCALREADYCREATED:
|
| 223 | + strcpy(str,"DDERR_DCALREADYCREATED");
|
| 224 | + break;
|
| 225 | + case DDERR_CANTPAGELOCK:
|
| 226 | + strcpy(str,"DDERR_CANTPAGELOCK");
|
| 227 | + break;
|
| 228 | + case DDERR_CANTPAGEUNLOCK:
|
| 229 | + strcpy(str,"DDERR_CANTPAGEUNLOCK");
|
| 230 | + break;
|
| 231 | + case DDERR_NOTPAGELOCKED:
|
| 232 | + strcpy(str,"DDERR_NOTPAGELOCKED");
|
| 233 | + break;
|
| 234 | + case DDERR_MOREDATA:
|
| 235 | + strcpy(str,"DDERR_MOREDATA");
|
| 236 | + break;
|
| 237 | + case DDERR_NOTINITIALIZED:
|
| 238 | + strcpy(str,"DDERR_NOTINITIALIZED");
|
| 239 | + break;
|
| 240 | + case E_NOINTERFACE:
|
| 241 | + strcpy(str,"E_NOINTERFACE");
|
| 242 | + break;
|
| 243 | + default:
|
| 244 | + sprintf(str,"(HRESULT)0x%08X",hr);
|
| 245 | + break;
|
| 246 | + }
|
| 247 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
26 | 248 | }
|
27 | | -void TRACE_ARG(int argtype, void *arg, int end)
|
| 249 | +static void trace_decode_guid(GUID *guid)
|
28 | 250 | {
|
| 251 | + DWORD byteswritten;
|
| 252 | + char str[64];
|
| 253 | + if(*guid == CLSID_DirectDraw) strcpy(str,"CLSID_DirectDraw");
|
| 254 | + else if(*guid == CLSID_DirectDraw7) strcpy(str,"CLSID_DirectDraw7");
|
| 255 | + else if(*guid == CLSID_DirectDrawClipper) strcpy(str,"CLSID_DirectDrawClipper");
|
| 256 | + else if(*guid == IID_IDirectDraw) strcpy(str,"IID_IDirectDraw");
|
| 257 | + else if(*guid == IID_IDirectDraw2) strcpy(str,"IID_IDirectDraw2");
|
| 258 | + else if(*guid == IID_IDirectDraw4) strcpy(str,"IID_IDirectDraw4");
|
| 259 | + else if(*guid == IID_IDirectDraw7) strcpy(str,"IID_IDirectDraw7");
|
| 260 | + else if(*guid == IID_IDirectDrawSurface) strcpy(str,"IID_IDirectDrawSurface");
|
| 261 | + else if(*guid == IID_IDirectDrawSurface2) strcpy(str,"IID_IDirectDrawSurface2");
|
| 262 | + else if(*guid == IID_IDirectDrawSurface3) strcpy(str,"IID_IDirectDrawSurface3");
|
| 263 | + else if(*guid == IID_IDirectDrawSurface4) strcpy(str,"IID_IDirectDrawSurface4");
|
| 264 | + else if(*guid == IID_IDirectDrawSurface7) strcpy(str,"IID_IDirectDrawSurface7");
|
| 265 | + else if(*guid == IID_IDirectDrawPalette) strcpy(str,"IID_IDirectDrawPalette");
|
| 266 | + else if(*guid == IID_IDirectDrawClipper) strcpy(str,"IID_IDirectDrawClipper");
|
| 267 | + else if(*guid == IID_IDirectDrawColorControl) strcpy(str,"IID_IDirectDrawColorControl");
|
| 268 | + else if(*guid == IID_IDirectDrawGammaControl) strcpy(str,"IID_IDirectDrawGammaControl");
|
| 269 | + else if(*guid == IID_IDirect3D) strcpy(str,"IID_IDirect3D");
|
| 270 | + else if(*guid == IID_IDirect3D2) strcpy(str,"IID_IDirect3D2");
|
| 271 | + else if(*guid == IID_IDirect3D3) strcpy(str,"IID_IDirect3D3");
|
| 272 | + else if(*guid == IID_IDirect3D7) strcpy(str,"IID_IDirect3D7");
|
| 273 | + else
|
| 274 | + {
|
| 275 | + OLECHAR guidstr[41] = {0};
|
| 276 | + StringFromGUID2(*guid,guidstr,40);
|
| 277 | + WideCharToMultiByte(CP_UTF8,0,guidstr,-1,str,64,NULL,NULL);
|
| 278 | + }
|
| 279 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
29 | 280 | }
|
| 281 | +static void trace_decode_rect(RECT *rect)
|
| 282 | +{
|
| 283 | + DWORD byteswritten;
|
| 284 | + char str[64];
|
| 285 | + sprintf(str,"{%d,%d,%d,%d}",rect->left,rect->top,rect->right,rect->bottom);
|
| 286 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 287 | +}
|
| 288 | +static void init_trace()
|
| 289 | +{
|
| 290 | + TCHAR path[MAX_PATH+1];
|
| 291 | + InitializeCriticalSection(&trace_cs);
|
| 292 | + GetModuleFileName(NULL,path,MAX_PATH);
|
| 293 | + TCHAR *path_truncate = _tcsrchr(path,_T('\\'));
|
| 294 | + if(path_truncate) *(path_truncate+1) = 0;
|
| 295 | + _tcscat(path,_T("dxgl.log"));
|
| 296 | + outfile = CreateFile(path,GENERIC_WRITE,FILE_SHARE_READ,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
| 297 | + if(outfile == INVALID_HANDLE_VALUE)
|
| 298 | + {
|
| 299 | + trace_fail = true;
|
| 300 | + return;
|
| 301 | + }
|
| 302 | + trace_ready = true;
|
| 303 | +}
|
| 304 | +static void trace_decode_arg(int type, void *arg)
|
| 305 | +{
|
| 306 | + DWORD byteswritten;
|
| 307 | + char str[128];
|
| 308 | + char *mbcsbuffer;
|
| 309 | + int buffersize;
|
| 310 | + str[0] = 0;
|
| 311 | + switch(type)
|
| 312 | + {
|
| 313 | + case 0: // void
|
| 314 | + WriteFile(outfile,"void",4,&byteswritten,NULL);
|
| 315 | + break;
|
| 316 | + case 1: // 8-bit signed
|
| 317 | + sprintf(str,"%d",(signed char)arg);
|
| 318 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 319 | + break;
|
| 320 | + case 2: // 8-bit unsigned
|
| 321 | + sprintf(str,"%u",(unsigned char)arg);
|
| 322 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 323 | + break;
|
| 324 | + case 3: // 8-bit hex
|
| 325 | + sprintf(str,"0x%02X",(unsigned char)arg);
|
| 326 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 327 | + break;
|
| 328 | + case 4: // 16-bit signed
|
| 329 | + sprintf(str,"%d",(signed short)arg);
|
| 330 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 331 | + break;
|
| 332 | + case 5: // 16-bit unsigned
|
| 333 | + sprintf(str,"%u",(unsigned short)arg);
|
| 334 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 335 | + break;
|
| 336 | + case 6: // 16-bit hex
|
| 337 | + sprintf(str,"0x%04X",(unsigned short)arg);
|
| 338 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 339 | + break;
|
| 340 | + case 7: // 32-bit signed
|
| 341 | + sprintf(str,"%d",(signed long)arg);
|
| 342 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 343 | + break;
|
| 344 | + case 8: // 32-bit unsigned
|
| 345 | + sprintf(str,"%u",(unsigned long)arg);
|
| 346 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 347 | + break;
|
| 348 | + case 9: // 32-bit hex
|
| 349 | + sprintf(str,"0x%08X",(unsigned long)arg);
|
| 350 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 351 | + break;
|
| 352 | + case 10: // pointer to 64-bit hex
|
| 353 | + sprintf(str,"0x%016I64X",(unsigned __int64)*(unsigned __int64*)arg);
|
| 354 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 355 | + break;
|
| 356 | + case 11: // native signed
|
| 357 | + sprintf(str,"%d",(signed int)arg);
|
| 358 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 359 | + break;
|
| 360 | + case 12: // native unsigned
|
| 361 | + sprintf(str,"%u",(unsigned int)arg);
|
| 362 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 363 | + break;
|
| 364 | + case 13: // native hex
|
| 365 | + sprintf(str,"0x%08X",(unsigned int)arg);
|
| 366 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 367 | + break;
|
| 368 | + case 14: // generic pointer
|
| 369 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 370 | + else
|
| 371 | + {
|
| 372 | + sprintf(str,"0x%08X",arg);
|
| 373 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 374 | + }
|
| 375 | + break;
|
| 376 | + case 15: // ASCII string
|
| 377 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 378 | + else
|
| 379 | + {
|
| 380 | + WriteFile(outfile,"\"",1,&byteswritten,NULL);
|
| 381 | + WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
|
| 382 | + WriteFile(outfile,"\"",1,&byteswritten,NULL);
|
| 383 | + }
|
| 384 | + break;
|
| 385 | + case 16: // Unicode string
|
| 386 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 387 | + else
|
| 388 | + {
|
| 389 | + WriteFile(outfile,"L\"",1,&byteswritten,NULL);
|
| 390 | + buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
|
| 391 | + mbcsbuffer = (char*)malloc(buffersize);
|
| 392 | + if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
|
| 393 | + else
|
| 394 | + {
|
| 395 | + WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
|
| 396 | + WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
|
| 397 | + free(mbcsbuffer);
|
| 398 | + }
|
| 399 | + WriteFile(outfile,"\"",1,&byteswritten,NULL);
|
| 400 | + }
|
| 401 | + break;
|
| 402 | + case 17: // TCHAR string
|
| 403 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 404 | +#ifdef _UNICODE
|
| 405 | + else
|
| 406 | + {
|
| 407 | + WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
|
| 408 | + buffersize = WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,NULL,0,NULL,NULL);
|
| 409 | + mbcsbuffer = (char*)malloc(buffersize);
|
| 410 | + if(!mbcsbuffer) WriteFile(outfile,"OUT OF MEMORY",13,&byteswritten,NULL);
|
| 411 | + else
|
| 412 | + {
|
| 413 | + WideCharToMultiByte(CP_UTF8,0,(wchar_t*)arg,-1,mbcsbuffer,buffersize,NULL,NULL);
|
| 414 | + WriteFile(outfile,mbcsbuffer,strlen(mbcsbuffer),&byteswritten,NULL);
|
| 415 | + free(mbcsbuffer);
|
| 416 | + }
|
| 417 | + WriteFile(outfile,"\")",1,&byteswritten,NULL);
|
| 418 | + }
|
| 419 | +#else
|
| 420 | + else
|
| 421 | + {
|
| 422 | + WriteFile(outfile,"_T(\"",1,&byteswritten,NULL);
|
| 423 | + WriteFile(outfile,arg,strlen((char*)arg),&byteswritten,NULL);
|
| 424 | + WriteFile(outfile,"\")",1,&byteswritten,NULL);
|
| 425 | + }
|
| 426 | +#endif
|
| 427 | + break;
|
| 428 | + case 18: // ASCII character
|
| 429 | + if(!(unsigned char)arg) WriteFile(outfile,"\'\\0\'",4,&byteswritten,NULL);
|
| 430 | + else
|
| 431 | + {
|
| 432 | + str[0] = str[2] = '\'';
|
| 433 | + str[1] = (unsigned char)arg;
|
| 434 | + str[3] = NULL;
|
| 435 | + WriteFile(outfile,str,3,&byteswritten,NULL);
|
| 436 | + }
|
| 437 | + break;
|
| 438 | + case 19: // pointer to 32 bit float
|
| 439 | + sprintf(str,"%f",arg);
|
| 440 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 441 | + break;
|
| 442 | + case 20: // pointer to 64 bit float
|
| 443 | + sprintf(str,"%lf",arg);
|
| 444 | + WriteFile(outfile,str,strlen(str),&byteswritten,NULL);
|
| 445 | + break;
|
| 446 | + case 21: // c++ bool
|
| 447 | + if((bool)arg) WriteFile(outfile,"true",4,&byteswritten,NULL);
|
| 448 | + else WriteFile(outfile,"false",5,&byteswritten,NULL);
|
| 449 | + break;
|
| 450 | + case 22: // c++ bool
|
| 451 | + if(arg) WriteFile(outfile,"TRUE",4,&byteswritten,NULL);
|
| 452 | + else WriteFile(outfile,"FALSE",5,&byteswritten,NULL);
|
| 453 | + break;
|
| 454 | + case 23: // HRESULT
|
| 455 | + trace_decode_hresult((HRESULT)arg);
|
| 456 | + break;
|
| 457 | + case 24: // GUID pointer
|
| 458 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 459 | + else trace_decode_guid((GUID*)arg);
|
| 460 | + break;
|
| 461 | + case 25: // reserved
|
| 462 | + WriteFile(outfile,"Unknown type",12,&byteswritten,NULL);
|
| 463 | + break;
|
| 464 | + case 26: // RECT pointer
|
| 465 | + if(!arg) WriteFile(outfile,"NULL",4,&byteswritten,NULL);
|
| 466 | + else trace_decode_rect((RECT*)arg);
|
| 467 | + break;
|
| 468 | + default:
|
| 469 | + WriteFile(outfile,"Unknown type",12,&byteswritten,NULL);
|
| 470 | + break;
|
| 471 | + }
|
| 472 | +}
|
| 473 | +void TRACE_ENTER(const char *function, int paramcount, ...)
|
| 474 | +{
|
| 475 | + if(trace_fail) return;
|
| 476 | + if(!trace_ready) init_trace();
|
| 477 | + EnterCriticalSection(&trace_cs);
|
| 478 | + va_list args;
|
| 479 | + va_start(args,paramcount);
|
| 480 | + DWORD byteswritten;
|
| 481 | + for(int i = 0; i < trace_depth; i++)
|
| 482 | + WriteFile(outfile," ",4,&byteswritten,NULL);
|
| 483 | + WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
|
| 484 | + WriteFile(outfile,"(",1,&byteswritten,NULL);
|
| 485 | + for(int i = 0; i < paramcount; i++)
|
| 486 | + {
|
| 487 | + if(i != 0) WriteFile(outfile,", ",2,&byteswritten,NULL);
|
| 488 | + int argtype = va_arg(args,int);
|
| 489 | + trace_decode_arg(argtype,va_arg(args,void*));
|
| 490 | + }
|
| 491 | + WriteFile(outfile,");\r\n",4,&byteswritten,NULL);
|
| 492 | + trace_depth++;
|
| 493 | + LeaveCriticalSection(&trace_cs);
|
| 494 | +}
|
30 | 495 | void TRACE_EXIT(const char *function, int argtype, void *arg)
|
31 | 496 | {
|
| 497 | + if(trace_fail) return;
|
| 498 | + if(!trace_ready) init_trace();
|
| 499 | + EnterCriticalSection(&trace_cs);
|
| 500 | + trace_depth--;
|
| 501 | + DWORD byteswritten;
|
| 502 | + for(int i = 0; i < trace_depth; i++)
|
| 503 | + WriteFile(outfile," ",4,&byteswritten,NULL);
|
| 504 | + WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
|
| 505 | + WriteFile(outfile," returned ",10,&byteswritten,NULL);
|
| 506 | + trace_decode_arg(argtype,arg);
|
| 507 | + WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
|
| 508 | + LeaveCriticalSection(&trace_cs);
|
32 | 509 | }
|
| 510 | +void TRACE_VAR(const char *function, const char *var, int argtype, void *arg)
|
| 511 | +{
|
| 512 | + if(trace_fail) return;
|
| 513 | + if(!trace_ready) init_trace();
|
| 514 | + EnterCriticalSection(&trace_cs);
|
| 515 | + DWORD byteswritten;
|
| 516 | + for(int i = 0; i < trace_depth-1; i++)
|
| 517 | + WriteFile(outfile," ",4,&byteswritten,NULL);
|
| 518 | + WriteFile(outfile,function,strlen(function),&byteswritten,NULL);
|
| 519 | + WriteFile(outfile,": ",2,&byteswritten,NULL);
|
| 520 | + WriteFile(outfile,var,strlen(var),&byteswritten,NULL);
|
| 521 | + WriteFile(outfile," set to ",8,&byteswritten,NULL);
|
| 522 | + trace_decode_arg(argtype,arg);
|
| 523 | + WriteFile(outfile,"\r\n",2,&byteswritten,NULL);
|
| 524 | + LeaveCriticalSection(&trace_cs);
|
| 525 | +}
|
33 | 526 | #endif |
\ No newline at end of file |
Index: ddraw/trace.h |
— | — | @@ -21,12 +21,11 @@ |
22 | 22 |
|
23 | 23 |
|
24 | 24 | #ifdef _TRACE
|
25 | | -void TRACE_ENTER(const char *function, int argtype, void *arg, int end);
|
26 | | -void TRACE_ARG(int argtype, void *arg, int end);
|
| 25 | +void TRACE_ENTER(const char *function, int paramcount, ...);
|
27 | 26 | void TRACE_EXIT(const char *function, int argtype, void *arg);
|
| 27 | +void TRACE_VAR(const char *function, const char *var, int argtype, void *arg);
|
28 | 28 | #else
|
29 | | -#define TRACE_ENTER(a,b,c,d)
|
30 | | -#define TRACE_ARG(a,b,c)
|
| 29 | +#define TRACE_ENTER(a,...)
|
31 | 30 | #define TRACE_EXIT(a,b,c)
|
32 | 31 | #endif
|
33 | 32 |
|