neptune
Freshman Member
👅
Posts: 33
OS: 👅
Theme: 👅
CPU: 👅
RAM: 👅
GPU: 👅
Computer Make/Model: 👅
|
Post by neptune on Apr 2, 2024 12:58:39 GMT -8
Technically, it is a uDWM patch still. The patching is just done in memory rather than modifying the file on disk. Yeah, but still, no more needing to risk bricking your Windows 10 install! you could say.. it's quasi unbrickable
|
|
kirta
Freshman Member
Posts: 59
OS: Windows 10 LTSC 2021
|
Post by kirta on Apr 5, 2024 18:33:47 GMT -8
This is a supposedly exhaustive list of Windhawk mods to directly hook into DWM in order to modify the window frame properties. Mods modifying basic or classic window frames, or forcing DWM to display basic or classic frames are not mentioned on this page. - Acrylic Effect Radius Changer (by Dulappy ) This mod changes the radius of the Accrylic blur effect in Windows 10, for applications using it. - Bring Back the Borders! (by teknixstuff ) Restores window borders and corners in Windows 11. This is particularly useful for good display of Aerolite visual styles (high contrast or not), and all older visual styles (Vista, 7, 8). This mod is based on the Disable rounded corners in Windows 11 mod. This mod forces thick frames in Windows 10/11, as was the case in Windows Vista/7/8/8.1. This is useful when using a visual style of one of its versions of Windows, or the Arolite visual style (which has not changed style since Windows 8).
This mod can have bugs, notably the bug that all windows become resizable. This is a Windhawk port of WinCenterTitle by Valinet. It centers the title bar text, like on Windows 8/8.1. - Restore Windows 7 Caption Buttons (by Dulappy ) Restores the Windows 7 style caption buttons (original lengths and heights). In some versions of Windows 11, this mod appears to conflict with the Bring Back the Borders! (to confirm). {Mod code}
// ==WindhawkMod== // @id restore-seven-caption-buttons // @name Restore Windows 7 Caption Buttons // @description This mod restores the caption buttons to their original lengths and heights in Windows 7. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compilerOptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # The leaker known as ImSwordQueen. The leaker of mods while sleeping */ // ==/WindhawkModReadme==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
void (*CText_SetColor_Original)(void *pThis, unsigned long color);
void CText_SetColor_Hook(void *pThis, unsigned long color) { color = 0x000000; return CText_SetColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
bool (__thiscall *CButton__UpdateCurrentGlyphOpacity_Original)(void *, bool); bool __thiscall CButton__UpdateCurrentGlyphOpacity_Hook(void *pThis, bool param_1) { *((float *)pThis + 101) = 1.0; return CButton__UpdateCurrentGlyphOpacity_Original(pThis, param_1); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { height = floor((float)((float)TBHeight * 21 / 21) + 0.5); if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 49 / 21) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { width = floor((float)((float)TBHeight * 49 / 21) + 0.5); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { width = floor((float)((float)TBHeight * 27 / 21) + 0.5); } else { width = floor((float)((float)TBHeight * 29 / 21) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400);
if (!already_running) { return FALSE; }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* UpdateCurrentGlyphOpacityAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CButton::UpdateCurrentGlyphOpacity(bool)") == 0) { UpdateCurrentGlyphOpacityAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(UpdateCurrentGlyphOpacityAddr, (void*)CButton__UpdateCurrentGlyphOpacity_Hook, (void**)&CButton__UpdateCurrentGlyphOpacity_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); Wh_SetFunctionHook(SetColorAddr, (void*)CText_SetColor_Hook, (void**)&CText_SetColor_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; }
- Restore Windows 8.X Caption Buttons (by Dulappy ) Restores the Windows 8.x style caption buttons (original lengths and heights). {Mod code}
// ==WindhawkMod== // @id restore-eight-caption-buttons // @name Restore Windows 8.X Caption Buttons // @description This mod restores the caption buttons to their original lengths and heights in Windows 8.X. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compilerOptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # Placeholder */ // ==/WindhawkModReadme==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
bool (*CTopLevelWindow_TreatAsActiveWindow_Original)(void);
bool CTopLevelWindow_TreatAsActiveWindow_Hook(void) { return TRUE; }
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
void (*CText_SetColor_Original)(void *pThis, unsigned long color);
void CText_SetColor_Hook(void *pThis, unsigned long color) { color = 0x000000; return CText_SetColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { height = floor((float)((float)TBHeight * 21 / 22) + 0.5); if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 47 / 22) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { width = floor((float)((float)TBHeight * 34 / 22) + 0.5); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { width = floor((float)((float)TBHeight * 26 / 22) + 0.5); } else { width = floor((float)((float)TBHeight * 29 / 22) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400);
if (!already_running) { return FALSE; }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* TreatAsActiveWindowAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::TreatAsActiveWindow(void)") == 0) { TreatAsActiveWindowAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(TreatAsActiveWindowAddr, (void*)CTopLevelWindow_TreatAsActiveWindow_Hook, (void**)&CTopLevelWindow_TreatAsActiveWindow_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); Wh_SetFunctionHook(SetColorAddr, (void*)CText_SetColor_Hook, (void**)&CText_SetColor_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; }
Restores the Windows XP/Classic theme style caption buttons (original lengths and heights). This mod is based on the Restore Windows 8.X Caption Buttons mod by Dulappy . {Mod code}
// ==WindhawkMod== // @id restore-classic-caption-buttons // @name Square Caption Buttons (was 8.X Caption buttons) // @description This mod restores the caption buttons to their original lengths and heights in Windows Classic and XP. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compilerOptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # Placeholder */ // ==/WindhawkModReadme==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
bool (*CButton__UpdateCurrentGlyphOpacity_Original)(void *, bool);
bool CButton__UpdateCurrentGlyphOpacity_Hook(void *pThis, bool b) { *((float *)pThis + 101) = 1.0f; return CButton__UpdateCurrentGlyphOpacity_Original(pThis, b); }
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { //height = floor((float)((float)TBHeight * 21 / 22) + 0.5); height = floor((float)((float)TBHeight * 23 / 22) + 2.0);
if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 23 / 22) + 2.0); //width = floor((float)((float)TBHeight * 47 / 22) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { //width = floor((float)((float)TBHeight * 24 / 22) + 0.5); width = floor((float)((float)TBHeight * 23 / 22) + 2.0); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { width = floor((float)((float)TBHeight * 23 / 22) + 1.0); //width = floor((float)((float)TBHeight * 26 / 22) + 0.5); } else { width = floor((float)((float)TBHeight * 23 / 22) + 1.0); //width = floor((float)((float)TBHeight * 29 / 22) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400);
if (!already_running) { return FALSE; }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* UpdateCurrentGlyphOpacityAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CButton::UpdateCurrentGlyphOpacity(bool)") == 0) { UpdateCurrentGlyphOpacityAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(UpdateCurrentGlyphOpacityAddr, (void*)CButton__UpdateCurrentGlyphOpacity_Hook, (void**)&CButton__UpdateCurrentGlyphOpacity_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; } It still needs to be confirmed whether the proportions are exactly the same as in Windows XP or in the classic theme. Square Caption Buttons mod!! so now there is no need for basicthemer ?
|
|
|
Post by OrthodoxWin32 on Apr 6, 2024 6:22:03 GMT -8
Square Caption Buttons mod!! so now there is no need for basicthemer ? In my opinion, this mod is especially useful for creating old style visual styles with modern features, such as support for accent color or transparency, that only DWM can support.
BasicThemer is always useful. Indeed, DWM window frames can be different : for example, it is difficult in Windows 10 to obtain rounded corners. In Windows 11, there is no good solution for having borders yet. And as for the classic theme, it is better to have the real basic theme. I find that using BasicThemer is simple, with a few Windhawk mods there are almost no issues anymore.
|
|
wadeduck
New Member
I just want to download things.
Posts: 5
|
Post by wadeduck on Apr 9, 2024 12:45:11 GMT -8
Hi, first post here. I forked the 7 caption button mod to add an option for Vista-style metrics (among other things). I don't know if it works outside of 96dpi. Here's what I changed: - removed mod unloading on process startup
- added a setting for the Vista metrics. At 96dpi it adds 1px to the width of the maximize button and subtracts 1px from the height of the caption buttons to be pixel accurate to Vista.
- removed the CText_SetColor hook. DWMBlurGlass already handles this for me.
- added a divisor setting, used in width and height calculations. See CTopLevelWindow_UpdateNCAreaButton_Hook.
Works best with the caption height set to 19. Above is Vista, below is 10. {Mod code}// ==WindhawkMod== // @id restore-seven-caption-buttons // @name Restore Windows 7 Caption Buttons // @description This mod restores the caption buttons to their original lengths and heights in Windows 7. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compilerOptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # The leaker known as ImSwordQueen. The leaker of mods while sleeping */ // ==/WindhawkModReadme==
// ==WindhawkModSettings== /* - Divisor: 21 $name: Divisor $description: The divisor in CTopLevelWindow_UpdateNCAreaButton_Hook (default 21) - VistaMaximize: false $name: Vista caption style $description: At 96dpi, add 1 pixel to the width of the Maximize/Restore button and subtracts 1 pixel from the button height. */ // ==/WindhawkModSettings==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int divisor = 21; BOOL vistaMaximize = false;
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
// void (*CText_SetColor_Original)(void *pThis, unsigned long color); // // void CText_SetColor_Hook(void *pThis, unsigned long color) { // color = 0x000000; // return CText_SetColor_Original(pThis, color); // }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
bool (__thiscall *CButton__UpdateCurrentGlyphOpacity_Original)(void *, bool); bool __thiscall CButton__UpdateCurrentGlyphOpacity_Hook(void *pThis, bool param_1) { *((float *)pThis + 101) = 1.0; return CButton__UpdateCurrentGlyphOpacity_Original(pThis, param_1); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { height = floor((float)((float)TBHeight * (vistaMaximize ? 20 : 21) / divisor) + 0.5); if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { // width = floor((float)((float)TBHeight * 27 / divisor) + 0.5); width = floor((float)((float)TBHeight * (vistaMaximize ? 28 : 27) / divisor) + 0.5); } else { width = floor((float)((float)TBHeight * 29 / divisor) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
void updateSettings(){ divisor = Wh_GetIntSetting(L"Divisor"); // Change this to 24 for Vista style if(divisor == 0) divisor = 21; vistaMaximize = Wh_GetIntSetting(L"VistaMaximize"); }
void Wh_ModSettingsChanged(){ updateSettings(); }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
// This is for developers i am not a devleoper i just want to use the mod. Please stop not loading the mod. //bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400); updateSettings(); // if (!already_running) { // return FALSE; // }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* UpdateCurrentGlyphOpacityAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CButton::UpdateCurrentGlyphOpacity(bool)") == 0) { UpdateCurrentGlyphOpacityAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(UpdateCurrentGlyphOpacityAddr, (void*)CButton__UpdateCurrentGlyphOpacity_Hook, (void**)&CButton__UpdateCurrentGlyphOpacity_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); // DWMBlurGlass already handles this. // Wh_SetFunctionHook(SetColorAddr, (void*)CText_SetColor_Hook, (void**)&CText_SetColor_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; }
|
|
|
Post by OrthodoxWin32 on Apr 23, 2024 0:59:50 GMT -8
eggcornkamuisuki I just thought of something regarding the "Bring back the borders" mod. Have you considered adding DWM to the inclusion list ? If not, you can try. However, temporarily disable all other mods. If it works, you can let me know.
|
|
kamuisuki
Regular Member
~
Posts: 499
OS: Windows Me
Theme: 5048
CPU: Intel Pentium III-S Tualatin
RAM: 2048
GPU: GeForce 3Ti 500
|
Post by kamuisuki on Apr 23, 2024 7:34:39 GMT -8
Hello, as said on the topic i added on inclusion list, still has no effect ^^ , by the way using slate theme with basicthemer , i changed the border size/padding using SCT classic theme settings to change it.
|
|
|
Post by Windows User on May 29, 2024 18:02:19 GMT -8
How about Windows Vista/7/8.x Animation?
|
|
CatmanFan
New Member
Posts: 17
OS: Windows 10 Pro 21H1
Theme: Windows 7 Aero/Basic
CPU: Intel Core i5-12400F 250 GHz
RAM: 16GB
GPU: NVIDIA GeForce RTX 4060
|
Post by CatmanFan on Jun 2, 2024 4:03:19 GMT -8
|
|
|
Post by Windows User on Jun 2, 2024 4:10:48 GMT -8
Stardock is just crap maybe a Windhawk mod will bring back Windows 7 Animations because Stardock WindowFX is money
|
|
|
Post by theinsane101 on Jun 7, 2024 1:59:24 GMT -8
I found an issue with the restore 8 captions mod; it disables the ColorizationBalance effects of DWMBlurGlass, while the 7 and even Vista, mods don't. Which lines of code do I need to modify to fix this?
|
|
|
Post by OrthodoxWin32 on Jun 7, 2024 8:33:33 GMT -8
I found an issue with the restore 8 captions mod; it disables the ColorizationBalance effects of DWMBlurGlass, while the 7 and even Vista, mods don't. Which lines of code do I need to modify to fix this?
I haven't tested it yet, I did this quickly, so I'm not sure it works.
|
|
|
Post by theinsane101 on Jun 7, 2024 9:21:32 GMT -8
I found an issue with the restore 8 captions mod; it disables the ColorizationBalance effects of DWMBlurGlass, while the 7 and even Vista, mods don't. Which lines of code do I need to modify to fix this?
I haven't tested it yet, I did this quickly, so I'm not sure it works.
Thanks for trying, but it doesn't work. It gives me these errors.
|
|
Entinty1999
New Member
Posts: 11
OS: Windows 10 22H2
Theme: Host Windows 7, VMs have XP and Vista themes.
|
Post by Entinty1999 on Jun 15, 2024 17:26:17 GMT -8
I've been having trouble getting the Windows 7 restore caption button mod to work on Windows 10 22H2, gives me an error about symbols in the log.
Update: restarting my computer fixed this issue.
|
|
|
Post by Brawllux on Jun 15, 2024 21:22:13 GMT -8
I've been having trouble getting the Windows 7 restore caption button mod to work on Windows 10 22H2, gives me an error about symbols in the log.
Did you install any preview updates to Windows?
|
|
|
Post by wartronica on Jun 16, 2024 19:09:52 GMT -8
I've been getting the same issue with Windows 7 restore caption button, it just doesn't work for me. None of the caption button mods posted in this thread do.
Fixed by adding dwm.exe into process inclusion list.
|
|
arbestriagain
Sophomore Member
👅
Posts: 143
OS: Windows 11 Home 23H2
Theme: Default
CPU: Intel Core i7-10700F
RAM: 32GB
GPU: GeForce RTX 2060 SUPER
Computer Make/Model: HP OMEN 25L Desktop GT12-0xxx
|
Post by arbestriagain on Jun 17, 2024 8:59:47 GMT -8
Hi, first post here. I forked the 7 caption button mod to add an option for Vista-style metrics (among other things). I don't know if it works outside of 96dpi. Here's what I changed: - removed mod unloading on process startup
- added a setting for the Vista metrics. At 96dpi it adds 1px to the width of the maximize button and subtracts 1px from the height of the caption buttons to be pixel accurate to Vista.
- removed the CText_SetColor hook. DWMBlurGlass already handles this for me.
- added a divisor setting, used in width and height calculations. See CTopLevelWindow_UpdateNCAreaButton_Hook.
Works best with the caption height set to 19. Above is Vista, below is 10. {Mod code}// ==WindhawkMod== // @id restore-seven-caption-buttons // @name Restore Windows 7 Caption Buttons // @description This mod restores the caption buttons to their original lengths and heights in Windows 7. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compileroptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # The leaker known as ImSwordQueen. The leaker of mods while sleeping */ // ==/WindhawkModReadme==
// ==WindhawkModSettings== /* - Divisor: 21 $name: Divisor $description: The divisor in CTopLevelWindow_UpdateNCAreaButton_Hook (default 21) - VistaMaximize: false $name: Vista caption style $description: At 96dpi, add 1 pixel to the width of the Maximize/Restore button and subtracts 1 pixel from the button height. */ // ==/WindhawkModSettings==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int divisor = 21; BOOL vistaMaximize = false;
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
// void (*CText_SetColor_Original)(void *pThis, unsigned long color); // // void CText_SetColor_Hook(void *pThis, unsigned long color) { // color = 0x000000; // return CText_SetColor_Original(pThis, color); // }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
bool (__thiscall *CButton__UpdateCurrentGlyphOpacity_Original)(void *, bool); bool __thiscall CButton__UpdateCurrentGlyphOpacity_Hook(void *pThis, bool param_1) { *((float *)pThis + 101) = 1.0; return CButton__UpdateCurrentGlyphOpacity_Original(pThis, param_1); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { height = floor((float)((float)TBHeight * (vistaMaximize ? 20 : 21) / divisor) + 0.5); if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { // width = floor((float)((float)TBHeight * 27 / divisor) + 0.5); width = floor((float)((float)TBHeight * (vistaMaximize ? 28 : 27) / divisor) + 0.5); } else { width = floor((float)((float)TBHeight * 29 / divisor) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
void updateSettings(){ divisor = Wh_GetIntSetting(L"Divisor"); // Change this to 24 for Vista style if(divisor == 0) divisor = 21; vistaMaximize = Wh_GetIntSetting(L"VistaMaximize"); }
void Wh_ModSettingsChanged(){ updateSettings(); }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
// This is for developers i am not a devleoper i just want to use the mod. Please stop not loading the mod. //bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400); updateSettings(); // if (!already_running) { // return FALSE; // }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* UpdateCurrentGlyphOpacityAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CButton::UpdateCurrentGlyphOpacity(bool)") == 0) { UpdateCurrentGlyphOpacityAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(UpdateCurrentGlyphOpacityAddr, (void*)CButton__UpdateCurrentGlyphOpacity_Hook, (void**)&CButton__UpdateCurrentGlyphOpacity_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); // DWMBlurGlass already handles this. // Wh_SetFunctionHook(SetColorAddr, (void*)CText_SetColor_Hook, (void**)&CText_SetColor_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; } Mod does absolutely nothing even when dwm.exe is in process inclusion list and critcal system processes in exclusion list removed. EDIT: Restarting fixed it.
|
|
|
Post by Windows User on Jun 18, 2024 8:41:05 GMT -8
Hi, first post here. I forked the 7 caption button mod to add an option for Vista-style metrics (among other things). I don't know if it works outside of 96dpi. Here's what I changed: - removed mod unloading on process startup
- added a setting for the Vista metrics. At 96dpi it adds 1px to the width of the maximize button and subtracts 1px from the height of the caption buttons to be pixel accurate to Vista.
- removed the CText_SetColor hook. DWMBlurGlass already handles this for me.
- added a divisor setting, used in width and height calculations. See CTopLevelWindow_UpdateNCAreaButton_Hook.
Works best with the caption height set to 19. Above is Vista, below is 10. {Mod code}// ==WindhawkMod== // @id restore-seven-caption-buttons // @name Restore Windows 7 Caption Buttons // @description This mod restores the caption buttons to their original lengths and heights in Windows 7. Works on Windows 10 21H2 (LTSC 2021). // @version 0.1 // @author Dulappy // @github https://github.com/Dulappy // @include dwm.exe // @architecture x86-64 // @compileroptions -ldwmapi -lgdi32 -ld2d1 -ldxguid -lcomdlg32 -lwindowscodecs // ==/WindhawkMod==
// ==WindhawkModReadme== /* # The leaker known as ImSwordQueen. The leaker of mods while sleeping */ // ==/WindhawkModReadme==
// ==WindhawkModSettings== /* - Divisor: 21 $name: Divisor $description: The divisor in CTopLevelWindow_UpdateNCAreaButton_Hook (default 21) - VistaMaximize: false $name: Vista caption style $description: At 96dpi, add 1 pixel to the width of the Maximize/Restore button and subtracts 1 pixel from the button height. */ // ==/WindhawkModSettings==
#include <windef.h> #include <wingdi.h> #include <dwmapi.h> #include <D3D9Types.h> #include <d2d1effects.h> #include <winuser.h> #include <math.h> #include <wincodec.h>
#define ID_CLOSE 3 #define ID_MAXRES 2 #define ID_MIN 1
#define STATE_MAXIMIZED 4
#define TYPE_TOOL 2
int divisor = 21; BOOL vistaMaximize = false;
int (WINAPI *GetSystemMetricsForDpiOrig)(int nIndex, UINT dpi); int WINAPI GetSystemMetricsForDpiHook(int nIndex, UINT dpi) { return GetSystemMetricsForDpiOrig(nIndex, dpi); }
/* =============================================================================== */
typedef void (*CTopLevelWindow_UpdatePinnedParts_t)(void* pThis); CTopLevelWindow_UpdatePinnedParts_t CTopLevelWindow_UpdatePinnedParts_Original;
typedef void (*CVisual_SetInsetFromParentTop_t)(void* pThis, int inset); CVisual_SetInsetFromParentTop_t CVisual_SetInsetFromParentTop_Original;
typedef void (*CVisual_SetInsetFromParentLeft_t)(void* pThis, int inset); CVisual_SetInsetFromParentLeft_t CVisual_SetInsetFromParentLeft_Original;
typedef void (*CVisual_SetDirtyFlags_t)(void* pThis, int flag); CVisual_SetDirtyFlags_t CVisual_SetDirtyFlags_Original;
typedef void (*CVisual_SetInsetFromParent_t)(void* pThis, struct _MARGINS const *); CVisual_SetInsetFromParent_t CVisual_SetInsetFromParent_Original;
typedef void (*CText_SetSize_t)(void* pThis, struct tagSIZE const *); CText_SetSize_t CText_SetSize_Original;
typedef void (*CSolidColorLegacyMilBrushProxy_Update_t)(void* pThis, double alpha, struct _D3DCOLORVALUE const *); CSolidColorLegacyMilBrushProxy_Update_t CSolidColorLegacyMilBrushProxy_Update_Original;
typedef void (*MilInstrumentationCheckHR_MaybeFailFast_t)(unsigned long, long const * const, unsigned int, long, unsigned int, void*); MilInstrumentationCheckHR_MaybeFailFast_t MilInstrumentationCheckHR_MaybeFailFast_Original;
typedef long (*CCompositor_CreateMilBrushProxy_t)(__int64, long **); CCompositor_CreateMilBrushProxy_t CCompositor_CreateMilBrushProxy_Original;
typedef long (*CCompositor_CreateMatrixTransformProxy_t)(__int64, char*); CCompositor_CreateMatrixTransformProxy_t CCompositor_CreateMatrixTransformProxy_Original;
typedef long (*CPushTransformInstruction_Create_t)(__int64*, volatile int**); CPushTransformInstruction_Create_t CPushTransformInstruction_Create_Original;
typedef long (*CRenderDataVisual_AddInstruction_t)(void* pThis, volatile signed __int32 *); CRenderDataVisual_AddInstruction_t CRenderDataVisual_AddInstruction_Original;
typedef long (*CBitmapSource_Create_t)(struct IWICBitmap*, const struct _MARGINS*, long long **); CBitmapSource_Create_t CBitmapSource_Create_Original;
typedef long (*CDrawImageInstruction_Create_t)(long long*, const struct tagRECT*, volatile int **); CDrawImageInstruction_Create_t CDrawImageInstruction_Create_Original;
typedef long (*CPopInstruction_Create_t)(volatile int **); CPopInstruction_Create_t CPopInstruction_Create_Original;
typedef void (*CTopLevelWindow_GetAccentBlurBehindBrush_t)(void*, long long**, long long**, void*); CTopLevelWindow_GetAccentBlurBehindBrush_t CTopLevelWindow_GetAccentBlurBehindBrush_Original;
typedef void (*CTopLevelWindow_OnAccentPolicyUpdated_t)(void*); CTopLevelWindow_OnAccentPolicyUpdated_t CTopLevelWindow_OnAccentPolicyUpdated_Original;
typedef void (*CText_ReleaseResources_t)(void* pThis); CText_ReleaseResources_t CText_ReleaseResources_Original;
long long* DesktopManagerInstance = nullptr;
long long (*CButton_DrawStateW_Original)(void* pThis, void* CAtlasButton, UINT ButtonState);
long long CButton_DrawStateW_Hook(void* pThis, void* CAtlasButton, UINT ButtonState) { /*Wh_Log(L"We runnin"); if (ButtonState!=4 && *(DWORD *)((long long)pThis + 328) >= 4u) { Wh_Log(L"We runnin but inside"); long long v10 = 1; if ((*(BYTE *)((long long)pThis + 280) & 0x10) == 0) { v10 = ButtonState; } if ( *(DWORD *)((long long)pThis + 360) >= 4u ) { Wh_Log(L"We runnin but double inside"); *(long long *)((long long)pThis + 368) = *(long long *)(*(long long *)((long long)pThis + 336) + 8 * v10); } }*/
return CButton_DrawStateW_Original(pThis, CAtlasButton, ButtonState); }
// void (*CText_SetColor_Original)(void *pThis, unsigned long color); // // void CText_SetColor_Hook(void *pThis, unsigned long color) { // color = 0x000000; // return CText_SetColor_Original(pThis, color); // }
long (*CTopLevelWindow_UpdateMarginsDependentOnStyle_Original)(void* pThis);
long CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook(void* pThis) { long retvalue = CTopLevelWindow_UpdateMarginsDependentOnStyle_Original(pThis); //long retvalue = 0;
long long CVisualInstance = *((long long *)pThis + 91);
MARGINS somemargins = *(struct _MARGINS *)(CVisualInstance + 280); //Wh_Log(L"%i", *((DWORD *)pThis + 19));
// DesktopManagerInstance + 60 CONTROLS SOMETHING RELATED TO VISUAL BORDER SIZE double v9 = *((double*)*DesktopManagerInstance + 60); // THIS IS HOW YOU USE DESKTOPMANAGERINSTANCE //Wh_Log(L"%llu", v9);
return retvalue; }
long (*CText_ValidateResources_Original)(void* pThis);
long CText_ValidateResources_Hook(void* pThis) { //return 0; long retvalue = CText_ValidateResources_Original(pThis); //long retvalue = 0; /*DWORD v1 = *((DWORD *)pThis + 20); if ((v1 & 0x1000)) { CText_ReleaseResources_Original(pThis); if ( *((unsigned long long *)pThis + 36) ) { long long* v10 = (long long*)*((long long*)*DesktopManagerInstance + 33); if (v10) { HDC hdc = (HDC)*((long long *)v10 + 13); if (hdc) { HBITMAP Bitmap = CreateBitmap(512, 30, 1u, 32, 0); if (Bitmap) { SelectObject(hdc, Bitmap); RECT fillbox; fillbox.left = 0; fillbox.right = 512; fillbox.top = 0; fillbox.bottom = 30; HBRUSH Brush = CreateSolidBrush(RGB(3, 48, 124)); FillRect(hdc, &fillbox, Brush); GdiFlush(); IWICImagingFactory* ImagingFactory = *((IWICImagingFactory**)*DesktopManagerInstance + 39); IWICBitmap* newBitmap; ImagingFactory->CreateBitmapFromHBITMAP(Bitmap, 0, WICBitmapIgnoreAlpha, &newBitmap); WICPixelFormatGUID test1; newBitmap->GetPixelFormat(&test1); Wh_Log(L"%i", test1.Data1); Wh_Log(L"%i", test1.Data2); Wh_Log(L"%i", test1.Data3); Wh_Log(L"%llu", test1.Data4); CCompositor_CreateMatrixTransformProxy_Original(*((long long *)*DesktopManagerInstance + 5), (char *)pThis + 392); volatile int * createdInstruction = 0; CPushTransformInstruction_Create_Original(*((long long **)pThis + 49), &createdInstruction); CRenderDataVisual_AddInstruction_Original(pThis, createdInstruction);
long long * CBitmapSource = 0; MARGINS test; test.cxLeftWidth = 8; test.cxRightWidth = 8; test.cyBottomHeight = 8; test.cyTopHeight = 8; CBitmapSource_Create_Original(newBitmap, 0, &CBitmapSource); // CRASHES DWM Wh_Log(L"does this run1?"); volatile int* CDrawImageInstruction = 0; CDrawImageInstruction_Create_Original(CBitmapSource, &fillbox, &CDrawImageInstruction);
CRenderDataVisual_AddInstruction_Original(pThis, CDrawImageInstruction); volatile int* CPopInst = 0; CPopInstruction_Create_Original(&CPopInst); CRenderDataVisual_AddInstruction_Original(pThis, CPopInst); Wh_Log(L"does this run2?"); } } } } *((DWORD *)pThis + 20) &= ~0x1000u; }*/ //long retvalue = 0; return retvalue; }
long (*CTopLevelWindow_UpdateColorizationColor_Original)(void* pThis);
long CTopLevelWindow_UpdateColorizationColor_Hook(void* pThis) { return CTopLevelWindow_UpdateColorizationColor_Original(pThis); }
void (*CText_SetBackgroundColor_Original)(void* pThis, unsigned long color);
void CText_SetBackgroundColor_Hook(void* pThis, unsigned long color) { return CText_SetBackgroundColor_Original(pThis, color); }
long (*CTopLevelWindow_UpdateNCAreaBackground_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaBackground_Hook(void* pThis) { //Wh_Log(L"%i", (int)*((double *)*DesktopManagerInstance + 60)); //*((double *)*DesktopManagerInstance + 60) = 1; /*Wh_Log(L"%i", *((DWORD *)pThis + 154));
RECT rc = *(struct tagRECT *)(*((long long *)pThis + 91) + 48); Wh_Log(L"%i", rc.left); Wh_Log(L"%i", rc.right); Wh_Log(L"%i", rc.top); Wh_Log(L"%i", rc.bottom);*/
//*((DWORD *)pThis + 157) = -20;
long retvalue = CTopLevelWindow_UpdateNCAreaBackground_Original(pThis); float *colorData = (float *)*((long long *)pThis + 73);
struct _D3DCOLORVALUE color; color.a = 0.5; color.b = colorData[6]; color.g = colorData[5]; color.r = colorData[4]; //Wh_Log(L"%i", *(DWORD *)(*((long long *)pThis + 91) + 152)); /*float v28[4]; v28[0] = 1.0; v28[1] = 1.0; v28[2] = 1.0; long long *v24; long long *v25; v24 = 0; v25 = 0;*/ //CTopLevelWindow_GetAccentBlurBehindBrush_Original(pThis, &v24, &v25, &v28);
return retvalue; }
long (*CVisual_SetSize_Original)(PVOID pThis, struct tagSIZE const *);
long CVisual_SetSize_Hook(PVOID pThis, struct tagSIZE* size) { return CVisual_SetSize_Original(pThis, size); }
bool (__thiscall *CButton__UpdateCurrentGlyphOpacity_Original)(void *, bool); bool __thiscall CButton__UpdateCurrentGlyphOpacity_Hook(void *pThis, bool param_1) { *((float *)pThis + 101) = 1.0; return CButton__UpdateCurrentGlyphOpacity_Original(pThis, param_1); }
long (*CTopLevelWindow_UpdateNCAreaButton_Original)(__int64, int, int, int, int*);
long CTopLevelWindow_UpdateNCAreaButton_Hook(__int64 pThis, int buttonId, int height, int offsetTop, int* offsetRight) { typedef DWORD CVisual;
if ( !*(CVisual *)(pThis + 488 + 8 * buttonId) ) { // if this button doesn't exist on the window, return. return 0; }
__int64 DPIValue = *(unsigned int *)(*(__int64 *)(pThis + 728) + 324);
// WINDOWS 7 HEIGHT CALCULATION!!! KEPT HERE FOR FUTURE REFERENCE //height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5;
bool isTool; int TBHeight; int width; if ( (*(BYTE *)(pThis + 592) & TYPE_TOOL) != 0 ) { isTool = TRUE; TBHeight = GetSystemMetricsForDpiHook((int)53, (UINT)DPIValue); } else { isTool = FALSE; TBHeight = GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue); }
if (isTool) { height = TBHeight; width = height; } else { height = floor((float)((float)TBHeight * (vistaMaximize ? 20 : 21) / divisor) + 0.5); if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) != 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if (buttonId==ID_CLOSE && (*(DWORD *)(pThis + 592) & 0xB00) == 0 ) { width = floor((float)((float)TBHeight * 49 / divisor) + 0.5); } else if ((buttonId != ID_MIN || *(long long *)(pThis + 488)) && buttonId) { // width = floor((float)((float)TBHeight * 27 / divisor) + 0.5); width = floor((float)((float)TBHeight * (vistaMaximize ? 28 : 27) / divisor) + 0.5); } else { width = floor((float)((float)TBHeight * 29 / divisor) + 0.5); } } CVisual *buttonData; buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); // this fetches the address where all the data for the specific button is stored
struct tagSIZE size; size.cx = width; size.cy = height;
CVisual_SetInsetFromParentTop_Original(*(CVisual**)(pThis + 8 * buttonId + 488), offsetTop);
if (buttonData[33] != *offsetRight) { buttonData[33] = *offsetRight; CVisual_SetDirtyFlags_Original(buttonData, 2); buttonData = *(CVisual**)(pThis + 8 * buttonId + 488); }
long retnvalue = CVisual_SetSize_Original(buttonData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC5Cu, 0); } else { *offsetRight += buttonData[30]; }
return retnvalue; }
long (*CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original)(void* pThis);
long CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook(void *pThis) {
bool isMaximized = *((BYTE *)pThis + 240) & STATE_MAXIMIZED; bool isTool = *((BYTE *)pThis + 592) & TYPE_TOOL;
if (*((long long *)pThis + 60)) { DWORD *clientData = (DWORD *)*((long long *)pThis + 68);
int insetLeft = *((DWORD *)pThis + 149); if (clientData[32] != insetLeft) { clientData[32] = insetLeft; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetTop = *((DWORD *)pThis + 151); if (clientData[34] != insetTop) { clientData[34] = insetTop; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetRight = *((DWORD *)pThis + 150); if (clientData[33] != insetRight) { clientData[33] = insetRight; CVisual_SetDirtyFlags_Original(clientData, 2); } int insetBottom = *((DWORD *)pThis + 152); if (clientData[35] != insetBottom) { clientData[35] = insetBottom; CVisual_SetDirtyFlags_Original(clientData, 2); } long *unknown = (long *)*((long long *)pThis + 37); if (unknown) { CVisual_SetInsetFromParent_Original(unknown, (const struct _MARGINS *)(*((long long *)pThis + 68) + 128)); } }
int insetRightNormal = *((DWORD *)pThis + 150); if (insetRightNormal <= 0) { // this+91 contains window data insetRightNormal = *(long long *)(*((long long *)pThis + 91) + 96); } long *borderSizeArray; if (isMaximized) { borderSizeArray = (long *)((char *)pThis + 644); } else { borderSizeArray = (long *)((char *)pThis + 628); }
int insetRight; if (insetRightNormal - 2 <= borderSizeArray[1] + 2) { insetRight = borderSizeArray[1] + 2; } else { insetRight = insetRightNormal - 2; } int insetLeft = *((DWORD *)pThis + 149);
__int64 DPIValue = *(unsigned int *)(*((long long *)pThis + 91) + 324);
int height; if (isTool) { height = GetSystemMetricsForDpiHook(53, DPIValue); } else { height = floor((float)(GetSystemMetricsForDpiHook((int)31, (UINT)DPIValue)) * 0.95238096) + 0.5; }
int insetTop = borderSizeArray[2]; if (isTool) { if (*((DWORD *)pThis + 151) - height - 4 > insetTop) { insetTop = *((DWORD *)pThis + 151) - height - 4; } insetRight++; } else if (isMaximized) { insetTop--; } else { insetTop++; }
CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 3, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 2, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 1, height, insetTop, &insetRight); CTopLevelWindow_UpdateNCAreaButton_Hook((long long)pThis, 0, height, insetTop, &insetRight);
bool hasIcon = (__int64 *)*((long long *)pThis + 66); if (hasIcon) { __int64 someData = *((long long *)pThis + 91); int width; int height; if (*(long long *)(someData + 136) || (*((long *)pThis + 148) & 0x10000) == 0) { width = GetSystemMetricsForDpiHook(49, *(unsigned int *)(someData + 324)); height = GetSystemMetricsForDpiHook(50, *(unsigned int *)(*((long long *)pThis + 91) + 324)); } else { width = 0; height = 0; } long long *iconData; iconData = (__int64 *)*((long long *)pThis + 66);
struct tagSIZE size; size.cx = width; size.cy = height; long retnvalue = CVisual_SetSize_Original(iconData, &size); if (retnvalue < 0) { MilInstrumentationCheckHR_MaybeFailFast_Original(0x14u, 0, 0, retnvalue, 0xC08u, 0); return (unsigned int)retnvalue; }
int insetTop = borderSizeArray[2] + (*((DWORD *)pThis + 151) - *(DWORD *)(*((long long *)pThis + 66) + 124) - borderSizeArray[2]) / 2;
CVisual_SetInsetFromParentTop_Original(iconData, insetTop); CVisual_SetInsetFromParentLeft_Original(iconData, insetLeft);
long iconWidth = *(long *)(*((long long *)pThis + 66) + 120);
if (iconWidth > 0) { insetLeft += iconWidth + 5; } } bool hasText = (DWORD *)*((long long *)pThis + 65); if (hasText) { DWORD *textData; textData = (DWORD *)*((long long *)pThis + 65); CVisual_SetInsetFromParentTop_Original(textData, borderSizeArray[2]); CVisual_SetInsetFromParentLeft_Original(textData, insetLeft); if ( textData[33] != insetRight ) { textData[33] = insetRight; CVisual_SetDirtyFlags_Original(textData, 2); } struct tagSIZE size; size.cx = textData[30]; size.cy = *((DWORD *)pThis + 151) - borderSizeArray[2]; CText_SetSize_Original(textData, &size); }
CTopLevelWindow_UpdatePinnedParts_Original(pThis);
return 0; }
void updateSettings(){ divisor = Wh_GetIntSetting(L"Divisor"); // Change this to 24 for Vista style if(divisor == 0) divisor = 21; vistaMaximize = Wh_GetIntSetting(L"VistaMaximize"); }
void Wh_ModSettingsChanged(){ updateSettings(); }
BOOL Wh_ModInit(void) { Wh_Log(L"We're back");
// This is for developers i am not a devleoper i just want to use the mod. Please stop not loading the mod. //bool already_running = !(*(USHORT*)((long long)NtCurrentTeb() + 0x17EE) & 0x0400); updateSettings(); // if (!already_running) { // return FALSE; // }
HMODULE hUser32 = GetModuleHandle(L"user32.dll");
void* GetSystemMetricsForDpiAddr = (void*)GetProcAddress(hUser32, "GetSystemMetricsForDpi"); Wh_SetFunctionHook(GetSystemMetricsForDpiAddr, (void*)GetSystemMetricsForDpiHook, (void**)&GetSystemMetricsForDpiOrig);
/* --------------------------- */
HMODULE uDWM = GetModuleHandle(L"uDWM.dll"); if (!uDWM) return FALSE;
WH_FIND_SYMBOL findSymbol; HANDLE findSymbolHandle = Wh_FindFirstSymbol(uDWM, nullptr, &findSymbol); if (!findSymbolHandle) { Wh_Log(L"Wh_FindFirstSymbol failed"); return FALSE; } void* UpdateCurrentGlyphOpacityAddr = nullptr; void* CVisualSetSizeAddr = nullptr; void* PositionsAndSizesAddr = nullptr; void* UpdateNCAreaButtonAddr = nullptr; void* UpdateColorizationColorAddr = nullptr; void* UpdateNCAreaBackgroundAddr = nullptr; void* CTextSetBackgroundColorAddr = nullptr; void* ValidateResourcesAddr = nullptr; void* UpdateMarginsDependentOnStyleAddr = nullptr; void* SetColorAddr = nullptr; void* DrawStateAddr = nullptr;
do { if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CButton::UpdateCurrentGlyphOpacity(bool)") == 0) { UpdateCurrentGlyphOpacityAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CVisual::SetSize(struct tagSIZE const *)") == 0) { CVisualSetSizeAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaPositionsAndSizes(void)") == 0) { PositionsAndSizesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaButton(enum CTopLevelWindow::ButtonType,int,int,int *)") == 0) { UpdateNCAreaButtonAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateColorizationColor(void)") == 0) { UpdateColorizationColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdateNCAreaBackground(void)") == 0) { UpdateNCAreaBackgroundAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetBackgroundColor(unsigned long)") == 0) { CTextSetBackgroundColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CText::ValidateResources(void)") == 0) { ValidateResourcesAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: bool __cdecl CTopLevelWindow::UpdateMarginsDependentOnStyle(void)") == 0) { UpdateMarginsDependentOnStyleAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CText::SetColor(unsigned long)") == 0) { SetColorAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CButton::DrawStateW(class CAtlasButton *,enum CButton::ButtonStates)") == 0) { DrawStateAddr = findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CTopLevelWindow::OnAccentPolicyUpdated(void)") == 0) { CTopLevelWindow_OnAccentPolicyUpdated_Original = (CTopLevelWindow_OnAccentPolicyUpdated_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"void __cdecl MilInstrumentationCheckHR_MaybeFailFast(unsigned long,long const * const,unsigned int,long,unsigned int,void *)") == 0) { MilInstrumentationCheckHR_MaybeFailFast_Original = (MilInstrumentationCheckHR_MaybeFailFast_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentTop(int)") == 0) { CVisual_SetInsetFromParentTop_Original = (CVisual_SetInsetFromParentTop_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParentLeft(int)") == 0) { CVisual_SetInsetFromParentLeft_Original = (CVisual_SetInsetFromParentLeft_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual void __cdecl CVisual::SetDirtyFlags(unsigned long)") == 0) { CVisual_SetDirtyFlags_Original = (CVisual_SetDirtyFlags_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: long __cdecl CTopLevelWindow::UpdatePinnedParts(void)") == 0) { CTopLevelWindow_UpdatePinnedParts_Original = (CTopLevelWindow_UpdatePinnedParts_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: void __cdecl CVisual::SetInsetFromParent(struct _MARGINS const &)") == 0) { CVisual_SetInsetFromParent_Original = (CVisual_SetInsetFromParent_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: virtual long __cdecl CText::SetSize(struct tagSIZE const *)") == 0) { CText_SetSize_Original = (CText_SetSize_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CSolidColorLegacyMilBrushProxy::Update(double,struct _D3DCOLORVALUE const &)") == 0) { CSolidColorLegacyMilBrushProxy_Update_Original = (CSolidColorLegacyMilBrushProxy_Update_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CSolidColorLegacyMilBrushProxy * *)") == 0) { CCompositor_CreateMilBrushProxy_Original = (CCompositor_CreateMilBrushProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"protected: long __cdecl CCompositor::CreateProxy(class CMatrixTransformProxy * *)") == 0) { CCompositor_CreateMatrixTransformProxy_Original = (CCompositor_CreateMatrixTransformProxy_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPushTransformInstruction::Create(class CBaseTransformProxy *,class CPushTransformInstruction * *)") == 0) { CPushTransformInstruction_Create_Original = (CPushTransformInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CRenderDataVisual::AddInstruction(class CRenderDataInstruction *)") == 0) { CRenderDataVisual_AddInstruction_Original = (CRenderDataVisual_AddInstruction_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CBitmapSource::Create(struct IWICBitmap *,struct _MARGINS const *,class CBitmapSource * *)") == 0) { CBitmapSource_Create_Original = (CBitmapSource_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CDrawImageInstruction::Create(class CBitmapSource *,struct tagRECT const *,class CDrawImageInstruction * *)") == 0) { CDrawImageInstruction_Create_Original = (CDrawImageInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: static long __cdecl CPopInstruction::Create(class CPopInstruction * *)") == 0) { CPopInstruction_Create_Original = (CPopInstruction_Create_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"public: long __cdecl CTopLevelWindow::GetAccentBlurBehindBrush(class CImageLegacyMilBrushProxy * *,class CCachedVisualImageProxy * *,struct MilPoint3F *)") == 0) { CTopLevelWindow_GetAccentBlurBehindBrush_Original = (CTopLevelWindow_GetAccentBlurBehindBrush_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: void __cdecl CText::ReleaseResources(void)") == 0) { CText_ReleaseResources_Original = (CText_ReleaseResources_t)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } else if (_wcsicmp(findSymbol.symbol, L"private: static class CDesktopManager * CDesktopManager::s_pDesktopManagerInstance") == 0) { DesktopManagerInstance = (long long*)findSymbol.address; Wh_Log(L"symbol: %s, Addr: %i", findSymbol.symbol, findSymbol.address); } /*else { Wh_Log(L"symbol: %s", findSymbol.symbol); }*/ } while (Wh_FindNextSymbol(findSymbolHandle, &findSymbol));
Wh_SetFunctionHook(UpdateCurrentGlyphOpacityAddr, (void*)CButton__UpdateCurrentGlyphOpacity_Hook, (void**)&CButton__UpdateCurrentGlyphOpacity_Original); Wh_SetFunctionHook(CVisualSetSizeAddr, (void*)CVisual_SetSize_Hook, (void**)&CVisual_SetSize_Original); Wh_SetFunctionHook(PositionsAndSizesAddr, (void*)CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Hook, (void**)&CTopLevelWindow_UpdateNCAreaPositionsAndSizes_Original); Wh_SetFunctionHook(UpdateNCAreaButtonAddr, (void*)CTopLevelWindow_UpdateNCAreaButton_Hook, (void**)&CTopLevelWindow_UpdateNCAreaButton_Original); Wh_SetFunctionHook(UpdateColorizationColorAddr, (void*)CTopLevelWindow_UpdateColorizationColor_Hook, (void**)&CTopLevelWindow_UpdateColorizationColor_Original); Wh_SetFunctionHook(UpdateNCAreaBackgroundAddr, (void*)CTopLevelWindow_UpdateNCAreaBackground_Hook, (void**)&CTopLevelWindow_UpdateNCAreaBackground_Original); Wh_SetFunctionHook(CTextSetBackgroundColorAddr, (void*)CText_SetBackgroundColor_Hook, (void**)&CText_SetBackgroundColor_Original); Wh_SetFunctionHook(ValidateResourcesAddr, (void*)CText_ValidateResources_Hook, (void**)&CText_ValidateResources_Original); Wh_SetFunctionHook(UpdateMarginsDependentOnStyleAddr, (void*)CTopLevelWindow_UpdateMarginsDependentOnStyle_Hook, (void**)&CTopLevelWindow_UpdateMarginsDependentOnStyle_Original); // DWMBlurGlass already handles this. // Wh_SetFunctionHook(SetColorAddr, (void*)CText_SetColor_Hook, (void**)&CText_SetColor_Original); Wh_SetFunctionHook(DrawStateAddr, (void*)CButton_DrawStateW_Hook, (void**)&CButton_DrawStateW_Original); Wh_Log(L"It's over"); return TRUE; } Mod does absolutely nothing even when dwm.exe is in process inclusion list and critcal system processes in exclusion list removed. EDIT: Restarting fixed it. Any help from that error?
|
|
Entinty1999
New Member
Posts: 11
OS: Windows 10 22H2
Theme: Host Windows 7, VMs have XP and Vista themes.
|
Post by Entinty1999 on Jun 18, 2024 8:53:58 GMT -8
Mod does absolutely nothing even when dwm.exe is in process inclusion list and critcal system processes in exclusion list removed. EDIT: Restarting fixed it. Any help from that error? View AttachmentI'd recommend restarting your computer, that seems to fix most issues with the caption size mods.
|
|
|
Post by Windows User on Jun 18, 2024 9:14:34 GMT -8
I'd recommend restarting your computer, that seems to fix most issues with the caption size mods. It's still not helping
|
|
arbestriagain
Sophomore Member
👅
Posts: 143
OS: Windows 11 Home 23H2
Theme: Default
CPU: Intel Core i7-10700F
RAM: 32GB
GPU: GeForce RTX 2060 SUPER
Computer Make/Model: HP OMEN 25L Desktop GT12-0xxx
|
Post by arbestriagain on Jun 18, 2024 9:58:58 GMT -8
Mod does absolutely nothing even when dwm.exe is in process inclusion list and critcal system processes in exclusion list removed. EDIT: Restarting fixed it. Any help from that error? View Attachmenteplace "compileroptions" with "compilerOptions" because Windhawk's comiler options thing is case-sensitive
|
|