| Index: cfgmgr/cfgmgr.cpp |
| — | — | @@ -278,7 +278,7 @@ |
| 279 | 279 | else return false;
|
| 280 | 280 | }
|
| 281 | 281 |
|
| 282 | | -void GetCurrentConfig(DXGLCFG *cfg)
|
| | 282 | +void GetCurrentConfig(DXGLCFG *cfg, bool initial)
|
| 283 | 283 | {
|
| 284 | 284 | HKEY hKey;
|
| 285 | 285 | unsigned long crc;
|
| — | — | @@ -312,100 +312,103 @@ |
| 313 | 313 | ReadSettings(hKey,cfg,NULL,false,true,NULL);
|
| 314 | 314 | RegCloseKey(hKey);
|
| 315 | 315 | hKey = NULL;
|
| 316 | | - HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
|
| 317 | | - BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
|
| 318 | | - if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
|
| 319 | | - BOOL is64 = FALSE;
|
| 320 | | - if(iswow64) iswow64(GetCurrentProcess(),&is64);
|
| 321 | | - if(hKernel32) FreeLibrary(hKernel32);
|
| 322 | | - LRESULT error;
|
| 323 | | - if(is64) error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
|
| 324 | | - else error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
|
| 325 | | - if(error == ERROR_SUCCESS)
|
| | 316 | + if (initial)
|
| 326 | 317 | {
|
| 327 | | - GetModuleFileName(NULL,filename,MAX_PATH);
|
| 328 | | - TCHAR buffer[1024];
|
| 329 | | - ZeroMemory(buffer,1024*sizeof(TCHAR));
|
| 330 | | - DWORD sizeout = 1024*sizeof(TCHAR);
|
| 331 | | - if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
|
| | 318 | + HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
|
| | 319 | + BOOL (WINAPI *iswow64)(HANDLE,PBOOL) = NULL;
|
| | 320 | + if(hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE,PBOOL))GetProcAddress(hKernel32,"IsWow64Process");
|
| | 321 | + BOOL is64 = FALSE;
|
| | 322 | + if(iswow64) iswow64(GetCurrentProcess(),&is64);
|
| | 323 | + if(hKernel32) FreeLibrary(hKernel32);
|
| | 324 | + LRESULT error;
|
| | 325 | + if(is64) error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
|
| | 326 | + else error = RegOpenKeyEx(HKEY_LOCAL_MACHINE,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
|
| | 327 | + if(error == ERROR_SUCCESS)
|
| 332 | 328 | {
|
| 333 | | - if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
|
| | 329 | + GetModuleFileName(NULL,filename,MAX_PATH);
|
| | 330 | + TCHAR buffer[1024];
|
| | 331 | + ZeroMemory(buffer,1024*sizeof(TCHAR));
|
| | 332 | + DWORD sizeout = 1024*sizeof(TCHAR);
|
| | 333 | + if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
|
| 334 | 334 | {
|
| 335 | | - MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
|
| 336 | | - _T("AppCompat error"),MB_OK|MB_ICONHAND);
|
| 337 | | - error = RegDeleteValue(hKey,filename);
|
| 338 | | - if(error == ERROR_ACCESS_DENIED)
|
| | 335 | + if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
|
| 339 | 336 | {
|
| 340 | | - tstring command;
|
| 341 | | - if(is64) command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| 342 | | - else command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| 343 | | - command.append(filename);
|
| 344 | | - command.append(_T("\""));
|
| 345 | | - SHELLEXECUTEINFO info;
|
| 346 | | - ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
|
| 347 | | - info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 348 | | - info.lpVerb = _T("runas");
|
| 349 | | - info.lpFile = _T("reg.exe");
|
| 350 | | - info.lpParameters = command.c_str();
|
| 351 | | - info.nShow = SW_SHOWNORMAL;
|
| 352 | | - info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 353 | | - ShellExecuteEx(&info);
|
| 354 | | - WaitForSingleObject(info.hProcess,INFINITE);
|
| 355 | | - GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
|
| | 337 | + MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
|
| | 338 | + _T("AppCompat error"),MB_OK|MB_ICONHAND);
|
| | 339 | + error = RegDeleteValue(hKey,filename);
|
| | 340 | + if(error == ERROR_ACCESS_DENIED)
|
| | 341 | + {
|
| | 342 | + tstring command;
|
| | 343 | + if(is64) command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| | 344 | + else command.assign(_T("DELETE \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| | 345 | + command.append(filename);
|
| | 346 | + command.append(_T("\""));
|
| | 347 | + SHELLEXECUTEINFO info;
|
| | 348 | + ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
|
| | 349 | + info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 350 | + info.lpVerb = _T("runas");
|
| | 351 | + info.lpFile = _T("reg.exe");
|
| | 352 | + info.lpParameters = command.c_str();
|
| | 353 | + info.nShow = SW_SHOWNORMAL;
|
| | 354 | + info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 355 | + ShellExecuteEx(&info);
|
| | 356 | + WaitForSingleObject(info.hProcess,INFINITE);
|
| | 357 | + GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
|
| | 358 | + }
|
| | 359 | + if(!error)
|
| | 360 | + {
|
| | 361 | + MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
|
| | 362 | + exit(0);
|
| | 363 | + }
|
| | 364 | + else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
|
| 356 | 365 | }
|
| 357 | | - if(!error)
|
| 358 | | - {
|
| 359 | | - MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
|
| 360 | | - exit(0);
|
| 361 | | - }
|
| 362 | | - else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
|
| 363 | 366 | }
|
| | 367 | + RegCloseKey(hKey);
|
| 364 | 368 | }
|
| 365 | | - RegCloseKey(hKey);
|
| 366 | | - }
|
| 367 | | - if(is64) error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
|
| 368 | | - else error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
|
| 369 | | - if(error == ERROR_SUCCESS)
|
| 370 | | - {
|
| 371 | | - GetModuleFileName(NULL,filename,MAX_PATH);
|
| 372 | | - TCHAR buffer[1024];
|
| 373 | | - ZeroMemory(buffer,1024*sizeof(TCHAR));
|
| 374 | | - DWORD sizeout = 1024*sizeof(TCHAR);
|
| 375 | | - if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
|
| | 369 | + if(is64) error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ|KEY_WOW64_64KEY,&hKey);
|
| | 370 | + else error = RegOpenKeyEx(HKEY_CURRENT_USER,_T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),0,KEY_READ,&hKey);
|
| | 371 | + if(error == ERROR_SUCCESS)
|
| 376 | 372 | {
|
| 377 | | - if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
|
| | 373 | + GetModuleFileName(NULL,filename,MAX_PATH);
|
| | 374 | + TCHAR buffer[1024];
|
| | 375 | + ZeroMemory(buffer,1024*sizeof(TCHAR));
|
| | 376 | + DWORD sizeout = 1024*sizeof(TCHAR);
|
| | 377 | + if(RegQueryValueEx(hKey,filename,NULL,NULL,(LPBYTE)buffer,&sizeout) == ERROR_SUCCESS)
|
| 378 | 378 | {
|
| 379 | | - MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
|
| 380 | | - _T("AppCompat error"),MB_OK|MB_ICONHAND);
|
| 381 | | - error = RegDeleteValue(hKey,filename);
|
| 382 | | - if(error == ERROR_ACCESS_DENIED)
|
| | 379 | + if(_tcsstr(buffer,_T("DWM8And16BitMitigation")))
|
| 383 | 380 | {
|
| 384 | | - tstring command;
|
| 385 | | - if(is64) command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| 386 | | - else command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| 387 | | - command.append(filename);
|
| 388 | | - command.append(_T("\""));
|
| 389 | | - SHELLEXECUTEINFO info;
|
| 390 | | - ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
|
| 391 | | - info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 392 | | - info.lpVerb = _T("runas");
|
| 393 | | - info.lpFile = _T("reg.exe");
|
| 394 | | - info.lpParameters = command.c_str();
|
| 395 | | - info.nShow = SW_SHOWNORMAL;
|
| 396 | | - info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 397 | | - ShellExecuteEx(&info);
|
| 398 | | - WaitForSingleObject(info.hProcess,INFINITE);
|
| 399 | | - GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
|
| | 381 | + MessageBox(NULL,_T("DXGL has detected an incompatible AppCompat flag for the program you are currently running. To continue, the registry value must be deleted.\nIf you see a UAC prompt, you must click Yes."),
|
| | 382 | + _T("AppCompat error"),MB_OK|MB_ICONHAND);
|
| | 383 | + error = RegDeleteValue(hKey,filename);
|
| | 384 | + if(error == ERROR_ACCESS_DENIED)
|
| | 385 | + {
|
| | 386 | + tstring command;
|
| | 387 | + if(is64) command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| | 388 | + else command.assign(_T("DELETE \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| | 389 | + command.append(filename);
|
| | 390 | + command.append(_T("\""));
|
| | 391 | + SHELLEXECUTEINFO info;
|
| | 392 | + ZeroMemory(&info,sizeof(SHELLEXECUTEINFO));
|
| | 393 | + info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 394 | + info.lpVerb = _T("runas");
|
| | 395 | + info.lpFile = _T("reg.exe");
|
| | 396 | + info.lpParameters = command.c_str();
|
| | 397 | + info.nShow = SW_SHOWNORMAL;
|
| | 398 | + info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 399 | + ShellExecuteEx(&info);
|
| | 400 | + WaitForSingleObject(info.hProcess,INFINITE);
|
| | 401 | + GetExitCodeProcess(info.hProcess,(LPDWORD)&error);
|
| | 402 | + }
|
| | 403 | + if(!error)
|
| | 404 | + {
|
| | 405 | + MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
|
| | 406 | + exit(0);
|
| | 407 | + }
|
| | 408 | + else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
|
| 400 | 409 | }
|
| 401 | | - if(!error)
|
| 402 | | - {
|
| 403 | | - MessageBox(NULL,_T("Registry value successfully deleted. Please restart the program."),_T("Success"),MB_OK|MB_ICONINFORMATION);
|
| 404 | | - exit(0);
|
| 405 | | - }
|
| 406 | | - else MessageBox(NULL,_T("Registry value could not be deleted. Your program may crash as a result."),_T("Error"),MB_OK|MB_ICONWARNING);
|
| 407 | 410 | }
|
| | 411 | + RegCloseKey(hKey);
|
| 408 | 412 | }
|
| 409 | | - RegCloseKey(hKey);
|
| 410 | 413 | }
|
| 411 | 414 | }
|
| 412 | 415 | void GetGlobalConfig(DXGLCFG *cfg)
|
| Index: cfgmgr/cfgmgr.h |
| — | — | @@ -42,7 +42,7 @@ |
| 43 | 43 |
|
| 44 | 44 | void ReadSettings(HKEY hKey, DXGLCFG *cfg, DXGLCFG *mask, bool global, bool dll, LPTSTR dir);
|
| 45 | 45 | void WriteSettings(HKEY hKey, const DXGLCFG *cfg, const DXGLCFG *mask, bool global);
|
| 46 | | -void GetCurrentConfig(DXGLCFG *cfg);
|
| | 46 | +void GetCurrentConfig(DXGLCFG *cfg, bool initial);
|
| 47 | 47 | void GetGlobalConfig(DXGLCFG *cfg);
|
| 48 | 48 | void SetGlobalConfig(const DXGLCFG *cfg);
|
| 49 | 49 | void GetConfig(DXGLCFG *cfg, DXGLCFG *mask, LPCTSTR name);
|
| Index: ddraw/ddraw.cpp |
| — | — | @@ -194,7 +194,7 @@ |
| 195 | 195 | TRACE_EXIT(23,DDERR_DIRECTDRAWALREADYCREATED);
|
| 196 | 196 | return DDERR_DIRECTDRAWALREADYCREATED;
|
| 197 | 197 | }
|
| 198 | | - GetCurrentConfig(&dxglcfg);
|
| | 198 | + GetCurrentConfig(&dxglcfg,false);
|
| 199 | 199 | glDirectDraw7 *myddraw7;
|
| 200 | 200 | glDirectDraw1 *myddraw;
|
| 201 | 201 | HRESULT error;
|
| — | — | @@ -267,7 +267,7 @@ |
| 268 | 268 | TRACE_EXIT(23,DDERR_DIRECTDRAWALREADYCREATED);
|
| 269 | 269 | return DDERR_DIRECTDRAWALREADYCREATED;
|
| 270 | 270 | }
|
| 271 | | - GetCurrentConfig(&dxglcfg);
|
| | 271 | + GetCurrentConfig(&dxglcfg,false);
|
| 272 | 272 | glDirectDraw7 *myddraw;
|
| 273 | 273 | HRESULT error;
|
| 274 | 274 | if(iid != IID_IDirectDraw7)
|
| — | — | @@ -527,7 +527,7 @@ |
| 528 | 528 | TRACE_EXIT(23,CLASS_E_CLASSNOTAVAILABLE);
|
| 529 | 529 | return CLASS_E_CLASSNOTAVAILABLE;
|
| 530 | 530 | }
|
| 531 | | - GetCurrentConfig(&dxglcfg);
|
| | 531 | + GetCurrentConfig(&dxglcfg,false);
|
| 532 | 532 | glClassFactory *factory = new glClassFactory;
|
| 533 | 533 | if(factory == NULL)
|
| 534 | 534 | {
|
| Index: ddraw/dllmain.cpp |
| — | — | @@ -26,6 +26,8 @@ |
| 27 | 27 | switch (ul_reason_for_call)
|
| 28 | 28 | {
|
| 29 | 29 | case DLL_PROCESS_ATTACH:
|
| | 30 | + GetCurrentConfig(&dxglcfg, true);
|
| | 31 | + break;
|
| 30 | 32 | case DLL_THREAD_ATTACH:
|
| 31 | 33 | case DLL_THREAD_DETACH:
|
| 32 | 34 | case DLL_PROCESS_DETACH:
|