1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-30 18:24:36 +01:00

Corrected registry access calls

This commit is contained in:
Valentin Radu 2021-10-10 23:06:49 +03:00
parent 958a9a6b20
commit 061f85f402
4 changed files with 68 additions and 15 deletions

View File

@ -629,6 +629,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,
name, name,
@ -651,6 +655,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
KEY_READ | (hDC ? 0 : KEY_WRITE), KEY_READ | (hDC ? 0 : KEY_WRITE),
&hKey &hKey
); );
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
value = hKey; value = hKey;
} }
if (bInvert || bBool || bJustCheck) if (bInvert || bBool || bJustCheck)
@ -744,6 +752,10 @@ static BOOL GUI_Build(HDC hDC, HWND hwnd, POINT pt)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
if (d[1] == '"') if (d[1] == '"')
{ {
wchar_t* p = wcschr(d + 2, L'"'); wchar_t* p = wcschr(d + 2, L'"');
@ -1173,6 +1185,10 @@ __declspec(dllexport) int ZZGUI(HWND hWnd, HINSTANCE hInstance, LPSTR lpszCmdLin
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
DWORD bAllocConsole = FALSE; DWORD bAllocConsole = FALSE;
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,

View File

@ -55,11 +55,20 @@ DWORD MonitorSettingsChanges(SettingsChangeParameters* params)
KEY_READ, KEY_READ,
&hKeyCU &hKeyCU
); );
if (hKeyCU == NULL || hKeyCU == INVALID_HANDLE_VALUE)
{
hKeyCU = NULL;
}
if (lRes != ERROR_SUCCESS) if (lRes != ERROR_SUCCESS)
{ {
return 0; return 0;
} }
HANDLE hEvHKCU = CreateEvent(NULL, FALSE, FALSE, NULL); HANDLE hEvHKCU = CreateEvent(NULL, FALSE, FALSE, NULL);
if (hEvHKCU == NULL || hEvHKCU == INVALID_HANDLE_VALUE)
{
hEvHKCU = NULL;
return 0;
}
RegNotifyChangeKeyValue( RegNotifyChangeKeyValue(
hKeyCU, hKeyCU,
FALSE, FALSE,
@ -75,11 +84,20 @@ DWORD MonitorSettingsChanges(SettingsChangeParameters* params)
KEY_READ, KEY_READ,
&hKeyLM &hKeyLM
); );
if (hKeyLM == NULL || hKeyLM == INVALID_HANDLE_VALUE)
{
hKeyLM = NULL;
}
if (lRes != ERROR_SUCCESS) if (lRes != ERROR_SUCCESS)
{ {
return 0; return 0;
} }
HANDLE hEvHKLM = CreateEvent(NULL, FALSE, FALSE, NULL); HANDLE hEvHKLM = CreateEvent(NULL, FALSE, FALSE, NULL);
if (hEvHKLM == NULL || hEvHKLM == INVALID_HANDLE_VALUE)
{
hEvHKLM = NULL;
return 0;
}
RegNotifyChangeKeyValue( RegNotifyChangeKeyValue(
hKeyLM, hKeyLM,
FALSE, FALSE,
@ -309,10 +327,10 @@ DWORD MonitorSettingsChanges(SettingsChangeParameters* params)
} }
} }
CloseHandle(hEvHKCU); if (hEvHKCU) CloseHandle(hEvHKCU);
CloseHandle(hEvHKLM); if (hEvHKLM) CloseHandle(hEvHKLM);
RegCloseKey(hKeyCU); if (hKeyCU) RegCloseKey(hKeyCU);
RegCloseKey(hKeyLM); if (hKeyLM) RegCloseKey(hKeyLM);
} }
} }
} }

View File

@ -1356,7 +1356,8 @@ __declspec(dllexport) DWORD WINAPI main(
{ {
funchook = funchook_create(); funchook = funchook_create();
printf("funchook create %d\n", funchook != 0); printf("funchook create %d\n", funchook != 0);
HKEY hKey;
HKEY hKey = NULL;
DWORD dwDisposition; DWORD dwDisposition;
DWORD dwSize = sizeof(DWORD); DWORD dwSize = sizeof(DWORD);
@ -1373,6 +1374,10 @@ __declspec(dllexport) DWORD WINAPI main(
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (hKey == NULL || hKey == INVALID_HANDLE_VALUE)
{
hKey = NULL;
}
DWORD bAllocConsole = FALSE; DWORD bAllocConsole = FALSE;
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,
@ -1760,6 +1765,12 @@ __declspec(dllexport) DWORD WINAPI main(
{ {
printf("Failed to register taskbar update notification.\n"); printf("Failed to register taskbar update notification.\n");
} }
if (hKey)
{
RegCloseKey(hKey);
}
} }
else else
{ {

View File

@ -59,7 +59,7 @@ L"</toast>\r\n";
DWORD DownloadSymbols(DownloadSymbolsParams* params) DWORD DownloadSymbols(DownloadSymbolsParams* params)
{ {
HKEY hKey; HKEY hKey = NULL;
DWORD dwDisposition; DWORD dwDisposition;
HMODULE hModule = params->hModule; HMODULE hModule = params->hModule;
@ -224,7 +224,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (!hKey) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
@ -296,7 +296,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&(symbols_PTRS.twinui_pcshell_PTRS[7]), &(symbols_PTRS.twinui_pcshell_PTRS[7]),
sizeof(DWORD) sizeof(DWORD)
); );
RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
@ -364,7 +364,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (!hKey) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
@ -412,7 +412,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&(symbols_PTRS.startdocked_PTRS[4]), &(symbols_PTRS.startdocked_PTRS[4]),
sizeof(DWORD) sizeof(DWORD)
); );
RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
@ -430,7 +430,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (!hKey) if (!hKey || hKey == INVALID_HANDLE_VALUE)
{ {
FreeLibraryAndExitThread( FreeLibraryAndExitThread(
hModule, hModule,
@ -446,7 +446,7 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
szReportedVersion, szReportedVersion,
wcslen(szReportedVersion) * sizeof(TCHAR) wcslen(szReportedVersion) * sizeof(TCHAR)
); );
RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
if (symbols_PTRS.twinui_pcshell_PTRS[0]) if (symbols_PTRS.twinui_pcshell_PTRS[0])
@ -503,9 +503,9 @@ DWORD DownloadSymbols(DownloadSymbolsParams* params)
exit(0); exit(0);
} }
BOOL LoadSymbols(symbols_addr* symbols_PTRS) BOOL LoadSymbols(symbols_addr* symbols_PTRS, HMODULE hModule)
{ {
HKEY hKey; HKEY hKey = NULL;
DWORD dwDisposition; DWORD dwDisposition;
DWORD dwSize = sizeof(DWORD); DWORD dwSize = sizeof(DWORD);
@ -520,6 +520,14 @@ BOOL LoadSymbols(symbols_addr* symbols_PTRS)
&hKey, &hKey,
&dwDisposition &dwDisposition
); );
if (!hKey || hKey == INVALID_HANDLE_VALUE)
{
FreeLibraryAndExitThread(
hModule,
1
);
return 1;
}
RegQueryValueExW( RegQueryValueExW(
hKey, hKey,
TEXT(TWINUI_PCSHELL_SB_0), TEXT(TWINUI_PCSHELL_SB_0),
@ -637,7 +645,7 @@ BOOL LoadSymbols(symbols_addr* symbols_PTRS)
&(symbols_PTRS->startdocked_PTRS[4]), &(symbols_PTRS->startdocked_PTRS[4]),
&dwSize &dwSize
); );
RegCloseKey(hKey); if (hKey) RegCloseKey(hKey);
BOOL bNeedToDownload = FALSE; BOOL bNeedToDownload = FALSE;
for (UINT i = 0; i < sizeof(symbols_addr) / sizeof(DWORD); ++i) for (UINT i = 0; i < sizeof(symbols_addr) / sizeof(DWORD); ++i)