| Index: cfgmgr/cfgmgr.c |
| — | — | @@ -60,6 +60,28 @@ |
| 61 | 61 |
|
| 62 | 62 | static int ini_currentsection = 0;
|
| 63 | 63 |
|
| | 64 | +void _tchartowchar(WCHAR *dest, TCHAR *src, int length)
|
| | 65 | +{
|
| | 66 | +#ifdef _UNICODE
|
| | 67 | + wcsncpy(dest,src,length);
|
| | 68 | +#else
|
| | 69 | + int length2 = length;
|
| | 70 | + if(length == -1) length2 = strlen(src) + 1;
|
| | 71 | + MultiByteToWideChar(CP_ACP,0,src,length,dest,length2);
|
| | 72 | +#endif
|
| | 73 | +}
|
| | 74 | +
|
| | 75 | +void _wchartotchar(TCHAR *dest, WCHAR *src, int length)
|
| | 76 | +{
|
| | 77 | +#ifdef _UNICODE
|
| | 78 | + wcsncpy(dest,src,length);
|
| | 79 | +#else
|
| | 80 | + int length2 = length;
|
| | 81 | + if(length == -1) length2 = wcslen(src) + 1;
|
| | 82 | + WideCharToMultiByte(CP_ACP,0,src,length,dest,length2,NULL,NULL);
|
| | 83 | +#endif
|
| | 84 | +}
|
| | 85 | +
|
| 64 | 86 | /**
|
| 65 | 87 | * Gets the hexadecimal digit for a number; the number must be less than 16
|
| 66 | 88 | * or 0x10.
|
| — | — | @@ -883,6 +905,7 @@ |
| 884 | 906 | TCHAR sha256string[65];
|
| 885 | 907 | TCHAR regkey[MAX_PATH + 80];
|
| 886 | 908 | TCHAR filename[MAX_PATH + 1];
|
| | 909 | + WCHAR filename2[MAX_PATH + 1];
|
| 887 | 910 | HKEY hKey;
|
| 888 | 911 | LONG error;
|
| 889 | 912 | int i;
|
| — | — | @@ -896,8 +919,9 @@ |
| 897 | 920 | i--;
|
| 898 | 921 | filename[i] = 0;
|
| 899 | 922 | _tcslwr(filename);
|
| | 923 | + _tchartowchar(filename2,filename,-1);
|
| 900 | 924 | Sha256Initialise(&sha_context);
|
| 901 | | - Sha256Update(&sha_context, filename, (uint32_t)_tcslen(filename));
|
| | 925 | + Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2));
|
| 902 | 926 | Sha256Finalise(&sha_context, &sha256);
|
| 903 | 927 | for (i = 0; i < (256 / 8); i++)
|
| 904 | 928 | {
|
| — | — | @@ -921,6 +945,7 @@ |
| 922 | 946 | SHA256_HASH sha256;
|
| 923 | 947 | TCHAR sha256string[65];
|
| 924 | 948 | TCHAR pathlwr[MAX_PATH + 1];
|
| | 949 | + WCHAR pathlwr2[MAX_PATH + 1];
|
| 925 | 950 | HKEY hKey;
|
| 926 | 951 | DXGLCFG tmp;
|
| 927 | 952 | TCHAR regkey[MAX_PATH + 80];
|
| — | — | @@ -931,8 +956,9 @@ |
| 932 | 957 | for (i = (int)_tcslen(pathlwr); (i > 0) && (pathlwr[i] != 92) && (pathlwr[i] != 47); i--);
|
| 933 | 958 | pathlwr[i] = 0;
|
| 934 | 959 | _tcslwr(pathlwr);
|
| | 960 | + _tchartowchar(pathlwr2,pathlwr,-1);
|
| 935 | 961 | Sha256Initialise(&sha_context);
|
| 936 | | - Sha256Update(&sha_context, pathlwr, (uint32_t)_tcslen(pathlwr));
|
| | 962 | + Sha256Update(&sha_context, pathlwr2, (uint32_t)wcslen(pathlwr2));
|
| 937 | 963 | Sha256Finalise(&sha_context, &sha256);
|
| 938 | 964 | for (i = 0; i < (256 / 8); i++)
|
| 939 | 965 | {
|
| — | — | @@ -1602,6 +1628,7 @@ |
| 1603 | 1629 | SHA256_HASH sha256;
|
| 1604 | 1630 | TCHAR sha256string[65];
|
| 1605 | 1631 | TCHAR filename[MAX_PATH+1];
|
| | 1632 | + WCHAR filename2[MAX_PATH+1];
|
| 1606 | 1633 | TCHAR regkey[MAX_PATH + 80];
|
| 1607 | 1634 | size_t i;
|
| 1608 | 1635 | BOOL DPIAwarePM = FALSE;
|
| — | — | @@ -1620,8 +1647,9 @@ |
| 1621 | 1648 | i--;
|
| 1622 | 1649 | filename[i] = 0;
|
| 1623 | 1650 | _tcslwr(filename);
|
| | 1651 | + _tchartowchar(filename2, filename, -1);
|
| 1624 | 1652 | Sha256Initialise(&sha_context);
|
| 1625 | | - Sha256Update(&sha_context, filename, (uint32_t)_tcslen(filename));
|
| | 1653 | + Sha256Update(&sha_context, filename2, (uint32_t)wcslen(filename2));
|
| 1626 | 1654 | Sha256Finalise(&sha_context, &sha256);
|
| 1627 | 1655 | for (i = 0; i < (256 / 8); i++)
|
| 1628 | 1656 | {
|
| — | — | @@ -1850,6 +1878,7 @@ |
| 1851 | 1879 | SHA256_HASH sha256;
|
| 1852 | 1880 | TCHAR sha256string[65];
|
| 1853 | 1881 | TCHAR installpath[MAX_PATH + 1];
|
| | 1882 | + WCHAR installpath2[MAX_PATH + 1];
|
| 1854 | 1883 | TCHAR profilepath[MAX_PATH + 80];
|
| 1855 | 1884 | TCHAR destpath[MAX_PATH + 80];
|
| 1856 | 1885 | LONG error;
|
| — | — | @@ -1872,8 +1901,9 @@ |
| 1873 | 1902 | if (error == ERROR_SUCCESS)
|
| 1874 | 1903 | {
|
| 1875 | 1904 | _tcslwr(installpath);
|
| | 1905 | + _tchartowchar(installpath2, installpath, -1);
|
| 1876 | 1906 | Sha256Initialise(&sha_context);
|
| 1877 | | - Sha256Update(&sha_context, installpath, (uint32_t)_tcslen(installpath));
|
| | 1907 | + Sha256Update(&sha_context, installpath2, (uint32_t)wcslen(installpath2));
|
| 1878 | 1908 | Sha256Finalise(&sha_context, &sha256);
|
| 1879 | 1909 | for (i = 0; i < (256 / 8); i++)
|
| 1880 | 1910 | {
|
| — | — | @@ -1956,7 +1986,7 @@ |
| 1957 | 1987 | /**
|
| 1958 | 1988 | * Checks the registry configuration version and if outdated upgrades to
|
| 1959 | 1989 | * the latest version - currently version 2
|
| 1960 | | - * Alpha version configuration is assumed to be version 0.
|
| | 1990 | + * Pre-versioned configuration is assumed to be version 0.
|
| 1961 | 1991 | */
|
| 1962 | 1992 | void UpgradeConfig()
|
| 1963 | 1993 | {
|
| — | — | @@ -2108,8 +2138,8 @@ |
| 2109 | 2139 | if (length)
|
| 2110 | 2140 | {
|
| 2111 | 2141 | _tcsncpy(oldkeys[oldconfigcount].InstallPath, ptr, MAX_PATH);
|
| 2112 | | - _tcsncpy(oldkeys[oldconfigcount].InstallPathLowercase, ptr, MAX_PATH);
|
| 2113 | | - _tcslwr(oldkeys[oldconfigcount].InstallPathLowercase);
|
| | 2142 | + _tchartowchar(oldkeys[oldconfigcount].InstallPathLowercase, ptr, MAX_PATH);
|
| | 2143 | + wcslwr(oldkeys[oldconfigcount].InstallPathLowercase);
|
| 2114 | 2144 | _tcsncpy(oldkeys[oldconfigcount].OldKey, subkey, MAX_PATH);
|
| 2115 | 2145 | if (!_tcscmp(subkey, _T("DXGLTestApp")))
|
| 2116 | 2146 | {
|
| — | — | @@ -2247,7 +2277,7 @@ |
| 2248 | 2278 | ver1to2:
|
| 2249 | 2279 | RegCloseKey(hKey);
|
| 2250 | 2280 | // Version 1 to 2: Fix an incorrectly written AddColorDepths value
|
| 2251 | | - if (version >= 2) return; // If version is 2 no need to upgrade.
|
| | 2281 | + if (version >= 2) goto ver2to3; // If version is 2 check for version 3.
|
| 2252 | 2282 | // Fix up the global Add color depths
|
| 2253 | 2283 | _tcscpy(regkey, regkeyglobal);
|
| 2254 | 2284 | error = RegCreateKeyEx(HKEY_CURRENT_USER, regkey, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hKey, NULL);
|
| — | — | @@ -2305,6 +2335,8 @@ |
| 2306 | 2336 | RegSetValueEx(hKey, _T("Configuration Version"), 0, REG_DWORD, (BYTE*)&sizeout, 4);
|
| 2307 | 2337 | RegCloseKey(hKey);
|
| 2308 | 2338 | }
|
| | 2339 | +ver2to3:
|
| | 2340 | + return;
|
| 2309 | 2341 | }
|
| 2310 | 2342 |
|
| 2311 | 2343 | int ReadINIOptionsCallback(app_ini_options *options, const char *section, const char *name,
|
| Index: cfgmgr/cfgmgr.h |
| — | — | @@ -126,7 +126,7 @@ |
| 127 | 127 | typedef struct
|
| 128 | 128 | {
|
| 129 | 129 | TCHAR InstallPath[MAX_PATH + 1];
|
| 130 | | - TCHAR InstallPathLowercase[MAX_PATH + 1];
|
| | 130 | + WCHAR InstallPathLowercase[MAX_PATH + 1];
|
| 131 | 131 | TCHAR EXEFile[MAX_PATH + 1];
|
| 132 | 132 | TCHAR OldKey[MAX_PATH + 1];
|
| 133 | 133 | TCHAR crc32[9];
|