mirror of
https://github.com/narzoul/DDrawCompat
synced 2024-12-30 08:55:36 +01:00
Disabled immersive context menus
Immersive context menus don't display correctly when theming is disabled: all menu items have empty labels and no icons. Disabled this menu style through a faked registry value.
This commit is contained in:
parent
62334dd32a
commit
4f4b0cf732
@ -3,6 +3,7 @@
|
||||
#include "CompatGdiPaintHandlers.h"
|
||||
#include "CompatGdiScrollBar.h"
|
||||
#include "CompatGdiTitleBar.h"
|
||||
#include "CompatRegistry.h"
|
||||
#include "DDrawLog.h"
|
||||
#include "Hook.h"
|
||||
|
||||
@ -297,6 +298,13 @@ namespace CompatGdiPaintHandlers
|
||||
{
|
||||
void installHooks()
|
||||
{
|
||||
// Immersive context menus don't display properly (empty items) when theming is disabled
|
||||
CompatRegistry::setValue(
|
||||
HKEY_LOCAL_MACHINE,
|
||||
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FlightedFeatures",
|
||||
"ImmersiveContextMenu",
|
||||
0);
|
||||
|
||||
CompatGdi::hookWndProc("Edit", g_origEditWndProc, &editWndProc);
|
||||
CompatGdi::hookWndProc("ListBox", g_origListBoxWndProc, &listBoxWndProc);
|
||||
CompatGdi::hookWndProc("#32768", g_origMenuWndProc, &menuWndProc);
|
||||
|
103
DDrawCompat/CompatRegistry.cpp
Normal file
103
DDrawCompat/CompatRegistry.cpp
Normal file
@ -0,0 +1,103 @@
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
|
||||
#include <atlstr.h>
|
||||
|
||||
#include "CompatRegistry.h"
|
||||
#include "DDrawLog.h"
|
||||
#include "Hook.h"
|
||||
|
||||
namespace
|
||||
{
|
||||
struct RegistryKey
|
||||
{
|
||||
HKEY key;
|
||||
CStringW subKey;
|
||||
CStringW value;
|
||||
|
||||
RegistryKey(HKEY key, CStringW subKey, CStringW value) : key(key), subKey(subKey), value(value) {}
|
||||
|
||||
bool operator<(const RegistryKey& rhs) const
|
||||
{
|
||||
if (key < rhs.key) { return true; }
|
||||
if (key > rhs.key) { return false; }
|
||||
const int subKeyComp = subKey.CompareNoCase(rhs.subKey);
|
||||
if (subKeyComp < 0) { return true; }
|
||||
if (subKeyComp > 0) { return false; }
|
||||
return value.CompareNoCase(rhs.value) < 0;
|
||||
}
|
||||
|
||||
bool operator==(const RegistryKey& rhs) const
|
||||
{
|
||||
return key == rhs.key &&
|
||||
0 == subKey.CompareNoCase(rhs.subKey) &&
|
||||
0 == value.CompareNoCase(rhs.value);
|
||||
}
|
||||
};
|
||||
|
||||
std::map<RegistryKey, DWORD> g_registryOverride;
|
||||
|
||||
LSTATUS WINAPI regGetValueW(HKEY hkey, LPCWSTR lpSubKey, LPCWSTR lpValue,
|
||||
DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
|
||||
{
|
||||
Compat::LogEnter("regGetValueW", hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
|
||||
LSTATUS result = ERROR_SUCCESS;
|
||||
|
||||
const auto it = hkey && lpSubKey && lpValue && (dwFlags & RRF_RT_REG_DWORD)
|
||||
? g_registryOverride.find(RegistryKey(hkey, lpSubKey, lpValue))
|
||||
: g_registryOverride.end();
|
||||
|
||||
if (it != g_registryOverride.end())
|
||||
{
|
||||
if (pdwType)
|
||||
{
|
||||
*pdwType = REG_DWORD;
|
||||
}
|
||||
|
||||
if (pvData)
|
||||
{
|
||||
if (!pcbData)
|
||||
{
|
||||
result = ERROR_INVALID_PARAMETER;
|
||||
}
|
||||
else if (*pcbData >= sizeof(DWORD))
|
||||
{
|
||||
std::memcpy(pvData, &it->second, sizeof(DWORD));
|
||||
}
|
||||
else
|
||||
{
|
||||
result = ERROR_MORE_DATA;
|
||||
}
|
||||
}
|
||||
|
||||
if (pcbData)
|
||||
{
|
||||
*pcbData = sizeof(DWORD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result = CALL_ORIG_FUNC(RegGetValueW)(hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData);
|
||||
}
|
||||
|
||||
Compat::LogLeave("regGetValueW", hkey, lpSubKey, lpValue, dwFlags, pdwType, pvData, pcbData) << result;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
namespace CompatRegistry
|
||||
{
|
||||
void installHooks()
|
||||
{
|
||||
Compat::beginHookTransaction();
|
||||
HOOK_FUNCTION(KernelBase, RegGetValueW, regGetValueW);
|
||||
Compat::endHookTransaction();
|
||||
}
|
||||
|
||||
void setValue(HKEY key, const char* subKey, const char* valueName, DWORD value)
|
||||
{
|
||||
assert(key && subKey && valueName);
|
||||
g_registryOverride[RegistryKey(key, subKey, valueName)] = value;
|
||||
}
|
||||
}
|
11
DDrawCompat/CompatRegistry.h
Normal file
11
DDrawCompat/CompatRegistry.h
Normal file
@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
namespace CompatRegistry
|
||||
{
|
||||
void installHooks();
|
||||
void setValue(HKEY key, const char* subKey, const char* valueName, DWORD value);
|
||||
}
|
@ -155,6 +155,7 @@
|
||||
<ClInclude Include="CompatGdiScrollFunctions.h" />
|
||||
<ClInclude Include="CompatGdiTitleBar.h" />
|
||||
<ClInclude Include="CompatGdiWinProc.h" />
|
||||
<ClInclude Include="CompatRegistry.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="DDrawProcs.h" />
|
||||
<ClInclude Include="CompatDirectDraw.h" />
|
||||
@ -185,6 +186,7 @@
|
||||
<ClCompile Include="CompatGdiScrollFunctions.cpp" />
|
||||
<ClCompile Include="CompatGdiTitleBar.cpp" />
|
||||
<ClCompile Include="CompatGdiWinProc.cpp" />
|
||||
<ClCompile Include="CompatRegistry.cpp" />
|
||||
<ClCompile Include="CompatVtable.cpp" />
|
||||
<ClCompile Include="DDrawLog.cpp" />
|
||||
<ClCompile Include="DllMain.cpp" />
|
||||
|
@ -96,6 +96,9 @@
|
||||
<ClInclude Include="Hook.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="CompatRegistry.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="DllMain.cpp">
|
||||
@ -164,6 +167,9 @@
|
||||
<ClCompile Include="Hook.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="CompatRegistry.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="DDrawCompat.def">
|
||||
|
@ -93,6 +93,8 @@ namespace Compat
|
||||
};
|
||||
|
||||
#ifdef _DEBUG
|
||||
typedef Log LogDebug;
|
||||
|
||||
class LogEnter : private Log
|
||||
{
|
||||
public:
|
||||
@ -117,6 +119,12 @@ namespace Compat
|
||||
}
|
||||
};
|
||||
#else
|
||||
class LogDebug
|
||||
{
|
||||
public:
|
||||
template <typename T> LogDebug& operator<<(const T&) { return *this; }
|
||||
};
|
||||
|
||||
class LogEnter
|
||||
{
|
||||
public:
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "CompatDirectDrawSurface.h"
|
||||
#include "CompatDirectDrawPalette.h"
|
||||
#include "CompatGdi.h"
|
||||
#include "CompatRegistry.h"
|
||||
#include "CompatVtable.h"
|
||||
#include "DDrawProcs.h"
|
||||
|
||||
@ -102,6 +103,9 @@ namespace
|
||||
Compat::Log() << "Installing GDI hooks";
|
||||
CompatGdi::installHooks();
|
||||
|
||||
Compat::Log() << "Installing registry hooks";
|
||||
CompatRegistry::installHooks();
|
||||
|
||||
dd->lpVtbl->Release(dd);
|
||||
}
|
||||
else
|
||||
|
@ -69,7 +69,7 @@ namespace Compat
|
||||
FARPROC procAddr = getProcAddress(GetModuleHandle(moduleName), funcName);
|
||||
if (!procAddr)
|
||||
{
|
||||
Compat::Log() << "Failed to load the address of a function: " << funcName;
|
||||
Compat::LogDebug() << "Failed to load the address of a function: " << funcName;
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user