|
36 | 36 | // we use the builtin one so all our crt methods aren't resolved from ntdll |
37 | 37 | #pragma comment(lib, "ntdll.lib") |
38 | 38 |
|
39 | | -extern void dll_loaded(PVOID base, PCWSTR name); |
40 | | - |
41 | 39 | HINSTANCE g_instance; |
42 | 40 | CComPtr<IThemeManager2> g_pThemeManager2; |
43 | 41 |
|
@@ -66,11 +64,37 @@ static int main_gui(int nCmdShow) |
66 | 64 | if (FAILED(hr)) |
67 | 65 | return POST_ERROR(L"g_pThemeManager2->Init failed, hr = %08X", hr); |
68 | 66 |
|
69 | | - const auto themeui = LoadLibraryW(L"themeui"); |
70 | | - if (!themeui) |
71 | | - return POST_ERROR(L"LoadLibrary(themeui) failed, LastError = %08X", GetLastError()); |
| 67 | + const auto advapi32 = LoadLibraryW(L"advapi32"); |
| 68 | + if (!advapi32) |
| 69 | + return POST_ERROR(L"Loading advapi32 failed, GetLastError() = %08X", GetLastError()); |
| 70 | + |
| 71 | + const auto pfn = GetProcAddress(advapi32, "CryptVerifySignatureW"); |
| 72 | + if (!pfn) |
| 73 | + return POST_ERROR(L"CryptVerifySignatureW not found, GetLastError() = %08X", GetLastError()); |
| 74 | + |
| 75 | + // We can just do a dirty patch here since noone else would be calling CryptVerifySignatureW in our process |
| 76 | + |
| 77 | +#if defined(_M_IX86) || defined(__i386__) |
| 78 | + |
| 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 | + ); |
| 90 | + |
| 91 | +#else |
| 92 | +#error ThemeTool only supports x86 builds |
| 93 | +#endif |
| 94 | + |
72 | 95 |
|
73 | | - dll_loaded(themeui, L"themeui"); |
| 96 | + if (!ret) |
| 97 | + return POST_ERROR(L"WriteProcessMemory failed, GetLastError() = %08X", GetLastError()); |
74 | 98 |
|
75 | 99 | const auto dialog = CreateDialogParam( |
76 | 100 | g_instance, |
|
0 commit comments