DXGL r10 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r9‎ | r10 | r11 >
Date:01:13, 23 November 2011
Author:admin
Status:new
Tags:
Comment:
Fix Windows XP compatibility
Modified paths:
  • /ddraw/ddraw.cpp (modified) (history)
  • /dxglcfg/dxglcfg.cpp (modified) (history)

Diff [purge]

Index: ddraw/ddraw.cpp
@@ -19,6 +19,8 @@
2020 #include "ddraw.h"
2121 #include "glDirectDraw.h"
2222 #include "glDirectDrawClipper.h"
 23+#include <intrin.h>
 24+#include <tlhelp32.h>
2325
2426 DXGLCFG dxglcfg;
2527 bool gllock = false;
@@ -61,10 +63,28 @@
6264 {
6365 FIXME("DSoundHelp: stub\n");
6466 }
 67+int IsCallerOpenGL(void *returnaddress)
 68+{
 69+ int isgl = 0;
 70+ MODULEENTRY32 modentry = {0};
 71+ HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE,0);
 72+ modentry.dwSize = sizeof(MODULEENTRY32);
 73+ Module32First(hSnapshot,&modentry);
 74+ do
 75+ {
 76+ if((modentry.modBaseAddr <= returnaddress) &&
 77+ (modentry.modBaseAddr+modentry.modBaseSize > returnaddress))
 78+ {
 79+ if(!_tcsicmp(modentry.szModule,_T("opengl32.dll"))) isgl=1;
 80+ break;
 81+ }
 82+ } while(Module32Next(hSnapshot,&modentry));
 83+ CloseHandle(hSnapshot);
 84+ return isgl;
 85+}
6586 HRESULT WINAPI DirectDrawCreate(GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter)
6687 {
67 - GetCurrentConfig(&dxglcfg);
68 - if(gllock)
 88+ if(gllock || IsCallerOpenGL(_ReturnAddress()))
6989 {
7090 if(!sysddraw)
7191 {
@@ -81,6 +101,7 @@
82102 }
83103 return sysddrawcreate(lpGUID,lplpDD,pUnkOuter);
84104 }
 105+ GetCurrentConfig(&dxglcfg);
85106 glDirectDraw7 *myddraw7;
86107 glDirectDraw1 *myddraw;
87108 HRESULT error;
Index: dxglcfg/dxglcfg.cpp
@@ -267,7 +267,7 @@
268268 bool hasname;
269269 void *verinfo;
270270 COLORREF OldTextColor,OldBackColor;
271 - HANDLE token;
 271+ HANDLE token = NULL;
272272 TOKEN_ELEVATION elevation;
273273 switch(Msg)
274274 {