Added basic ICoreWindow and CoreWindow implementation.
Some checks failed
MSBuild / build (push) Has been cancelled
Generate DLL Progress JSONs / generate_commit (push) Has been cancelled
Deploy static content to Pages / deploy (push) Has been cancelled

This commit is contained in:
Tyler Jaacks 2024-10-07 18:13:39 -05:00
parent d6c54e0492
commit 136dae13c8
9 changed files with 395 additions and 1319 deletions

View File

@ -0,0 +1,226 @@
// ReSharper disable CppInconsistentNaming
// ReSharper disable CppFunctionResultShouldBeUsed
// ReSharper disable CppParameterMayBeConst
#include "pch.h"
#include "CoreWindowX.h"
HRESULT CoreWindowX::GetIids(ULONG* iidCount, IID** iids)
{
return m_coreWindow->GetIids(iidCount, iids);
}
HRESULT CoreWindowX::GetRuntimeClassName(HSTRING* className)
{
return m_coreWindow->GetRuntimeClassName(className);
}
HRESULT CoreWindowX::GetTrustLevel(TrustLevel* trustLevel)
{
return m_coreWindow->GetTrustLevel(trustLevel);
}
void CoreWindowX::Activate()
{
m_coreWindow->Activate();
}
void CoreWindowX::Close()
{
m_coreWindow->Close();
}
CoreVirtualKeyStates CoreWindowX::GetAsyncKeyState(VirtualKey key)
{
//return ICoreWindowX::GetAsyncKeyState(key);
return CoreVirtualKeyStates_None;
}
CoreVirtualKeyStates CoreWindowX::GetKeyState(VirtualKey key)
{
//return ICoreWindowX::GetKeyState(key);
return CoreVirtualKeyStates_None;
}
int32_t CoreWindowX::get_Bounds(Rect* rect)
{
return m_coreWindow->get_Bounds(rect);
}
int32_t CoreWindowX::get_Dispatcher(CoreDispatcher** dispatcher)
{
//return ICoreWindowX::get_Dispatcher(dispatcher);
return 0;
}
int32_t CoreWindowX::get_IsInputEnabled(boolean* value)
{
return m_coreWindow->get_IsInputEnabled(value);
}
int32_t CoreWindowX::set_IsInputEnabled(boolean value)
{
//return ICoreWindowX::set_IsInputEnabled(value);
return 0;
}
int32_t CoreWindowX::get_Visible(boolean* value)
{
return m_coreWindow->get_Visible(value);
}
int32_t CoreWindowX::_abi_Activate()
{
return m_coreWindow->Activate();
}
int32_t CoreWindowX::_abi_Close()
{
return m_coreWindow->Close();
}
int32_t CoreWindowX::get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value)
{
return m_coreWindow->GetAsyncKeyState(key, value);
}
int32_t CoreWindowX::get_KeyState(VirtualKey key, CoreVirtualKeyStates* value)
{
return m_coreWindow->GetKeyState(key, value);
}
int32_t CoreWindowX::add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_Activated(handler, token);
}
int32_t CoreWindowX::remove_Activated(EventRegistrationToken token)
{
return m_coreWindow->remove_Activated(token);
}
int32_t CoreWindowX::add_CharacterRecieved(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_CharacterReceived(handler, token);
}
int32_t CoreWindowX::remove_CharacterRecieved(EventRegistrationToken token)
{
return m_coreWindow->remove_CharacterReceived(token);
}
int32_t CoreWindowX::add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_Closed(handler, token);
}
int32_t CoreWindowX::remove_Closed(EventRegistrationToken token)
{
return m_coreWindow->remove_Closed(token);
}
int32_t CoreWindowX::add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_InputEnabled(handler, token);
}
int32_t CoreWindowX::remove_InputEnabled(EventRegistrationToken token)
{
return m_coreWindow->remove_InputEnabled(token);
}
int32_t CoreWindowX::add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token)
{
return m_coreWindow->add_KeyDown(handler, token);
}
int32_t CoreWindowX::remove_KeyDown(EventRegistrationToken token)
{
return m_coreWindow->remove_KeyDown(token);
}
int32_t CoreWindowX::add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token)
{
return m_coreWindow->add_KeyUp(handler, token);
}
int32_t CoreWindowX::remove_KeyUp(EventRegistrationToken token)
{
return m_coreWindow->remove_KeyUp(token);
}
int32_t CoreWindowX::add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_PointerMoved(handler, token);
}
int32_t CoreWindowX::remove_PointerMoved(EventRegistrationToken token)
{
return m_coreWindow->remove_PointerMoved(token);
}
int32_t CoreWindowX::add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_PointerEntered(handler, token);
}
int32_t CoreWindowX::remove_PointerEntered(EventRegistrationToken token)
{
return m_coreWindow->remove_PointerCaptureLost(token);
}
int32_t CoreWindowX::add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_PointerExited(handler, token);
}
int32_t CoreWindowX::remove_PointerExited(EventRegistrationToken token)
{
return m_coreWindow->remove_PointerExited(token);
}
int32_t CoreWindowX::add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_SizeChanged(handler, token);
}
int32_t CoreWindowX::remove_SizeChanged(EventRegistrationToken token)
{
return m_coreWindow->remove_SizeChanged(token);
}
int32_t CoreWindowX::add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler,
EventRegistrationToken* token)
{
return m_coreWindow->add_VisibilityChanged(handler, token);
}
int32_t CoreWindowX::remove_VisibilityChanged(EventRegistrationToken token)
{
return m_coreWindow->remove_VisibilityChanged(token);
}
HRESULT CoreWindowX::QueryInterface(const IID& riid, void** ppvObject)
{
return m_coreWindow->QueryInterface(riid, ppvObject);
}
ULONG CoreWindowX::AddRef()
{
return m_coreWindow->AddRef();
}
ULONG CoreWindowX::Release()
{
return m_coreWindow->Release();
}

View File

@ -0,0 +1,64 @@
// ReSharper disable CppInconsistentNaming
// ReSharper disable CppClassCanBeFinal
#pragma once
#include "ICoreWindowX.h"
#include <windows.ui.core.h>
class CoreWindowX : public ICoreWindowX
{
Microsoft::WRL::ComPtr<ICoreWindow> m_coreWindow;
public:
HRESULT GetIids(ULONG* iidCount, IID** iids) override;
HRESULT GetRuntimeClassName(HSTRING* className) override;
HRESULT GetTrustLevel(TrustLevel* trustLevel) override;
void Activate() override;
void Close() override;
CoreVirtualKeyStates GetAsyncKeyState(VirtualKey key) override;
CoreVirtualKeyStates GetKeyState(VirtualKey key) override;
int32_t get_Bounds(Rect* rect) override;
int32_t get_Dispatcher(CoreDispatcher** dispatcher) override;
int32_t get_IsInputEnabled(boolean* value) override;
int32_t set_IsInputEnabled(boolean value) override;
int32_t get_Visible(boolean* value) override;
int32_t _abi_Activate() override;
int32_t _abi_Close() override;
int32_t get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value) override;
int32_t get_KeyState(VirtualKey key, CoreVirtualKeyStates* value) override;
int32_t add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_Activated(EventRegistrationToken token) override;
int32_t add_CharacterRecieved(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_CharacterRecieved(EventRegistrationToken token) override;
int32_t add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_Closed(EventRegistrationToken token) override;
int32_t add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_InputEnabled(EventRegistrationToken token) override;
int32_t add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_KeyDown(EventRegistrationToken token) override;
int32_t add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token) override;
int32_t remove_KeyUp(EventRegistrationToken token) override;
int32_t add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_PointerMoved(EventRegistrationToken token) override;
int32_t add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_PointerEntered(EventRegistrationToken token) override;
int32_t add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_PointerExited(EventRegistrationToken token) override;
int32_t add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_SizeChanged(EventRegistrationToken token) override;
int32_t add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler,
EventRegistrationToken* token) override;
int32_t remove_VisibilityChanged(EventRegistrationToken token) override;
HRESULT QueryInterface(const IID& riid, void** ppvObject) override;
ULONG AddRef() override;
ULONG Release() override;
};

View File

@ -0,0 +1,62 @@
// ReSharper disable CppPolymorphicClassWithNonVirtualPublicDestructor
// ReSharper disable CppInconsistentNaming
// ReSharper disable CppClangTidyClangDiagnosticNonVirtualDtor
// ReSharper disable IdentifierTypo
// ReSharper disable CppClangTidyClangDiagnosticHeaderHygiene
#pragma once
#include <inspectable.h>
#include <windows.foundation.h>
#include <windows.ui.core.h>
#include <windows.system.h>
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::UI::Core;
using namespace ABI::Windows::System;
class ICoreWindowX : public IInspectable
{
public:
virtual ~ICoreWindowX() = default;
virtual void Activate();
virtual void Close();
virtual CoreVirtualKeyStates GetAsyncKeyState(VirtualKey key);
virtual CoreVirtualKeyStates GetKeyState(VirtualKey key);
virtual int32_t get_Bounds(Rect* rect);
virtual int32_t get_Dispatcher(CoreDispatcher** dispatcher);
virtual int32_t get_IsInputEnabled(boolean* value);
virtual int32_t set_IsInputEnabled(boolean value);
virtual int32_t get_Visible(boolean* value);
virtual int32_t _abi_Activate();
virtual int32_t _abi_Close();
virtual int32_t get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value);
virtual int32_t get_KeyState(VirtualKey key, CoreVirtualKeyStates* value);
virtual int32_t add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_Activated(EventRegistrationToken token);
virtual int32_t add_CharacterRecieved(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_CharacterRecieved(EventRegistrationToken token);
virtual int32_t add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_Closed(EventRegistrationToken token);
virtual int32_t add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_InputEnabled(EventRegistrationToken token);
virtual int32_t add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_KeyDown(EventRegistrationToken token);
virtual int32_t add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_KeyUp(EventRegistrationToken token);
virtual int32_t add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_PointerMoved(EventRegistrationToken token);
virtual int32_t add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_PointerEntered(EventRegistrationToken token);
virtual int32_t add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_PointerExited(EventRegistrationToken token);
virtual int32_t add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_SizeChanged(EventRegistrationToken token);
virtual int32_t add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler, EventRegistrationToken* token);
virtual int32_t remove_VisibilityChanged(EventRegistrationToken token);
public:
HRESULT QueryInterface(const IID& riid, void** ppvObject) override;
ULONG AddRef() override;
ULONG Release() override;
};

View File

@ -4,15 +4,29 @@
// ReSharper disable CppClangTidyClangDiagnosticUndefinedReinterpretCast
// ReSharper disable CppClangTidyClangDiagnosticShadow
// ReSharper disable CppClangTidyClangDiagnosticCastFunctionTypeStrict
// ReSharper disable CppFunctionalStyleCast
// ReSharper disable CppClangTidyClangDiagnosticCastAlign
// ReSharper disable CppClangTidyClangDiagnosticCastQual
// ReSharper disable CppZeroConstantCanBeReplacedWithNullptr
#include "pch.h"
#include "ICoreWindowX.h"
using namespace Microsoft::WRL;
bool IsClassName(HSTRING classId, const char* classIdName)
{
const wchar_t* classIdString = WindowsGetStringRawBuffer(classId, nullptr);
std::wstring classIdWString(classIdString);
const std::string classIdStringUTF8(classIdWString.begin(), classIdWString.end());
return (classIdStringUTF8 == classIdName);
}
typedef HRESULT(*DllGetActivationFactoryFunc) (HSTRING, IActivationFactory**);
DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr;
HRESULT(WINAPI* TrueRoGetActivationFactory)(HSTRING classId, REFIID iid, void** factory) = RoGetActivationFactory;
HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, void** factory)
@ -35,7 +49,15 @@ HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, void** f
ComPtr<IActivationFactory> _factory;
hr = pDllGetActivationFactory(classId, _factory.GetAddressOf());
if (IsClassName(classId, "Windows.UI.Core.ICoreWindow"))
{
// _factory = winrt::detach_abi(winrt::make<winrt::Windows::Xbox::System::factory_implementation::User>());
}
else
{
hr = pDllGetActivationFactory(classId, _factory.GetAddressOf());
}
if (FAILED(hr)) return hr;
@ -45,6 +67,8 @@ HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, void** f
return hr;
}
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
{
if (DetourIsHelperProcess()) return TRUE;

View File

@ -92,11 +92,14 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CoreWindowX.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="ICoreWindowX.h" />
<ClInclude Include="kernelx.h" />
<ClInclude Include="pch.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CoreWindowX.cpp" />
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="kernelx.cpp" />
<ClCompile Include="pch.cpp">

View File

@ -4,11 +4,20 @@
<ClCompile Include="dllmain.cpp" />
<ClCompile Include="kernelx.cpp" />
<ClCompile Include="pch.cpp" />
<ClCompile Include="CoreWindowX.cpp">
<Filter>Windows.UI.Core</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="framework.h" />
<ClInclude Include="kernelx.h" />
<ClInclude Include="pch.h" />
<ClInclude Include="ICoreWindowX.h">
<Filter>Windows.UI.Core</Filter>
</ClInclude>
<ClInclude Include="CoreWindowX.h">
<Filter>Windows.UI.Core</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="Exports.def" />
@ -17,5 +26,8 @@
<Filter Include="Headers">
<UniqueIdentifier>{1fd01865-5063-43f8-8e37-2d5b0dd81b88}</UniqueIdentifier>
</Filter>
<Filter Include="Windows.UI.Core">
<UniqueIdentifier>{bb53c96d-38a7-46b6-bfc9-84fc5b33678e}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -13,5 +13,7 @@
#include <roapi.h>
#include <wrl.h>
#include <string>
#include <string_view>
#include <__msvc_string_view.hpp>
#endif //PCH_H

File diff suppressed because it is too large Load Diff

View File

@ -220,7 +220,6 @@
<None Include="PropertySheet.props" />
</ItemGroup>
<ItemGroup>
<Midl Include="External\Windows.UI.Core.idl" />
<Midl Include="External\Windows.Xbox.ApplicationModel.State.idl" />
<Midl Include="External\Windows.Xbox.ApplicationModel.State.Internal.idl" />
<Midl Include="External\Windows.Xbox.ApplicationModel.Store.idl" />