Skip to content

Commit

Permalink
Update .editorconfig.
Browse files Browse the repository at this point in the history
  • Loading branch information
TylerJaacks committed Oct 14, 2024
1 parent 001450d commit 2b6b80f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 27 deletions.
3 changes: 2 additions & 1 deletion dlls/kernelx/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,5 @@ resharper_cpp_clang_tidy_clang_diagnostic_microsoft_cast_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_undefined_reinterpret_cast_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_shadow_highlighting = none
resharper_cpp_clang_tidy_clang_diagnostic_cast_function_type_strict_highlighting = none
resharper_cpp_functional_style_cast_highlighting = none
resharper_cpp_functional_style_cast_highlighting = none
resharper_cpp_non_inline_variable_definition_in_header_file_highlighting = none
41 changes: 15 additions & 26 deletions dlls/kernelx/hooks.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ inline bool IsClassName(HSTRING classId, const char* classIdName)
}

typedef HRESULT(*DllGetForCurrentThreadFunc) (ICoreWindowStatic*, CoreWindow**);
typedef HRESULT(*DllGetForCurrentThreadFunc_App) (ABI::Windows::ApplicationModel::Core::ICoreApplication*, winrt::Windows::ApplicationModel::Core::CoreApplication**);
typedef HRESULT(*DllGetForCurrentThreadFunc_App) (ICoreApplication*, winrt::Windows::ApplicationModel::Core::CoreApplication**);
typedef HRESULT(*DllGetActivationFactoryFunc) (HSTRING, IActivationFactory**);

DllGetForCurrentThreadFunc pDllGetForCurrentThread = nullptr;
DllGetForCurrentThreadFunc_App pDllGetForCurrentThread_App = nullptr;
DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr;

HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread_App)(ABI::Windows::ApplicationModel::Core::ICoreApplication* Iapplication,
winrt::Windows::ApplicationModel::Core::CoreApplication** Application);
// ReSharper disable once CppNonInlineVariableDefinitionInHeaderFile
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread_App)(ICoreApplication* application, winrt::Windows::ApplicationModel::Core::CoreApplication** Application);
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread)(ICoreWindowStatic* staticWindow, CoreWindow** window);
HRESULT(WINAPI* TrueRoGetActivationFactory)(HSTRING classId, REFIID iid, void** factory) = RoGetActivationFactory;

Expand All @@ -37,13 +37,12 @@ inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook(ICoreWindowStatic* par
return hr;
}

inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook_App(ABI::Windows::ApplicationModel::Core::ICoreApplication* paramThis,
inline HRESULT STDMETHODCALLTYPE GetForCurrentThreadApp_Hook(ICoreApplication* paramThis,
winrt::Windows::ApplicationModel::Core::CoreApplication** Application)
{
// ReSharper disable once CppLocalVariableMayBeConst
HRESULT hrApp = TrueGetForCurrentThread_App(paramThis, Application);

//*reinterpret_cast<void**>(Application) = new CoreApplicationX(*Application);
auto pApp = *reinterpret_cast<void**>(Application);

pApp = new CoreApplicationX(*Application);
Expand Down Expand Up @@ -71,39 +70,29 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v

ComPtr<IActivationFactory> _factory;


if (IsClassName(classId, "Windows.UI.Core.CoreWindow"))
if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication"))
{
ComPtr<ICoreWindowStatic> coreWindowStatic;
ComPtr<ABI::Windows::ApplicationModel::Core::ICoreApplication> ICoreApplicationPtr;

hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get( ), IID_PPV_ARGS(&coreWindowStatic));
hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&ICoreApplicationPtr));

*reinterpret_cast<void**>(&TrueGetForCurrentThread) = (*reinterpret_cast<void***>(coreWindowStatic.Get( )))[ 6 ];
*reinterpret_cast<void**>(&TrueGetForCurrentThread_App) = (*reinterpret_cast<void***>(ICoreApplicationPtr.Get()))[ 6 ];

DetourAttach(&TrueGetForCurrentThread, GetForCurrentThread_Hook);
DetourAttach(&TrueGetForCurrentThread_App, GetForCurrentThreadApp_Hook);
}
else
else if (IsClassName(classId, "Windows.UI.Core.CoreWindow"))
{
hr = pDllGetActivationFactory(classId, _factory.GetAddressOf( ));
}

if (FAILED(hr)) return hr;

return _factory.CopyTo(iid, factory);

if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication"))
{
ComPtr<ABI::Windows::ApplicationModel::Core::ICoreApplication> ICoreApplicationPtr;
ComPtr<ICoreWindowStatic> coreWindowStatic;

hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get( ), IID_PPV_ARGS(&ICoreApplicationPtr));
hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), IID_PPV_ARGS(&coreWindowStatic));

*reinterpret_cast<void**>(&TrueGetForCurrentThread_App) = (*reinterpret_cast<void***>(ICoreApplicationPtr.Get( )))[ 6 ];
*reinterpret_cast<void**>(&TrueGetForCurrentThread) = (*reinterpret_cast<void***>(coreWindowStatic.Get()))[ 6 ];

DetourAttach(&TrueGetForCurrentThread_App, GetForCurrentThread_Hook_App);
DetourAttach(&TrueGetForCurrentThread, GetForCurrentThread_Hook);
}
else
{
hr = pDllGetActivationFactory(classId, _factory.GetAddressOf( ));
hr = pDllGetActivationFactory(classId, _factory.GetAddressOf());
}

if (FAILED(hr)) return hr;
Expand Down

0 comments on commit 2b6b80f

Please sign in to comment.