Index: cfgmgr/cfgmgr.c |
— | — | @@ -1402,6 +1402,8 @@ |
1403 | 1403 | char buffer[512];
|
1404 | 1404 | DWORD bytesread;
|
1405 | 1405 | TCHAR path2[MAX_PATH + 1];
|
| 1406 | + options->NoOverwrite = FALSE;
|
| 1407 | + options->NoUninstall = FALSE;
|
1406 | 1408 | ZeroMemory(options->sha256, 65*sizeof(char));
|
1407 | 1409 | ZeroMemory(options->sha256comp, 65*sizeof(char));
|
1408 | 1410 | _tcsncpy(path2, path, MAX_PATH + 1);
|
— | — | @@ -1413,11 +1415,6 @@ |
1414 | 1416 | ini_parse_file(file, ReadINIOptionsCallback, options);
|
1415 | 1417 | fclose(file);
|
1416 | 1418 | }
|
1417 | | - else
|
1418 | | - {
|
1419 | | - options->NoOverwrite = FALSE;
|
1420 | | - options->NoUninstall = FALSE;
|
1421 | | - }
|
1422 | 1419 | // Check for existing ddraw.dll and get SHA256 sum
|
1423 | 1420 | if ((options->sha256comp[0] != 0) && !options->NoOverwrite)
|
1424 | 1421 | {
|
— | — | @@ -1434,7 +1431,7 @@ |
1435 | 1432 | {
|
1436 | 1433 | while (1)
|
1437 | 1434 | {
|
1438 | | - ReadFile(file, buffer, 512, &bytesread, NULL);
|
| 1435 | + ReadFile(file2, buffer, 512, &bytesread, NULL);
|
1439 | 1436 | if (!bytesread) break;
|
1440 | 1437 | Sha256Update(&sha_context, buffer, bytesread);
|
1441 | 1438 | if (bytesread < 512) break;
|
Index: dxglcfg/dxglcfg.c |
— | — | @@ -85,6 +85,7 @@ |
86 | 86 | BOOL installed = FALSE;
|
87 | 87 | BOOL dxgl_installdir = FALSE;
|
88 | 88 | BOOL old_dxgl = TRUE;
|
| 89 | + BOOL backupped = FALSE;
|
89 | 90 | TCHAR command[MAX_PATH + 37];
|
90 | 91 | SHELLEXECUTEINFO shex;
|
91 | 92 | DWORD exitcode;
|
— | — | @@ -142,10 +143,10 @@ |
143 | 144 | DirectDraw library in your game folder."), _T("Error"), MB_OK | MB_ICONERROR);
|
144 | 145 | return 0; // Continue to install registry key anyway
|
145 | 146 | }
|
146 | | - if (!memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 147 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
147 | 148 | // Detected original ddraw matches INI hash
|
148 | 149 | {
|
149 | | - error = CopyFile(srcpath, backuppath, FALSE);
|
| 150 | + error = CopyFile(destpath, backuppath, FALSE);
|
150 | 151 | if (!error)
|
151 | 152 | {
|
152 | 153 | error = GetLastError();
|
— | — | @@ -166,8 +167,12 @@ |
167 | 168 | return exitcode;
|
168 | 169 | }
|
169 | 170 | }
|
| 171 | + else backupped = TRUE;
|
170 | 172 | }
|
| 173 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 174 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
171 | 175 | hmod = LoadLibrary(destpath);
|
| 176 | + SetErrorMode(error);
|
172 | 177 | if(hmod)
|
173 | 178 | {
|
174 | 179 | if(GetProcAddress(hmod,"IsDXGLDDraw") || force) old_dxgl = TRUE;
|
— | — | @@ -195,6 +200,10 @@ |
196 | 201 | error = CopyFile(srcpath, destpath, FALSE);
|
197 | 202 | goto error_loop;
|
198 | 203 | }
|
| 204 | + else
|
| 205 | + {
|
| 206 | + if (backupped) DeleteFile(backuppath);
|
| 207 | + }
|
199 | 208 | }
|
200 | 209 | }
|
201 | 210 | if((error == ERROR_ACCESS_DENIED) && !admin)
|
— | — | @@ -264,7 +273,10 @@ |
265 | 274 | shipped with a custom DirectDraw library."), _T("Warning"), MB_OK | MB_ICONWARNING);
|
266 | 275 | return 0; // Continue to delete registry profile.
|
267 | 276 | }
|
| 277 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 278 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
268 | 279 | hmod = LoadLibrary(path);
|
| 280 | + SetErrorMode(error);
|
269 | 281 | if(hmod)
|
270 | 282 | {
|
271 | 283 | if(!GetProcAddress(hmod,"IsDXGLDDraw")) old_dxgl = FALSE;
|
— | — | @@ -1687,11 +1699,14 @@ |
1688 | 1700 | if (error == ERROR_FILE_EXISTS)
|
1689 | 1701 | {
|
1690 | 1702 | if (inioptions.NoOverwrite) continue;
|
1691 | | - if (!memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 1703 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
1692 | 1704 | // Detected original ddraw matches INI hash
|
1693 | 1705 | CopyFile(srcpath, backuppath, FALSE);
|
1694 | 1706 | old_dxgl = FALSE;
|
| 1707 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 1708 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
1695 | 1709 | hmod = LoadLibrary(destpath);
|
| 1710 | + SetErrorMode(error);
|
1696 | 1711 | if (hmod)
|
1697 | 1712 | {
|
1698 | 1713 | if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
— | — | @@ -1786,7 +1801,10 @@ |
1787 | 1802 | if (GetFileAttributes(destpath) != INVALID_FILE_ATTRIBUTES)
|
1788 | 1803 | {
|
1789 | 1804 | old_dxgl = FALSE;
|
| 1805 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 1806 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
1790 | 1807 | hmod = LoadLibrary(destpath);
|
| 1808 | + SetErrorMode(error);
|
1791 | 1809 | if (hmod)
|
1792 | 1810 | {
|
1793 | 1811 | if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
Index: dxglcfg2/dxglcfg2.c |
— | — | @@ -133,6 +133,7 @@ |
134 | 134 | BOOL installed = FALSE;
|
135 | 135 | BOOL dxgl_installdir = FALSE;
|
136 | 136 | BOOL old_dxgl = TRUE;
|
| 137 | + BOOL backupped = FALSE;
|
137 | 138 | TCHAR command[MAX_PATH + 37];
|
138 | 139 | SHELLEXECUTEINFO shex;
|
139 | 140 | DWORD exitcode;
|
— | — | @@ -190,10 +191,10 @@ |
191 | 192 | DirectDraw library in your game folder."), _T("Error"), MB_OK | MB_ICONERROR);
|
192 | 193 | return 0; // Continue to install registry key anyway
|
193 | 194 | }
|
194 | | - if (!memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 195 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
195 | 196 | // Detected original ddraw matches INI hash
|
196 | 197 | {
|
197 | | - error = CopyFile(srcpath, backuppath, FALSE);
|
| 198 | + error = CopyFile(destpath, backuppath, FALSE);
|
198 | 199 | if (!error)
|
199 | 200 | {
|
200 | 201 | error = GetLastError();
|
— | — | @@ -214,8 +215,12 @@ |
215 | 216 | return exitcode;
|
216 | 217 | }
|
217 | 218 | }
|
| 219 | + else backupped = TRUE;
|
218 | 220 | }
|
| 221 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 222 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
219 | 223 | hmod = LoadLibrary(destpath);
|
| 224 | + SetErrorMode(error);
|
220 | 225 | if(hmod)
|
221 | 226 | {
|
222 | 227 | if(GetProcAddress(hmod,"IsDXGLDDraw") || force) old_dxgl = TRUE;
|
— | — | @@ -243,6 +248,10 @@ |
244 | 249 | error = CopyFile(srcpath, destpath, FALSE);
|
245 | 250 | goto error_loop;
|
246 | 251 | }
|
| 252 | + else
|
| 253 | + {
|
| 254 | + if (backupped) DeleteFile(backuppath);
|
| 255 | + }
|
247 | 256 | }
|
248 | 257 | }
|
249 | 258 | if((error == ERROR_ACCESS_DENIED) && !admin)
|
— | — | @@ -312,7 +321,10 @@ |
313 | 322 | shipped with a custom DirectDraw library."), _T("Warning"), MB_OK | MB_ICONWARNING);
|
314 | 323 | return 0; // Continue to delete registry profile.
|
315 | 324 | }
|
| 325 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 326 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
316 | 327 | hmod = LoadLibrary(path);
|
| 328 | + SetErrorMode(error);
|
317 | 329 | if(hmod)
|
318 | 330 | {
|
319 | 331 | if(!GetProcAddress(hmod,"IsDXGLDDraw")) old_dxgl = FALSE;
|
— | — | @@ -1904,6 +1916,9 @@ |
1905 | 1917 | TCHAR installpath[MAX_PATH + 1];
|
1906 | 1918 | TCHAR srcpath[MAX_PATH + 1];
|
1907 | 1919 | TCHAR destpath[MAX_PATH + 1];
|
| 1920 | + TCHAR inipath[MAX_PATH + 1];
|
| 1921 | + TCHAR backuppath[MAX_PATH + 1];
|
| 1922 | + app_ini_options inioptions;
|
1908 | 1923 | HMODULE hmod;
|
1909 | 1924 | UpgradeConfig();
|
1910 | 1925 | regbuffersize = 1024;
|
— | — | @@ -1948,8 +1963,12 @@ |
1949 | 1964 | if (regbuffer[0] != 0)
|
1950 | 1965 | {
|
1951 | 1966 | _tcsncpy(destpath, regbuffer, MAX_PATH + 1);
|
1952 | | - _tcscat(destpath, _T("\\"));
|
1953 | | - _tcscat(destpath, _T("ddraw.dll"));
|
| 1967 | + _tcscat(destpath, _T("\\ddraw.dll"));
|
| 1968 | + _tcsncpy(inipath, regbuffer, MAX_PATH + 1);
|
| 1969 | + _tcscat(inipath, _T("\\dxgl.ini"));
|
| 1970 | + _tcsncpy(backuppath, regbuffer, MAX_PATH + 1);
|
| 1971 | + _tcscat(backuppath, _T("\\ddraw.dll.dxgl-backup"));
|
| 1972 | + ReadAppINIOptions(inipath, &inioptions);
|
1954 | 1973 | error = CopyFile(srcpath, destpath, TRUE);
|
1955 | 1974 | if (!error)
|
1956 | 1975 | {
|
— | — | @@ -1956,8 +1975,15 @@ |
1957 | 1976 | error = GetLastError();
|
1958 | 1977 | if (error == ERROR_FILE_EXISTS)
|
1959 | 1978 | {
|
| 1979 | + if (inioptions.NoOverwrite) continue;
|
| 1980 | + if ((inioptions.sha256[0] != 0) && !memcmp(inioptions.sha256, inioptions.sha256comp, 64))
|
| 1981 | + // Detected original ddraw matches INI hash
|
| 1982 | + CopyFile(srcpath, backuppath, FALSE);
|
1960 | 1983 | old_dxgl = FALSE;
|
| 1984 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 1985 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
1961 | 1986 | hmod = LoadLibrary(destpath);
|
| 1987 | + SetErrorMode(error);
|
1962 | 1988 | if (hmod)
|
1963 | 1989 | {
|
1964 | 1990 | if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|
— | — | @@ -2052,7 +2078,10 @@ |
2053 | 2079 | if (GetFileAttributes(destpath) != INVALID_FILE_ATTRIBUTES)
|
2054 | 2080 | {
|
2055 | 2081 | old_dxgl = FALSE;
|
| 2082 | + error = SetErrorMode(SEM_FAILCRITICALERRORS);
|
| 2083 | + SetErrorMode(error | SEM_FAILCRITICALERRORS);
|
2056 | 2084 | hmod = LoadLibrary(destpath);
|
| 2085 | + SetErrorMode(error);
|
2057 | 2086 | if (hmod)
|
2058 | 2087 | {
|
2059 | 2088 | if (GetProcAddress(hmod, "IsDXGLDDraw")) old_dxgl = TRUE;
|