1
0
mirror of https://github.com/valinet/ExplorerPatcher.git synced 2024-11-14 19:17:35 +01:00

Taskbar10: Reworked ImmersiveColor.h's referencing to uxtheme.dll private functions

This commit is contained in:
Amrsatrio 2024-07-21 14:57:31 +07:00
parent c69eb5f11a
commit a9b089a86a
4 changed files with 67 additions and 107 deletions

View File

@ -2,76 +2,7 @@
#include <Windows.h>
enum IMMERSIVE_COLOR_TYPE
{
// Defining only used ones
IMCLR_SystemAccentLight2 = 2,
IMCLR_SystemAccentDark2 = 6
};
struct IMMERSIVE_COLOR_PREFERENCE
{
DWORD crStartColor;
DWORD crAccentColor;
};
enum IMMERSIVE_HC_CACHE_MODE
{
IHCM_USE_CACHED_VALUE = 0,
IHCM_REFRESH = 1
};
typedef bool (*RefreshImmersiveColorPolicyState_t)(); // 104
inline bool RefreshImmersiveColorPolicyState()
{
static RefreshImmersiveColorPolicyState_t fn;
if (!fn)
{
HMODULE h = GetModuleHandleW(L"uxtheme.dll");
if (h)
fn = (RefreshImmersiveColorPolicyState_t)GetProcAddress(h, MAKEINTRESOURCEA(104));
}
return fn ? fn() : false;
}
typedef bool (*GetIsImmersiveColorUsingHighContrast_t)(IMMERSIVE_HC_CACHE_MODE); // 106
inline bool GetIsImmersiveColorUsingHighContrast(IMMERSIVE_HC_CACHE_MODE mode)
{
static GetIsImmersiveColorUsingHighContrast_t fn;
if (!fn)
{
HMODULE h = GetModuleHandleW(L"uxtheme.dll");
if (h)
fn = (GetIsImmersiveColorUsingHighContrast_t)GetProcAddress(h, MAKEINTRESOURCEA(106));
}
return fn ? fn(mode) : false;
}
typedef HRESULT (*GetUserColorPreference_t)(IMMERSIVE_COLOR_PREFERENCE*, bool); // 120
inline HRESULT GetUserColorPreference(IMMERSIVE_COLOR_PREFERENCE* pcpColorPreference, bool fForceReload)
{
static GetUserColorPreference_t fn;
if (!fn)
{
HMODULE h = GetModuleHandleW(L"uxtheme.dll");
if (h)
fn = (GetUserColorPreference_t)GetProcAddress(h, MAKEINTRESOURCEA(120));
}
return fn ? fn(pcpColorPreference, fForceReload) : E_FAIL;
}
typedef DWORD (*GetColorFromPreference_t)(const IMMERSIVE_COLOR_PREFERENCE*, IMMERSIVE_COLOR_TYPE, bool, IMMERSIVE_HC_CACHE_MODE); // 121
inline DWORD GetColorFromPreference(const IMMERSIVE_COLOR_PREFERENCE* cpcpPreference, IMMERSIVE_COLOR_TYPE colorType, bool fNoHighContrast, IMMERSIVE_HC_CACHE_MODE mode)
{
static GetColorFromPreference_t fn;
if (!fn)
{
HMODULE h = GetModuleHandleW(L"uxtheme.dll");
if (h)
fn = (GetColorFromPreference_t)GetProcAddress(h, MAKEINTRESOURCEA(121));
}
return fn ? fn(cpcpPreference, colorType, fNoHighContrast, mode) : 0;
}
#include "utility.h"
class CImmersiveColor
{

View File

@ -12597,15 +12597,19 @@ DWORD Inject(BOOL bIsExplorer)
HANDLE hUxtheme = LoadLibraryW(L"uxtheme.dll");
SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)0x87);
AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)0x85);
ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x84);
ShouldSystemUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x8A);
GetThemeName = GetProcAddress(hUxtheme, (LPCSTR)0x4A);
PeopleBand_DrawTextWithGlowFunc = GetProcAddress(hUxtheme, (LPCSTR)0x7E);
GetThemeName = (GetThemeName_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(74));
RefreshImmersiveColorPolicyState = (RefreshImmersiveColorPolicyState_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104));
GetIsImmersiveColorUsingHighContrast = (GetIsImmersiveColorUsingHighContrast_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106));
GetUserColorPreference = (GetUserColorPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(120));
GetColorFromPreference = (GetColorFromPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(121));
PeopleBand_DrawTextWithGlowFunc = GetProcAddress(hUxtheme, MAKEINTRESOURCEA(126));
ShouldAppsUseDarkMode = (ShouldAppsUseDarkMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(132));
AllowDarkModeForWindow = (AllowDarkModeForWindow_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(133));
SetPreferredAppMode = (SetPreferredAppMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(135));
ShouldSystemUseDarkMode = (ShouldSystemUseDarkMode_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(138));
if (bOldTaskbar)
{
VnPatchIAT(hExplorer, "uxtheme.dll", (LPCSTR)0x7E, PeopleBand_DrawTextWithGlowHook);
VnPatchIAT(hExplorer, "uxtheme.dll", MAKEINTRESOURCEA(138), PeopleBand_DrawTextWithGlowHook);
}
// DwmExtendFrameIntoClientArea hooked in LoadSettings
printf("Setup uxtheme functions done\n");

View File

@ -32,6 +32,12 @@
#define WM_MSG_GUI_SECTION WM_USER + 1
#define WM_MSG_GUI_SECTION_GET 1
#ifdef __cplusplus
#define EP_INLINE inline
#else
#define EP_INLINE
#endif
#ifdef __cplusplus
extern "C" {
#endif
@ -98,10 +104,7 @@ DEFINE_GUID(IID_ITrayUIComponent,
0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b
);
#ifdef __cplusplus
inline
#endif
HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv);
EP_INLINE HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv);
#pragma endregion
inline int FileExistsW(wchar_t* file)
@ -144,10 +147,7 @@ typedef LSTATUS(*t_SHRegGetValueFromHKCUHKLM)(
void* pvData,
DWORD* pcbData
);
#ifdef __cplusplus
inline
#endif
t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc;
EP_INLINE t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc;
inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
PCWSTR pwszKey,
@ -217,10 +217,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
return lRes;
}
#ifdef __cplusplus
inline
#endif
HWND(WINAPI* CreateWindowInBand)(
EP_INLINE HWND(WINAPI* CreateWindowInBand)(
_In_ DWORD dwExStyle,
_In_opt_ LPCWSTR lpClassName,
_In_opt_ LPCWSTR lpWindowName,
@ -236,30 +233,59 @@ HWND(WINAPI* CreateWindowInBand)(
DWORD band
);
#ifdef __cplusplus
inline
#endif
BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand);
EP_INLINE BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand);
#ifdef __cplusplus
inline
#endif
BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
EP_INLINE BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
#ifdef __cplusplus
inline
#endif
INT64(*SetWindowCompositionAttribute)(HWND, void*);
EP_INLINE INT64(*SetWindowCompositionAttribute)(HWND, void*);
static void(*SetPreferredAppMode)(BOOL bAllowDark);
// uxtheme.dll private functions
static void(*AllowDarkModeForWindow)(HWND hWnd, BOOL bAllowDark);
typedef enum IMMERSIVE_COLOR_TYPE
{
// Defining only used ones
IMCLR_SystemAccentLight2 = 2,
IMCLR_SystemAccentDark2 = 6
} IMMERSIVE_COLOR_TYPE;
static bool(*ShouldAppsUseDarkMode)();
typedef struct IMMERSIVE_COLOR_PREFERENCE
{
DWORD crStartColor;
DWORD crAccentColor;
} IMMERSIVE_COLOR_PREFERENCE;
static bool(*ShouldSystemUseDarkMode)();
typedef enum IMMERSIVE_HC_CACHE_MODE
{
IHCM_USE_CACHED_VALUE = 0,
IHCM_REFRESH = 1
} IMMERSIVE_HC_CACHE_MODE;
static void(*GetThemeName)(void*, void*, void*);
typedef void(*GetThemeName_t)(void*, void*, void*); // 74
EP_INLINE GetThemeName_t GetThemeName;
typedef bool(*RefreshImmersiveColorPolicyState_t)(); // 104
EP_INLINE RefreshImmersiveColorPolicyState_t RefreshImmersiveColorPolicyState;
typedef bool(*GetIsImmersiveColorUsingHighContrast_t)(IMMERSIVE_HC_CACHE_MODE); // 106
EP_INLINE GetIsImmersiveColorUsingHighContrast_t GetIsImmersiveColorUsingHighContrast;
typedef HRESULT(*GetUserColorPreference_t)(IMMERSIVE_COLOR_PREFERENCE*, bool); // 120
EP_INLINE GetUserColorPreference_t GetUserColorPreference;
typedef DWORD(*GetColorFromPreference_t)(const IMMERSIVE_COLOR_PREFERENCE*, IMMERSIVE_COLOR_TYPE, bool, IMMERSIVE_HC_CACHE_MODE); // 121
EP_INLINE GetColorFromPreference_t GetColorFromPreference;
typedef bool(*ShouldAppsUseDarkMode_t)(); // 132
EP_INLINE ShouldAppsUseDarkMode_t ShouldAppsUseDarkMode;
typedef void(*AllowDarkModeForWindow_t)(HWND hWnd, BOOL bAllowDark); // 133
EP_INLINE AllowDarkModeForWindow_t AllowDarkModeForWindow;
typedef void(*SetPreferredAppMode_t)(BOOL bAllowDark); // 135
EP_INLINE SetPreferredAppMode_t SetPreferredAppMode;
typedef bool(*ShouldSystemUseDarkMode_t)(); // 138
EP_INLINE ShouldSystemUseDarkMode_t ShouldSystemUseDarkMode;
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize);

View File

@ -10,7 +10,6 @@ WCHAR wszThreadLanguage[LOCALE_NAME_MAX_LENGTH];
void* GUI_FileMapping = NULL;
DWORD GUI_FileSize = 0;
BOOL g_darkModeEnabled = FALSE;
static void(*RefreshImmersiveColorPolicyState)() = NULL;
DWORD dwTaskbarPosition = 3;
DWORD GUI_TaskbarStyle = 1;