| Index: cfgmgr/cfgmgr.cpp |
| — | — | @@ -32,7 +32,6 @@ |
| 33 | 33 | TCHAR regkeybase[] = _T("Software\\DXGL\\");
|
| 34 | 34 |
|
| 35 | 35 | DXGLCFG defaultmask;
|
| 36 | | -UINT_PTR timerid;
|
| 37 | 36 |
|
| 38 | 37 | INT_PTR CALLBACK CompatDialogCallback(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
| 39 | 38 | {
|
| — | — | @@ -39,7 +38,7 @@ |
| 40 | 39 | switch (Msg)
|
| 41 | 40 | {
|
| 42 | 41 | case WM_INITDIALOG:
|
| 43 | | - timerid = SetTimer(hWnd, NULL, 5000, NULL);
|
| | 42 | + SetTimer(hWnd, NULL, 3000, NULL);
|
| 44 | 43 | return TRUE;
|
| 45 | 44 | case WM_TIMER:
|
| 46 | 45 | EndDialog(hWnd, 0);
|
| — | — | @@ -47,14 +46,22 @@ |
| 48 | 47 | default:
|
| 49 | 48 | return FALSE;
|
| 50 | 49 | }
|
| | 50 | + return FALSE;
|
| 51 | 51 | }
|
| 52 | 52 |
|
| 53 | 53 | void ShowRestartDialog()
|
| 54 | 54 | {
|
| 55 | | - BOOL(*_GetModuleHandleEx)(DWORD dwFlags, LPCTSTR lpModuleName, HMODULE* phModule) = FALSE;
|
| | 55 | + BOOL(WINAPI *_GetModuleHandleEx)(DWORD dwFlags, LPCTSTR lpModuleName, HMODULE* phModule) = FALSE;
|
| 56 | 56 | HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
|
| 57 | 57 | HMODULE hddraw;
|
| 58 | | - if (hKernel32) _GetModuleHandleEx = (BOOL(*)(DWORD,LPCTSTR,HMODULE*))GetProcAddress(hKernel32, "GetModuleHandleEx");
|
| | 58 | + if (hKernel32)
|
| | 59 | + {
|
| | 60 | +#ifdef _UNICODE
|
| | 61 | + _GetModuleHandleEx = (BOOL(WINAPI*)(DWORD, LPCTSTR, HMODULE*))GetProcAddress(hKernel32, "GetModuleHandleExW");
|
| | 62 | +#else
|
| | 63 | + _GetModuleHandleEx = (BOOL(WINAPI*)(DWORD, LPCTSTR, HMODULE*))GetProcAddress(hKernel32, "GetModuleHandleExA");
|
| | 64 | +#endif
|
| | 65 | + }
|
| 59 | 66 | if (_GetModuleHandleEx) _GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, (LPCTSTR)ShowRestartDialog, &hddraw);
|
| 60 | 67 | else hddraw = GetModuleHandle(_T("ddraw.dll")); //For old versions of Windows, may fail but they shouldn't have AppCompat anyways.
|
| 61 | 68 | if (hKernel32) FreeLibrary(hKernel32);
|
| — | — | @@ -85,7 +92,6 @@ |
| 86 | 93 | LRESULT error,error2;
|
| 87 | 94 | TCHAR filename[MAX_PATH + 1];
|
| 88 | 95 | TCHAR buffer[1024];
|
| 89 | | - TCHAR *bufferpos;
|
| 90 | 96 | error = RegCreateKeyEx(HKEY_CURRENT_USER, _T("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers"),
|
| 91 | 97 | 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| 92 | 98 | if (error == ERROR_SUCCESS)
|
| — | — | @@ -134,10 +140,10 @@ |
| 135 | 141 | return false;
|
| 136 | 142 | }
|
| 137 | 143 |
|
| 138 | | -bool DelCompatFlag(LPTSTR flag)
|
| | 144 | +bool DelCompatFlag(LPTSTR flag, bool initial)
|
| 139 | 145 | {
|
| 140 | 146 | HKEY hKey;
|
| 141 | | - HKEY hKeyWrite;
|
| | 147 | + HKEY hKeyWrite = NULL;
|
| 142 | 148 | HMODULE hKernel32 = LoadLibrary(_T("kernel32.dll"));
|
| 143 | 149 | BOOL(WINAPI *iswow64)(HANDLE, PBOOL) = NULL;
|
| 144 | 150 | if (hKernel32) iswow64 = (BOOL(WINAPI*)(HANDLE, PBOOL))GetProcAddress(hKernel32, "IsWow64Process");
|
| — | — | @@ -170,34 +176,49 @@ |
| 171 | 177 | {
|
| 172 | 178 | error = RegSetValueEx(hKeyWrite, filename, 0, REG_SZ, (BYTE*)buffer, (_tcslen(bufferpos + _tcslen(flag)))*sizeof(TCHAR)+sizeof(TCHAR));
|
| 173 | 179 | RegCloseKey(hKeyWrite);
|
| | 180 | + hKeyWrite = NULL;
|
| 174 | 181 | }
|
| 175 | 182 | if (error == ERROR_ACCESS_DENIED)
|
| 176 | 183 | {
|
| 177 | | - if (MessageBox(NULL, _T("DXGL has detected an incompatible AppCompat flag for the program you are currently running and requires administrative rights to remove it.\nWould you like to continue?"),
|
| 178 | | - _T("AppCompat error"), MB_YESNO | MB_ICONWARNING) == IDYES)
|
| | 184 | + if (!initial)
|
| 179 | 185 | {
|
| 180 | | - tstring command;
|
| 181 | | - if (is64) command.assign(_T("ADD \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| 182 | | - else command.assign(_T("ADD \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| 183 | | - command.append(filename);
|
| 184 | | - command.append(_T("\" /t REG_SZ /d \""));
|
| 185 | | - command.append(buffer);
|
| 186 | | - command.append(_T("\""));
|
| 187 | | - SHELLEXECUTEINFO info;
|
| 188 | | - ZeroMemory(&info, sizeof(SHELLEXECUTEINFO));
|
| 189 | | - info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 190 | | - info.lpVerb = _T("runas");
|
| 191 | | - info.lpFile = _T("reg.exe");
|
| 192 | | - info.lpParameters = command.c_str();
|
| 193 | | - info.nShow = SW_SHOWNORMAL;
|
| 194 | | - info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 195 | | - ShellExecuteEx(&info);
|
| 196 | | - WaitForSingleObject(info.hProcess, INFINITE);
|
| 197 | | - GetExitCodeProcess(info.hProcess, (LPDWORD)&error);
|
| | 186 | + if (MessageBox(NULL, _T("DXGL has detected an incompatible AppCompat flag for the program you are currently running and requires administrative rights to remove it.\nWould you like to continue?"),
|
| | 187 | + _T("AppCompat error"), MB_YESNO | MB_ICONWARNING) == IDYES)
|
| | 188 | + {
|
| | 189 | + tstring command;
|
| | 190 | + if (is64) command.assign(_T("ADD \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /reg:64 /f /v \""));
|
| | 191 | + else command.assign(_T("ADD \"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| | 192 | + command.append(filename);
|
| | 193 | + command.append(_T("\" /t REG_SZ /d \""));
|
| | 194 | + command.append(buffer);
|
| | 195 | + command.append(_T("\""));
|
| | 196 | + SHELLEXECUTEINFO info;
|
| | 197 | + ZeroMemory(&info, sizeof(SHELLEXECUTEINFO));
|
| | 198 | + info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 199 | + info.lpVerb = _T("runas");
|
| | 200 | + info.lpFile = _T("reg.exe");
|
| | 201 | + info.lpParameters = command.c_str();
|
| | 202 | + info.nShow = SW_SHOWNORMAL;
|
| | 203 | + info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 204 | + ShellExecuteEx(&info);
|
| | 205 | + WaitForSingleObject(info.hProcess, INFINITE);
|
| | 206 | + GetExitCodeProcess(info.hProcess, (LPDWORD)&error);
|
| | 207 | + }
|
| | 208 | + if (!error) ShowRestartDialog();
|
| | 209 | + else
|
| | 210 | + {
|
| | 211 | + MessageBox(NULL, _T("Registry value could not be updated. Your program may crash as a result."), _T("Error"), MB_OK | MB_ICONWARNING);
|
| | 212 | + if(hKeyWrite) RegCloseKey(hKeyWrite);
|
| | 213 | + RegCloseKey(hKey);
|
| | 214 | + }
|
| | 215 | + return false;
|
| 198 | 216 | }
|
| 199 | | - if (!error) ShowRestartDialog();
|
| 200 | | - else MessageBox(NULL, _T("Registry value could not be updated. Your program may crash as a result."), _T("Error"), MB_OK | MB_ICONWARNING);
|
| 201 | | - return false;
|
| | 217 | + else
|
| | 218 | + {
|
| | 219 | + if (hKeyWrite) RegCloseKey(hKeyWrite);
|
| | 220 | + RegCloseKey(hKey);
|
| | 221 | + return false;
|
| | 222 | + }
|
| 202 | 223 | }
|
| 203 | 224 | else if (error == ERROR_SUCCESS) ShowRestartDialog();
|
| 204 | 225 | }
|
| — | — | @@ -223,36 +244,51 @@ |
| 224 | 245 | {
|
| 225 | 246 | error = RegSetValueEx(hKeyWrite, filename, 0, REG_SZ, (BYTE*)buffer, (_tcslen(bufferpos + _tcslen(flag)))*sizeof(TCHAR)+sizeof(TCHAR));
|
| 226 | 247 | RegCloseKey(hKeyWrite);
|
| | 248 | + hKeyWrite = NULL;
|
| 227 | 249 | }
|
| 228 | 250 | if (error == ERROR_ACCESS_DENIED)
|
| 229 | 251 | {
|
| 230 | | - if (MessageBox(NULL, _T("DXGL has detected an incompatible AppCompat flag for the program you are currently running and requires administrative rights to remove it.\nWould you like to continue?"),
|
| 231 | | - _T("AppCompat error"), MB_YESNO | MB_ICONWARNING) == IDYES)
|
| | 252 | + if (hKeyWrite)
|
| 232 | 253 | {
|
| 233 | | - tstring command;
|
| 234 | | - command.assign(_T("ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| 235 | | - command.append(filename);
|
| 236 | | - command.append(_T("\" /t REG_SZ /d \""));
|
| 237 | | - command.append(buffer);
|
| 238 | | - command.append(_T("\""));
|
| 239 | | - SHELLEXECUTEINFO info;
|
| 240 | | - ZeroMemory(&info, sizeof(SHELLEXECUTEINFO));
|
| 241 | | - info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| 242 | | - info.lpVerb = _T("runas");
|
| 243 | | - info.lpFile = _T("reg.exe");
|
| 244 | | - info.lpParameters = command.c_str();
|
| 245 | | - info.nShow = SW_SHOWNORMAL;
|
| 246 | | - info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| 247 | | - ShellExecuteEx(&info);
|
| 248 | | - WaitForSingleObject(info.hProcess, INFINITE);
|
| 249 | | - GetExitCodeProcess(info.hProcess, (LPDWORD)&error);
|
| | 254 | + RegCloseKey(hKeyWrite);
|
| | 255 | + hKeyWrite = NULL;
|
| 250 | 256 | }
|
| 251 | | - if (!error)
|
| | 257 | + if (!initial)
|
| 252 | 258 | {
|
| 253 | | - ShowRestartDialog();
|
| | 259 | + if (MessageBox(NULL, _T("DXGL has detected an incompatible AppCompat flag for the program you are currently running and requires administrative rights to remove it.\nWould you like to continue?"),
|
| | 260 | + _T("AppCompat error"), MB_YESNO | MB_ICONWARNING) == IDYES)
|
| | 261 | + {
|
| | 262 | + tstring command;
|
| | 263 | + command.assign(_T("ADD \"HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Layers\" /f /v \""));
|
| | 264 | + command.append(filename);
|
| | 265 | + command.append(_T("\" /t REG_SZ /d \""));
|
| | 266 | + command.append(buffer);
|
| | 267 | + command.append(_T("\""));
|
| | 268 | + SHELLEXECUTEINFO info;
|
| | 269 | + ZeroMemory(&info, sizeof(SHELLEXECUTEINFO));
|
| | 270 | + info.cbSize = sizeof(SHELLEXECUTEINFO);
|
| | 271 | + info.lpVerb = _T("runas");
|
| | 272 | + info.lpFile = _T("reg.exe");
|
| | 273 | + info.lpParameters = command.c_str();
|
| | 274 | + info.nShow = SW_SHOWNORMAL;
|
| | 275 | + info.fMask = SEE_MASK_NOCLOSEPROCESS;
|
| | 276 | + ShellExecuteEx(&info);
|
| | 277 | + WaitForSingleObject(info.hProcess, INFINITE);
|
| | 278 | + GetExitCodeProcess(info.hProcess, (LPDWORD)&error);
|
| | 279 | + }
|
| | 280 | + if (!error)
|
| | 281 | + {
|
| | 282 | + ShowRestartDialog();
|
| | 283 | + }
|
| | 284 | + else MessageBox(NULL, _T("Registry value could not be updated. Your program may crash as a result."), _T("Error"), MB_OK | MB_ICONWARNING);
|
| | 285 | + if (hKeyWrite) RegCloseKey(hKeyWrite);
|
| | 286 | + return false;
|
| 254 | 287 | }
|
| 255 | | - else MessageBox(NULL, _T("Registry value could not be updated. Your program may crash as a result."), _T("Error"), MB_OK | MB_ICONWARNING);
|
| 256 | | - return false;
|
| | 288 | + else
|
| | 289 | + {
|
| | 290 | + if (hKeyWrite) RegCloseKey(hKeyWrite);
|
| | 291 | + return false;
|
| | 292 | + }
|
| 257 | 293 | }
|
| 258 | 294 | else if (error == ERROR_SUCCESS)
|
| 259 | 295 | {
|
| — | — | @@ -567,10 +603,10 @@ |
| 568 | 604 | hKey = NULL;
|
| 569 | 605 | HMODULE hSHCore = NULL;
|
| 570 | 606 | HMODULE hUser32 = NULL;
|
| | 607 | + if (cfg->DPIScale == 2) AddCompatFlag(_T("HIGHDPIAWARE"));
|
| | 608 | + else DelCompatFlag(_T("HIGHDPIAWARE"),initial);
|
| 571 | 609 | if (initial)
|
| 572 | 610 | {
|
| 573 | | - if (cfg->DPIScale == 2) AddCompatFlag(_T("HIGHDPIAWARE"));
|
| 574 | | - else DelCompatFlag(_T("HIGHDPIAWARE"));
|
| 575 | 611 | if (cfg->DPIScale == 1)
|
| 576 | 612 | {
|
| 577 | 613 | bool DPIAwarePM = false;
|
| — | — | @@ -598,8 +634,8 @@ |
| 599 | 635 | if (hSHCore) FreeLibrary(hSHCore);
|
| 600 | 636 | if (hUser32) FreeLibrary(hUser32);
|
| 601 | 637 | }
|
| 602 | | - DelCompatFlag(_T("DWM8And16BitMitigation"));
|
| 603 | 638 | }
|
| | 639 | + DelCompatFlag(_T("DWM8And16BitMitigation"), initial);
|
| 604 | 640 | }
|
| 605 | 641 | void GetGlobalConfig(DXGLCFG *cfg)
|
| 606 | 642 | {
|
| Index: common/releasever.h |
| — | — | @@ -4,7 +4,7 @@ |
| 5 | 5 |
|
| 6 | 6 | #define DXGLMAJORVER 0
|
| 7 | 7 | #define DXGLMINORVER 5
|
| 8 | | -#define DXGLPOINTVER 1
|
| | 8 | +#define DXGLPOINTVER 2
|
| 9 | 9 |
|
| 10 | 10 | #define STR2(x) #x
|
| 11 | 11 | #define STR(x) STR2(x)
|
| Index: ddraw/ddraw.rc |
| — | — | @@ -34,12 +34,12 @@ |
| 35 | 35 | // Dialog resources
|
| 36 | 36 | //
|
| 37 | 37 | LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
| 38 | | -IDD_COMPAT DIALOG 0, 0, 193, 19
|
| | 38 | +IDD_COMPAT DIALOG 0, 0, 196, 19
|
| 39 | 39 | STYLE DS_3DLOOK | DS_CENTER | DS_MODALFRAME | DS_SHELLFONT | WS_VISIBLE | WS_POPUP
|
| 40 | 40 | EXSTYLE WS_EX_WINDOWEDGE
|
| 41 | 41 | FONT 8, "Ms Shell Dlg"
|
| 42 | 42 | {
|
| 43 | | - LTEXT "Compatibility settings applied; now restarting your program.", IDC_STATIC, 5, 5, 183, 8, SS_LEFT
|
| | 43 | + CTEXT "Compatibility settings applied; now restarting your program.", IDC_STATIC, 5, 5, 186, 8, SS_CENTER, WS_EX_LEFT
|
| 44 | 44 | }
|
| 45 | 45 |
|
| 46 | 46 |
|