Added ICoreApplicationResourceAvailability.
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-16 20:06:53 -05:00
parent 8d6de4a33c
commit 920467987f
9 changed files with 93 additions and 16 deletions

View File

@ -0,0 +1,19 @@
#include "pch.h"
#include "CoreApplicationResourceAvailabilityX.h"
INT32 CoreApplicationResourceAvailabilityX::_abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability)
{
*resourceAvailability = Full;
return S_OK;
}
INT32 CoreApplicationResourceAvailabilityX::_abi_add_ResourceAvailabilityChanged(__FIEventHandler_1_IInspectable* handler, EventRegistrationToken* token)
{
return S_OK;
}
INT32 CoreApplicationResourceAvailabilityX::_abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token)
{
return S_OK;
}

View File

@ -0,0 +1,10 @@
#pragma once
#include "ICoreApplicationResourceAvailabilityX.h"
class CoreApplicationResourceAvailabilityX : public ICoreApplicationResourceAvailabilityX
{
public:
virtual INT32 _abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability) override;
virtual INT32 _abi_add_ResourceAvailabilityChanged(__FIEventHandler_1_IInspectable* handler, EventRegistrationToken* token) override;
virtual INT32 _abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token) override;
};

View File

@ -36,11 +36,17 @@ INT32 CoreApplicationX::_abi_remove_Suspending(EventRegistrationToken token)
return m_IapplicationCore->remove_Suspending(token);
}
//INT32 CoreApplicationX::_abi_get_ResourceAvailability(Windows::ApplicationModel::Core::ResourceAvailability*)
INT32 CoreApplicationX::_abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability)
{
// TODO: Stubbed for now.
*resourceAvailability = Full;
return S_OK;
}
INT32 CoreApplicationX::_abi_get_ResourceAvailability()
{
//Stubbed at this moment.
return 0;
return S_OK;
}
INT32 CoreApplicationX::_abi_add_ResourceAvailabilityChanged(winrt::Windows::Foundation::EventHandler<IInspectable>* handler, EventRegistrationToken* token)

View File

@ -24,6 +24,7 @@ public:
INT32 _abi_remove_Resuming(EventRegistrationToken token) override;
INT32 _abi_add_Suspending(__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs* handler, EventRegistrationToken* token) override;
INT32 _abi_remove_Suspending(EventRegistrationToken token) override;
INT32 _abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability) override;
INT32 _abi_get_ResourceAvailability() override;
INT32 _abi_add_ResourceAvailabilityChanged(winrt::Windows::Foundation::EventHandler<IInspectable>* handler, EventRegistrationToken* token) override;
INT32 _abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token) override;

View File

@ -0,0 +1,23 @@
#pragma once
#include <winrt/Windows.ApplicationModel.h>
#include <windows.ui.core.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;
enum ResourceAvailability : INT32 {
Full = 0x0000,
Constrained = 0x0001,
FullWithExtendedSystemReserve = 0x0002,
};
class ICoreApplicationResourceAvailabilityX : public IInspectable
{
public:
virtual INT32 _abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability) = 0;
virtual INT32 _abi_add_ResourceAvailabilityChanged(__FIEventHandler_1_IInspectable* handler, EventRegistrationToken* token) = 0;
virtual INT32 _abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token) = 0;
};

View File

@ -2,11 +2,12 @@
#include <winrt/Windows.ApplicationModel.h>
#include <windows.ui.core.h>
#include "ICoreApplicationResourceAvailabilityX.h"
using namespace ABI::Windows::ApplicationModel::Activation;
using namespace ABI::Windows::ApplicationModel;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::ApplicationModel::Activation;
using namespace ABI::Windows::ApplicationModel::Core;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::System;
class ICoreApplicationX : public IInspectable
@ -16,7 +17,7 @@ public:
virtual INT32 _abi_remove_Resuming(EventRegistrationToken token) = 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_get_ResourceAvailability(Windows::ApplicationModel::Core::ResourceAvailability*) = 0;
virtual INT32 _abi_get_ResourceAvailability(ResourceAvailability* resourceAvailability) = 0;
virtual INT32 _abi_get_ResourceAvailability() = 0;
virtual INT32 _abi_add_ResourceAvailabilityChanged(winrt::Windows::Foundation::EventHandler<IInspectable>* handler, EventRegistrationToken* token) = 0;
virtual INT32 _abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token) = 0;
@ -42,5 +43,4 @@ public:
virtual HRESULT QueryInterface(const IID& riid, void** ppvObject) override = 0;
virtual ULONG AddRef() override = 0;
virtual ULONG Release() override = 0;
};

View File

@ -1,5 +1,6 @@
#pragma once
#include <winrt/Windows.ApplicationModel.h>
#include "CoreApplicationX.h"
inline bool IsClassName(HSTRING classId, const char* classIdName)
@ -19,8 +20,8 @@ DllGetForCurrentThreadFunc pDllGetForCurrentThread = nullptr;
DllGetForCurrentThreadFunc_App pDllGetForCurrentThread_App = nullptr;
DllGetActivationFactoryFunc pDllGetActivationFactory = nullptr;
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread_App)(ICoreApplication* application, winrt::Windows::ApplicationModel::Core::CoreApplication** Application);
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread)(ICoreWindowStatic* staticWindow, CoreWindow** window);
HRESULT(STDMETHODCALLTYPE* TrueGetForCurrentThread_App)(ICoreApplication* application, winrt::Windows::ApplicationModel::Core::CoreApplication** Application);
HRESULT(WINAPI* TrueRoGetActivationFactory)(HSTRING classId, REFIID iid, void** factory) = RoGetActivationFactory;
inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook(ICoreWindowStatic* paramThis, CoreWindow** window)
@ -36,8 +37,7 @@ inline HRESULT STDMETHODCALLTYPE GetForCurrentThread_Hook(ICoreWindowStatic* par
return hr;
}
inline HRESULT STDMETHODCALLTYPE GetForCurrentThreadApp_Hook(ICoreApplication* paramThis,
winrt::Windows::ApplicationModel::Core::CoreApplication** Application)
inline HRESULT STDMETHODCALLTYPE GetForCurrentThreadApp_Hook(ICoreApplication* paramThis, winrt::Windows::ApplicationModel::Core::CoreApplication** Application)
{
// ReSharper disable once CppLocalVariableMayBeConst
HRESULT hrApp = TrueGetForCurrentThread_App(paramThis, Application);
@ -69,9 +69,13 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
ComPtr<IActivationFactory> _factory;
if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication"))
if (IsClassName(classId, "Windows.ApplicationModel.Core.ICoreApplicationResourceAvailability"))
{
ComPtr<ABI::Windows::ApplicationModel::Core::ICoreApplication> ICoreApplicationPtr;
}
else if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication"))
{
ComPtr<ICoreApplication> ICoreApplicationPtr;
hr = RoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&ICoreApplicationPtr));
@ -100,5 +104,4 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
}
return hr;
}

View File

@ -93,10 +93,12 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="CoreApplicationResourceAvailabilityX.h" />
<ClInclude Include="CoreApplicationX.h" />
<ClInclude Include="CoreWindowX.h" />
<ClInclude Include="framework.h" />
<ClInclude Include="hooks.h" />
<ClInclude Include="ICoreApplicationResourceAvailabilityX.h" />
<ClInclude Include="ICoreApplicationX.h" />
<ClInclude Include="ICoreWindowX.h" />
<ClInclude Include="kernelx.h" />
@ -104,6 +106,7 @@
<ClInclude Include="utils.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="CoreApplicationResourceAvailabilityX.cpp" />
<ClCompile Include="CoreApplicationX.cpp" />
<ClCompile Include="CoreWindowX.cpp" />
<ClCompile Include="dllmain.cpp" />

View File

@ -8,6 +8,9 @@
<Filter>Windows.UI.Core</Filter>
</ClCompile>
<ClCompile Include="CoreApplicationX.cpp">
<Filter>Windows.ApplicationModel.Core\CoreApplication</Filter>
</ClCompile>
<ClCompile Include="CoreApplicationResourceAvailabilityX.cpp">
<Filter>Windows.ApplicationModel.Core</Filter>
</ClCompile>
</ItemGroup>
@ -23,10 +26,16 @@
</ClInclude>
<ClInclude Include="hooks.h" />
<ClInclude Include="utils.h" />
<ClInclude Include="ICoreApplicationX.h">
<Filter>Windows.ApplicationModel.Core\CoreApplication</Filter>
</ClInclude>
<ClInclude Include="CoreApplicationX.h">
<Filter>Windows.ApplicationModel.Core\CoreApplication</Filter>
</ClInclude>
<ClInclude Include="ICoreApplicationResourceAvailabilityX.h">
<Filter>Windows.ApplicationModel.Core</Filter>
</ClInclude>
<ClInclude Include="ICoreApplicationX.h">
<ClInclude Include="CoreApplicationResourceAvailabilityX.h">
<Filter>Windows.ApplicationModel.Core</Filter>
</ClInclude>
</ItemGroup>
@ -43,5 +52,8 @@
<Filter Include="Windows.ApplicationModel.Core">
<UniqueIdentifier>{22d419bf-d552-4ab7-a078-94a3d47e5051}</UniqueIdentifier>
</Filter>
<Filter Include="Windows.ApplicationModel.Core\CoreApplication">
<UniqueIdentifier>{ee124397-8dbc-48c3-869f-10201a7d04fd}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>