mirror of
https://github.com/WinDurango-project/WinDurango.git
synced 2025-02-17 01:09:01 +00:00
Fixed ICoreWindowX, CoreWindow, and the GetForCurrentThread() method.
This commit is contained in:
parent
75201d2c5b
commit
97dabb888e
@ -1,6 +1,7 @@
|
||||
// ReSharper disable CppInconsistentNaming
|
||||
// ReSharper disable CppClassCanBeFinal
|
||||
// ReSharper disable CppPolymorphicClassWithNonVirtualPublicDestructor
|
||||
// ReSharper disable CppClangTidyClangDiagnosticNonVirtualDtor
|
||||
#pragma once
|
||||
#include <wrl/client.h>
|
||||
|
||||
@ -8,6 +9,12 @@
|
||||
|
||||
class CoreWindowX : public ICoreWindowX
|
||||
{
|
||||
public:
|
||||
CoreWindowX(CoreWindow* window)
|
||||
{
|
||||
m_coreWindow = reinterpret_cast<ICoreWindow*>(window);
|
||||
}
|
||||
|
||||
public:
|
||||
HRESULT GetIids(ULONG* iidCount, IID** iids) override;
|
||||
HRESULT GetRuntimeClassName(HSTRING* className) override;
|
||||
@ -59,5 +66,5 @@ public:
|
||||
ULONG Release() override;
|
||||
|
||||
private:
|
||||
Microsoft::WRL::ComPtr<ICoreWindow> m_coreWindow;
|
||||
ICoreWindow* m_coreWindow;
|
||||
};
|
@ -16,39 +16,39 @@ using namespace ABI::Windows::System;
|
||||
class ICoreWindowX : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual INT32 _abi_get_Bounds(Rect* rect);
|
||||
virtual INT32 _abi_get_Dispatcher(ICoreDispatcher** dispatcher);
|
||||
virtual INT32 _abi_get_IsInputEnabled(boolean* value);
|
||||
virtual INT32 _abi_set_IsInputEnabled(boolean value);
|
||||
virtual INT32 _abi_get_Visible(boolean* value);
|
||||
virtual INT32 _abi_Activate();
|
||||
virtual INT32 _abi_Close();
|
||||
virtual INT32 _abi_get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value);
|
||||
virtual INT32 _abi_get_KeyState(VirtualKey key, CoreVirtualKeyStates* value);
|
||||
virtual INT32 _abi_add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_Activated(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_CharacterRecieved(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_CharacterRecieved(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_Closed(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_InputEnabled(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_KeyDown(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_KeyUp(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_PointerMoved(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_PointerEntered(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_PointerExited(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_SizeChanged(EventRegistrationToken token);
|
||||
virtual INT32 _abi_add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler, EventRegistrationToken* token);
|
||||
virtual INT32 _abi_remove_VisibilityChanged(EventRegistrationToken token);
|
||||
virtual INT32 _abi_get_Bounds(Rect* rect) = 0;
|
||||
virtual INT32 _abi_get_Dispatcher(ICoreDispatcher** dispatcher) = 0;
|
||||
virtual INT32 _abi_get_IsInputEnabled(boolean* value) = 0;
|
||||
virtual INT32 _abi_set_IsInputEnabled(boolean value) = 0;
|
||||
virtual INT32 _abi_get_Visible(boolean* value) = 0;
|
||||
virtual INT32 _abi_Activate() = 0;
|
||||
virtual INT32 _abi_Close() = 0;
|
||||
virtual INT32 _abi_get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value) = 0;
|
||||
virtual INT32 _abi_get_KeyState(VirtualKey key, CoreVirtualKeyStates* value) = 0;
|
||||
virtual INT32 _abi_add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_Activated(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_CharacterRecieved(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_CharacterRecieved(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_Closed(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_InputEnabled(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_KeyDown(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_KeyUp(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_PointerMoved(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_PointerEntered(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_PointerExited(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_SizeChanged(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler, EventRegistrationToken* token) = 0;
|
||||
virtual INT32 _abi_remove_VisibilityChanged(EventRegistrationToken token) = 0;
|
||||
|
||||
HRESULT QueryInterface(const IID& riid, void** ppvObject) override;
|
||||
ULONG AddRef() override;
|
||||
ULONG Release() override;
|
||||
virtual HRESULT QueryInterface(const IID& riid, void** ppvObject) override = 0;
|
||||
virtual ULONG AddRef() override = 0;
|
||||
virtual ULONG Release() override = 0;
|
||||
};
|
@ -29,7 +29,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueRoGetActivationFactory), RoGetActivationFactory_Hook);
|
||||
DetourDetach(&GetForCurrentThread, GetForCurrentThread_Hook);
|
||||
DetourDetach(&TrueGetForCurrentThread, GetForCurrentThread_Hook);
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
|
@ -19,24 +19,26 @@ inline bool IsClassName(HSTRING classId, const char* classIdName)
|
||||
return (classIdStringUTF8 == classIdName);
|
||||
}
|
||||
|
||||
typedef HRESULT(*DllGetForCurrentThreadFunc) (ICoreWindowStatic*, CoreWindow**);
|
||||
typedef HRESULT(*DllGetActivationFactoryFunc) (HSTRING, IActivationFactory**);
|
||||
typedef HRESULT(*DllGetForCurrentThreadFunc) (CoreWindow**);
|
||||
|
||||
DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr;
|
||||
DllGetForCurrentThreadFunc pDllGetForCurrentThread = nullptr;
|
||||
DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr;
|
||||
|
||||
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread)(CoreWindow** window);
|
||||
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread)(ICoreWindowStatic* staticWindow, CoreWindow** window);
|
||||
HRESULT(WINAPI* TrueRoGetActivationFactory)(HSTRING classId, REFIID iid, void** factory) = RoGetActivationFactory;
|
||||
|
||||
void* GetForCurrentThread = nullptr;
|
||||
|
||||
inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook(CoreWindow** window)
|
||||
inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook(ICoreWindowStatic* paramThis, CoreWindow** window)
|
||||
{
|
||||
ComPtr<CoreWindowX> coreWindowX = Make<CoreWindowX>();
|
||||
// ReSharper disable once CppLocalVariableMayBeConst
|
||||
HRESULT hr = TrueGetForCurrentThread(paramThis, window);
|
||||
|
||||
coreWindowX.CopyTo(window);
|
||||
//*reinterpret_cast<void**>(window) = new CoreWindowX(*window);
|
||||
auto p = *reinterpret_cast<void**>(window);
|
||||
|
||||
return S_OK();
|
||||
p = new CoreWindowX(*window);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, void** factory)
|
||||
@ -66,9 +68,9 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
|
||||
|
||||
hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), IID_PPV_ARGS(&coreWindowStatic));
|
||||
|
||||
GetForCurrentThread = (*reinterpret_cast<void***>(coreWindowStatic.Get()))[6];
|
||||
*reinterpret_cast<void**>(&TrueGetForCurrentThread) = (*reinterpret_cast<void***>(coreWindowStatic.Get()))[6];
|
||||
|
||||
DetourAttach(&GetForCurrentThread, GetForCurrentThread_Hook);
|
||||
DetourAttach(&TrueGetForCurrentThread, GetForCurrentThread_Hook);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -98,6 +98,7 @@
|
||||
<ClInclude Include="ICoreWindowX.h" />
|
||||
<ClInclude Include="kernelx.h" />
|
||||
<ClInclude Include="pch.h" />
|
||||
<ClInclude Include="utils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="CoreWindowX.cpp" />
|
||||
|
@ -19,6 +19,7 @@
|
||||
<Filter>Windows.UI.Core</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="hooks.h" />
|
||||
<ClInclude Include="utils.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Exports.def" />
|
||||
|
28
dlls/kernelx/utils.h
Normal file
28
dlls/kernelx/utils.h
Normal file
@ -0,0 +1,28 @@
|
||||
// ReSharper disable CppInconsistentNaming
|
||||
#pragma once
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#define FAILED(hr) (((HRESULT)(hr)) < 0)
|
||||
#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0)
|
||||
#define RETURN_IF_FAILED(hr) if (FAILED(hr)) return hr
|
||||
#define THROW_IF_FAILED(hr) if (FAILED(hr)) throw hr
|
||||
|
||||
#define IsXboxCallee() IsXboxAddress(_ReturnAddress())
|
||||
|
||||
#define GetXDKVersion() "10.0.19041.0"
|
||||
|
||||
inline BOOL IsXboxModule(HMODULE Module)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
inline BOOL IsXboxAddress(const PVOID Address)
|
||||
{
|
||||
HMODULE hModule;
|
||||
|
||||
if (!GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS, static_cast<LPCWSTR>(Address), &hModule))
|
||||
return FALSE;
|
||||
|
||||
return IsXboxModule(hModule);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user