| Index: ddraw/ddraw.cpp |
| — | — | @@ -35,6 +35,21 @@ |
| 36 | 36 | int vsyncstatus;
|
| 37 | 37 | bool ddenabled = false;
|
| 38 | 38 |
|
| | 39 | +bool IsBadReadPointer(void *ptr)
|
| | 40 | +{
|
| | 41 | + char a;
|
| | 42 | + try
|
| | 43 | + {
|
| | 44 | + a = *(char*)ptr;
|
| | 45 | + if(a == *(char*)ptr) return false;
|
| | 46 | + else return true;
|
| | 47 | + }
|
| | 48 | + catch(...)
|
| | 49 | + {
|
| | 50 | + return true;
|
| | 51 | + }
|
| | 52 | +}
|
| | 53 | +
|
| 39 | 54 | DDRAW_API void WINAPI AcquireDDThreadLock()
|
| 40 | 55 | {
|
| 41 | 56 | // FIXME: Add thread lock
|
| — | — | @@ -155,6 +170,7 @@ |
| 156 | 171 |
|
| 157 | 172 | HRESULT WINAPI DirectDrawEnumerateA(LPDDENUMCALLBACKA lpCallback, LPVOID lpContext)
|
| 158 | 173 | {
|
| | 174 | + if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 159 | 175 | LPVOID context[2];
|
| 160 | 176 | context[0] = (LPVOID) lpCallback;
|
| 161 | 177 | context[1] = lpContext;
|
| — | — | @@ -170,6 +186,7 @@ |
| 171 | 187 |
|
| 172 | 188 | HRESULT WINAPI DirectDrawEnumerateW(LPDDENUMCALLBACKW lpCallback, LPVOID lpContext)
|
| 173 | 189 | {
|
| | 190 | + if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 174 | 191 | LPVOID context[2];
|
| 175 | 192 | context[0] = (LPVOID) lpCallback;
|
| 176 | 193 | context[1] = lpContext;
|
| — | — | @@ -189,6 +206,7 @@ |
| 190 | 207 |
|
| 191 | 208 | HRESULT WINAPI DirectDrawEnumerateExA(LPDDENUMCALLBACKEXA lpCallback, LPVOID lpContext, DWORD dwFlags)
|
| 192 | 209 | {
|
| | 210 | + if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 193 | 211 | LPVOID context[2];
|
| 194 | 212 | context[0] = (LPVOID) lpCallback;
|
| 195 | 213 | context[1] = lpContext;
|
| — | — | @@ -212,6 +230,7 @@ |
| 213 | 231 |
|
| 214 | 232 | HRESULT WINAPI DirectDrawEnumerateExW(LPDDENUMCALLBACKEXW lpCallback, LPVOID lpContext, DWORD dwFlags)
|
| 215 | 233 | {
|
| | 234 | + if(IsBadReadPointer(lpCallback)) return DDERR_INVALIDPARAMS;
|
| 216 | 235 | int *monitors = NULL;
|
| 217 | 236 | GUID guid;
|
| 218 | 237 | MONITORINFOEXW monitorinfo;
|
| — | — | @@ -255,7 +274,7 @@ |
| 256 | 275 | }
|
| 257 | 276 | DDRAW_API HANDLE WINAPI GetOLEThunkData(int i1)
|
| 258 | 277 | {
|
| 259 | | - FIXME("GetOleThunkData: stub\n");
|
| | 278 | + DEBUG("GetOleThunkData: stub\n");
|
| 260 | 279 | return 0;
|
| 261 | 280 | }
|
| 262 | 281 | DDRAW_API HRESULT WINAPI GlobalGetSurfaceFromDC(LPDIRECTDRAW7 lpDD, HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS)
|
| Index: ddraw/ddraw.vcxproj |
| — | — | @@ -84,6 +84,7 @@ |
| 85 | 85 | <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;DDRAW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
| 86 | 86 | <AdditionalIncludeDirectories>../include;../glew/glew-1.6.0/include</AdditionalIncludeDirectories>
|
| 87 | 87 | <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
|
| | 88 | + <ExceptionHandling>Async</ExceptionHandling>
|
| 88 | 89 | </ClCompile>
|
| 89 | 90 | <Link>
|
| 90 | 91 | <SubSystem>Windows</SubSystem>
|
| — | — | @@ -100,6 +101,7 @@ |
| 101 | 102 | <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_WINDOWS;_USRDLL;DDRAW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
| 102 | 103 | <AdditionalIncludeDirectories>../include;../glew/glew-1.6.0/include</AdditionalIncludeDirectories>
|
| 103 | 104 | <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
|
| | 105 | + <ExceptionHandling>Async</ExceptionHandling>
|
| 104 | 106 | </ClCompile>
|
| 105 | 107 | <Link>
|
| 106 | 108 | <SubSystem>Windows</SubSystem>
|
| — | — | @@ -121,6 +123,7 @@ |
| 122 | 124 | <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;DDRAW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
| 123 | 125 | <AdditionalIncludeDirectories>../include;../glew/glew-1.6.0/include</AdditionalIncludeDirectories>
|
| 124 | 126 | <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
|
| | 127 | + <ExceptionHandling>Async</ExceptionHandling>
|
| 125 | 128 | </ClCompile>
|
| 126 | 129 | <Link>
|
| 127 | 130 | <SubSystem>Windows</SubSystem>
|
| — | — | @@ -142,6 +145,7 @@ |
| 143 | 146 | <PreprocessorDefinitions>WIN32;_CRT_SECURE_NO_WARNINGS;NDEBUG;_WINDOWS;_USRDLL;DDRAW_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
| 144 | 147 | <AdditionalIncludeDirectories>../include;../glew/glew-1.6.0/include</AdditionalIncludeDirectories>
|
| 145 | 148 | <PrecompiledHeaderFile>common.h</PrecompiledHeaderFile>
|
| | 149 | + <ExceptionHandling>Async</ExceptionHandling>
|
| 146 | 150 | </ClCompile>
|
| 147 | 151 | <Link>
|
| 148 | 152 | <SubSystem>Windows</SubSystem>
|
| Index: ddraw/glDirectDraw.cpp |
| — | — | @@ -548,6 +548,10 @@ |
| 549 | 549 |
|
| 550 | 550 | glDirectDraw7::glDirectDraw7()
|
| 551 | 551 | {
|
| | 552 | + glD3D7 = NULL;
|
| | 553 | + clippers = NULL;
|
| | 554 | + surfaces = NULL;
|
| | 555 | + renderer = NULL;
|
| 552 | 556 | initialized = false;
|
| 553 | 557 | devid.liDriverVersion.QuadPart = DXGLVERQWORD;
|
| 554 | 558 | refcount = 1;
|
| — | — | @@ -701,6 +705,7 @@ |
| 702 | 706 | }
|
| 703 | 707 | HRESULT WINAPI glDirectDraw7::CreateSurface(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
| 704 | 708 | {
|
| | 709 | + if(!lpDDSurfaceDesc2) return DDERR_INVALIDPARAMS;
|
| 705 | 710 | if(primary && (lpDDSurfaceDesc2->ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) && (renderer->hRC == primary->hRC) )
|
| 706 | 711 | {
|
| 707 | 712 | if(primarylost)
|
| — | — | @@ -899,7 +904,7 @@ |
| 900 | 905 | }
|
| 901 | 906 | HRESULT WINAPI glDirectDraw7::GetVerticalBlankStatus(LPBOOL lpbIsInVB)
|
| 902 | 907 | {
|
| 903 | | - FIXME("IDirectDraw::GetVerticalBlankStatis: stub\n");
|
| | 908 | + FIXME("IDirectDraw::GetVerticalBlankStatus: stub\n");
|
| 904 | 909 | ERR(DDERR_GENERIC);
|
| 905 | 910 | }
|
| 906 | 911 | HRESULT WINAPI glDirectDraw7::Initialize(GUID FAR *lpGUID)
|
| — | — | @@ -1513,6 +1518,7 @@ |
| 1514 | 1519 | }
|
| 1515 | 1520 | HRESULT WINAPI glDirectDraw2::CreateSurface(LPDDSURFACEDESC lpDDSurfaceDesc, LPDIRECTDRAWSURFACE FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
| 1516 | 1521 | {
|
| | 1522 | + if(!lplpDDSurface) return DDERR_INVALIDPARAMS;
|
| 1517 | 1523 | LPDIRECTDRAWSURFACE7 lpDDS7;
|
| 1518 | 1524 | HRESULT err = glDD7->CreateSurface((LPDDSURFACEDESC2)lpDDSurfaceDesc,&lpDDS7,pUnkOuter);
|
| 1519 | 1525 | if(err == DD_OK)
|
| Index: ddraw/glDirectDrawSurface.cpp |
| — | — | @@ -235,12 +235,57 @@ |
| 236 | 236 | ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth);
|
| 237 | 237 | break;
|
| 238 | 238 | case 16:
|
| 239 | | - FIXME("Support 16 bit pixelformat");
|
| | 239 | + if((ddsd.ddpfPixelFormat.dwRBitMask == 0x7C00) && (ddsd.ddpfPixelFormat.dwGBitMask == 0x3E0)
|
| | 240 | + && (ddsd.ddpfPixelFormat.dwBBitMask == 0x1F))
|
| | 241 | + {
|
| | 242 | + texformat = GL_BGRA;
|
| | 243 | + texformat2 = GL_UNSIGNED_SHORT_1_5_5_5_REV;
|
| | 244 | + if(dxglcfg.texformat) texformat3 = GL_RGB5_A1;
|
| | 245 | + else texformat3 = GL_RGBA8;
|
| | 246 | + }
|
| | 247 | + else // fixme: support more formats
|
| | 248 | + {
|
| | 249 | + texformat = GL_RGB;
|
| | 250 | + texformat2 = GL_UNSIGNED_SHORT_5_6_5;
|
| | 251 | + if(dxglcfg.texformat) texformat3 = GL_RGB;
|
| | 252 | + else texformat3 = GL_RGBA8;
|
| | 253 | + }
|
| | 254 | + ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*2);
|
| | 255 | + break;
|
| 240 | 256 | case 24:
|
| 241 | | - FIXME("Support 24 bit pixelformat");
|
| | 257 | + if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
|
| | 258 | + && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
|
| | 259 | + {
|
| | 260 | + texformat = GL_BGR;
|
| | 261 | + texformat2 = GL_UNSIGNED_BYTE;
|
| | 262 | + if(dxglcfg.texformat) texformat3 = GL_RGB8;
|
| | 263 | + else texformat3 = GL_RGBA8;
|
| | 264 | + }
|
| | 265 | + else // fixme: support more formats
|
| | 266 | + {
|
| | 267 | + texformat = GL_RGB;
|
| | 268 | + texformat2 = GL_UNSIGNED_BYTE;
|
| | 269 | + if(dxglcfg.texformat) texformat3 = GL_RGB8;
|
| | 270 | + else texformat3 = GL_RGBA8;
|
| | 271 | + }
|
| | 272 | + ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*3);
|
| | 273 | + break;
|
| 242 | 274 | case 32:
|
| 243 | 275 | default:
|
| 244 | | - FIXME("Support 32 bit pixelformat");
|
| | 276 | + if((ddsd.ddpfPixelFormat.dwRBitMask == 0xFF0000) && (ddsd.ddpfPixelFormat.dwGBitMask == 0xFF00)
|
| | 277 | + && (ddsd.ddpfPixelFormat.dwBBitMask == 0xFF))
|
| | 278 | + {
|
| | 279 | + texformat = GL_BGRA;
|
| | 280 | + texformat2 = GL_UNSIGNED_BYTE;
|
| | 281 | + texformat3 = GL_RGBA8;
|
| | 282 | + }
|
| | 283 | + else // fixme: support more formats
|
| | 284 | + {
|
| | 285 | + texformat = GL_RGBA;
|
| | 286 | + texformat2 = GL_UNSIGNED_BYTE;
|
| | 287 | + texformat3 = GL_RGBA8;
|
| | 288 | + }
|
| | 289 | + ddsd.lPitch = NextMultipleOfWord(ddsd.dwWidth*4);
|
| 245 | 290 | }
|
| 246 | 291 | }
|
| 247 | 292 | else if(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)
|