Index: ddraw/ddraw.cpp |
— | — | @@ -303,7 +303,7 @@ |
304 | 304 | HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext)
|
305 | 305 | {
|
306 | 306 | TRACE_ENTER(2,14,lpCallback,14,lpContext);
|
307 | | - if(IsBadReadPointer(lpCallback))
|
| 307 | + if(!IsReadablePointer(lpCallback))
|
308 | 308 | {
|
309 | 309 | TRACE_EXIT(23,DDERR_INVALIDPARAMS);
|
310 | 310 | return DDERR_INVALIDPARAMS;
|
— | — | @@ -341,7 +341,7 @@ |
342 | 342 | HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW lpCallback, LPVOID lpContext)
|
343 | 343 | {
|
344 | 344 | TRACE_ENTER(2,14,lpCallback,14,lpContext);
|
345 | | - if(IsBadReadPointer(lpCallback))
|
| 345 | + if(!IsReadablePointer(lpCallback))
|
346 | 346 | {
|
347 | 347 | TRACE_EXIT(23,DDERR_INVALIDPARAMS);
|
348 | 348 | return DDERR_INVALIDPARAMS;
|
— | — | @@ -387,7 +387,7 @@ |
388 | 388 | HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
|
389 | 389 | {
|
390 | 390 | TRACE_ENTER(3,14,lpCallback,14,lpContext,9,dwFlags);
|
391 | | - if(IsBadReadPointer(lpCallback))
|
| 391 | + if(!IsReadablePointer(lpCallback))
|
392 | 392 | {
|
393 | 393 | TRACE_EXIT(23,DDERR_INVALIDPARAMS);
|
394 | 394 | return DDERR_INVALIDPARAMS;
|
— | — | @@ -448,7 +448,7 @@ |
449 | 449 | HRESULT WINAPI DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags)
|
450 | 450 | {
|
451 | 451 | TRACE_ENTER(3,14,lpCallback,14,lpContext,9,dwFlags);
|
452 | | - if(IsBadReadPointer(lpCallback))
|
| 452 | + if(!IsReadablePointer(lpCallback))
|
453 | 453 | {
|
454 | 454 | TRACE_EXIT(23,DDERR_GENERIC);
|
455 | 455 | return DDERR_INVALIDPARAMS;
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -573,7 +573,7 @@ |
574 | 574 | {
|
575 | 575 | TRACE_ENTER(3,14,this,24,lpGUID,14,pUnkOuter);
|
576 | 576 | initialized = false;
|
577 | | - if(((ULONG_PTR)lpGUID > 2) && IsBadReadPointer(lpGUID))
|
| 577 | + if(((ULONG_PTR)lpGUID > 2) && !IsReadablePointer(lpGUID))
|
578 | 578 | {
|
579 | 579 | error = DDERR_INVALIDPARAMS ;
|
580 | 580 | TRACE_EXIT(-1,0);
|
Index: ddraw/util.c |
— | — | @@ -27,36 +27,23 @@ |
28 | 28 | * @return
|
29 | 29 | * Returns false if the pointer is valid, or true if an error occurs.
|
30 | 30 | */
|
31 | | -BOOL IsBadReadPointer(void *ptr)
|
| 31 | +char IsReadablePointer(void *ptr)
|
32 | 32 | {
|
33 | 33 | char a;
|
34 | | - TRACE_ENTER(1, 14, ptr);
|
35 | | - if(!ptr)
|
36 | | - {
|
37 | | - TRACE_EXIT(22,1);
|
38 | | - return TRUE;
|
39 | | - }
|
| 34 | + if(!ptr) return 0;
|
40 | 35 | #ifdef _MSC_VER
|
41 | 36 | __try
|
42 | 37 | {
|
43 | 38 | a = *(char*)ptr;
|
44 | | - if(a == *(char*)ptr)
|
45 | | - {
|
46 | | - TRACE_EXIT(22,0);
|
47 | | - return FALSE;
|
48 | | - }
|
49 | | - else
|
50 | | - {
|
51 | | - TRACE_EXIT(22,1);
|
52 | | - return TRUE;
|
53 | | - }
|
| 39 | + if (!a) a++;
|
| 40 | + return a;
|
54 | 41 | }
|
55 | 42 | __except (GetExceptionCode() == STATUS_ACCESS_VIOLATION)
|
56 | 43 | {
|
57 | | - TRACE_EXIT(22,1);
|
58 | | - return TRUE;
|
| 44 | + return 0;
|
59 | 45 | }
|
60 | 46 | #else
|
61 | | - TRACE_RET(BOOL, 22, IsBadReadPtr(ptr, 1));
|
| 47 | + if(IsBadReadPtr(ptr,1) return 0;
|
| 48 | + else return 1;)
|
62 | 49 | #endif
|
63 | 50 | }
|
Index: ddraw/util.h |
— | — | @@ -23,7 +23,7 @@ |
24 | 24 | extern "C" {
|
25 | 25 | #endif
|
26 | 26 |
|
27 | | -BOOL IsBadReadPointer(void *ptr);
|
| 27 | +char IsReadablePointer(void *ptr);
|
28 | 28 |
|
29 | 29 | #ifdef __cplusplus
|
30 | 30 | }
|