/** * FileName: DWMStruct.cpp * * Copyright (C) 2024 Maplespe、ALTaleX531 * * This file is part of MToolBox and DWMBlurGlass. * DWMBlurGlass is free software: you can redistribute it and/or modify it under the terms of the * GNU Lesser General Public License as published by the Free Software Foundation, either version 3 * of the License, or any later version. * * DWMBlurGlass is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License along with Foobar. * If not, see . */ #include "DWMStruct.h" #pragma push_macro("DEFCALL_MHOST_METHOD") #define DEFCALL_MHOST_METHOD(name, ...) (this->*class_method_cast(#name))(__VA_ARGS__); namespace MDWMBlurGlassExt::DWM { using namespace MDWMBlurGlass; inline HANDLE g_hProcessHeap{ GetProcessHeap() }; HRESULT Core::CVisual::GetVisualTree(CVisualTree** visualTree, bool value) const { return DEFCALL_MHOST_METHOD(CVisual::GetVisualTree, visualTree, value); } const D2D1_RECT_F& Core::CVisual::GetBounds(CVisualTree* visualTree) const { return DEFCALL_MHOST_METHOD(CVisual::GetBounds, visualTree); } HWND Core::CVisual::GetHwnd() const { return DEFCALL_MHOST_METHOD(CVisual::GetHwnd); } HWND Core::CVisual::GetTopLevelWindow() const { return DEFCALL_MHOST_METHOD(CVisual::GetTopLevelWindow); } HRESULT Core::CZOrderedRect::UpdateDeviceRect(const MilMatrix3x2D* matrix) { return DEFCALL_MHOST_METHOD(CZOrderedRect::UpdateDeviceRect, matrix); } HRESULT Core::CArrayBasedCoverageSet::Add(const D2D1_RECT_F& lprc, int depth, const MilMatrix3x2D* matrix) { return DEFCALL_MHOST_METHOD(CArrayBasedCoverageSet::Add, lprc, depth, matrix); } Core::DynArray* Core::CArrayBasedCoverageSet::GetAntiOccluderArray() const { DynArray* array{ nullptr }; if (os::buildNumber < 19041) { array = reinterpret_cast*>(const_cast(this + 52)); } else { array = reinterpret_cast*>(const_cast(this + 49)); } return array; } Core::CVisual* Core::COcclusionContext::GetVisual() const { CVisual* visual{ nullptr }; if (os::buildNumber < 19041) { visual = reinterpret_cast(this)[6]; } else { visual = reinterpret_cast(this)[1]; } return visual; } HRESULT Core::COcclusionContext::PostSubgraph(CVisualTree* visualTree, bool* unknown) { return DEFCALL_MHOST_METHOD(COcclusionContext::PostSubgraph, visualTree, unknown); } HRESULT Core::CD2DContext::FillEffect(const ID2DContextOwner* contextOwner, ID2D1Effect* effect, const D2D_RECT_F* lprc, const D2D_POINT_2F* point, D2D1_INTERPOLATION_MODE interpolationMode, D2D1_COMPOSITE_MODE compositeMode) { return DEFCALL_MHOST_METHOD(CD2DContext::FillEffect, contextOwner, effect, lprc, point, interpolationMode, compositeMode); } Core::CD2DContext* Core::CDrawingContext::GetD2DContext() const { if (os::buildNumber < 19041) { return reinterpret_cast(this)[48]; } return reinterpret_cast(reinterpret_cast(this)[5] + 16); } Core::ID2DContextOwner* Core::CDrawingContext::GetD2DContextOwner() const { if (os::buildNumber < 19041) { return reinterpret_cast(this)[8]; } return reinterpret_cast(reinterpret_cast(this) + 24); } bool Core::CDrawingContext::IsOccluded(const D2D1_RECT_F& lprc, int flag) const { return DEFCALL_MHOST_METHOD(CDrawingContext::IsOccluded, lprc, flag); } Core::CVisual* Core::CDrawingContext::GetCurrentVisual() const { return DEFCALL_MHOST_METHOD(CDrawingContext::GetCurrentVisual); } HRESULT Core::CDrawingContext::GetClipBoundsWorld(D2D1_RECT_F& lprc) const { return DEFCALL_MHOST_METHOD(CDrawingContext::GetClipBoundsWorld, lprc); } void Core::CCustomBlur::Reset() { DEFCALL_MHOST_METHOD(CCustomBlur::Reset); } HRESULT Core::CCustomBlur::Create(ID2D1DeviceContext* deviceContext, CCustomBlur** customBlur) { static auto pfun = MHostGetProcAddress("CCustomBlur::Create"); return pfun(deviceContext, customBlur); } float Core::CCustomBlur::DetermineOutputScale(float size, float blurAmount, D2D1_GAUSSIANBLUR_OPTIMIZATION optimization) { static auto pfun = MHostGetProcAddress("CCustomBlur::DetermineOutputScale"); return pfun(size, blurAmount, optimization); } ULONGLONG Core::GetCurrentFrameId() { static auto pfun = MHostGetProcAddress("GetCurrentFrameId"); return pfun(); } void* CBaseObject::operator new(size_t size) { return HeapAlloc(g_hProcessHeap, 0, size); } void CBaseObject::operator delete(void* ptr) { if (ptr) HeapFree(g_hProcessHeap, 0, ptr); } size_t CBaseObject::AddRef() { return InterlockedIncrement(reinterpret_cast(this) + 2); } size_t CBaseObject::Release() { auto result{ InterlockedDecrement(reinterpret_cast(this) + 2) }; if (!result) { delete this; } return result; } HRESULT CBaseObject::QueryInterface(const IID& riid, PVOID* ppvObject) { *ppvObject = this; return S_OK; } HWND CWindowData::GetHWND() const { const HWND hWnd = *((HWND*)this + 5); return hWnd; } CTopLevelWindow* CWindowData::GetWindow() const { CTopLevelWindow* window{ nullptr }; if (os::buildNumber < os::w11_21h2) { window = reinterpret_cast(this)[48]; } else { window = reinterpret_cast(this)[55]; } return window; } bool CWindowData::IsUsingDarkMode() const { bool darkMode; if (os::buildNumber < os::w11_21h2) { darkMode = (reinterpret_cast(this)[613] & 8) != 0; } else if (os::buildNumber < os::w11_23h2) { darkMode = (reinterpret_cast(this)[669] & 4) != 0; } else if (os::buildNumber < os::w11_25h2 && os::ubrNumber < 7171) { darkMode = (reinterpret_cast(this)[677] & 4) != 0; // ok with build 26020 } else darkMode = (reinterpret_cast(this)[741] & 4) != 0; return darkMode; } DWORD CWindowData::GetNonClientAttribute() const { DWORD attribute{ 0 }; if (os::buildNumber < os::w11_21h2) { attribute = *reinterpret_cast(reinterpret_cast(this) + 608); } else if (os::buildNumber < os::w11_23h2) { attribute = *reinterpret_cast(reinterpret_cast(this) + 664); } else if (os::buildNumber < os::w11_25h2 && os::ubrNumber < 7171) { attribute = *reinterpret_cast(reinterpret_cast(this) + 672); // ok with build 26020 } else attribute = *reinterpret_cast(reinterpret_cast(this) + 736); return attribute; } bool CWindowData::IsImmersiveWindow() const { return DEFCALL_MHOST_METHOD(CWindowData::IsImmersiveWindow); } bool CWindowData::IsWindowVisibleAndUncloaked() const { return DEFCALL_MHOST_METHOD(CWindowData::IsWindowVisibleAndUncloaked); } ACCENT_POLICY* CWindowData::GetAccentPolicy() { ACCENT_POLICY* accentpolicy; if (os::buildNumber >= os::w11_21h2) accentpolicy = (ACCENT_POLICY*)((ULONG64)this + 168); else accentpolicy = (ACCENT_POLICY*)((ULONG64)this + 152); return accentpolicy; } const MARGINS* CWindowData::GetExtendedFrameMargins() const { const MARGINS* margins{ nullptr }; if (os::buildNumber < os::w11_21h2) { margins = reinterpret_cast(reinterpret_cast(this) + 80); } else { margins = reinterpret_cast(reinterpret_cast(this) + 96); } return margins; } bool CWindowData::IsFrameExtendedIntoClientAreaLRB() const { const MARGINS* margins{ GetExtendedFrameMargins() }; return margins->cxLeftWidth || margins->cxRightWidth || margins->cyBottomHeight; } HRESULT CMatrixTransformProxy::Update(const MilMatrix3x2D* matrix) { return DEFCALL_MHOST_METHOD(CMatrixTransformProxy::Update, matrix); } HRESULT CVisualProxy::SetClip(CBaseGeometryProxy* geometry) { return DEFCALL_MHOST_METHOD(CVisualProxy::SetClip, geometry); } HRESULT CVisualProxy::SetSize(double width, double height) { return DEFCALL_MHOST_METHOD(CVisualProxy::SetSize, width, height); } HRESULT CContainerVisual::Create(CVisual** pVisual) { static auto pfun = MHostGetProcAddress("CContainerVisual::Create"); return pfun(pVisual); } HRESULT CVisual::Create(CVisual** pVisual) { static auto pfun = MHostGetProcAddress("CVisual::Create"); return pfun(pVisual); } VisualCollection* CVisual::GetVisualCollection() const { if (os::buildNumber < 26020) { return const_cast(reinterpret_cast(reinterpret_cast(this) + 32)); } return const_cast(reinterpret_cast(reinterpret_cast(this) + 144)); } CVisualProxy* CVisual::GetVisualProxy() const { return reinterpret_cast(reinterpret_cast(this)[2]); } bool CVisual::IsCloneAllowed() const { const BYTE* properties{ nullptr }; if (os::buildNumber < 22000) { properties = &reinterpret_cast(this)[84]; } else if (os::buildNumber < 26020) { properties = &reinterpret_cast(this)[92]; } else { properties = &reinterpret_cast(this)[36]; } bool allowed{ false }; if (properties) { allowed = (*properties & 8) == 0; } return allowed; } bool CVisual::AllowVisualTreeClone(bool allow) { BYTE* properties; if (os::buildNumber < os::w11_21h2) { properties = &reinterpret_cast(this)[84]; } else if (os::buildNumber < os::w11_24h2) { properties = &reinterpret_cast(this)[92]; } else { properties = &reinterpret_cast(this)[36]; // ok with build 26200 } bool allowed{ false }; if (properties) { allowed = (*properties & 8) == 0; if (allow) { *properties = *properties & ~8; } else { *properties |= 8; } } return allowed; } void CVisual::SetInsetFromParent(MARGINS* margins) { DEFCALL_MHOST_METHOD(CVisual::SetInsetFromParent, margins); } void CVisual::SetInsetFromParentRight(int right) { DEFCALL_MHOST_METHOD(CVisual::SetInsetFromParentRight, right); } void CVisual::SetInsetFromParentLeft(int left) { DEFCALL_MHOST_METHOD(CVisual::SetInsetFromParentLeft, left); } HRESULT CVisual::SetSize(const SIZE& size) { return DEFCALL_MHOST_METHOD(CVisual::SetSize, size); } void CVisual::SetOffset(const POINT& pt) { DEFCALL_MHOST_METHOD(CVisual::SetOffset, pt); } HRESULT CVisual::InitializeVisualTreeClone(CBaseObject* baseObject, UINT cloneOptions) { return DEFCALL_MHOST_METHOD(CVisual::InitializeVisualTreeClone, baseObject, cloneOptions); } void CVisual::Unhide() { DEFCALL_MHOST_METHOD(CVisual::Unhide); } void CVisual::Hide() { DEFCALL_MHOST_METHOD(CVisual::Hide); } void CVisual::ConnectToParent(bool connect) { DEFCALL_MHOST_METHOD(CVisual::ConnectToParent, connect); } void CVisual::SetOpacity(double opacity) { DEFCALL_MHOST_METHOD(CVisual::SetOpacity, opacity); } HRESULT STDMETHODCALLTYPE CVisual::UpdateOpacity() { return DEFCALL_MHOST_METHOD(CVisual::UpdateOpacity, ); } void CVisual::SetScale(double x, double y) { DEFCALL_MHOST_METHOD(CVisual::SetScale, x, y); } HRESULT CVisual::SendSetOpacity(double opacity) { return DEFCALL_MHOST_METHOD(CVisual::SendSetOpacity, opacity); } HRESULT CVisual::RenderRecursive() { return DEFCALL_MHOST_METHOD(CVisual::RenderRecursive); } void CVisual::SetDirtyChildren() { if (os::buildNumber < os::w11_24h2) { return DEFCALL_MHOST_METHOD(CVisual::SetDirtyChildren); } return (this->*class_method_cast("CContainerVisual"))(); } HRESULT CVisual::WrapExistingResource(UINT handleIndex, CVisual** visual) { static auto pfun = (HRESULT(*)(UINT, CVisual**))MHostGetProcAddress("CVisual::WrapExistingResource"); return pfun(handleIndex, visual); } HRESULT CVisual::WrapExistingResource(Core::CChannel* channel, UINT handleIndex, CVisual** visual) { static auto pfun = (HRESULT(*)(Core::CChannel*, UINT, CVisual**))MHostGetProcAddress("CVisual::WrapExistingResource"); return pfun(channel, handleIndex, visual); } HRESULT CVisual::CreateFromSharedHandle(HANDLE handle, CVisual** visual) { static auto pfun = MHostGetProcAddress("CVisual::CreateFromSharedHandle"); return pfun(handle, visual); } HRESULT CVisual::InitializeFromSharedHandle(HANDLE handle) { return DEFCALL_MHOST_METHOD(CVisual::InitializeFromSharedHandle, handle); } HRESULT CVisual::MoveToFront(bool unknown) { return DEFCALL_MHOST_METHOD(CVisual::MoveToFront, unknown); } HRESULT CVisual::Initialize() { return DEFCALL_MHOST_METHOD(CVisual::Initialize); } LONG CVisual::GetWidth() const { LONG width{ 0 }; if (os::buildNumber < os::w11_21h2) { width = reinterpret_cast(this)[30]; } else { width = reinterpret_cast(this)[32]; } return width; } LONG CVisual::GetHeight() const { LONG height{ 0 }; if (os::buildNumber < os::w11_21h2) { height = reinterpret_cast(this)[31]; } else { height = reinterpret_cast(this)[33]; } return height; } MARGINS* CVisual::GetMargins() { MARGINS* margins{ nullptr }; if (os::buildNumber < os::w11_21h2) { margins = reinterpret_cast(this) + 8; } else { margins = reinterpret_cast(reinterpret_cast(this) + 136); } return margins; } HRESULT VisualCollection::RemoveAll() { return DEFCALL_MHOST_METHOD(VisualCollection::RemoveAll); } HRESULT VisualCollection::Remove(CVisual* visual) { return DEFCALL_MHOST_METHOD(VisualCollection::Remove, visual); } HRESULT VisualCollection::InsertRelative(CVisual* visual, CVisual* reference, bool insterAfter, bool updateNow) { return DEFCALL_MHOST_METHOD(VisualCollection::InsertRelative, visual, reference, insterAfter, updateNow); } CWindowData* CTopLevelWindow::GetData() { PVOID windowData; if (os::buildNumber >= os::w11_21h2) { if (os::buildNumber < 26020) windowData = *((PVOID*)this + 94); else windowData = *((PVOID*)this + 89); } else { if (os::buildNumber > 18363) windowData = *((PVOID*)this + 91); else windowData = *((PVOID*)this + 90); } return static_cast(windowData); } VisualCollection* CTopLevelWindow::GetNCAreaVisualCollection() { const auto collection = (VisualCollection*)(*((ULONG64*)this + 33) + 32); return collection; } CCanvasVisual* CTopLevelWindow::GetVisual() const { CCanvasVisual* visual{ nullptr }; if (os::buildNumber < 19041) { visual = reinterpret_cast(this)[32]; } else if (os::buildNumber < os::w11_21h2) { visual = reinterpret_cast(this)[33]; } else if (os::buildNumber < os::w11_23h2) { visual = reinterpret_cast(this)[34]; } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[36]; } else { visual = reinterpret_cast(this)[31]; // ok with build 26200 } return visual; } CAccent* CTopLevelWindow::GetAccent() const { CAccent* accent{ nullptr }; if (os::buildNumber < os::w11_21h2) { accent = reinterpret_cast(this)[34]; } else if (os::buildNumber < os::w11_23h2) { accent = reinterpret_cast(this)[35]; } else if (os::buildNumber < os::w11_24h2) { accent = reinterpret_cast(this)[37]; } else { accent = reinterpret_cast(this)[32]; } return accent; } CCanvasVisual* CTopLevelWindow::GetLegacyVisual() const { CCanvasVisual* visual{ nullptr }; if (os::buildNumber < 19041) { visual = reinterpret_cast(this)[35]; } else if (os::buildNumber < os::w11_21h2) { visual = reinterpret_cast(this)[36]; } else if (os::buildNumber < os::w11_23h2) { visual = reinterpret_cast(this)[37]; } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[39]; } else { visual = reinterpret_cast(this)[34]; } return visual; } CVisual* CTopLevelWindow::GetClientBlurVisual() const { CVisual* visual{ nullptr }; if (os::buildNumber < os::w11_21h2) { visual = reinterpret_cast(this)[37]; } else if (os::buildNumber < os::w11_23h2) { visual = reinterpret_cast(this)[39]; } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[42]; } else { visual = reinterpret_cast(this)[37]; } return visual; } CVisual* CTopLevelWindow::GetSystemBackdropVisual() const { CVisual* visual{ nullptr }; if (os::buildNumber < os::w11_21h2) { } else if (os::buildNumber < os::w11_23h2) { visual = reinterpret_cast(this)[38]; } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[40]; } else { visual = reinterpret_cast(this)[35]; } return visual; } CCanvasVisual* CTopLevelWindow::GetAccentColorVisual() const { CCanvasVisual* visual{ nullptr }; if (os::buildNumber < os::w11_21h2) { } else if (os::buildNumber < os::w11_23h2) { } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[41]; } else { visual = reinterpret_cast(this)[36]; } return visual; } CVisual* CTopLevelWindow::GetClientAreaContainerParentVisual() const { CVisual* visual{ nullptr }; if (os::buildNumber < 19041) { visual = reinterpret_cast(this)[67]; } else if (os::buildNumber < os::w11_21h2) { visual = reinterpret_cast(this)[68]; } else if (os::buildNumber < os::w11_23h2) { visual = reinterpret_cast(this)[70]; } else if (os::buildNumber < os::w11_24h2) { visual = reinterpret_cast(this)[74]; } else { visual = reinterpret_cast(this)[69]; } return visual; } std::vector> CTopLevelWindow::GetNCBackgroundVisuals() const { std::vector> visuals{}; if (GetLegacyVisual()) { visuals.emplace_back(nullptr).copy_from(GetLegacyVisual()); } if (GetAccent()) { visuals.emplace_back(nullptr).copy_from(GetAccent()); } if (GetClientBlurVisual()) { visuals.emplace_back(nullptr).copy_from(GetClientBlurVisual()); } if (GetSystemBackdropVisual()) { visuals.emplace_back(nullptr).copy_from(GetSystemBackdropVisual()); } if (GetAccentColorVisual()) { visuals.emplace_back(nullptr).copy_from(GetAccentColorVisual()); } return visuals; } CSolidColorLegacyMilBrushProxy* const* CTopLevelWindow::GetBorderMilBrush() const { CSolidColorLegacyMilBrushProxy* const* brush{ nullptr }; if (os::buildNumber < 19041) { // TO-DO } else if (os::buildNumber < os::w11_21h2) { brush = &reinterpret_cast(this)[94]; } else if (os::buildNumber < os::w11_23h2) { brush = &reinterpret_cast(this)[98]; } else if (os::buildNumber < 26020) { auto legacyBackgroundVisual{ reinterpret_cast(this)[39] }; if (legacyBackgroundVisual) { brush = &reinterpret_cast(legacyBackgroundVisual)[38]; } } else { auto legacyBackgroundVisual{ reinterpret_cast(this)[34] }; if (legacyBackgroundVisual) { brush = &reinterpret_cast(legacyBackgroundVisual)[32]; } } return brush; } CRgnGeometryProxy* const& CTopLevelWindow::GetBorderGeometry() const { CRgnGeometryProxy* geometry{ nullptr }; if (os::buildNumber < 19041) { geometry = reinterpret_cast(this)[68]; } else if (os::buildNumber < os::w11_21h2) { geometry = reinterpret_cast(this)[69]; } else if (os::buildNumber < os::w11_23h2) { geometry = reinterpret_cast(this)[71]; } else if (os::buildNumber < os::w11_24h2) { auto legacyBackgroundVisual{ reinterpret_cast(this)[39] }; if (legacyBackgroundVisual) { geometry = reinterpret_cast(legacyBackgroundVisual)[40]; } } else { auto legacyBackgroundVisual{ reinterpret_cast(this)[34] }; if (legacyBackgroundVisual) { geometry = reinterpret_cast(legacyBackgroundVisual)[34]; } } return geometry; } CRgnGeometryProxy* const& CTopLevelWindow::GetTitlebarGeometry() const { CRgnGeometryProxy* const* geometry{ nullptr }; if (os::buildNumber < 19041) { geometry = &reinterpret_cast(this)[69]; } else if (os::buildNumber < os::w11_21h2) { geometry = &reinterpret_cast(this)[70]; } else if (os::buildNumber < os::w11_23h2) { geometry = &reinterpret_cast(this)[72]; } else if (os::buildNumber < 26020) { auto legacyBackgroundVisual{ reinterpret_cast(this)[39] }; if (legacyBackgroundVisual) { geometry = &reinterpret_cast(legacyBackgroundVisual)[39]; } } else { auto legacyBackgroundVisual{ reinterpret_cast(this)[34] }; if (legacyBackgroundVisual) { geometry = &reinterpret_cast(legacyBackgroundVisual)[33]; } } return *geometry; } bool CTopLevelWindow::HasNonClientBackground(CWindowData* data) { auto windowData{ GetData() }; if (data) windowData = data; if ((windowData->GetNonClientAttribute() & 8) == 0) { return false; } /*if (windowData->IsImmersiveWindow()) { return false; }*/ bool nonClientEmpty{ false }; if (os::buildNumber < os::w11_21h2) { nonClientEmpty = !reinterpret_cast(this)[153] && !reinterpret_cast(this)[154] && !reinterpret_cast(this)[155] && !reinterpret_cast(this)[156]; } else if (os::buildNumber < os::w11_23h2) { nonClientEmpty = !reinterpret_cast(this)[157] && !reinterpret_cast(this)[158] && !reinterpret_cast(this)[159] && !reinterpret_cast(this)[160]; } else if (os::buildNumber < os::w11_24h2) { nonClientEmpty = !reinterpret_cast(this)[161] && !reinterpret_cast(this)[162] && !reinterpret_cast(this)[163] && !reinterpret_cast(this)[164]; } else // ok with build 26200、26100 { nonClientEmpty = !reinterpret_cast(this)[151] && !reinterpret_cast(this)[152] && !reinterpret_cast(this)[153] && !reinterpret_cast(this)[154]; } if (nonClientEmpty) { return false; } return true; } bool CTopLevelWindow::IsSystemBackdropApplied() { bool systemBackdropApplied{ false }; if (os::buildNumber < os::w11_21h2) { systemBackdropApplied = false; } else if (os::buildNumber < os::w11_23h2) { systemBackdropApplied = *reinterpret_cast(reinterpret_cast(GetData()) + 204); } else if (os::buildNumber < os::w11_24h2) { systemBackdropApplied = (reinterpret_cast(this)[210] <= 3); } else { systemBackdropApplied = (reinterpret_cast(this)[200] <= 3); } return systemBackdropApplied; } HRESULT CTopLevelWindow::UpdateNCAreaButton(int index, int height, int top, DWORD* right) { return DEFCALL_MHOST_METHOD(CTopLevelWindow::UpdateNCAreaButton, index, height, top, right); } CText* CTopLevelWindow::GetCText() { CText* text{nullptr}; if (os::buildNumber < os::w11_21h2) { text = *((CText**)this + 65); } else { text = *((CText**)this + 67); } return text; } void CTopLevelWindow::CDWriteTextSetColor(COLORREF color) { if(os::buildNumber < os::w11_24h2) { auto text = (CDWriteText*)*((ULONG64*)this + 71);//CDWriteText This typedef void(__fastcall**** CDWriteText_SetColor)(CDWriteText*, UINT);//(***((void(__fastcall****)(ULONG64, __int64))This + 71))(*((ULONG64*)This + 71), inputVec); auto pfunCDWriteText_SetColor = ***((CDWriteText_SetColor)this + 71);//CDWriteText::SetColor(CDWriteText *this, int a2) pfunCDWriteText_SetColor(text, color); } else { auto text = (CDWriteText*)*((ULONG64*)this + 66); typedef void(__fastcall**** CDWriteText_SetColor)(CDWriteText*, UINT); auto pfunCDWriteText_SetColor = ***((CDWriteText_SetColor)this + 66); pfunCDWriteText_SetColor(text, color); } } bool CTopLevelWindow::TreatAsActiveWindow() { return DEFCALL_MHOST_METHOD(CTopLevelWindow::TreatAsActiveWindow); } RECT* CTopLevelWindow::GetActualWindowRect(RECT* rect, char eraseOffset, char includeNonClient, bool excludeBorderMargins) { return DEFCALL_MHOST_METHOD(CTopLevelWindow::GetActualWindowRect, rect, eraseOffset, includeNonClient, excludeBorderMargins); } void CTopLevelWindow::GetBorderMargins(MARGINS* margins) const { DEFCALL_MHOST_METHOD(CTopLevelWindow::GetBorderMargins, margins); } bool CTopLevelWindow::IsTrullyMinimized() { RECT borderRect{}; if (!GetActualWindowRect(&borderRect, false, true, false)) return true; return borderRect.left <= -32000 || borderRect.top <= -32000; } void CTopLevelWindow::SetDirtyFlags(int flags) { DEFCALL_MHOST_METHOD(CTopLevelWindow::SetDirtyFlags, flags); } HRESULT CTopLevelWindow::OnSystemBackdropUpdated() { return DEFCALL_MHOST_METHOD(CTopLevelWindow::OnSystemBackdropUpdated); } HRESULT CTopLevelWindow::OnClipUpdated() { return DEFCALL_MHOST_METHOD(CTopLevelWindow::OnClipUpdated); } HRESULT CTopLevelWindow::OnBlurBehindUpdated() { return DEFCALL_MHOST_METHOD(CTopLevelWindow::OnBlurBehindUpdated); } HRESULT CTopLevelWindow::OnAccentPolicyUpdated() { return DEFCALL_MHOST_METHOD(CTopLevelWindow::OnAccentPolicyUpdated); } bool CTopLevelWindow::IsRTLMirrored() const { bool rtlMirrored{ false }; if (os::buildNumber < 19041) { rtlMirrored = (reinterpret_cast(this)[146] & 0x20000) != 0; } else if (os::buildNumber < os::w11_21h2) { rtlMirrored = (reinterpret_cast(this)[148] & 0x20000) != 0; } else if (os::buildNumber < os::w11_23h2) { rtlMirrored = (reinterpret_cast(this)[152] & 0x20000) != 0; } else if (os::buildNumber < os::w11_24h2) { rtlMirrored = (reinterpret_cast(this)[156] & 0x20000) != 0; } else { rtlMirrored = (reinterpret_cast(this)[146] & 0x20000) != 0; } return rtlMirrored; } DWORD CTopLevelWindow::GetSolidColorCaptionColor() const { return DEFCALL_MHOST_METHOD(CTopLevelWindow::GetSolidColorCaptionColor); } DWORD CTopLevelWindow::GetWindowColorizationColor(BYTE flags) const { return DEFCALL_MHOST_METHOD(CTopLevelWindow::GetWindowColorizationColor, flags); } DWORD* CTopLevelWindow::GetCurrentDefaultColorizationFlags(DWORD* flags) const { return DEFCALL_MHOST_METHOD(CTopLevelWindow::GetCurrentDefaultColorizationFlags, flags); } DWORD CTopLevelWindow::GetCurrentColorizationColor() const { DWORD color{}; if (os::buildNumber < os::w11_23h2) { DWORD flags{}; color = GetWindowColorizationColor(static_cast(*GetCurrentDefaultColorizationFlags(&flags) | 8u)); } else { color = GetSolidColorCaptionColor(); } return color; } CTopLevelWindow::WindowFrame* CTopLevelWindow::s_ChooseWindowFrameFromStyle(char a1, bool a2, bool a3) { static auto pfun = MHostGetProcAddress("CTopLevelWindow::s_ChooseWindowFrameFromStyle"); return pfun(a1, a2, a3); } ID2D1Effect* CCustomBlur::CropEffect() { ID2D1Effect* cropEffect = *((ID2D1Effect**)this + 3); return cropEffect; } ID2D1Effect* CCustomBlur::ScaleEffect() { ID2D1Effect* scaleEffect = *((ID2D1Effect**)this + 5); return scaleEffect; } ID2D1Effect* CCustomBlur::DirBlurKernelXEffect() { ID2D1Effect* dirBlurKernelXEffect = *((ID2D1Effect**)this + 6); return dirBlurKernelXEffect; } ID2D1Effect* CCustomBlur::DirBlurKernelYEffect() { ID2D1Effect* dirBlurKernelYEffect = *((ID2D1Effect**)this + 7); return dirBlurKernelYEffect; } bool CAccent::s_IsPolicyActive(const ACCENT_POLICY* accentPolicy) { static auto pfun = MHostGetProcAddress("CAccent::s_IsPolicyActive"); return pfun(accentPolicy); } CBaseGeometryProxy* const& CAccent::GetClipGeometry() const { CBaseGeometryProxy* const* geometry{ nullptr }; if (os::buildNumber < os::w11_21h2) { geometry = &reinterpret_cast(this)[52]; } else if (os::buildNumber < os::w11_23h2) { geometry = &reinterpret_cast(this)[53]; } else if (os::buildNumber < os::w11_24h2) { geometry = &reinterpret_cast(this)[48]; } else { geometry = &reinterpret_cast(this)[42]; } return *geometry; } HRESULT STDMETHODCALLTYPE CDrawGeometryInstruction::Create(CBaseLegacyMilBrushProxy* brush, CBaseGeometryProxy* geometry, CDrawGeometryInstruction** instruction) { static auto pfun = MHostGetProcAddress("CDrawGeometryInstruction::Create"); return pfun(brush, geometry, instruction); } HRESULT STDMETHODCALLTYPE CRenderDataVisual::AddInstruction(CRenderDataInstruction* instruction) { return DEFCALL_MHOST_METHOD(CRenderDataVisual::AddInstruction, instruction); } HRESULT STDMETHODCALLTYPE CRenderDataVisual::ClearInstructions() { return DEFCALL_MHOST_METHOD(CRenderDataVisual::ClearInstructions, ); } HRESULT STDMETHODCALLTYPE CCanvasVisual::Create(CCanvasVisual** visual) { static auto pfun = MHostGetProcAddress("CCanvasVisual::Create"); return pfun(visual); } POINT* CButton::GetPoint() { POINT* pt; if (os::buildNumber < os::w11_21h2) pt = (POINT*)this + 14; else if(os::buildNumber < os::w11_24h2) pt = (POINT*)this + 15; else pt = (POINT*)this + 8; return pt; } SIZE* CButton::GetSize() { SIZE* size; if (os::buildNumber < os::w11_21h2) size = (SIZE*)this + 15; else if (os::buildNumber < os::w11_24h2) size = (SIZE*)this + 16; else size = (SIZE*)this + 9; return size; } HRESULT CCompositor::CreateVisualProxyFromSharedHandle(HANDLE handle, CVisualProxy** visualProxy) { return (this->*class_method_cast("CCompositor::CreateProxyFromSharedHandle"))(handle, visualProxy); } Core::CChannel* CCompositor::GetChannel() const { Core::CChannel* channel{ nullptr }; if (os::buildNumber < 18362) { channel = reinterpret_cast(const_cast(this)); } else if (os::buildNumber < 19041) { channel = reinterpret_cast(this)[2]; } return channel; } CWindowList* CDesktopManager::GetWindowList() const { CWindowList* windowList{ nullptr }; if (os::buildNumber < os::w11_21h2) { windowList = reinterpret_cast(this)[61]; } else if (os::buildNumber < os::w11_23h2) { windowList = reinterpret_cast(this)[52]; } else if (os::buildNumber < os::w11_24h2) { windowList = reinterpret_cast(this)[54]; } else { windowList = reinterpret_cast(this)[53]; } return windowList; } IWICImagingFactory2* CDesktopManager::GetWICFactory() const { IWICImagingFactory2* factory = nullptr; if (os::buildNumber < 19041) { // TO-DO } else if (os::buildNumber < os::w11_21h2) { factory = static_cast(reinterpret_cast(this)[39]); } else if (os::buildNumber < os::w11_23h2) { factory = static_cast(reinterpret_cast(this)[30]); } else if (os::buildNumber < os::w11_24h2) { factory = static_cast(reinterpret_cast(this)[31]); } else { factory = static_cast(reinterpret_cast(this)[30]); } return factory; } ID2D1Device* CDesktopManager::GetD2DDevice() const { ID2D1Device* d2dDevice = nullptr; if (os::buildNumber < 19041) { // TO-DO } else if (os::buildNumber < os::w11_21h2) { d2dDevice = reinterpret_cast(this)[29]; } else if (os::buildNumber < os::w11_23h2) { d2dDevice = static_cast(reinterpret_cast(this)[6])[3]; } else if (os::buildNumber < os::w11_24h2) { d2dDevice = static_cast(reinterpret_cast(this)[7])[3]; } else { d2dDevice = static_cast(reinterpret_cast(this)[7])[4]; } return d2dDevice; } DCompPrivate::IDCompositionDesktopDevicePartner* CDesktopManager::GetDCompositionInteropDevice() const { DCompPrivate::IDCompositionDesktopDevicePartner* interopDevice = nullptr; if (os::buildNumber < os::w11_21h2) { interopDevice = reinterpret_cast(this)[27]; BOOL valid{ FALSE }; com_ptr desktopDevice{ nullptr }; check_hresult(interopDevice->QueryInterface(desktopDevice.put())); check_hresult(desktopDevice->CheckDeviceState(&valid)); if (!valid) { class_method_cast("CDesktopManager::HandleInteropDeviceLost")(); } } else if (os::buildNumber < os::w11_23h2) { interopDevice = static_cast(reinterpret_cast(this)[5])[4]; } else { interopDevice = static_cast(reinterpret_cast(this)[6])[4]; // ok with build 26020 } return interopDevice; } CCompositor* CDesktopManager::GetCompositor() const { CCompositor* compositor{ nullptr }; if (os::buildNumber < os::w11_21h2) { compositor = reinterpret_cast(this)[5]; } else { compositor = reinterpret_cast(this)[6]; } return compositor; } UINT CDesktopManager::MonitorDpiFromPoint(POINT pt) const { return DEFCALL_MHOST_METHOD(CDesktopManager::MonitorDpiFromPoint, pt); } HWND CWindowNode::GetHwnd() const { return DEFCALL_MHOST_METHOD(CWindowNode::GetHwnd); } HRESULT ResourceHelper::CreateGeometryFromHRGN(HRGN hrgn, CRgnGeometryProxy** geometry) { static auto pfun = MHostGetProcAddress("ResourceHelper::CreateGeometryFromHRGN"); return pfun(hrgn, geometry); } void CText::SetColor(COLORREF color) { DEFCALL_MHOST_METHOD(CText::SetColor, color); } HRESULT CText::SetText(LPCWSTR text) { return DEFCALL_MHOST_METHOD(CText::SetText, text); } HRESULT CText::SetSize(SIZE* size) { return DEFCALL_MHOST_METHOD(CText::SetSize, size); } LPCWSTR CText::GetText() { LPCWSTR text{nullptr}; if (os::buildNumber < os::w11_21h2) { text = (wchar_t*)*((DWORD64*)this + 36); } else { text = (wchar_t*)*((DWORD64*)this + 37); } return text; } bool CText::IsRTL() const { return (reinterpret_cast(this)[280] & 2) != 0; } CMatrixTransformProxy* CText::GetMatrixProxy() { if(os::buildNumber >= os::w11_21h2) return (CMatrixTransformProxy*)*((DWORD64*)this + 50); return (CMatrixTransformProxy*)*((DWORD64*)this + 49); } HRESULT CWindowList::GetExtendedFrameBounds(HWND hWnd, RECT* rect) { return DEFCALL_MHOST_METHOD(CWindowList::GetExtendedFrameBounds, hWnd, rect); } HRESULT CWindowList::GetSyncedWindowData(IDwmWindow* dwmWindow, bool shared, CWindowData** pWindowData) { return DEFCALL_MHOST_METHOD(CWindowList::GetSyncedWindowData, dwmWindow, shared, pWindowData); } HRESULT STDMETHODCALLTYPE CWindowList::GetSyncedWindowDataByHwnd(HWND hwnd, CWindowData** windowData) { auto hr = DEFCALL_MHOST_METHOD(CWindowList::GetSyncedWindowDataByHwnd, hwnd, windowData); if (os::buildNumber >= 26020) return S_OK; return hr; } PRLIST_ENTRY CWindowList::GetWindowListForDesktop(ULONG_PTR desktopID) { return DEFCALL_MHOST_METHOD(CWindowList::GetWindowListForDesktop, desktopID); } HWND CWindowList::GetShellWindowForDesktop(ULONG_PTR desktopID) { return DEFCALL_MHOST_METHOD(CWindowList::GetShellWindowForDesktop, desktopID); } namespace Core { UINT CResource::GetOwningProcessId() { return DEFCALL_MHOST_METHOD(CResource::GetOwningProcessId); } HRESULT CChannel::DuplicateSharedResource(HANDLE handle, UINT type, UINT* handleIndex) { return DEFCALL_MHOST_METHOD(CChannel::DuplicateSharedResource, handle, type, handleIndex); } HRESULT CChannel::MatrixTransformUpdate(UINT handleIndex, MilMatrix3x2D* matrix) { return DEFCALL_MHOST_METHOD(CChannel::MatrixTransformUpdate, handleIndex, matrix); } } } #pragma pop_macro("DEFCALL_MHOST_METHOD")