Skip to content

Commit 72a800a

Browse files
committed
Fix ThemeTool on Win8.1
1 parent c9ad3f6 commit 72a800a

3 files changed

Lines changed: 30 additions & 23 deletions

File tree

ThemeTool/ThemeTool.vcxproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -244,20 +244,6 @@
244244
<ClInclude Include="utl.h" />
245245
</ItemGroup>
246246
<ItemGroup>
247-
<ClCompile Include="..\SecureUxTheme\avrf.cpp">
248-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
249-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
250-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">NotUsing</PrecompiledHeader>
251-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">NotUsing</PrecompiledHeader>
252-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
253-
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
254-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NO_ATOMS;WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
255-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NO_ATOMS;WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
256-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">NO_ATOMS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
257-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">NO_ATOMS;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
258-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NO_ATOMS;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
259-
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|x64'">THEME_TOOL;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
260-
</ClCompile>
261247
<ClCompile Include="main.cpp" />
262248
<ClCompile Include="pch.cpp">
263249
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>

ThemeTool/ThemeTool.vcxproj.filters

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
<ClCompile Include="signature.cpp">
2828
<Filter>Source Files</Filter>
2929
</ClCompile>
30-
<ClCompile Include="..\SecureUxTheme\avrf.cpp">
31-
<Filter>Source Files</Filter>
32-
</ClCompile>
3330
<ClCompile Include="utl.cpp">
3431
<Filter>Source Files</Filter>
3532
</ClCompile>

ThemeTool/main.cpp

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
// we use the builtin one so all our crt methods aren't resolved from ntdll
3737
#pragma comment(lib, "ntdll.lib")
3838

39-
extern void dll_loaded(PVOID base, PCWSTR name);
40-
4139
HINSTANCE g_instance;
4240
CComPtr<IThemeManager2> g_pThemeManager2;
4341

@@ -66,11 +64,37 @@ static int main_gui(int nCmdShow)
6664
if (FAILED(hr))
6765
return POST_ERROR(L"g_pThemeManager2->Init failed, hr = %08X", hr);
6866

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+
7295

73-
dll_loaded(themeui, L"themeui");
96+
if (!ret)
97+
return POST_ERROR(L"WriteProcessMemory failed, GetLastError() = %08X", GetLastError());
7498

7599
const auto dialog = CreateDialogParam(
76100
g_instance,

0 commit comments

Comments
 (0)