mirror of
https://github.com/valinet/ExplorerPatcher.git
synced 2024-11-30 18:24:36 +01:00
Taskbar10: Reworked ImmersiveColor.h
's referencing to uxtheme.dll
private functions
This commit is contained in:
parent
c69eb5f11a
commit
a9b089a86a
@ -2,76 +2,7 @@
|
|||||||
|
|
||||||
#include <Windows.h>
|
#include <Windows.h>
|
||||||
|
|
||||||
enum IMMERSIVE_COLOR_TYPE
|
#include "utility.h"
|
||||||
{
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
class CImmersiveColor
|
class CImmersiveColor
|
||||||
{
|
{
|
||||||
|
@ -12597,15 +12597,19 @@ DWORD Inject(BOOL bIsExplorer)
|
|||||||
|
|
||||||
|
|
||||||
HANDLE hUxtheme = LoadLibraryW(L"uxtheme.dll");
|
HANDLE hUxtheme = LoadLibraryW(L"uxtheme.dll");
|
||||||
SetPreferredAppMode = GetProcAddress(hUxtheme, (LPCSTR)0x87);
|
GetThemeName = (GetThemeName_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(74));
|
||||||
AllowDarkModeForWindow = GetProcAddress(hUxtheme, (LPCSTR)0x85);
|
RefreshImmersiveColorPolicyState = (RefreshImmersiveColorPolicyState_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(104));
|
||||||
ShouldAppsUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x84);
|
GetIsImmersiveColorUsingHighContrast = (GetIsImmersiveColorUsingHighContrast_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(106));
|
||||||
ShouldSystemUseDarkMode = GetProcAddress(hUxtheme, (LPCSTR)0x8A);
|
GetUserColorPreference = (GetUserColorPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(120));
|
||||||
GetThemeName = GetProcAddress(hUxtheme, (LPCSTR)0x4A);
|
GetColorFromPreference = (GetColorFromPreference_t)GetProcAddress(hUxtheme, MAKEINTRESOURCEA(121));
|
||||||
PeopleBand_DrawTextWithGlowFunc = GetProcAddress(hUxtheme, (LPCSTR)0x7E);
|
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)
|
if (bOldTaskbar)
|
||||||
{
|
{
|
||||||
VnPatchIAT(hExplorer, "uxtheme.dll", (LPCSTR)0x7E, PeopleBand_DrawTextWithGlowHook);
|
VnPatchIAT(hExplorer, "uxtheme.dll", MAKEINTRESOURCEA(138), PeopleBand_DrawTextWithGlowHook);
|
||||||
}
|
}
|
||||||
// DwmExtendFrameIntoClientArea hooked in LoadSettings
|
// DwmExtendFrameIntoClientArea hooked in LoadSettings
|
||||||
printf("Setup uxtheme functions done\n");
|
printf("Setup uxtheme functions done\n");
|
||||||
|
@ -32,6 +32,12 @@
|
|||||||
#define WM_MSG_GUI_SECTION WM_USER + 1
|
#define WM_MSG_GUI_SECTION WM_USER + 1
|
||||||
#define WM_MSG_GUI_SECTION_GET 1
|
#define WM_MSG_GUI_SECTION_GET 1
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EP_INLINE inline
|
||||||
|
#else
|
||||||
|
#define EP_INLINE
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -98,10 +104,7 @@ DEFINE_GUID(IID_ITrayUIComponent,
|
|||||||
0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b
|
0x64, 0xb4, 0xc0, 0x9b, 0x21, 0x1b
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EP_INLINE HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv);
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
HRESULT(*explorer_TrayUI_CreateInstanceFunc)(ITrayUIHost* host, REFIID riid, void** ppv);
|
|
||||||
#pragma endregion
|
#pragma endregion
|
||||||
|
|
||||||
inline int FileExistsW(wchar_t* file)
|
inline int FileExistsW(wchar_t* file)
|
||||||
@ -144,10 +147,7 @@ typedef LSTATUS(*t_SHRegGetValueFromHKCUHKLM)(
|
|||||||
void* pvData,
|
void* pvData,
|
||||||
DWORD* pcbData
|
DWORD* pcbData
|
||||||
);
|
);
|
||||||
#ifdef __cplusplus
|
EP_INLINE t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc;
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
t_SHRegGetValueFromHKCUHKLM SHRegGetValueFromHKCUHKLMFunc;
|
|
||||||
|
|
||||||
inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
|
inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
|
||||||
PCWSTR pwszKey,
|
PCWSTR pwszKey,
|
||||||
@ -217,10 +217,7 @@ inline LSTATUS SHRegGetValueFromHKCUHKLMWithOpt(
|
|||||||
return lRes;
|
return lRes;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EP_INLINE HWND(WINAPI* CreateWindowInBand)(
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
HWND(WINAPI* CreateWindowInBand)(
|
|
||||||
_In_ DWORD dwExStyle,
|
_In_ DWORD dwExStyle,
|
||||||
_In_opt_ LPCWSTR lpClassName,
|
_In_opt_ LPCWSTR lpClassName,
|
||||||
_In_opt_ LPCWSTR lpWindowName,
|
_In_opt_ LPCWSTR lpWindowName,
|
||||||
@ -236,30 +233,59 @@ HWND(WINAPI* CreateWindowInBand)(
|
|||||||
DWORD band
|
DWORD band
|
||||||
);
|
);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EP_INLINE BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand);
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
BOOL(WINAPI* GetWindowBand)(HWND hWnd, PDWORD pdwBand);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EP_INLINE BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
BOOL(WINAPI* SetWindowBand)(HWND hWnd, HWND hwndInsertAfter, DWORD dwBand);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
EP_INLINE INT64(*SetWindowCompositionAttribute)(HWND, void*);
|
||||||
inline
|
|
||||||
#endif
|
|
||||||
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);
|
void* ReadFromFile(wchar_t* wszFileName, DWORD* dwSize);
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ WCHAR wszThreadLanguage[LOCALE_NAME_MAX_LENGTH];
|
|||||||
void* GUI_FileMapping = NULL;
|
void* GUI_FileMapping = NULL;
|
||||||
DWORD GUI_FileSize = 0;
|
DWORD GUI_FileSize = 0;
|
||||||
BOOL g_darkModeEnabled = FALSE;
|
BOOL g_darkModeEnabled = FALSE;
|
||||||
static void(*RefreshImmersiveColorPolicyState)() = NULL;
|
|
||||||
DWORD dwTaskbarPosition = 3;
|
DWORD dwTaskbarPosition = 3;
|
||||||
DWORD GUI_TaskbarStyle = 1;
|
DWORD GUI_TaskbarStyle = 1;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user