DXGL r343 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r342‎ | r343 | r344 >
Date:16:02, 2 March 2013
Author:admin
Status:new
Tags:
Comment:
Add tracing code.
Trace ddraw.cpp
Modified paths:
  • /ddraw/common.h (modified) (history)
  • /ddraw/ddraw.cpp (modified) (history)
  • /ddraw/trace.cpp (modified) (history)
  • /ddraw/trace.h (modified) (history)

Diff [purge]

Index: ddraw/common.h
@@ -104,5 +104,7 @@
105105 #define NextMultipleOfWord NextMultipleOf4
106106 #endif
107107
 108+#include "trace.h"
 109+
108110 #include "../cfgmgr/cfgmgr.h"
109111 #endif //_COMMON_H
Index: ddraw/ddraw.cpp
@@ -49,15 +49,25 @@
5050 */
5151 bool IsBadReadPointer(void *ptr)
5252 {
 53+ TRACE_ENTER("IsBadReadPointer",1,14,ptr);
5354 char a;
5455 try
5556 {
5657 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+ }
5968 }
6069 catch(...)
6170 {
 71+ TRACE_EXIT("IsBadReadPointer",21,(void*)1);
6272 return true;
6373 }
6474 }
@@ -64,53 +74,69 @@
6575
6676 void InitGL(int width, int height, int bpp, bool fullscreen, HWND hWnd, glDirectDraw7 *glDD7)
6777 {
 78+ TRACE_ENTER("InitGL",6,11,width,11,height,11,bpp,21,fullscreen,13,hWnd,14,glDD7);
6879 if(!renderer) renderer = new glRenderer(width,height,bpp,fullscreen,hWnd,glDD7);
6980 else renderer->SetWnd(width,height,bpp,fullscreen,hWnd);
 81+ TRACE_EXIT("InitGL",0,0);
7082 }
7183
7284 /// Stub for function found in system ddraw.dll
7385 DDRAW_API void WINAPI AcquireDDThreadLock()
7486 {
 87+ TRACE_ENTER("AcquireDDThreadLock",0);
7588 // FIXME: Add thread lock
7689 FIXME("AcquireDDThreadLock: stub\n");
 90+ TRACE_EXIT("AcquireDDThreadLock",0,0);
7791 }
7892
7993 /// Stub for function found in system ddraw.dll
8094 DDRAW_API void WINAPI CompleteCreateSystemSurface()
8195 {
 96+ TRACE_ENTER("CompleteCreateSystemSurface",0);
8297 FIXME("CompleteCreateSystemSurface: stub\n");
 98+ TRACE_EXIT("CompleteCreateSystemSurface",0,0);
8399 }
84100
85101 /// Stub for function found in system ddraw.dll
86102 DDRAW_API void WINAPI D3DParseUnknownCommand()
87103 {
 104+ TRACE_ENTER("D3DParseUnknownCommand",0);
88105 FIXME("D3DParseUnknownCommand: stub\n");
 106+ TRACE_EXIT("D3DParseUnknownCommand",0,0);
89107 }
90108
91109 /// Stub for function found in system ddraw.dll
92110 DDRAW_API void WINAPI DDGetAttachedSurfaceLcl()
93111 {
 112+ TRACE_ENTER("DDGetAttachedSurfaceLcl",0);
94113 FIXME("DDGetAttachedSurfaceLcl: stub\n");
 114+ TRACE_EXIT("DDGetAttachedSurfaceLcl",0,0);
95115 }
96116
97117 /// Stub for function found in system ddraw.dll
98118 DDRAW_API void WINAPI DDInternalLock()
99119 {
 120+ TRACE_ENTER("DDInternalLock",0);
100121 //FIXME: Add locking code
101122 FIXME("DDInternalLock: stub\n");
 123+ TRACE_EXIT("DDInternalLock",0,0);
102124 }
103125
104126 /// Stub for function found in system ddraw.dll
105127 DDRAW_API void WINAPI DDInternalUnlock()
106128 {
 129+ TRACE_ENTER("DDInternalUnlock",0);
107130 //FIXME: Add unlocking code
108131 FIXME("DDInternalUnlock: stub\n");
 132+ TRACE_EXIT("DDInternalUnlock",0,0);
109133 }
110134
111135 /// Stub for function found in system ddraw.dll
112136 DDRAW_API void WINAPI DSoundHelp()
113137 {
 138+ TRACE_ENTER("DSoundHelp",0);
114139 FIXME("DSoundHelp: stub\n");
 140+ TRACE_EXIT("DSoundHelp",0,0);
115141 }
116142
117143 /**
@@ -124,8 +150,9 @@
125151 * @return
126152 * Returns nonzero if the address points to opengl32.dll, otherwise returns zero.
127153 */
128 -int IsCallerOpenGL(void *returnaddress)
 154+BOOL IsCallerOpenGL(void *returnaddress)
129155 {
 156+ TRACE_ENTER("IsCallerOpenGL",1,14,returnaddress);
130157 int isgl = 0;
131158 MODULEENTRY32 modentry = {0};
132159 HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
@@ -141,6 +168,7 @@
142169 }
143170 } while(Module32Next(hSnapshot,&modentry));
144171 CloseHandle(hSnapshot);
 172+ TRACE_EXIT("IsCallerOpenGL",22,(void*)isgl);
145173 return isgl;
146174 }
147175
@@ -161,6 +189,8 @@
162190 */
163191 HRESULT WINAPI DirectDrawCreate(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter)
164192 {
 193+ TRACE_ENTER("DirectDrawCreate",3,24,lpGUID,14,lplpDD,14,pUnkOuter);
 194+ HRESULT ret;
165195 if(gllock || IsCallerOpenGL(_ReturnAddress()))
166196 {
167197 if(!sysddraw)
@@ -169,16 +199,31 @@
170200 GetSystemDirectoryA(buffer,MAX_PATH);
171201 strcat(buffer,"\\ddraw.dll");
172202 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+ }
174208 }
175209 if(!sysddrawcreate)
176210 {
177211 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+ }
179217 }
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;
181222 }
182 - if(dxglinterface) return DDERR_DIRECTDRAWALREADYCREATED;
 223+ if(dxglinterface)
 224+ {
 225+ TRACE_EXIT("DirectDrawCreate",23,(void*)DDERR_DIRECTDRAWALREADYCREATED);
 226+ return DDERR_DIRECTDRAWALREADYCREATED;
 227+ }
183228 GetCurrentConfig(&dxglcfg);
184229 glDirectDraw7 *myddraw7;
185230 glDirectDraw1 *myddraw;
@@ -188,11 +233,14 @@
189234 if(error != DD_OK)
190235 {
191236 delete myddraw7;
 237+ TRACE_EXIT("DirectDrawCreate",23,(void*)error);
192238 return error;
193239 }
194240 myddraw7->QueryInterface(IID_IDirectDraw,(VOID**)&myddraw);
195241 myddraw7->Release();
196242 *lplpDD = (LPDIRECTDRAW)myddraw;
 243+ TRACE_VAR("DirectDrawCreate","*lplpDD",14,*lplpDD);
 244+ TRACE_EXIT("DirectDrawCreate",23,(void*)error);
197245 return error;
198246 }
199247
@@ -211,7 +259,15 @@
212260 */
213261 HRESULT WINAPI DirectDrawCreateClipper(DWORD dwFlags, LPDIRECTDRAWCLIPPER FAR *lplpDDClipper, IUnknown FAR *pUnkOuter)
214262 {
 263+ TRACE_ENTER("DirectDrawCreateClipper",3,9,dwFlags,14,lplpDDClipper,14,pUnkOuter);
215264 *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);
216272 return DD_OK;
217273 }
218274
@@ -234,19 +290,31 @@
235291 */
236292 HRESULT WINAPI DirectDrawCreateEx(GUID FAR *lpGUID, LPVOID *lplpDD, REFIID iid, IUnknown FAR *pUnkOuter)
237293 {
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+ }
239300 GetCurrentConfig(&dxglcfg);
240301 glDirectDraw7 *myddraw;
241302 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+ }
243308 myddraw = new glDirectDraw7(lpGUID,pUnkOuter);
244309 error = myddraw->err();
245310 if(error != DD_OK)
246311 {
247312 delete myddraw;
 313+ TRACE_EXIT("DirectDrawCreateEx",23,(void*)error);
248314 return error;
249315 }
250316 *lplpDD = (LPDIRECTDRAW7)myddraw;
 317+ TRACE_VAR("DirectDrawCreateEx","*lplpDD",14,*lplpDD);
 318+ TRACE_EXIT("DirectDrawCreateEx",23,(void*)error);
251319 return error;
252320 }
253321
@@ -253,9 +321,12 @@
254322 /// Callback wrapper for DirectDrawEnumerateA
255323 BOOL WINAPI DDEnumA(GUID FAR *guid, LPSTR lpDriverDescription, LPSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
256324 {
 325+ TRACE_ENTER("DDEnumA",5,24,guid,15,lpDriverDescription,15,lpDriverName,14,lpContext,13,hMonitor);
257326 int *context = (int *)lpContext;
258327 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;
260331 }
261332
262333 /**
@@ -271,19 +342,29 @@
272343 */
273344 HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext)
274345 {
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+ }
276352 LPVOID context[2];
277353 context[0] = (LPVOID) lpCallback;
278354 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;
280358 }
281359
282360 /// Callback wrapper for DirectDrawEnumerateW
283361 BOOL WINAPI DDEnumW(GUID FAR *guid, LPWSTR lpDriverDescription, LPWSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
284362 {
 363+ TRACE_ENTER("DDEnumW",5,24,guid,16,lpDriverDescription,16,lpDriverName,14,lpContext,13,hMonitor);
285364 int *context = (int *)lpContext;
286365 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;
288369 }
289370
290371 /**
@@ -299,11 +380,18 @@
300381 */
301382 HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW lpCallback, LPVOID lpContext)
302383 {
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+ }
304390 LPVOID context[2];
305391 context[0] = (LPVOID) lpCallback;
306392 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;
308396 }
309397
310398 /// Callback wrapper for DirectDrawEnumerateExA
@@ -310,6 +398,7 @@
311399 /// Converts Unicode strings to ANSI.
312400 BOOL WINAPI DDEnumExA(GUID FAR *guid, LPWSTR lpDriverDescription, LPWSTR lpDriverName, LPVOID lpContext, HMONITOR hMonitor)
313401 {
 402+ TRACE_ENTER("DDEnumExA",5,24,guid,16,lpDriverDescription,16,lpDriverName,14,lpContext,13,hMonitor);
314403 int *context = (int *)lpContext;
315404 LPDDENUMCALLBACKEXA callback = (LPDDENUMCALLBACKEXA)context[0];
316405 CHAR desc[MAX_PATH];
@@ -316,7 +405,9 @@
317406 CHAR driver[MAX_PATH];
318407 WideCharToMultiByte(CP_ACP,0,lpDriverDescription,-1,desc,MAX_PATH,NULL,NULL);
319408 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;
321412 }
322413
323414 /**
@@ -335,11 +426,18 @@
336427 */
337428 HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
338429 {
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+ }
340436 LPVOID context[2];
341437 context[0] = (LPVOID) lpCallback;
342438 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;
344442 }
345443
346444 /**
@@ -352,18 +450,25 @@
353451 */
354452 BOOL CALLBACK MonitorEnum(HMONITOR hMonitor, HDC unused, LPRECT unused2, LPARAM ptr)
355453 {
 454+ TRACE_ENTER("MonitorEnum",4,13,hMonitor,13,unused,26,unused2,13,ptr);
356455 int * monitors = *(int**)ptr;
357456 if(!monitors)
358457 {
359458 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+ }
361464 monitors[0] = 1;
362465 }
363466 else monitors[0]++;
364467 monitors[monitors[0]] = (int)hMonitor;
365468 *(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);
368473 }
369474
370475 /**
@@ -381,7 +486,12 @@
382487 */
383488 HRESULT WINAPI DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags)
384489 {
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+ }
386496 int *monitors = NULL;
387497 GUID guid;
388498 MONITORINFOEXW monitorinfo;
@@ -392,7 +502,11 @@
393503 if(dwFlags & DDENUM_ATTACHEDSECONDARYDEVICES)
394504 {
395505 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+ }
397511 for(int i = 1; i < monitors[0]; i++)
398512 {
399513 guid = device_template;
@@ -403,6 +517,7 @@
404518 }
405519 free(monitors);
406520 }
 521+ TRACE_EXIT("DirectDrawEnumerateExW",23,(void*)DDERR_OUTOFMEMORY);
407522 return DD_OK;
408523 }
409524
@@ -414,6 +529,8 @@
415530 */
416531 HRESULT WINAPI DllCanUnloadNow()
417532 {
 533+ TRACE_ENTER("DllCanUnloadNow",0);
 534+ TRACE_EXIT("DllCanUnloadNow",23,(void*)S_FALSE);
418535 return S_FALSE;
419536 }
420537
@@ -431,13 +548,24 @@
432549 */
433550 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
434551 {
 552+ TRACE_ENTER("DllGetClassObject",3,24,&rclsid,24,&riid,14,ppv);
435553 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+ }
437559 GetCurrentConfig(&dxglcfg);
438560 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+ }
440566 HRESULT result = factory->QueryInterface(riid,ppv);
 567+ TRACE_VAR("DllGetClassObject","*ppv",14,*ppv);
441568 factory->Release();
 569+ TRACE_EXIT("DllGetClassObject",23,(void*)result);
442570 return result;
443571 }
444572
@@ -444,6 +572,8 @@
445573 /// Stub for function found in system ddraw.dll
446574 DDRAW_API void WINAPI GetDDSurfaceLocal()
447575 {
 576+ TRACE_ENTER("GetDDSurfaceLocal",0);
 577+ TRACE_EXIT("GetDDSurfaceLocal",0,0);
448578 FIXME("GetDDSurfaceLocal: stub\n");
449579 }
450580
@@ -451,6 +581,8 @@
452582 /// This function gets called by the fnddraw.exe test application.
453583 DDRAW_API HANDLE WINAPI GetOLEThunkData(int i1)
454584 {
 585+ TRACE_ENTER("GetOLEThunkData",1,9,i1);
 586+ TRACE_EXIT("GetOleThunkData",14,NULL);
455587 DEBUG("GetOleThunkData: stub\n");
456588 return 0;
457589 }
@@ -459,26 +591,36 @@
460592 /// Function import is GetSurfaceFromDC
461593 DDRAW_API HRESULT WINAPI GlobalGetSurfaceFromDC(LPDIRECTDRAW7 lpDD, HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS)
462594 {
 595+ TRACE_ENTER("GetSurfaceFromDC",3,14,lpDD,9,hdc,14,lpDDS);
463596 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;
465601 }
466602
467603 /// Stub for function found in system ddraw.dll
468604 DDRAW_API void WINAPI RegisterSpecialCase()
469605 {
 606+ TRACE_ENTER("RegisterSpecialCase",0);
470607 FIXME("RegisterSpecialCase: stub\n");
 608+ TRACE_EXIT("RegisterSpecialCase",0,0);
471609 }
472610
473611 /// Stub for function found in system ddraw.dll
474612 DDRAW_API void WINAPI ReleaseDDThreadLock()
475613 {
 614+ TRACE_ENTER("ReleaseDDThreadLock",0);
476615 FIXME("ReleaseDDThreadLock: stub\n");
 616+ TRACE_EXIT("ReleaseDDThreadLock",0,0);
477617 }
478618
479619 /// Stub for function found in system ddraw.dll
480620 DDRAW_API void WINAPI SetAppCompatData()
481621 {
 622+ TRACE_ENTER("SetAppCompatData",0);
482623 FIXME("SetAppCompatData: stub\n");
 624+ TRACE_EXIT("SetAppCompatData",0,0);
483625 }
484626
485627 /**
@@ -494,5 +636,7 @@
495637
496638 DDRAW_API BOOL IsDXGLDDraw()
497639 {
 640+ TRACE_ENTER("IsDXGLDDraw",0);
 641+ TRACE_EXIT("IsDXGLDDraw",0,0);
498642 return TRUE;
499643 }
Index: ddraw/trace.cpp
@@ -16,17 +16,510 @@
1717 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1818
1919 #include "common.h"
20 -#include "trace.h"
2120
 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+
2251 #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)
2558 {
 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);
26248 }
27 -void TRACE_ARG(int argtype, void *arg, int end)
 249+static void trace_decode_guid(GUID *guid)
28250 {
 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);
29280 }
 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+}
30495 void TRACE_EXIT(const char *function, int argtype, void *arg)
31496 {
 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);
32509 }
 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+}
33526 #endif
\ No newline at end of file
Index: ddraw/trace.h
@@ -21,12 +21,11 @@
2222
2323
2424 #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, ...);
2726 void TRACE_EXIT(const char *function, int argtype, void *arg);
 27+void TRACE_VAR(const char *function, const char *var, int argtype, void *arg);
2828 #else
29 -#define TRACE_ENTER(a,b,c,d)
30 -#define TRACE_ARG(a,b,c)
 29+#define TRACE_ENTER(a,...)
3130 #define TRACE_EXIT(a,b,c)
3231 #endif
3332