Index: Installer/dxgl.nsi |
— | — | @@ -251,8 +251,11 @@ |
252 | 252 | !endif
|
253 | 253 |
|
254 | 254 | Section -PostInstall
|
255 | | - ExecWait '"$INSTDIR\dxglcfg.exe" upgrade'
|
| 255 | + CreateDirectory $INSTDIR\Temp
|
| 256 | + CopyFiles $INSTDIR\dxglcfg.exe $INSTDIR\Temp
|
| 257 | + ExecWait '"$INSTDIR\Temp\dxglcfg.exe" upgrade'
|
256 | 258 | ExecWait '"$INSTDIR\dxglcfg.exe" profile_install'
|
| 259 | + RMDir /r /REBOOTOK $INSTDIR\Temp
|
257 | 260 | SectionEnd
|
258 | 261 |
|
259 | 262 | Section "Set Wine DLL Overrides" SEC_WINEDLLOVERRIDE
|
Index: cfgmgr/cfgmgr.c |
— | — | @@ -41,10 +41,11 @@ |
42 | 42 | typedef LONG LSTATUS;
|
43 | 43 | #endif
|
44 | 44 |
|
45 | | -TCHAR regkeyglobal[] = _T("Software\\DXGL\\Global");
|
46 | | -TCHAR regkeyprofiles[] = _T("Software\\DXGL\\Profiles\\");
|
47 | | -TCHAR regkeybase[] = _T("Software\\DXGL\\");
|
48 | | -TCHAR regkeydxgl[] = _T("Software\\DXGL");
|
| 45 | +static const TCHAR regkeyglobal[] = _T("Software\\DXGL\\Global");
|
| 46 | +static const TCHAR regkeyprofiles[] = _T("Software\\DXGL\\Profiles\\");
|
| 47 | +static const TCHAR regkeyprofilesmigrated[] = _T("Software\\DXGL\\ProfilesMigrated\\");
|
| 48 | +static const TCHAR regkeybase[] = _T("Software\\DXGL\\");
|
| 49 | +static const TCHAR regkeydxgl[] = _T("Software\\DXGL");
|
49 | 50 |
|
50 | 51 | DXGLCFG defaultmask;
|
51 | 52 |
|
— | — | @@ -73,7 +74,7 @@ |
74 | 75 | #endif
|
75 | 76 | }
|
76 | 77 |
|
77 | | -void _wchartotchar(TCHAR *dest, WCHAR *src, int length)
|
| 78 | +void _wchartotchar(TCHAR *dest, const WCHAR *src, int length)
|
78 | 79 | {
|
79 | 80 | #ifdef _UNICODE
|
80 | 81 | if (length == -1) wcscpy(dest, src);
|
— | — | @@ -85,7 +86,7 @@ |
86 | 87 | #endif
|
87 | 88 | }
|
88 | 89 |
|
89 | | -void utf8to16(WCHAR* dest, CHAR* src)
|
| 90 | +void utf8to16(WCHAR* dest, const CHAR* src)
|
90 | 91 | {
|
91 | 92 | int sizein;
|
92 | 93 | int sizeout;
|
— | — | @@ -933,7 +934,7 @@ |
934 | 935 | _tcslwr(filename);
|
935 | 936 | _tchartowchar(filename2,filename,-1);
|
936 | 937 | Sha256Initialise(&sha_context);
|
937 | | - Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2));
|
| 938 | + Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2) * sizeof(WCHAR));
|
938 | 939 | Sha256Finalise(&sha_context, &sha256);
|
939 | 940 | for (i = 0; i < (256 / 8); i++)
|
940 | 941 | {
|
— | — | @@ -970,7 +971,7 @@ |
971 | 972 | _tcslwr(pathlwr);
|
972 | 973 | _tchartowchar(pathlwr2,pathlwr,-1);
|
973 | 974 | Sha256Initialise(&sha_context);
|
974 | | - Sha256Update(&sha_context, pathlwr2, (uint32_t)wcslen(pathlwr2));
|
| 975 | + Sha256Update(&sha_context, pathlwr2, (uint32_t)wcslen(pathlwr2) * sizeof(WCHAR));
|
975 | 976 | Sha256Finalise(&sha_context, &sha256);
|
976 | 977 | for (i = 0; i < (256 / 8); i++)
|
977 | 978 | {
|
— | — | @@ -1700,7 +1701,7 @@ |
1701 | 1702 | _tcslwr(filename);
|
1702 | 1703 | _tchartowchar(filename2, filename, -1);
|
1703 | 1704 | Sha256Initialise(&sha_context);
|
1704 | | - Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2));
|
| 1705 | + Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2) * sizeof(WCHAR));
|
1705 | 1706 | Sha256Finalise(&sha_context, &sha256);
|
1706 | 1707 | for (i = 0; i < (256 / 8); i++)
|
1707 | 1708 | {
|
— | — | @@ -1954,7 +1955,7 @@ |
1955 | 1956 | _tcslwr(installpath);
|
1956 | 1957 | _tchartowchar(installpath2, installpath, -1);
|
1957 | 1958 | Sha256Initialise(&sha_context);
|
1958 | | - Sha256Update(&sha_context, installpath2, (uint32_t)wcslen(installpath2));
|
| 1959 | + Sha256Update(&sha_context, installpath2, (uint32_t)wcslen(installpath2) * sizeof(WCHAR));
|
1959 | 1960 | Sha256Finalise(&sha_context, &sha256);
|
1960 | 1961 | for (i = 0; i < (256 / 8); i++)
|
1961 | 1962 | {
|
— | — | @@ -2046,6 +2047,7 @@ |
2047 | 2048 | HKEY hKey;
|
2048 | 2049 | HKEY hKeyProfile;
|
2049 | 2050 | HKEY hKeyDest;
|
| 2051 | + HKEY hKeyProfileDest;
|
2050 | 2052 | TCHAR regkey[MAX_PATH + 24];
|
2051 | 2053 | TCHAR subkey[MAX_PATH];
|
2052 | 2054 | TCHAR exepath[(MAX_PATH * 2) + 1];
|
— | — | @@ -2058,6 +2060,7 @@ |
2059 | 2061 | DWORD olddirsize = 1024;
|
2060 | 2062 | TCHAR *olddir = NULL;
|
2061 | 2063 | DWORD oldvaluesize = 1024;
|
| 2064 | + WCHAR dir_unicode[MAX_PATH];
|
2062 | 2065 | TCHAR *oldvalue = NULL;
|
2063 | 2066 | TCHAR *ptr;
|
2064 | 2067 | size_t length;
|
— | — | @@ -2065,6 +2068,8 @@ |
2066 | 2069 | DWORD regtype;
|
2067 | 2070 | DWORD sizeout, sizeout2;
|
2068 | 2071 | Sha256Context sha_context;
|
| 2072 | + SHA256_HASH PathHash;
|
| 2073 | + TCHAR PathHashString[65];
|
2069 | 2074 | LONG error;
|
2070 | 2075 | LONG error2;
|
2071 | 2076 | DWORD i;
|
— | — | @@ -2387,8 +2392,216 @@ |
2388 | 2393 | RegCloseKey(hKey);
|
2389 | 2394 | }
|
2390 | 2395 | ver2to3:
|
| 2396 | + // Version 2 to 3: Fix profile path hashes
|
| 2397 | + if (version >= 3) return;
|
2391 | 2398 | // Transfer profiles to pre-migrate path
|
2392 | | -
|
| 2399 | + error = RegCreateKeyEx(HKEY_CURRENT_USER, regkeyprofiles, 0, NULL, 0, KEY_READ, NULL, &hKey, NULL);
|
| 2400 | + if (error == ERROR_SUCCESS)
|
| 2401 | + {
|
| 2402 | + error = RegCreateKeyEx(HKEY_CURRENT_USER, regkeyprofilesmigrated, 0, NULL, 0, KEY_ALL_ACCESS,
|
| 2403 | + NULL, &hKeyDest, NULL);
|
| 2404 | + if (error == ERROR_SUCCESS)
|
| 2405 | + {
|
| 2406 | + olddirsize = 1024;
|
| 2407 | + oldvaluesize = 1024;
|
| 2408 | + olddir = malloc(olddirsize * 2);
|
| 2409 | + oldvalue = malloc(oldvaluesize);
|
| 2410 | + keyindex = 0;
|
| 2411 | + do
|
| 2412 | + {
|
| 2413 | + sizeout = MAX_PATH;
|
| 2414 | + error = RegEnumKeyEx(hKey, keyindex, subkey, &sizeout,
|
| 2415 | + NULL, NULL, NULL, NULL);
|
| 2416 | + keyindex++;
|
| 2417 | + if (error == ERROR_SUCCESS)
|
| 2418 | + {
|
| 2419 | + error2 = RegOpenKeyEx(hKey, subkey, 0, KEY_READ, &hKeyProfile);
|
| 2420 | + if (error2 == ERROR_SUCCESS)
|
| 2421 | + {
|
| 2422 | + // Rename subkey
|
| 2423 | + sizeout = MAX_PATH;
|
| 2424 | + regtype = REG_SZ;
|
| 2425 | + error2 = RegQueryValueEx(hKeyProfile, _T("InstallPath"), NULL, ®type, (LPBYTE)olddir, &sizeout);
|
| 2426 | + if (error2 == ERROR_SUCCESS)
|
| 2427 | + {
|
| 2428 | + _tcslwr(olddir);
|
| 2429 | + _tchartowchar(dir_unicode, olddir, MAX_PATH);
|
| 2430 | + Sha256Initialise(&sha_context);
|
| 2431 | + Sha256Update(&sha_context, dir_unicode, (uint32_t)wcslen(dir_unicode) * sizeof(WCHAR));
|
| 2432 | + Sha256Finalise(&sha_context, &PathHash);
|
| 2433 | + for (i = 0; i < (256 / 8); i++)
|
| 2434 | + {
|
| 2435 | + PathHashString[i * 2] = (TCHAR)hexdigit(PathHash.bytes[i] >> 4);
|
| 2436 | + PathHashString[(i * 2) + 1] = (TCHAR)hexdigit(PathHash.bytes[i] & 0xF);
|
| 2437 | + }
|
| 2438 | + PathHashString[256 / 4] = 0;
|
| 2439 | + ptr = _tcsrchr(subkey, '-');
|
| 2440 | + _tcscpy(ptr + 1, PathHashString);
|
| 2441 | + }
|
| 2442 | + error2 = RegCreateKeyEx(hKeyDest, subkey, 0, NULL, 0, KEY_ALL_ACCESS,
|
| 2443 | + NULL, &hKeyProfileDest, NULL);
|
| 2444 | + if (error2 == ERROR_SUCCESS)
|
| 2445 | + {
|
| 2446 | + numvalue = 0;
|
| 2447 | + do
|
| 2448 | + {
|
| 2449 | + sizeout = olddirsize;
|
| 2450 | + sizeout2 = oldvaluesize;
|
| 2451 | + error2 = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, ®type, (LPBYTE)oldvalue, &sizeout2);
|
| 2452 | + if (error2 == ERROR_MORE_DATA)
|
| 2453 | + {
|
| 2454 | + if (sizeout > olddirsize)
|
| 2455 | + {
|
| 2456 | + olddirsize = sizeout;
|
| 2457 | + olddir = realloc(olddir, olddirsize * 2);
|
| 2458 | + if (!olddir)
|
| 2459 | + {
|
| 2460 | + MessageBox(NULL, _T("Out of memory updating registry"), _T("Fatal error"), MB_ICONSTOP | MB_OK);
|
| 2461 | + ExitProcess(error2);
|
| 2462 | + }
|
| 2463 | + }
|
| 2464 | + if (sizeout2 > oldvaluesize)
|
| 2465 | + {
|
| 2466 | + oldvaluesize = sizeout2;
|
| 2467 | + oldvalue = realloc(oldvalue, oldvaluesize);
|
| 2468 | + if (!oldvalue)
|
| 2469 | + {
|
| 2470 | + MessageBox(NULL, _T("Out of memory updating registry"), _T("Fatal error"), MB_ICONSTOP | MB_OK);
|
| 2471 | + ExitProcess(error2);
|
| 2472 | + }
|
| 2473 | + }
|
| 2474 | + sizeout = olddirsize;
|
| 2475 | + sizeout2 = oldvaluesize;
|
| 2476 | + error2 = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, ®type, (LPBYTE)oldvalue, &sizeout2);
|
| 2477 | + }
|
| 2478 | + if (error2 == ERROR_SUCCESS)
|
| 2479 | + {
|
| 2480 | + RegSetValueEx(hKeyProfileDest, olddir, 0, regtype, (BYTE*)oldvalue, sizeout2);
|
| 2481 | + }
|
| 2482 | + numvalue++;
|
| 2483 | + } while (error2 == ERROR_SUCCESS);
|
| 2484 | + RegCloseKey(hKeyProfileDest);
|
| 2485 | + }
|
| 2486 | + RegCloseKey(hKeyProfile);
|
| 2487 | + }
|
| 2488 | + }
|
| 2489 | + } while (error == ERROR_SUCCESS);
|
| 2490 | + RegCloseKey(hKeyDest);
|
| 2491 | + free(olddir);
|
| 2492 | + free(oldvalue);
|
| 2493 | + }
|
| 2494 | + // Delete source keys
|
| 2495 | + do
|
| 2496 | + {
|
| 2497 | + sizeout = MAX_PATH;
|
| 2498 | + error = RegEnumKeyEx(hKey, 0, subkey, &sizeout,
|
| 2499 | + NULL, NULL, NULL, NULL);
|
| 2500 | + if (error == ERROR_SUCCESS)
|
| 2501 | + {
|
| 2502 | + error2 = RegDeleteKey(hKey, subkey);
|
| 2503 | + if (error2 != ERROR_SUCCESS) break;
|
| 2504 | + }
|
| 2505 | + } while (error == ERROR_SUCCESS);
|
| 2506 | + RegCloseKey(hKey);
|
| 2507 | + }
|
| 2508 | + // Migrate keys to new names
|
| 2509 | + error = RegCreateKeyEx(HKEY_CURRENT_USER, regkeyprofilesmigrated, 0, NULL, 0, KEY_READ, NULL, &hKey, NULL);
|
| 2510 | + if (error == ERROR_SUCCESS)
|
| 2511 | + {
|
| 2512 | + error = RegCreateKeyEx(HKEY_CURRENT_USER, regkeyprofiles, 0, NULL, 0, KEY_ALL_ACCESS,
|
| 2513 | + NULL, &hKeyDest, NULL);
|
| 2514 | + if (error == ERROR_SUCCESS)
|
| 2515 | + {
|
| 2516 | + olddirsize = 1024;
|
| 2517 | + oldvaluesize = 1024;
|
| 2518 | + olddir = malloc(olddirsize * 2);
|
| 2519 | + oldvalue = malloc(oldvaluesize);
|
| 2520 | + keyindex = 0;
|
| 2521 | + do
|
| 2522 | + {
|
| 2523 | + sizeout = MAX_PATH;
|
| 2524 | + error = RegEnumKeyEx(hKey, keyindex, subkey, &sizeout,
|
| 2525 | + NULL, NULL, NULL, NULL);
|
| 2526 | + keyindex++;
|
| 2527 | + if (error == ERROR_SUCCESS)
|
| 2528 | + {
|
| 2529 | + error2 = RegOpenKeyEx(hKey, subkey, 0, KEY_READ, &hKeyProfile);
|
| 2530 | + if (error2 == ERROR_SUCCESS)
|
| 2531 | + {
|
| 2532 | + error2 = RegCreateKeyEx(hKeyDest, subkey, 0, NULL, 0, KEY_ALL_ACCESS,
|
| 2533 | + NULL, &hKeyProfileDest, NULL);
|
| 2534 | + if (error2 == ERROR_SUCCESS)
|
| 2535 | + {
|
| 2536 | + numvalue = 0;
|
| 2537 | + do
|
| 2538 | + {
|
| 2539 | + sizeout = olddirsize;
|
| 2540 | + sizeout2 = oldvaluesize;
|
| 2541 | + error2 = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, ®type, (LPBYTE)oldvalue, &sizeout2);
|
| 2542 | + if (error2 == ERROR_MORE_DATA)
|
| 2543 | + {
|
| 2544 | + if (sizeout > olddirsize)
|
| 2545 | + {
|
| 2546 | + olddirsize = sizeout;
|
| 2547 | + olddir = realloc(olddir, olddirsize * 2);
|
| 2548 | + if (!olddir)
|
| 2549 | + {
|
| 2550 | + MessageBox(NULL, _T("Out of memory updating registry"), _T("Fatal error"), MB_ICONSTOP | MB_OK);
|
| 2551 | + ExitProcess(error2);
|
| 2552 | + }
|
| 2553 | + }
|
| 2554 | + if (sizeout2 > oldvaluesize)
|
| 2555 | + {
|
| 2556 | + oldvaluesize = sizeout2;
|
| 2557 | + oldvalue = realloc(oldvalue, oldvaluesize);
|
| 2558 | + if (!oldvalue)
|
| 2559 | + {
|
| 2560 | + MessageBox(NULL, _T("Out of memory updating registry"), _T("Fatal error"), MB_ICONSTOP | MB_OK);
|
| 2561 | + ExitProcess(error2);
|
| 2562 | + }
|
| 2563 | + }
|
| 2564 | + sizeout = olddirsize;
|
| 2565 | + sizeout2 = oldvaluesize;
|
| 2566 | + error2 = RegEnumValue(hKeyProfile, numvalue, olddir, &sizeout, NULL, ®type, (LPBYTE)oldvalue, &sizeout2);
|
| 2567 | + }
|
| 2568 | + if (error2 == ERROR_SUCCESS)
|
| 2569 | + {
|
| 2570 | + RegSetValueEx(hKeyProfileDest, olddir, 0, regtype, (BYTE*)oldvalue, sizeout2);
|
| 2571 | + }
|
| 2572 | + numvalue++;
|
| 2573 | + } while (error2 == ERROR_SUCCESS);
|
| 2574 | + RegCloseKey(hKeyProfileDest);
|
| 2575 | + }
|
| 2576 | + RegCloseKey(hKeyProfile);
|
| 2577 | + }
|
| 2578 | + }
|
| 2579 | + } while (error == ERROR_SUCCESS);
|
| 2580 | + RegCloseKey(hKeyDest);
|
| 2581 | + free(olddir);
|
| 2582 | + free(oldvalue);
|
| 2583 | + }
|
| 2584 | + // Delete temporary keys
|
| 2585 | + do
|
| 2586 | + {
|
| 2587 | + sizeout = MAX_PATH;
|
| 2588 | + error = RegEnumKeyEx(hKey, 0, subkey, &sizeout,
|
| 2589 | + NULL, NULL, NULL, NULL);
|
| 2590 | + if (error == ERROR_SUCCESS)
|
| 2591 | + {
|
| 2592 | + error2 = RegDeleteKey(hKey, subkey);
|
| 2593 | + if (error2 != ERROR_SUCCESS) break;
|
| 2594 | + }
|
| 2595 | + } while (error == ERROR_SUCCESS);
|
| 2596 | + RegCloseKey(hKey);
|
| 2597 | + RegDeleteKey(HKEY_CURRENT_USER, regkeyprofilesmigrated);
|
| 2598 | + }
|
| 2599 | + error = RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| 2600 | + if (error == ERROR_SUCCESS)
|
| 2601 | + {
|
| 2602 | + sizeout = 3;
|
| 2603 | + RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, (BYTE*)& sizeout, 4);
|
| 2604 | + RegCloseKey(hKey);
|
| 2605 | + }
|
2393 | 2606 | return;
|
2394 | 2607 | }
|
2395 | 2608 |
|