mirror of
https://codeberg.org/WinDurango/WinDurango.git
synced 2026-04-18 02:23:34 -04:00
Add GUIDs to Input and System + CoreApplication/CoreWindow impl
This commit is contained in:
@@ -61,19 +61,19 @@ namespace Windows.Xbox.Input
|
||||
|
||||
runtimeclass Controller;
|
||||
|
||||
[interface_name("IControllerAddedEventArgs", AACAAAAB-ACAA-AAAA-AAAA-AAACCCAAAAAA)]
|
||||
[interface_name("IControllerAddedEventArgs", 3dacf202-8c03-4db7-9e89-8f2e1c5374be)]
|
||||
runtimeclass ControllerAddedEventArgs
|
||||
{
|
||||
Controller Controller { get; };
|
||||
}
|
||||
|
||||
[interface_name("IControllerRemovedEventArgs", FAFAAAAB-AAAA-AEAA-AAAA-AAACCCAAAAAA)]
|
||||
[interface_name("IControllerRemovedEventArgs", fd4af91e-40c3-4de0-821b-0be1bd1417d1)]
|
||||
runtimeclass ControllerRemovedEventArgs
|
||||
{
|
||||
Controller Controller { get; };
|
||||
}
|
||||
|
||||
[interface_name("IControllerPairingChangedEventArgs", FAFAAAAB-AAAA-AAAA-AAAA-AAAECCAAFAFA)]
|
||||
[interface_name("IControllerPairingChangedEventArgs", 414591c9-0467-44ad-a1c1-087488cb0769)]
|
||||
runtimeclass ControllerPairingChangedEventArgs
|
||||
{
|
||||
Controller Controller { get; };
|
||||
@@ -81,7 +81,7 @@ namespace Windows.Xbox.Input
|
||||
Windows.Xbox.System.User PreviousUser { get; };
|
||||
}
|
||||
|
||||
[interface_name("IControllerOrderChangedEventArgs", FAFAAAAB-AABA-ABAA-AEAA-AAACCCAAFAFA)]
|
||||
[interface_name("IControllerOrderChangedEventArgs", 5D992A1E-70B7-4269-ACDD-F36668291D98)]
|
||||
runtimeclass ControllerOrderChangedEventArgs
|
||||
{
|
||||
}
|
||||
@@ -206,7 +206,7 @@ namespace Windows.Xbox.Input
|
||||
Single RightThumbstickY { get; };
|
||||
}
|
||||
|
||||
[uuid(AACAAAAB-AAAA-AAAA-AAAA-DDFAAAAAAAAA)]
|
||||
[uuid(9776ff56-9bfd-4581-ad45-b645bba526d6)]
|
||||
interface IController
|
||||
{
|
||||
UInt64 Id { get; };
|
||||
@@ -214,7 +214,7 @@ namespace Windows.Xbox.Input
|
||||
Windows.Xbox.System.User User { get; };
|
||||
}
|
||||
|
||||
[static_name("IControllerStatics", AACAAAAB-AAAA-AAAA-AAAA-AADDAFFFFAAA)]
|
||||
[static_name("IControllerStatics", 7400624f-144b-47fc-9f3b-1dcafb482873)]
|
||||
runtimeclass Controller : [default] IController
|
||||
{
|
||||
static Windows.Foundation.Collections.IVectorView<Controller> Controllers { get; };
|
||||
@@ -258,7 +258,7 @@ namespace Windows.Xbox.Input
|
||||
NavigationController();
|
||||
}
|
||||
|
||||
[uuid(AACAAAAB-AADC-AAAA-AAAA-AFAAAAAAAAAA)]
|
||||
[uuid(E0422A66-C480-4C70-9F99-F8371DCC3E30)]
|
||||
interface IGamepad requires INavigationController
|
||||
{
|
||||
GamepadVibration SetVibration();
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//All GUIDs came from "EmbeddedXvd/Windows/System32/config/SOFTWARE".
|
||||
import "Windows.Xbox.Input.idl";
|
||||
|
||||
namespace Windows.Xbox.System
|
||||
@@ -51,6 +52,7 @@ namespace Windows.Xbox.System
|
||||
Multimedia = 0x2,
|
||||
};
|
||||
|
||||
//Real GUID is unknown (does not appear in EmbeddedXvd/Windows/System32/config/SOFTWARE).
|
||||
[interface_name("IGetPictureResult", DDCCAAAA-AAFC-ACDA-AAAA-AAAFFCCAABBA)]
|
||||
runtimeclass GetPictureResult
|
||||
{
|
||||
@@ -59,8 +61,8 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IUser", DDCCAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[static_name("IUserStatics", ABAACCAA-AAAA-AAAA-AAAA-FAAAAAAAAAAA)]
|
||||
[interface_name("IUser", a2c2223e-2f00-44e2-897e-015bceb87717)]
|
||||
[static_name("IUserStatics", b4f23a93-7fc6-4a50-b153-950016389e50)]
|
||||
runtimeclass User
|
||||
{
|
||||
User();
|
||||
@@ -98,7 +100,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID TODO
|
||||
[interface_name("IUserDisplayInfo", AACAAAAA-ADCA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IUserDisplayInfo", b86dc0dc-caef-4a9b-91c0-2d1b67fccdf1)]
|
||||
runtimeclass UserDisplayInfo
|
||||
{
|
||||
String Gamertag();
|
||||
@@ -113,7 +115,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IAudioDeviceInfo", AAAAAAAA-DFAF-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IAudioDeviceInfo", BBE6BE21-5D0A-48A7-89C7-0F11B5B182EB)]
|
||||
runtimeclass AudioDeviceInfo
|
||||
{
|
||||
String Id { get; };
|
||||
@@ -124,35 +126,35 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IUserDisplayInfoChangedEventArgs", CCDDAAAA-AAAA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IUserDisplayInfoChangedEventArgs", 1d531669-848a-4935-a623-9d58b04fc288)]
|
||||
runtimeclass UserDisplayInfoChangedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IUserAddedEventArgs", AAAAEAAA-ADEA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IUserAddedEventArgs", f8d70cb9-66eb-4421-98b3-7fd524ad8b54)]
|
||||
runtimeclass UserAddedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IUserRemovedEventArgs", AAAAAFAA-AAAA-AAAA-ADEA-AAAAAAAAAAAA)]
|
||||
[interface_name("IUserRemovedEventArgs", 240e94f6-ae76-4897-bc80-686e136f7c4a)]
|
||||
runtimeclass UserRemovedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IOnlineStateChangedEventArgs", DEAAAAFA-AAAA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IOnlineStateChangedEventArgs", cde05277-7781-4ba2-b248-37b0ce11d09d)]
|
||||
runtimeclass OnlineStateChangedEventArgs
|
||||
{
|
||||
UserOnlineState State { get; };
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IGetTokenAndSignatureResult", ADEAAAAF-AAAA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("IGetTokenAndSignatureResult", 4FBC0506-0503-4027-9489-8E46C81D2316)]
|
||||
runtimeclass GetTokenAndSignatureResult
|
||||
{
|
||||
String Signature { get; };
|
||||
@@ -160,7 +162,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("ISignInCompletedEventArgs", DEFFAAAA-FAAA-AAAA-AAAA-AAAAAAAAAAAA)]
|
||||
[interface_name("ISignInCompletedEventArgs", CEE6FFB4-C6AB-4083-A6F8-1A50162A4647)]
|
||||
runtimeclass SignInCompletedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
@@ -179,7 +181,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("ISignOutStartedEventArgs", AAAAAAAA-AFAA-AAAA-AAAA-AAAAAAADEFAA)]
|
||||
[interface_name("ISignOutStartedEventArgs", DEBF2CE1-65D7-4D73-8384-6B5B756D9BAC)]
|
||||
runtimeclass SignOutStartedEventArgs
|
||||
{
|
||||
SignOutDeferral GetDeferral();
|
||||
@@ -187,7 +189,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("ISignOutCompletedEventArgs", AAAAAAAA-AAFA-AAAA-AAAA-AFDEECAAAAAA)]
|
||||
[interface_name("ISignOutCompletedEventArgs", 23479C5C-3C95-40E6-B45B-3CB046214E1A)]
|
||||
runtimeclass SignOutCompletedEventArgs
|
||||
{
|
||||
HRESULT Result { get; };
|
||||
@@ -195,7 +197,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IAudioDeviceAddedEventArgs", AAAAAAAA-AAAF-AAAA-FCCF-AAAAAAAAAAAA)]
|
||||
[interface_name("IAudioDeviceAddedEventArgs", 72666912-9F1E-4251-9B16-08C1374A3108)]
|
||||
runtimeclass AudioDeviceAddedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
@@ -203,7 +205,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IAudioDeviceRemovedEventArgs", AAAAAAAA-AAAA-FAAA-DCCD-AAAAAAAAAAAA)]
|
||||
[interface_name("IAudioDeviceRemovedEventArgs", B0F6F338-E4CA-4031-A639-D7004D01087B)]
|
||||
runtimeclass AudioDeviceRemovedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
@@ -211,7 +213,7 @@ namespace Windows.Xbox.System
|
||||
}
|
||||
|
||||
// Placeholder GUID
|
||||
[interface_name("IAudioDeviceChangedEventArgs", AAAAAAAA-AAAA-AFAA-DCDD-AAAAAAAAAAAA)]
|
||||
[interface_name("IAudioDeviceChangedEventArgs", 7d3b938f-8113-40ce-b6e3-becca85ef17e)]
|
||||
runtimeclass AudioDeviceChangedEventArgs
|
||||
{
|
||||
User User { get; };
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Created by DexrnZacAttack on 1/23/26 using zPc-i2.
|
||||
//
|
||||
#pragma once
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
#include "Config.h"
|
||||
#include "Interfaces/Storage/Directory.h"
|
||||
#include "Logging.h"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// TODO we can just move this all to Common I believe.
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
|
||||
#ifdef WD_API_EXPORTS
|
||||
#define WD_API __declspec(dllexport)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include "WinDurangoImplWinRT.h"
|
||||
#include <iostream>
|
||||
#include <windows.h>
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
|
||||
/*
|
||||
* Found here
|
||||
|
||||
@@ -15,7 +15,7 @@ set(FILES
|
||||
include/WinDurango.KernelX/Hooks.h
|
||||
)
|
||||
|
||||
add_library(WinDurango.KernelX SHARED ${FILES})
|
||||
add_library(WinDurango.KernelX SHARED ${FILES} "include/WinDurango.KernelX/EraCoreApplication.h" "src/EraCoreApplication.cpp" "include/WinDurango.KernelX/EraCoreWindow.h" "src/EraCoreWindow.cpp")
|
||||
|
||||
target_link_libraries(WinDurango.KernelX PRIVATE
|
||||
WinDurango.Common
|
||||
|
||||
@@ -0,0 +1,280 @@
|
||||
#pragma once
|
||||
#include "CoreWindow.h"
|
||||
#include <windows.ui.core.h>
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/Windows.UI.ViewManagement.h>
|
||||
#include <wrl.h>
|
||||
#include "EraCoreWindow.h"
|
||||
|
||||
using namespace ABI::Windows::ApplicationModel;
|
||||
using namespace ABI::Windows::ApplicationModel::Activation;
|
||||
using namespace ABI::Windows::ApplicationModel::Core;
|
||||
using namespace ABI::Windows::Foundation;
|
||||
using namespace ABI::Windows::System;
|
||||
using namespace Microsoft::WRL;
|
||||
|
||||
MIDL_INTERFACE("0aacf7a4-5e1d-49df-8034-fb6a68bc5ed1")
|
||||
ICoreApplicationEra : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual HRESULT QueryInterface(const IID &riid, void **ppvObject) override = 0;
|
||||
virtual ULONG AddRef() override = 0;
|
||||
virtual ULONG Release() override = 0;
|
||||
|
||||
virtual INT32 _abi_get_Id(HSTRING * value) = 0;
|
||||
virtual INT32 _abi_add_Suspending(__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual INT32 _abi_remove_Suspending(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_add_Resuming(__FIEventHandler_1_IInspectable * handler, EventRegistrationToken * token) = 0;
|
||||
virtual INT32 _abi_remove_Resuming(EventRegistrationToken token) = 0;
|
||||
virtual INT32 _abi_get_Properties(ABI::Windows::Foundation::Collections::IPropertySet * *value) = 0;
|
||||
virtual INT32 _abi_GetCurrentView(ABI::Windows::ApplicationModel::Core::ICoreApplicationView * *value) = 0;
|
||||
virtual INT32 _abi_Run(ABI::Windows::ApplicationModel::Core::IFrameworkViewSource * viewSource) = 0;
|
||||
virtual INT32 _abi_RunWithActivationFactories(ABI::Windows::Foundation::IGetActivationFactory *
|
||||
activationFactoryCallback) = 0;
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("42A6A529-3CC6-4867-B5B7-6D1FAF5325F9")
|
||||
ICoreApplicationGpuPolicyEra : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual HRESULT get_DisableKinectGpuReservation(bool *) = 0;
|
||||
virtual HRESULT set_DisableKinectGpuReservation(bool) = 0;
|
||||
};
|
||||
|
||||
enum ResourceAvailability
|
||||
{
|
||||
ResourceAvailability_Full,
|
||||
ResourceAvailability_Constrained,
|
||||
ResourceAvailability_FullWithExtendedSystemReserve,
|
||||
};
|
||||
|
||||
MIDL_INTERFACE("9FF3799E-6E83-468C-A5B0-501CE6BB0FA1")
|
||||
ICoreApplicationResourceAvailabilityEra : public IInspectable
|
||||
{
|
||||
public:
|
||||
STDMETHOD(_abi_get_ResourceAvailability)(ResourceAvailability *) PURE;
|
||||
STDMETHOD(_abi_add_ResourceAvailabilityChanged)(winrt::Windows::Foundation::EventHandler<IInspectable> * handler,
|
||||
EventRegistrationToken * token) PURE;
|
||||
STDMETHOD(_abi_remove_ResourceAvailabilityChanged)(EventRegistrationToken) PURE;
|
||||
};
|
||||
|
||||
// Main Wrapper
|
||||
class CoreApplicationEra : public RuntimeClass<IActivationFactory, ICoreApplicationResourceAvailabilityEra,
|
||||
ICoreApplicationGpuPolicyEra, ICoreApplicationEra>
|
||||
{
|
||||
public:
|
||||
CoreApplicationEra(ComPtr<IActivationFactory> realFactory)
|
||||
{
|
||||
m_realFactory = realFactory;
|
||||
HRESULT hr = m_realFactory.As(&m_realCoreApplication);
|
||||
if (FAILED(hr))
|
||||
throw E_FAIL;
|
||||
AddRef();
|
||||
}
|
||||
|
||||
// for IActivationFactory
|
||||
HRESULT STDMETHODCALLTYPE ActivateInstance(__RPC__deref_out_opt IInspectable **instance) override
|
||||
{
|
||||
return m_realFactory->ActivateInstance(instance);
|
||||
}
|
||||
|
||||
// ICoreApplication
|
||||
INT32 _abi_get_Id(HSTRING *value) override;
|
||||
INT32 _abi_add_Suspending(__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
INT32 _abi_remove_Suspending(EventRegistrationToken token) override;
|
||||
INT32 _abi_add_Resuming(__FIEventHandler_1_IInspectable *handler, EventRegistrationToken *token) override;
|
||||
INT32 _abi_remove_Resuming(EventRegistrationToken token) override;
|
||||
INT32 _abi_get_Properties(ABI::Windows::Foundation::Collections::IPropertySet **value) override;
|
||||
INT32 _abi_GetCurrentView(ABI::Windows::ApplicationModel::Core::ICoreApplicationView **value) override;
|
||||
INT32 _abi_Run(ABI::Windows::ApplicationModel::Core::IFrameworkViewSource *viewSource) override;
|
||||
INT32 _abi_RunWithActivationFactories(
|
||||
ABI::Windows::Foundation::IGetActivationFactory *activationFactoryCallback) override;
|
||||
|
||||
// ICoreApplicationResourceAvailability
|
||||
HRESULT _abi_get_ResourceAvailability(ResourceAvailability *resourceAvailability) override;
|
||||
HRESULT _abi_add_ResourceAvailabilityChanged(winrt::Windows::Foundation::EventHandler<IInspectable> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token) override;
|
||||
|
||||
// ICoreApplicationGpuPolicy
|
||||
HRESULT get_DisableKinectGpuReservation(bool *) override;
|
||||
HRESULT set_DisableKinectGpuReservation(bool) override;
|
||||
|
||||
// IActivationFactory (IInspectable + IUnknown)
|
||||
HRESULT QueryInterface(const IID &riid, void **ppvObject) override;
|
||||
ULONG AddRef() override;
|
||||
ULONG Release() override;
|
||||
|
||||
HRESULT GetIids(ULONG *iidCount, IID **iids) override;
|
||||
HRESULT GetRuntimeClassName(HSTRING *className) override;
|
||||
HRESULT GetTrustLevel(TrustLevel *trustLevel) override;
|
||||
|
||||
private:
|
||||
ULONG m_RefCount = 0;
|
||||
ComPtr<ICoreApplication> m_realCoreApplication;
|
||||
ComPtr<IActivationFactory> m_realFactory;
|
||||
bool m_KinectGpuReservation = false;
|
||||
};
|
||||
|
||||
class FrameworkViewEra : public IFrameworkView
|
||||
{
|
||||
public:
|
||||
FrameworkViewEra(IFrameworkView *windowView)
|
||||
{
|
||||
m_realView = windowView;
|
||||
AddRef();
|
||||
}
|
||||
|
||||
HRESULT Initialize(ABI::Windows::ApplicationModel::Core::ICoreApplicationView *applicationView) override
|
||||
{
|
||||
return m_realView->Initialize(applicationView);
|
||||
}
|
||||
|
||||
HRESULT SetWindow(ABI::Windows::UI::Core::ICoreWindow *window) override
|
||||
{
|
||||
window = reinterpret_cast<ABI::Windows::UI::Core::ICoreWindow *>(
|
||||
new CoreWindowEra((ABI::Windows::UI::Core::CoreWindow *)window));
|
||||
m_realView->SetWindow(window);
|
||||
|
||||
//Resizes game window to 1280x720 so it's not a square by default.
|
||||
auto view = winrt::Windows::UI::ViewManagement::ApplicationView::GetForCurrentView();
|
||||
winrt::Windows::Foundation::Size desiredSize{1280.0f, 720.0f};
|
||||
view.TryResizeView(desiredSize);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Load(HSTRING entryPoint) override
|
||||
{
|
||||
return m_realView->Load(entryPoint);
|
||||
}
|
||||
|
||||
HRESULT Run() override
|
||||
{
|
||||
return m_realView->Run();
|
||||
}
|
||||
|
||||
HRESULT Uninitialize() override
|
||||
{
|
||||
return m_realView->Uninitialize();
|
||||
}
|
||||
|
||||
// IActivationFactory (IInspectable + IUnknown)
|
||||
HRESULT QueryInterface(const IID &riid, void **ppvObject) override
|
||||
{
|
||||
if (riid == __uuidof(IFrameworkView) || riid == __uuidof(IUnknown) || riid == __uuidof(IInspectable))
|
||||
{
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
*ppvObject = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG AddRef() override
|
||||
{
|
||||
return InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
ULONG Release() override
|
||||
{
|
||||
ULONG refCount = InterlockedDecrement(&m_RefCount);
|
||||
if (refCount == 0)
|
||||
delete this;
|
||||
return refCount;
|
||||
}
|
||||
|
||||
HRESULT GetIids(ULONG *iidCount, IID **iids) override
|
||||
{
|
||||
return m_realView->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT GetRuntimeClassName(HSTRING *className) override
|
||||
{
|
||||
return m_realView->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT GetTrustLevel(TrustLevel *trustLevel) override
|
||||
{
|
||||
return m_realView->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
private:
|
||||
ULONG m_RefCount = 0;
|
||||
IFrameworkView *m_realView;
|
||||
};
|
||||
|
||||
class FrameworkViewSourceEra : public IFrameworkViewSource
|
||||
{
|
||||
public:
|
||||
FrameworkViewSourceEra(IFrameworkViewSource *windowViewSource)
|
||||
{
|
||||
m_realViewSource = windowViewSource;
|
||||
AddRef();
|
||||
}
|
||||
|
||||
HRESULT STDMETHODCALLTYPE CreateView(ABI::Windows::ApplicationModel::Core::IFrameworkView **viewProvider) override
|
||||
{
|
||||
auto hr = m_realViewSource->CreateView(viewProvider);
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
*viewProvider = new FrameworkViewEra(*viewProvider);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
// IActivationFactory (IInspectable + IUnknown)
|
||||
HRESULT QueryInterface(const IID &riid, void **ppvObject) override
|
||||
{
|
||||
if (riid == __uuidof(IFrameworkViewSource))
|
||||
{
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
char iidstr[sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}")];
|
||||
OLECHAR iidwstr[sizeof(iidstr)];
|
||||
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
|
||||
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
|
||||
MessageBoxA(nullptr, iidstr, typeid(*this).name(), MB_OK);
|
||||
*ppvObject = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG AddRef() override
|
||||
{
|
||||
return InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
ULONG Release() override
|
||||
{
|
||||
ULONG refCount = InterlockedDecrement(&m_RefCount);
|
||||
if (refCount == 0)
|
||||
delete this;
|
||||
return refCount;
|
||||
}
|
||||
|
||||
HRESULT GetIids(ULONG *iidCount, IID **iids) override
|
||||
{
|
||||
return m_realViewSource->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT GetRuntimeClassName(HSTRING *className) override
|
||||
{
|
||||
return m_realViewSource->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT GetTrustLevel(TrustLevel *trustLevel) override
|
||||
{
|
||||
return m_realViewSource->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
private:
|
||||
ULONG m_RefCount = 0;
|
||||
IFrameworkViewSource *m_realViewSource;
|
||||
};
|
||||
@@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
#include <windows.foundation.h>
|
||||
#include <windows.system.h>
|
||||
#include <windows.ui.core.h>
|
||||
#include <winrt/Windows.UI.ViewManagement.h>
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace Microsoft::WRL;
|
||||
using namespace ABI::Windows::Foundation;
|
||||
using namespace ABI::Windows::UI::Core;
|
||||
using namespace ABI::Windows::System;
|
||||
|
||||
MIDL_INTERFACE("79b9d5f2-879e-4b89-b798-79e47598030c")
|
||||
ICoreWindowEra : public IInspectable
|
||||
{
|
||||
public:
|
||||
virtual HRESULT _abi_get_Bounds(Rect * rect) = 0;
|
||||
virtual HRESULT _abi_get_Dispatcher(ICoreDispatcher * *dispatcher) = 0;
|
||||
virtual HRESULT _abi_get_IsInputEnabled(boolean * value) = 0;
|
||||
virtual HRESULT _abi_set_IsInputEnabled(boolean value) = 0;
|
||||
virtual HRESULT _abi_get_Visible(boolean * value) = 0;
|
||||
virtual HRESULT Activate() = 0;
|
||||
virtual HRESULT Close() = 0;
|
||||
virtual HRESULT GetAsyncKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates * KeyState) = 0;
|
||||
virtual HRESULT GetKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates * KeyState) = 0;
|
||||
virtual HRESULT _abi_add_Activated(ITypedEventHandler<CoreWindow *, WindowActivatedEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_Activated(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_CharacterReceived(ITypedEventHandler<CoreWindow *, CharacterReceivedEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_CharacterReceived(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_Closed(ITypedEventHandler<CoreWindow *, CoreWindowEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_Closed(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_InputEnabled(ITypedEventHandler<CoreWindow *, InputEnabledEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_InputEnabled(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_KeyDown(ITypedEventHandler<CoreWindow *, KeyEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_KeyDown(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_KeyUp(ITypedEventHandler<CoreWindow *, KeyEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_KeyUp(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_PointerMoved(ITypedEventHandler<CoreWindow *, PointerEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_PointerMoved(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_PointerEntered(ITypedEventHandler<CoreWindow *, PointerEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_PointerEntered(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_PointerExited(ITypedEventHandler<CoreWindow *, PointerEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_PointerExited(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_SizeChanged(ITypedEventHandler<CoreWindow *, WindowSizeChangedEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_SizeChanged(EventRegistrationToken token) = 0;
|
||||
virtual HRESULT _abi_add_VisibilityChanged(ITypedEventHandler<CoreWindow *, VisibilityChangedEventArgs *> * handler,
|
||||
EventRegistrationToken * token) = 0;
|
||||
virtual HRESULT _abi_remove_VisibilityChanged(EventRegistrationToken token) = 0;
|
||||
};
|
||||
|
||||
class CoreWindowEra : public ICoreWindowEra
|
||||
{
|
||||
public:
|
||||
ICoreWindow *m_realWindow;
|
||||
|
||||
CoreWindowEra(CoreWindow *realWind)
|
||||
{
|
||||
m_realWindow = reinterpret_cast<ICoreWindow *>(realWind);
|
||||
InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
HRESULT _abi_get_Bounds(Rect *rect) override;
|
||||
HRESULT _abi_get_Dispatcher(ICoreDispatcher **dispatcher) override;
|
||||
HRESULT _abi_get_IsInputEnabled(boolean *value) override;
|
||||
HRESULT _abi_set_IsInputEnabled(boolean value) override;
|
||||
HRESULT _abi_get_Visible(boolean *value) override;
|
||||
HRESULT Activate() override;
|
||||
HRESULT Close() override;
|
||||
HRESULT GetAsyncKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates *KeyState) override;
|
||||
HRESULT GetKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates *KeyState) override;
|
||||
HRESULT _abi_add_Activated(ITypedEventHandler<CoreWindow *, WindowActivatedEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_Activated(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_CharacterReceived(ITypedEventHandler<CoreWindow *, CharacterReceivedEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_CharacterReceived(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_Closed(ITypedEventHandler<CoreWindow *, CoreWindowEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_Closed(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_InputEnabled(ITypedEventHandler<CoreWindow *, InputEnabledEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_InputEnabled(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_KeyDown(ITypedEventHandler<CoreWindow *, KeyEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_KeyDown(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_KeyUp(ITypedEventHandler<CoreWindow *, KeyEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_KeyUp(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_PointerMoved(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_PointerMoved(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_PointerEntered(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_PointerEntered(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_PointerExited(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_PointerExited(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_SizeChanged(ITypedEventHandler<CoreWindow *, WindowSizeChangedEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_SizeChanged(EventRegistrationToken token) override;
|
||||
HRESULT _abi_add_VisibilityChanged(ITypedEventHandler<CoreWindow *, VisibilityChangedEventArgs *> *handler,
|
||||
EventRegistrationToken *token) override;
|
||||
HRESULT _abi_remove_VisibilityChanged(EventRegistrationToken token) override;
|
||||
|
||||
// IInspectable + IUnknown
|
||||
HRESULT QueryInterface(const IID &riid, void **ppvObject) override;
|
||||
ULONG AddRef() override;
|
||||
ULONG Release() override;
|
||||
|
||||
HRESULT GetIids(ULONG *iidCount, IID **iids) override;
|
||||
HRESULT GetRuntimeClassName(HSTRING *className) override;
|
||||
HRESULT GetTrustLevel(TrustLevel *trustLevel) override;
|
||||
|
||||
private:
|
||||
ULONG m_RefCount = 0;
|
||||
};
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <wrl/client.h>
|
||||
#include <detours.h>
|
||||
#include "CurrentApp.h"
|
||||
#include "EraCoreWindow.h"
|
||||
#include "EraCoreApplication.h"
|
||||
|
||||
typedef int32_t (__stdcall *GetActivationFactory_t)(HSTRING classId, IActivationFactory** factory);
|
||||
|
||||
@@ -38,4 +40,25 @@ inline bool IsClassName(HSTRING classId, const char *classIdName)
|
||||
return (classIdStringUTF8 == classIdName);
|
||||
}
|
||||
|
||||
HRESULT(WINAPI *TrueActivateInstance)(IActivationFactory *thisptr, IInspectable **instance) = nullptr;
|
||||
HRESULT(WINAPI *TrueActivateInstance)(IActivationFactory *thisptr, IInspectable **instance) = nullptr;
|
||||
|
||||
#define IsXboxCallee() IsXboxAddress(_ReturnAddress())
|
||||
|
||||
BOOL IsXboxModule(HMODULE module)
|
||||
{
|
||||
return module == GetModuleHandleW(nullptr);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
HRESULT(STDMETHODCALLTYPE *TrueGetForCurrentThread)(ICoreWindowStatic *staticWindow, CoreWindow **window);
|
||||
|
||||
HRESULT STDMETHODCALLTYPE EraGetForCurrentThread(ICoreWindowStatic *pThis, CoreWindow **ppWindow);
|
||||
146
projects/WinDurango.KernelX/src/EraCoreApplication.cpp
Normal file
146
projects/WinDurango.KernelX/src/EraCoreApplication.cpp
Normal file
@@ -0,0 +1,146 @@
|
||||
#include "EraCoreApplication.h"
|
||||
|
||||
INT32 CoreApplicationEra::_abi_get_Id(HSTRING *value)
|
||||
{
|
||||
return m_realCoreApplication->get_Id(value);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_add_Suspending(
|
||||
__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs *handler, EventRegistrationToken *token)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_remove_Suspending(EventRegistrationToken token)
|
||||
{
|
||||
return m_realCoreApplication->remove_Suspending(token);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_add_Resuming(__FIEventHandler_1_IInspectable *handler, EventRegistrationToken *token)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_remove_Resuming(EventRegistrationToken token)
|
||||
{
|
||||
return m_realCoreApplication->remove_Resuming(token);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_get_Properties(ABI::Windows::Foundation::Collections::IPropertySet **value)
|
||||
{
|
||||
return m_realCoreApplication->get_Properties(value);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_GetCurrentView(ABI::Windows::ApplicationModel::Core::ICoreApplicationView **value)
|
||||
{
|
||||
return m_realCoreApplication->GetCurrentView(value);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_Run(ABI::Windows::ApplicationModel::Core::IFrameworkViewSource *viewSource)
|
||||
{
|
||||
FrameworkViewSourceEra *ViewSource = new FrameworkViewSourceEra(viewSource);
|
||||
return m_realCoreApplication->Run(ViewSource);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationEra::_abi_RunWithActivationFactories(
|
||||
ABI::Windows::Foundation::IGetActivationFactory *activationFactoryCallback)
|
||||
{
|
||||
throw winrt::hresult_not_implemented();
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::_abi_get_ResourceAvailability(ResourceAvailability *resourceAvailability)
|
||||
{
|
||||
*resourceAvailability = ResourceAvailability_Full;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::_abi_add_ResourceAvailabilityChanged(
|
||||
winrt::Windows::Foundation::EventHandler<IInspectable> *handler, EventRegistrationToken *token)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::_abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token)
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::get_DisableKinectGpuReservation(bool *Value)
|
||||
{
|
||||
*Value = this->m_KinectGpuReservation;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::set_DisableKinectGpuReservation(bool Value)
|
||||
{
|
||||
this->m_KinectGpuReservation = Value;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::QueryInterface(const IID &riid, void **ppvObject)
|
||||
{
|
||||
if (riid == __uuidof(IActivationFactory) || riid == __uuidof(IUnknown))
|
||||
{
|
||||
*ppvObject = static_cast<IActivationFactory *>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ICoreApplicationEra))
|
||||
{
|
||||
*ppvObject = static_cast<ICoreApplicationEra *>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ICoreApplicationResourceAvailabilityEra))
|
||||
{
|
||||
*ppvObject = static_cast<ICoreApplicationResourceAvailabilityEra *>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ICoreApplicationGpuPolicyEra))
|
||||
{
|
||||
*ppvObject = static_cast<ICoreApplicationGpuPolicyEra *>(this);
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
char iidstr[sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}")];
|
||||
OLECHAR iidwstr[sizeof(iidstr)];
|
||||
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
|
||||
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
|
||||
MessageBoxA(nullptr, iidstr, typeid(*this).name(), MB_OK);
|
||||
|
||||
*ppvObject = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG CoreApplicationEra::AddRef()
|
||||
{
|
||||
return InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
ULONG CoreApplicationEra::Release()
|
||||
{
|
||||
ULONG refCount = InterlockedDecrement(&m_RefCount);
|
||||
if (!refCount)
|
||||
delete this;
|
||||
return refCount;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::GetIids(ULONG *iidCount, IID **iids)
|
||||
{
|
||||
return m_realFactory->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::GetRuntimeClassName(HSTRING *className)
|
||||
{
|
||||
return m_realFactory->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationEra::GetTrustLevel(TrustLevel *trustLevel)
|
||||
{
|
||||
return m_realFactory->GetTrustLevel(trustLevel);
|
||||
}
|
||||
232
projects/WinDurango.KernelX/src/EraCoreWindow.cpp
Normal file
232
projects/WinDurango.KernelX/src/EraCoreWindow.cpp
Normal file
@@ -0,0 +1,232 @@
|
||||
#include "EraCoreWindow.h"
|
||||
#include <CoreWindow.h>
|
||||
#include <windows.applicationmodel.core.h>
|
||||
#include <winrt/Windows.ApplicationModel.h>
|
||||
#include <winrt/windows.storage.provider.h>
|
||||
|
||||
HRESULT CoreWindowEra::GetIids(ULONG *iidCount, IID **iids)
|
||||
{
|
||||
return m_realWindow->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::GetRuntimeClassName(HSTRING *className)
|
||||
{
|
||||
return m_realWindow->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::GetTrustLevel(TrustLevel *trustLevel)
|
||||
{
|
||||
return m_realWindow->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_get_Bounds(Rect *rect)
|
||||
{
|
||||
return m_realWindow->get_Bounds(rect);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_get_Dispatcher(ICoreDispatcher **dispatcher)
|
||||
{
|
||||
return m_realWindow->get_Dispatcher(dispatcher);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_get_IsInputEnabled(boolean *value)
|
||||
{
|
||||
return m_realWindow->get_IsInputEnabled(value);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_set_IsInputEnabled(boolean value)
|
||||
{
|
||||
return m_realWindow->put_IsInputEnabled(value);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_get_Visible(boolean *value)
|
||||
{
|
||||
return m_realWindow->get_Visible(value);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::Activate()
|
||||
{
|
||||
return m_realWindow->Activate();
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::Close()
|
||||
{
|
||||
return m_realWindow->Close();
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::GetAsyncKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates *KeyState)
|
||||
{
|
||||
return m_realWindow->GetAsyncKeyState(virtualKey, KeyState);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::GetKeyState(ABI::Windows::System::VirtualKey virtualKey,
|
||||
ABI::Windows::UI::Core::CoreVirtualKeyStates *KeyState)
|
||||
{
|
||||
return m_realWindow->GetKeyState(virtualKey, KeyState);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_Activated(ITypedEventHandler<CoreWindow *, WindowActivatedEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_Activated(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_Activated(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_Activated(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_CharacterReceived(
|
||||
ITypedEventHandler<CoreWindow *, CharacterReceivedEventArgs *> *handler, EventRegistrationToken *token)
|
||||
{
|
||||
*token = EventRegistrationToken();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_CharacterReceived(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_CharacterReceived(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_Closed(ITypedEventHandler<CoreWindow *, CoreWindowEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
*token = EventRegistrationToken();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_Closed(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_Closed(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_InputEnabled(ITypedEventHandler<CoreWindow *, InputEnabledEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_InputEnabled(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_InputEnabled(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_InputEnabled(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_KeyDown(ITypedEventHandler<CoreWindow *, KeyEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
*token = EventRegistrationToken();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_KeyDown(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_KeyDown(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_KeyUp(ITypedEventHandler<CoreWindow *, KeyEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
*token = EventRegistrationToken();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_KeyUp(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_KeyUp(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_PointerMoved(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_PointerMoved(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_PointerMoved(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_PointerMoved(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_PointerEntered(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_PointerEntered(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_PointerEntered(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_PointerEntered(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_PointerExited(ITypedEventHandler<CoreWindow *, PointerEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_PointerExited(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_PointerExited(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_PointerExited(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_SizeChanged(ITypedEventHandler<CoreWindow *, WindowSizeChangedEventArgs *> *handler,
|
||||
EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_SizeChanged(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_SizeChanged(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_SizeChanged(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_add_VisibilityChanged(
|
||||
ITypedEventHandler<CoreWindow *, VisibilityChangedEventArgs *> *handler, EventRegistrationToken *token)
|
||||
{
|
||||
return m_realWindow->add_VisibilityChanged(handler, token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::_abi_remove_VisibilityChanged(EventRegistrationToken token)
|
||||
{
|
||||
return m_realWindow->remove_VisibilityChanged(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowEra::QueryInterface(const IID &riid, void **ppvObject)
|
||||
{
|
||||
if (riid == __uuidof(IUnknown) || riid == __uuidof(IInspectable) || riid == __uuidof(ICoreWindowEra) ||
|
||||
riid == __uuidof(IAgileObject))
|
||||
{
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
else if (riid == __uuidof(ICoreWindowInterop))
|
||||
{
|
||||
return m_realWindow->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
char iidstr[sizeof("{AAAAAAAA-BBBB-CCCC-DDEE-FFGGHHIIJJKK}")];
|
||||
OLECHAR iidwstr[sizeof(iidstr)];
|
||||
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
|
||||
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
|
||||
MessageBoxA(nullptr, iidstr, typeid(*this).name(), MB_OK);
|
||||
*ppvObject = nullptr;
|
||||
return E_NOINTERFACE;
|
||||
}
|
||||
|
||||
ULONG CoreWindowEra::AddRef()
|
||||
{
|
||||
if (m_realWindow)
|
||||
m_realWindow->AddRef();
|
||||
return InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
ULONG CoreWindowEra::Release()
|
||||
{
|
||||
if (m_realWindow)
|
||||
m_realWindow->Release();
|
||||
ULONG refCount = InterlockedDecrement(&m_RefCount);
|
||||
if (refCount == 0)
|
||||
delete this;
|
||||
return refCount;
|
||||
}
|
||||
@@ -1,6 +1,9 @@
|
||||
#pragma comment(lib, "runtimeobject.lib")
|
||||
#include "Hooks.h"
|
||||
#include "kernelx.h"
|
||||
#include "CurrentApp.h"
|
||||
#include <detours.h>
|
||||
#include <wrl.h>
|
||||
|
||||
using namespace ABI::Windows::ApplicationModel::Store;
|
||||
|
||||
@@ -126,6 +129,25 @@ HRESULT __stdcall EraAppActivateInstance(IActivationFactory *thisptr, IInspectab
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT __stdcall EraGetForCurrentThread(ICoreWindowStatic *pThis, CoreWindow **ppWindow)
|
||||
{
|
||||
HRESULT hr = TrueGetForCurrentThread(pThis, ppWindow);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (*ppWindow == NULL)
|
||||
{
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (IsXboxCallee())
|
||||
*reinterpret_cast<ICoreWindowEra **>(ppWindow) = new CoreWindowEra(*ppWindow);
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, void **factory)
|
||||
{
|
||||
@@ -153,6 +175,49 @@ inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, voi
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
if (rss == std::string("Windows.ApplicationModel.Core.CoreApplication"))
|
||||
{
|
||||
ComPtr<IActivationFactory> realFactory;
|
||||
|
||||
HRESULT hr = RoGetActivationFactory(Microsoft::WRL::Wrappers::HStringReference::HStringReference(
|
||||
RuntimeClass_Windows_ApplicationModel_Core_CoreApplication)
|
||||
.Get(),
|
||||
IID_PPV_ARGS(&realFactory));
|
||||
|
||||
if (FAILED(hr))
|
||||
return hr;
|
||||
|
||||
ComPtr<CoreApplicationEra> wrappedFactory = Make<CoreApplicationEra>(realFactory);
|
||||
|
||||
return wrappedFactory.CopyTo(iid, factory);
|
||||
}
|
||||
|
||||
if (rss == std::string("Windows.UI.Core.CoreWindow"))
|
||||
{
|
||||
ComPtr<ICoreWindowStatic> coreWindowStatic;
|
||||
HRESULT hr = RoGetActivationFactory(
|
||||
Microsoft::WRL::Wrappers::HStringReference::HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(),
|
||||
IID_PPV_ARGS(&coreWindowStatic));
|
||||
if (FAILED(hr))
|
||||
{
|
||||
DebugBreak();
|
||||
return hr;
|
||||
}
|
||||
|
||||
if (!TrueGetForCurrentThread)
|
||||
{
|
||||
*reinterpret_cast<void **>(&TrueGetForCurrentThread) =
|
||||
(*reinterpret_cast<void ***>(coreWindowStatic.Get()))[6];
|
||||
|
||||
DetourTransactionBegin();
|
||||
DetourUpdateThread(GetCurrentThread());
|
||||
DetourAttach(reinterpret_cast<PVOID *>(&TrueGetForCurrentThread), reinterpret_cast<PVOID>(EraGetForCurrentThread));
|
||||
DetourTransactionCommit();
|
||||
}
|
||||
|
||||
return coreWindowStatic.CopyTo(iid, factory);
|
||||
}
|
||||
|
||||
if (!p_GetActivationFactory)
|
||||
{
|
||||
HINSTANCE hGetActivationFactoryDLL = LoadLibrary("winrt_x.dll");
|
||||
|
||||
@@ -228,7 +228,7 @@ EXTERN_C LPVOID __stdcall EraVirtualAllocEx(HANDLE hProcess, LPVOID lpAddress, S
|
||||
{
|
||||
if (flAllocationType & MEM_GRAPHICS)
|
||||
{
|
||||
flProtect = PAGE_READONLY;
|
||||
//flProtect = PAGE_READONLY;
|
||||
flAllocationType |= MEM_COMMIT;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user