@@ -64,38 +64,49 @@ static int main_gui(int nCmdShow)
6464 if (FAILED (hr))
6565 return POST_ERROR (L" g_pThemeManager2->Init failed, hr = %08X" , hr);
6666
67- const auto advapi32 = LoadLibraryW (L" advapi32" );
68- if (!advapi32)
69- return POST_ERROR (L" Loading advapi32 failed, GetLastError() = %08X" , GetLastError ());
67+ // win8
68+ LoadLibraryExW (L" advapi32" , nullptr , LOAD_LIBRARY_SEARCH_SYSTEM32 );
69+ // win10
70+ LoadLibraryExW (L" cryptsp" , nullptr , LOAD_LIBRARY_SEARCH_SYSTEM32 );
7071
71- const auto pfn = GetProcAddress (advapi32, " CryptVerifySignatureW" );
72- if (!pfn)
73- return POST_ERROR (L" CryptVerifySignatureW not found, GetLastError() = %08X" , GetLastError ());
72+ HMODULE modules[1024 ];
73+ DWORD needed = 0 ;
7474
75- // We can just do a dirty patch here since noone else would be calling CryptVerifySignatureW in our process
75+ if (EnumProcessModules (GetCurrentProcess (), modules, sizeof (modules), &needed))
76+ {
77+ for (auto i = 0u ; i < (needed / sizeof (HMODULE )); i++)
78+ {
79+ if (const auto pfn = GetProcAddress (modules[i], " CryptVerifySignatureW" ))
80+ {
81+ // We can just do a dirty patch here since noone else would be calling CryptVerifySignatureW in our process
7682
7783#if defined(_M_IX86) || defined(__i386__)
7884
79- constexpr BYTE bytes[] = {
80- 0xB8 , 0x01 , 0x00 , 0x00 , 0x00 , // mov eax, 1
81- 0xC2 , 0x18 , 0x00 // ret 18
82- };
83- const auto ret = WriteProcessMemory (
84- GetCurrentProcess (),
85- (PVOID )pfn,
86- bytes,
87- sizeof (bytes),
88- nullptr
89- );
85+ constexpr BYTE bytes[] = {
86+ 0xB8 , 0x01 , 0x00 , 0x00 , 0x00 , // mov eax, 1
87+ 0xC2 , 0x18 , 0x00 // ret 18
88+ };
89+ const auto ret = WriteProcessMemory (
90+ GetCurrentProcess (),
91+ (PVOID )pfn,
92+ bytes,
93+ sizeof (bytes),
94+ nullptr
95+ );
9096
9197#else
9298#error ThemeTool only supports x86 builds
9399#endif
94100
95-
96- if (!ret)
101+ if (!ret)
102+ return POST_ERROR (L" EnumProcessModules failed, GetLastError() = %08X" , GetLastError ());
103+ }
104+ }
105+ }
106+ else
97107 return POST_ERROR (L" WriteProcessMemory failed, GetLastError() = %08X" , GetLastError ());
98108
109+
99110 const auto dialog = CreateDialogParam (
100111 g_instance,
101112 MAKEINTRESOURCE (IDD_MAIN ),
0 commit comments