feat!: added gametransportcontrols implementations and fixed winrt prop error

This commit is contained in:
CT5
2026-01-28 20:08:58 +11:00
parent 33e1ccd198
commit 3cb8f89417
22 changed files with 463 additions and 169 deletions

View File

@@ -25,17 +25,17 @@ namespace wd::common {
* >> [WinDurango::Common::Storage] 11:25AM 26/12/2025 - Failed to do smth - Code 5
*/
template<typename... Args>
void Log(std::string codespace, Args&&... args) {
void Log(std::string codespace, fmt::format_string<Args...> fmt, Args&&... args) {
if (!isInitialized) {
std::cout << "[WinDurango::Common::Logging.Initialize] - Critical: Logging isn't Initiailized\n";
return;
}
try {
if (log.find(codespace) != log.end()) {
log[codespace]->info(std::forward<Args>(args)...);
log[codespace]->info(fmt, std::forward<Args>(args)...);
} else {
AddLogger(codespace);
log[codespace]->info(std::forward<Args>(args)...);
log[codespace]->info(fmt, std::forward<Args>(args)...);
}
} catch (const spdlog::spdlog_ex& e) {
std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";
@@ -47,17 +47,17 @@ namespace wd::common {
}
template<typename... Args>
void Warn(std::string codespace, Args&&... args) {
void Warn(std::string codespace, fmt::format_string<Args...> fmt, Args&&... args) {
if (!isInitialized) {
std::cout << "[WinDurango::Common::Logging.Initialize] - Critical: Logging isn't Initiailized\n";
return;
}
try {
if (log.find(codespace) != log.end()) {
log[codespace]->warn(std::forward<Args>(args)...);
log[codespace]->warn(fmt, std::forward<Args>(args)...);
} else {
AddLogger(codespace);
log[codespace]->warn(std::forward<Args>(args)...);
log[codespace]->warn(fmt, std::forward<Args>(args)...);
}
} catch (const spdlog::spdlog_ex& e) {
std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";
@@ -69,17 +69,17 @@ namespace wd::common {
}
template<typename... Args>
void Error(std::string codespace, Args&&... args) {
void Error(std::string codespace, fmt::format_string<Args...> fmt, Args&&... args) {
if (!isInitialized) {
std::cout << "[WinDurango::Common::Logging.Initialize] - Critical: Logging isn't Initiailized\n";
return;
}
try {
if (log.find(codespace) != log.end()) {
log[codespace]->error(std::forward<Args>(args)...);
log[codespace]->error(fmt, std::forward<Args>(args)...);
} else {
AddLogger(codespace);
log[codespace]->error(std::forward<Args>(args)...);
log[codespace]->error(fmt, std::forward<Args>(args)...);
}
} catch (const spdlog::spdlog_ex& e) {
std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";

View File

@@ -11,11 +11,12 @@
namespace wd::common {
class WD_API WinDurango {
public:
static WinDurango *GetInstance();
static std::shared_ptr<WinDurango> GetInstance();
WinDurango() = default;
void Init(std::shared_ptr<interfaces::storage::Directory> rootDir);
bool inited();
Config config;
Logging log;

View File

@@ -17,7 +17,8 @@ void wd::common::Logging::Initialize() {
log["WinDurango"] = logg;
log["WinDurango"]->set_pattern("[%n] [%H:%M:%S] [thread %t] - %^%l%$: %v");
logg->info("Setting Log File: {}", pFile->fullfilepath().string());
log["WinDurango"]->info("Setting Log File: {}", pFile->fullfilepath().string());
log["WinDurango"]->flush_on(spdlog::level::info);
isInitialized = true;
} catch (const spdlog::spdlog_ex& e) {
std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";
@@ -44,6 +45,7 @@ void wd::common::Logging::AddLogger(std::string codespace) {
log[codespace] = logg;
log[codespace]->set_pattern("[%n] [%H:%M:%S] [thread %t] - %^%l%$: %v");
log[codespace]->flush_on(spdlog::level::info);
} catch (const spdlog::spdlog_ex& e) {
std::cout << "[WinDurango::Common::Logging.spdlog] - Critical: " << e.what() << "\n";
} catch (const std::exception& e) {

View File

@@ -5,22 +5,29 @@
namespace wd::common
{
WinDurango *WinDurango::GetInstance()
std::shared_ptr<WinDurango> WinDurango::GetInstance()
{
static WinDurango Instance = WinDurango(); // if we don't declare it in src, it will make multiple instances per
static std::shared_ptr<WinDurango> Instance = std::make_shared<WinDurango>(); // if we don't declare it in src, it will make multiple instances per
// header import in different libs afaik
return &Instance;
return Instance;
}
bool WinDurango::inited() {
return _inited;
}
void WinDurango::Init(std::shared_ptr<interfaces::storage::Directory> rootDir) {
if (this->_inited) {
return;
}
try {
rootDir->open();
std::time_t timestamp = std::time(nullptr);
std::tm datetm = *std::localtime(&timestamp);
char* buf;
char buf[512];
std::strftime(buf, sizeof(buf), "%d.%m.%Y", &datetm);
std::string date(buf);

View File

@@ -20,6 +20,7 @@ add_library(WinDurango.Implementation.WinRT SHARED ${FILES})
target_include_directories(WinDurango.Implementation.WinRT PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/WinDurango.Implementation.WinRT>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/projects/WinDurango.Common/include>
)
set_property(

View File

@@ -3,7 +3,7 @@
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/base.h>
#include "WinDurango.Implementation.WinRT/WinDurangoWinRT.h"
#include "WinDurango.Implementation.WinRT/WinDurangoImplWinRT.h"
#include "WinDurango.Common/interfaces/Storage/Directory.h"
#include "WinDurango.Implementation.WinRT/Interfaces/Storage/File.h"

View File

@@ -5,7 +5,7 @@
#include <winrt/Windows.Foundation.h>
#include <winrt/Windows.Foundation.Collections.h>
#include <winrt/base.h>
#include "WinDurango.Implementation.WinRT/WinDurangoWinRT.h"
#include "WinDurango.Implementation.WinRT/WinDurangoImplWinRT.h"
#include "WinDurango.Common/Interfaces/Storage/File.h"
using namespace winrt::Windows::Storage;

View File

@@ -1,6 +1,6 @@
#include <windows.h>
#include <iostream>
#include "WinDurangoWinRT.h"
#include "WinDurangoImplWinRT.h"
/*
* Found here

View File

@@ -17,6 +17,7 @@ FetchContent_MakeAvailable(safetyhook)
set(FILES
src/kernelx.cpp
src/dllmain.cpp
src/Hooks.cpp
include/WinDurango.KernelX/kernelx.h
include/WinDurango.KernelX/Logan.h
include/WinDurango.KernelX/Hooks.h
@@ -24,7 +25,7 @@ set(FILES
add_library(WinDurango.KernelX SHARED ${FILES})
target_link_libraries(WinDurango.KernelX PRIVATE WinDurango.Common)
target_link_libraries(WinDurango.KernelX PRIVATE WinDurango.Common WinDurango.Implementation.WinRT)
target_link_options(WinDurango.KernelX
PUBLIC
@@ -33,6 +34,8 @@ target_link_options(WinDurango.KernelX
target_include_directories(WinDurango.KernelX PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/include/WinDurango.KernelX/
${CMAKE_SOURCE_DIR}/projects/WinDurango.Common/include
${CMAKE_SOURCE_DIR}/projects/WinDurango.Implementation.WinRT/include
)
set_target_properties(WinDurango.KernelX PROPERTIES

View File

@@ -5,141 +5,17 @@
#include <Shlwapi.h>
#include <winrt/windows.storage.provider.h>
#include <windows.applicationmodel.core.h>
#include <string>
#include <locale>
#include <codecvt>
//Provided by XWine1, all credits to them.
//(This is from the old impl but we can use it just fine).
HRESULT XWineGetImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ LPCSTR Import,
_Out_ PIMAGE_THUNK_DATA *pThunk)
{
if (ImportModule == nullptr)
return E_INVALIDARG;
if (pThunk == nullptr)
return E_POINTER;
if (Module == nullptr)
Module = GetModuleHandleW(nullptr);
auto dosHeader = (PIMAGE_DOS_HEADER)Module;
auto ntHeaders = (PIMAGE_NT_HEADERS)((PBYTE)Module + dosHeader->e_lfanew);
auto directory = &ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
if (directory->VirtualAddress == 0)
return E_FAIL;
auto peImports = (PIMAGE_IMPORT_DESCRIPTOR)((PBYTE)Module + directory->VirtualAddress);
for (size_t i = 0; peImports[i].Name; i++)
{
if (GetModuleHandleA((LPCSTR)((PBYTE)Module + peImports[i].Name)) != ImportModule)
continue;
auto iatThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].FirstThunk);
auto intThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].OriginalFirstThunk);
for (size_t j = 0; intThunks[j].u1.AddressOfData; j++)
{
if ((intThunks[j].u1.AddressOfData & IMAGE_ORDINAL_FLAG) != 0)
{
if (!IS_INTRESOURCE(Import))
continue;
if (((intThunks[j].u1.Ordinal & ~IMAGE_ORDINAL_FLAG) == (ULONG_PTR)Import))
{
*pThunk = &iatThunks[j];
return S_OK;
}
continue;
}
if (strcmp(((PIMAGE_IMPORT_BY_NAME)((PBYTE)Module + intThunks[j].u1.AddressOfData))->Name, Import))
continue;
*pThunk = &iatThunks[j];
return S_OK;
}
}
*pThunk = nullptr;
return E_FAIL;
}
HRESULT XWinePatchImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function)
{
DWORD protect;
PIMAGE_THUNK_DATA pThunk;
HRESULT hr = XWineGetImport(Module, ImportModule, Import, &pThunk);
if (FAILED(hr)) return hr;
if (!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &protect))
return GetLastError();
pThunk->u1.Function = (ULONG_PTR)Function;
if (!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), protect, &protect))
return GetLastError();
return S_OK;
}
HRESULT PatchNeededImports(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function)
{
PIMAGE_THUNK_DATA pThunk;
HRESULT hr = XWineGetImport(Module, ImportModule, Import, &pThunk);
if (FAILED(hr))
return hr;
return XWinePatchImport(Module, ImportModule, Import, Function);
}
HMODULE GetRuntimeModule()
{
std::array<const wchar_t *, 3> modules = {L"vccorlib140.dll", L"vccorlib110.dll", L"vccorlib120.dll"};
static HMODULE hModule = nullptr;
if (hModule != nullptr)
{
return hModule;
}
for (auto &module : modules)
{
hModule = GetModuleHandleW(module);
if (hModule != nullptr)
{
break;
}
}
return hModule;
}
inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, void **factory)
{
const wchar_t *rawString = WindowsGetStringRawBuffer(classId, nullptr);
MessageBoxW(nullptr, rawString, L"EraRoGetActivationFactory", MB_OK | MB_ICONERROR);
return E_NOINTERFACE;
}
HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void **ppFactory)
{
HRESULT hr = 0;
HSTRING className;
HSTRING_HEADER classNameHeader;
hr = WindowsCreateStringReference(str, wcslen(str), &classNameHeader, &className);
if (FAILED(hr))
return hr;
hr = EraRoGetActivationFactory(className, riid, ppFactory);
if (FAILED(hr))
DebugBreak();
WindowsDeleteString(className);
return hr;
}
_Out_ PIMAGE_THUNK_DATA *pThunk);
HRESULT XWinePatchImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function);
HRESULT PatchNeededImports(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function);
HMODULE GetRuntimeModule();
inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, void **factory);
HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void **ppFactory);

View File

@@ -0,0 +1,153 @@
#include "Hooks.h"
#include "WinDurango.Implementation.WinRT/Interfaces/Storage/Directory.h"
#include "WinDurango.Common/Interfaces/Storage/Directory.h"
#include "WinDurango.Common/WinDurango.h"
std::shared_ptr<wd::common::WinDurango> winDurango;
HRESULT XWineGetImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ LPCSTR Import,
_Out_ PIMAGE_THUNK_DATA *pThunk)
{
if (ImportModule == nullptr)
return E_INVALIDARG;
if (pThunk == nullptr)
return E_POINTER;
if (Module == nullptr)
Module = GetModuleHandleW(nullptr);
auto dosHeader = (PIMAGE_DOS_HEADER)Module;
auto ntHeaders = (PIMAGE_NT_HEADERS)((PBYTE)Module + dosHeader->e_lfanew);
auto directory = &ntHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT];
if (directory->VirtualAddress == 0)
return E_FAIL;
auto peImports = (PIMAGE_IMPORT_DESCRIPTOR)((PBYTE)Module + directory->VirtualAddress);
for (size_t i = 0; peImports[i].Name; i++)
{
if (GetModuleHandleA((LPCSTR)((PBYTE)Module + peImports[i].Name)) != ImportModule)
continue;
auto iatThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].FirstThunk);
auto intThunks = (PIMAGE_THUNK_DATA)((PBYTE)Module + peImports[i].OriginalFirstThunk);
for (size_t j = 0; intThunks[j].u1.AddressOfData; j++)
{
if ((intThunks[j].u1.AddressOfData & IMAGE_ORDINAL_FLAG) != 0)
{
if (!IS_INTRESOURCE(Import))
continue;
if (((intThunks[j].u1.Ordinal & ~IMAGE_ORDINAL_FLAG) == (ULONG_PTR)Import))
{
*pThunk = &iatThunks[j];
return S_OK;
}
continue;
}
if (strcmp(((PIMAGE_IMPORT_BY_NAME)((PBYTE)Module + intThunks[j].u1.AddressOfData))->Name, Import))
continue;
*pThunk = &iatThunks[j];
return S_OK;
}
}
*pThunk = nullptr;
return E_FAIL;
}
HRESULT XWinePatchImport(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function)
{
DWORD protect;
PIMAGE_THUNK_DATA pThunk;
HRESULT hr = XWineGetImport(Module, ImportModule, Import, &pThunk);
if (FAILED(hr)) return hr;
if (!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), PAGE_READWRITE, &protect))
return GetLastError();
pThunk->u1.Function = (ULONG_PTR)Function;
if (!VirtualProtect(&pThunk->u1.Function, sizeof(ULONG_PTR), protect, &protect))
return GetLastError();
return S_OK;
}
HRESULT PatchNeededImports(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _In_ PCSTR Import, _In_ PVOID Function)
{
PIMAGE_THUNK_DATA pThunk;
HRESULT hr = XWineGetImport(Module, ImportModule, Import, &pThunk);
if (FAILED(hr))
return hr;
return XWinePatchImport(Module, ImportModule, Import, Function);
}
HMODULE GetRuntimeModule()
{
std::array<const wchar_t *, 3> modules = {L"vccorlib140.dll", L"vccorlib110.dll", L"vccorlib120.dll"};
static HMODULE hModule = nullptr;
if (hModule != nullptr)
{
return hModule;
}
for (auto &module : modules)
{
hModule = GetModuleHandleW(module);
if (hModule != nullptr)
{
break;
}
}
return hModule;
}
inline HRESULT WINAPI EraRoGetActivationFactory(HSTRING classId, REFIID iid, void **factory)
{
const wchar_t *rawString = WindowsGetStringRawBuffer(classId, nullptr);
MessageBoxW(nullptr, rawString, L"EraRoGetActivationFactory", MB_OK | MB_ICONERROR);
std::wstring rsws(rawString);
std::string rss(rsws.begin(), rsws.end());
winDurango->log.Log("WinDurango::KernelX", "EraRoGetActivationFactory: {}", rss);
return E_NOINTERFACE;
}
HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void **ppFactory)
{
winDurango = wd::common::WinDurango::GetInstance();
if (!winDurango->inited()) {
#ifndef CROSS_PLATFORM
std::shared_ptr<wd::common::interfaces::storage::Directory> rootDir = std::make_shared<wd::impl::winrt::interfaces::storage::WinRTDirectory>("");
winDurango->Init(rootDir);
#endif
}
HRESULT hr = 0;
HSTRING className;
HSTRING_HEADER classNameHeader;
hr = WindowsCreateStringReference(str, wcslen(str), &classNameHeader, &className);
if (FAILED(hr))
return hr;
hr = EraRoGetActivationFactory(className, riid, ppFactory);
if (FAILED(hr))
DebugBreak();
WindowsDeleteString(className);
return hr;
}

View File

@@ -38,26 +38,36 @@ execute_process(
-out "${CMAKE_CURRENT_SOURCE_DIR}\\Generated Files")
set(FILES
"include/WinDurango.WinRT/stub.h"
"src/Windows/Xbox/Media/GameTransportControls.cpp"
"src/Windows/Xbox/Media/GameTransportControlsButtonPressedEventArgs.cpp"
"src/Windows/Xbox/Media/GameTransportControlsPropertyChangedEventArgs.cpp"
"src/WinDurangoWinRT.cpp"
)
file(GLOB WINRT_FILES CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/*.h" "${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/winrt/*.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/winrt/*.h")
file(GLOB WINRT_FILES
"${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/winrt/*.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/Generated Files/winrt/impl/*.cpp"
)
add_library(WinDurango.WinRT SHARED ${FILES} ${WINRT_FILES} WinDurango.WinRT.def)
target_include_directories(WinDurango.WinRT PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
"${CMAKE_CURRENT_SOURCE_DIR}/include"
"${CMAKE_CURRENT_SOURCE_DIR}/include/WinDurango.WinRT"
"${CMAKE_CURRENT_SOURCE_DIR}/Generated Files"
"${CMAKE_SOURCE_DIR}/projects/WinDurango.Common/include"
)
set_property(
TARGET WinDurango.WinRT
PROPERTY VS_PACKAGE_REFERENCES
"Microsoft.Windows.CppWinRT_2.0.230706.1"
"Microsoft.Windows.CppWinRT_2.0.250303.1"
"Microsoft.WindowsAppSDK_1.4.231115000"
"Microsoft.Windows.SDK.BuildTools_10.0.22621.756"
"Microsoft.Windows.ImplementationLibrary_1.0.230629.1"
)
target_link_libraries(WinDurango.WinRT PRIVATE WinDurango.Common Microsoft::CppWinRT)
target_link_libraries(WinDurango.WinRT PRIVATE WinDurango.Common Microsoft::CppWinRT WindowsApp)
target_compile_definitions(WinDurango.WinRT PUBLIC
WINDURANGO_WINRT_COMPILER_NAME="${CMAKE_CXX_COMPILER_ID}"
@@ -67,10 +77,9 @@ target_compile_definitions(WinDurango.WinRT PUBLIC
WINDURANGO_WINRT_RC_VERSION=${PROJECT_VERSION_MAJOR},${PROJECT_VERSION_MINOR},${PROJECT_VERSION_PATCH}
)
set_target_properties(WinDurango.Implementation.WinRT PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(WinDurango.WinRT PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(${PROJECT_NAME} PROPERTIES VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION 10.0.18362.0)
target_compile_definitions(WinDurango.Implementation.WinRT PRIVATE _WINRT_DLL WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN)
target_compile_definitions(WinDurango.WinRT PRIVATE _WINRT_DLL WIN32_LEAN_AND_MEAN WINRT_LEAN_AND_MEAN)
if (WINRT_USE_CROSS_PLATFORM STREQUAL ON)
target_link_libraries(WinDurango.WinRT PUBLIC WinDurango.Implementation.Native)

View File

@@ -0,0 +1,5 @@
#pragma once
#include <Windows.h>
#include "WinDurango.Common/WinDurango.h"
extern std::shared_ptr<wd::common::WinDurango> p_wd;

View File

@@ -0,0 +1,45 @@
#pragma once
#include <Windows.h>
#include "Windows.Xbox.Media.GameTransportControls.g.h"
namespace winrt::Windows::Xbox::Media::implementation {
struct GameTransportControls : GameTransportControlsT<GameTransportControls> {
GameTransportControls() = default;
hstring Title();
void Title(hstring const& value);
hstring Subtitle();
void Subtitle(hstring const& value);
winrt::Windows::Xbox::Media::GamePlaybackStatus PlaybackStatus();
void PlaybackStatus(winrt::Windows::Xbox::Media::GamePlaybackStatus const& value);
winrt::Windows::Xbox::Media::SoundLevel SoundLevel();
bool IsEnabled();
void IsEnabled(bool value);
bool IsPlayEnabled();
void IsPlayEnabled(bool value);
bool IsPauseEnabled();
void IsPauseEnabled(bool value);
bool IsMenuEnabled();
void IsMenuEnabled(bool value);
bool IsViewEnabled();
void IsViewEnabled(bool value);
bool IsBackEnabled();
void IsBackEnabled(bool value);
winrt::event_token add_ButtonPressed(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsButtonPressedEventArgs> const& handler);
void remove_ButtonPressed(winrt::event_token const& token);
winrt::event_token add_PropertyChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsPropertyChangedEventArgs> const& handler);
void remove_PropertyChanged(winrt::event_token const& token);
private:
hstring _title;
hstring _subtitle;
winrt::Windows::Xbox::Media::GamePlaybackStatus _playbackStatus;
bool _isEnabled;
bool _isPlayEnabled;
bool _isPauseEnabled;
bool _isMenuEnabled;
bool _isViewEnabled;
bool _isBackEnabled;
winrt::event<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsButtonPressedEventArgs>> e_ButtonPressedHandler;
winrt::event<winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsPropertyChangedEventArgs>> e_PropertyChangedHandler;
};
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include <Windows.h>
#include "Windows.Xbox.Media.GameTransportControlsButtonPressedEventArgs.g.h"
namespace winrt::Windows::Xbox::Media::implementation {
struct GameTransportControlsButtonPressedEventArgs : GameTransportControlsButtonPressedEventArgsT<GameTransportControlsButtonPressedEventArgs> {
GameTransportControlsButtonPressedEventArgs() = default;
GameTransportControlsButton Button();
};
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include <Windows.h>
#include "Windows.Xbox.Media.GameTransportControlsPropertyChangedEventArgs.g.h"
namespace winrt::Windows::Xbox::Media::implementation {
struct GameTransportControlsPropertyChangedEventArgs : GameTransportControlsPropertyChangedEventArgsT<GameTransportControlsPropertyChangedEventArgs> {
GameTransportControlsPropertyChangedEventArgs() = default;
GameTransportControlsProperty Property();
};
}

View File

@@ -1,9 +0,0 @@
//
// Created by DexrnZacAttack on 1/23/26 using zPc-i2.
//
#ifndef WINDURANGO_STUB_H
#define WINDURANGO_STUB_H
// cant reload cmake without this
#endif // WINDURANGO_STUB_H

View File

@@ -0,0 +1,40 @@
#include "WinDurangoWinRT.h"
std::shared_ptr<wd::common::WinDurango> p_wd;
/*
* https://learn.microsoft.com/en-us/windows/win32/dlls/dllmain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved ) // reserved
{
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
p_wd = wd::common::WinDurango::GetInstance();
p_wd->log.Log("WinDurango::WinRT", "Initialized");
break;
case DLL_THREAD_ATTACH:
p_wd = wd::common::WinDurango::GetInstance();
p_wd->log.Log("WinDurango::WinRT", "Initialized");
break;
case DLL_THREAD_DETACH:
p_wd = wd::common::WinDurango::GetInstance();
p_wd->log.Log("WinDurango::WinRT", "Initialized");
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr)
{
break; // do not do cleanup if process termination scenario
}
// Perform any necessary cleanup.
break;
}
return TRUE; // Successful DLL_PROCESS_ATTACH.
}

View File

@@ -0,0 +1,123 @@
#include "Windows/Xbox/Media/GameTransportControls.h"
#include "WinDurangoWinRT.h"
namespace winrt::Windows::Xbox::Media::implementation {
hstring GameTransportControls::Title() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Title _out_");
return _title;
}
void GameTransportControls::Title(hstring const& value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Title _in_");
_title = value;
}
hstring GameTransportControls::Subtitle() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Subtitle _out_");
return _subtitle;
}
void GameTransportControls::Subtitle(hstring const& value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Subtitle _in_");
_subtitle = value;
}
winrt::Windows::Xbox::Media::GamePlaybackStatus GameTransportControls::PlaybackStatus() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: PlaybackStatus _out_");
return _playbackStatus;
}
void GameTransportControls::PlaybackStatus(winrt::Windows::Xbox::Media::GamePlaybackStatus const& value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: PlaybackStatus _in_");
_playbackStatus = value;
}
Windows::Xbox::Media::SoundLevel GameTransportControls::SoundLevel() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: SoundLevel");
return Windows::Xbox::Media::SoundLevel::Unknown;
}
bool GameTransportControls::IsEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsEnabled _out_");
return _isEnabled;
}
void GameTransportControls::IsEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsEnabled _in_");
_isEnabled = value;
}
bool GameTransportControls::IsPlayEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsPlayEnabled _out_");
return _isPlayEnabled;
}
void GameTransportControls::IsPlayEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsPlayEnabled _in_");
_isPlayEnabled = value;
}
bool GameTransportControls::IsPauseEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsPauseEnabled _out_");
return _isPauseEnabled;
}
void GameTransportControls::IsPauseEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsPauseEnabled _in_");
_isPauseEnabled = value;
}
bool GameTransportControls::IsMenuEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsMenuEnabled _out_");
return _isMenuEnabled;
}
void GameTransportControls::IsMenuEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsMenuEnabled _in_");
_isMenuEnabled = value;
}
bool GameTransportControls::IsViewEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsViewEnabled _out_");
return _isViewEnabled;
}
void GameTransportControls::IsViewEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsViewEnabled _in_");
_isViewEnabled = value;
}
bool GameTransportControls::IsBackEnabled() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsBackEnabled _out_");
return _isBackEnabled;
}
void GameTransportControls::IsBackEnabled(bool value) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: IsBackEnabled _in_");
_isBackEnabled = value;
}
/*
* Dont use EventRegistrationToken
* https://stackoverflow.com/questions/63346461/namespace-winrtwindowsfoundationeventregistrationtoken-has-no-member-ev
*/
winrt::event_token GameTransportControls::add_ButtonPressed(Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsButtonPressedEventArgs> const& handler) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: add_ButtonPressed");
return e_ButtonPressedHandler.add(handler);
}
void GameTransportControls::remove_ButtonPressed(winrt::event_token const& token) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: remove_ButtonPressed");
e_ButtonPressedHandler.remove(token);
}
winrt::event_token GameTransportControls::add_PropertyChanged(Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Media::GameTransportControls, winrt::Windows::Xbox::Media::GameTransportControlsPropertyChangedEventArgs> const& handler) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: add_PropertyChanged");
return e_PropertyChangedHandler.add(handler);
}
void GameTransportControls::remove_PropertyChanged(winrt::event_token const& token) {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: remove_PropertyChanged");
e_PropertyChangedHandler.remove(token);
}
}

View File

@@ -0,0 +1,9 @@
#include "Windows/Xbox/Media/GameTransportControlsButtonPressedEventArgs.h"
#include "WinDurangoWinRT.h"
namespace winrt::Windows::Xbox::Media::implementation {
GameTransportControlsButton GameTransportControlsButtonPressedEventArgs::Button() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Button");
return GameTransportControlsButton::Play;
}
}

View File

@@ -0,0 +1,9 @@
#include "Windows/Xbox/Media/GameTransportControlsPropertyChangedEventArgs.h"
#include "WinDurangoWinRT.h"
namespace winrt::Windows::Xbox::Media::implementation {
GameTransportControlsProperty GameTransportControlsPropertyChangedEventArgs::Property() {
p_wd->log.Warn("WinDurango::WinRT::Windows::Xbox::Media", "Unimplemented: Property");
return GameTransportControlsProperty::Unknown;
}
}