mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-01-06 03:09:42 -06:00
Refactor logging system and remove deprecated methods
This commit introduces a new `Logger` class to replace all instances of `printf` and `DEBUG_LOG` throughout the codebase. Key changes include: - Replaced logging calls in `Audio2.cpp` and `appmodel.cpp` with structured log levels (`LOG_WARNING`, `LOG_DEBUG`, etc.). - Removed `DebugLogger.h` and `Logger.cpp`, consolidating logging functionality into `Logger.h`. - Added `Config.h` for configuration management using TOML files. - Updated project files to reflect the removal of old logging files and inclusion of the new logging system. These changes enhance logging capabilities, improve code maintainability, and standardize logging practices across the codebase.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
#include <xaudio2.h>
|
||||
#include <wrl.h>
|
||||
#include <stdio.h>
|
||||
#include "../common/Logger.h"
|
||||
|
||||
#define WAVE_FORMAT_XMA2 0x166
|
||||
|
||||
@@ -258,26 +259,26 @@ HRESULT STDAPICALLTYPE CreateXAudio2Object(
|
||||
|
||||
HRESULT STDAPICALLTYPE CreateAudioReverb_X()
|
||||
{
|
||||
printf("[XAudio]: CreateAudioReverb_X IS STUBBED\n");
|
||||
LOG_WARNING("[XAudio]: CreateAudioReverb_X IS STUBBED\n");
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDAPICALLTYPE CreateAudioVolumeMeter_X()
|
||||
{
|
||||
printf("[XAudio]: CreateAudioVolumeMeter_X IS STUBBED\n");
|
||||
LOG_WARNING("[XAudio]: CreateAudioVolumeMeter_X IS STUBBED\n");
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDAPICALLTYPE CreateFX_X()
|
||||
{
|
||||
printf("[XAudio]: CreateFX_X IS STUBBED\n");
|
||||
LOG_WARNING("[XAudio]: CreateFX_X IS STUBBED\n");
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDAPICALLTYPE X3DAudioCalculate_X()
|
||||
{
|
||||
printf("[XAudio]: X3DAudioCalculate_X IS STUBBED\n");
|
||||
LOG_WARNING("[XAudio]: X3DAudioCalculate_X IS STUBBED\n");
|
||||
return S_OK;
|
||||
}
|
||||
HRESULT STDAPICALLTYPE X3DAudioInitialize_X()
|
||||
{
|
||||
printf("[XAudio]: X3DAudioInitialize_X IS STUBBED\n");
|
||||
LOG_WARNING("[XAudio]: X3DAudioInitialize_X IS STUBBED\n");
|
||||
return S_OK;
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <strsafe.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "../common/DebugLogger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
CRITICAL_SECTION CriticalSection;
|
||||
__int64 qword_18009E948 = 0;
|
||||
@@ -45,7 +45,7 @@ namespace AppModel {
|
||||
}
|
||||
__int64 __fastcall GetCurrentPackageFullName_X(std::wstring& packageFullName)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("GetCurrentPackageFullName %s", packageFullName);
|
||||
packageFullName.clear( );
|
||||
//if ((NtCurrentPeb( )->BitField & 0x20) == 0)
|
||||
// return 15700;
|
||||
@@ -92,7 +92,7 @@ namespace AppModel {
|
||||
}
|
||||
__int64 __fastcall GetPackagesByPackageFamily_X(LPCWSTR lpSubKey, std::vector<std::wstring>& packageList)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("GetPackagesByPackageFamily_X %s", lpSubKey ? lpSubKey : L"nullptr");
|
||||
if (lpSubKey == nullptr)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
@@ -172,12 +172,12 @@ HRESULT CreateRandomAccessStreamOverStream_X(
|
||||
|
||||
__int64 __fastcall DllGetActivationFactory_X(HSTRING string, PVOID Ptr)
|
||||
{
|
||||
DEBUG_LOG( ); return 0;
|
||||
LOG_NOT_IMPLEMENTED( ); return 0;
|
||||
}
|
||||
|
||||
HRESULT __stdcall DllGetClassObject_X(const IID* const rclsid, const IID* const riid, LPVOID* ppv)
|
||||
{
|
||||
DEBUG_LOG( ); return 0;
|
||||
LOG_NOT_IMPLEMENTED( ); return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetApplicationUserModelId_X(
|
||||
@@ -185,31 +185,31 @@ LONG __stdcall GetApplicationUserModelId_X(
|
||||
UINT32* applicationUserModelIdLength,
|
||||
PWSTR applicationUserModelId)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return GetCurrentApplicationUserModelId_X(applicationUserModelIdLength, applicationUserModelId);
|
||||
}
|
||||
|
||||
__int64 __fastcall GetApplicationXboxLiveInfo_X(WCHAR* a1, int a2, void* a3, unsigned int a4)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentApplicationUserModelId_X(UINT32* applicationUserModelIdLength, PWSTR applicationUserModelId)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentPackageFamilyName_X(UINT32* packageFamilyNameLength, PWSTR packageFamilyName)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
LONG __stdcall GetCurrentPackageFullName_X(UINT32* packageFullNameLength, PWSTR packageFullName)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
LONG CurrentPackageFullName; // edi
|
||||
UINT32 v5; // edi
|
||||
const wchar_t* v6; // r8
|
||||
@@ -254,14 +254,14 @@ LONG __stdcall GetCurrentPackageFullName_X(UINT32* packageFullNameLength, PWSTR
|
||||
|
||||
LONG __stdcall GetCurrentPackageId_X(UINT32* bufferLength, BYTE* buffer)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
LONG __stdcall GetCurrentPackagePath_X(UINT32* pathLength, PWSTR path)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -269,45 +269,45 @@ LONG __stdcall GetCurrentPackagePath_X(UINT32* pathLength, PWSTR path)
|
||||
|
||||
LONG __stdcall GetPackageFamilyName_X(HANDLE hProcess, UINT32* packageFamilyNameLength, PWSTR packageFamilyName)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return GetCurrentPackageFamilyName_X(packageFamilyNameLength, packageFamilyName);
|
||||
}
|
||||
|
||||
LONG __stdcall GetPackagePath_X(const PVOID* packageId, const UINT32 reserved, UINT32* pathLength, PWSTR path)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return GetCurrentPackagePath_X(pathLength, path);
|
||||
}
|
||||
|
||||
void GetPackageXboxLiveInfo_X( ) { DEBUG_LOG( ); }
|
||||
void GetPackageXboxLiveInfo_X( ) { }
|
||||
|
||||
void GetProcessXboxLiveInfo_X( ) { DEBUG_LOG( ); }
|
||||
void GetProcessXboxLiveInfo_X( ) { }
|
||||
|
||||
void GetXboxLiveTitleId_X( ) { DEBUG_LOG( ); }
|
||||
void GetXboxLiveTitleId_X( ) { }
|
||||
|
||||
void PsmBlockAppStateChangeCompletion_X( ) { DEBUG_LOG( ); }
|
||||
void PsmBlockAppStateChangeCompletion_X( ) { }
|
||||
|
||||
void PsmRegisterAppStateChangeNotification_X( ) { DEBUG_LOG( ); }
|
||||
void PsmRegisterAppStateChangeNotification_X( ) { }
|
||||
|
||||
void PsmShutdownApplication_X( ) { DEBUG_LOG( ); }
|
||||
void PsmShutdownApplication_X( ) { }
|
||||
|
||||
void PsmUnblockAppStateChangeCompletion_X( ) { DEBUG_LOG( ); }
|
||||
void PsmUnblockAppStateChangeCompletion_X( ) { }
|
||||
|
||||
void PsmWaitForAppResume_X( ) { DEBUG_LOG( ); }
|
||||
void PsmWaitForAppResume_X( ) { }
|
||||
|
||||
LONG __stdcall GetPackageId(HANDLE hProcess, UINT32* bufferLength, BYTE* buffer)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return GetCurrentPackageId_X(bufferLength, buffer);
|
||||
}
|
||||
|
||||
LONG __stdcall GetPackageFullName_X(HANDLE hProcess, UINT32* packageFullNameLength, PWSTR packageFullName)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return GetCurrentPackageFullName_X(packageFullNameLength, packageFullName);
|
||||
}
|
||||
|
||||
LONG GetCurrentPackageInfo_X(const UINT32 flags, UINT32* bufferLength, BYTE* buffer, UINT32* count) { DEBUG_LOG( ); return 0; }
|
||||
LONG GetCurrentPackageInfo_X(const UINT32 flags, UINT32* bufferLength, BYTE* buffer, UINT32* count) { return 0; }
|
||||
|
||||
LONG __stdcall GetPackagesByPackageFamily_X(
|
||||
PCWSTR packageFamilyName,
|
||||
@@ -316,7 +316,7 @@ LONG __stdcall GetPackagesByPackageFamily_X(
|
||||
UINT32* bufferLength,
|
||||
WCHAR* buffer)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
if (!packageFamilyName || !count || !bufferLength || (*count && !packageFullNames) || (*bufferLength && !buffer))
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
@@ -356,7 +356,7 @@ LONG __stdcall GetPackagesByPackageFamily_X(
|
||||
|
||||
_int64 __fastcall GetCurrentXboxLiveTitleId_X(int* a1)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
int v4[ 6 ]; // [rsp+20h] [rbp-28h] BYREF
|
||||
|
||||
int v1 = 0;
|
||||
@@ -370,12 +370,12 @@ _int64 __fastcall GetCurrentXboxLiveTitleId_X(int* a1)
|
||||
}
|
||||
__int64 __fastcall GetSystemXboxLiveInfo_X(int a1, void* a2, unsigned int a3)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
return 0;
|
||||
}
|
||||
LONG __fastcall GetCurrentXboxLiveInfo_X(unsigned int a1, void* a2, unsigned int a3)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
LONG result; // eax
|
||||
HMODULE ModuleHandleW; // rax
|
||||
UINT32 applicationUserModelIdLength[ 4 ]; // [rsp+20h] [rbp-138h] BYREF
|
||||
@@ -411,7 +411,7 @@ LONG __fastcall GetCurrentXboxLiveInfo_X(unsigned int a1, void* a2, unsigned int
|
||||
}
|
||||
LSTATUS __fastcall XblRegReadValue_X(HKEY hKey, LPCWSTR valueName, int expectedType, void* buffer, unsigned int bufferSize)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
|
||||
DWORD dataType = 0;
|
||||
DWORD dataSize = bufferSize;
|
||||
|
||||
@@ -424,7 +424,7 @@ LSTATUS __fastcall XblRegReadValue_X(HKEY hKey, LPCWSTR valueName, int expectedT
|
||||
}
|
||||
__int64 __fastcall XblRegReadModuleTitleInfo_X(HINSTANCE a1, const unsigned __int16* a2, void* a3, unsigned int a4)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("XblRegReadModuleTitleInfo_X called with a1: %p, a2: %s, a3: %p, a4: %u", a1, a2 ? a2 : L"nullptr", a3, a4);
|
||||
unsigned int result;
|
||||
HKEY hKey = nullptr;
|
||||
int useSystemTitleId = 0;
|
||||
@@ -449,7 +449,7 @@ __int64 __fastcall XblRegReadModuleTitleInfo_X(HINSTANCE a1, const unsigned __in
|
||||
}
|
||||
LSTATUS __fastcall XblRegReadTitleInfo_X(HKEY a1, struct _XBOX_LIVE_TITLE_INFO* TitleInfo)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("XblRegReadTitleInfo_X called with a1: %p", a1);
|
||||
LSTATUS result; // eax
|
||||
|
||||
result = XblRegReadValue_X(a1, L"TitleId", 4, TitleInfo, 4u);
|
||||
@@ -471,7 +471,7 @@ LSTATUS __fastcall XblRegReadTitleInfo_X(HKEY a1, struct _XBOX_LIVE_TITLE_INFO*
|
||||
|
||||
__int64 __fastcall XblRegOpenModuleKey_X(HMODULE a1, __int64 a2, HKEY* a3)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("XblRegOpenModuleKey_X called with a1: %p, a2: %lld", a1, a2);
|
||||
unsigned int v4 = 1359;
|
||||
WCHAR Filename[ 264 ] = { 0 };
|
||||
WCHAR SubKey[ 512 ] = { 0 };
|
||||
@@ -500,7 +500,7 @@ __int64 __fastcall XblRegOpenModuleKey_X(HMODULE a1, __int64 a2, HKEY* a3)
|
||||
|
||||
void __fastcall PsmCli::UnregisterAppStateChangeNotification(PsmCli* instance, struct _PSM_APPSTATE_REGISTRATION* a2)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_DEBUG("PsmCli::UnregisterAppStateChangeNotification called");
|
||||
_LIST_ENTRY* Flink;
|
||||
_LIST_ENTRY* Blink;
|
||||
|
||||
@@ -539,7 +539,7 @@ void __fastcall PsmCli::UnregisterAppStateChangeNotification(PsmCli* instance, s
|
||||
|
||||
void __fastcall PsmUnregisterAppStateChangeNotification_X(struct _PSM_APPSTATE_REGISTRATION* a1)
|
||||
{
|
||||
DEBUG_LOG( );
|
||||
LOG_NOT_IMPLEMENTED( );
|
||||
if (a1)
|
||||
PsmCli::UnregisterAppStateChangeNotification(reinterpret_cast<PsmCli*>(a1), a1);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
#include "../common/DebugLogger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
||||
|
||||
95
dlls/common/Config.h
Normal file
95
dlls/common/Config.h
Normal file
@@ -0,0 +1,95 @@
|
||||
//// Config.h
|
||||
//#pragma once
|
||||
//
|
||||
//#include <string>
|
||||
//#include <mutex>
|
||||
//#include <iostream>
|
||||
//#include <filesystem>
|
||||
//#include <toml++/toml.h>
|
||||
//
|
||||
//struct Config {
|
||||
//private:
|
||||
// static inline toml::table configTable;
|
||||
// static inline std::mutex configMutex;
|
||||
// static inline bool initialized = false;
|
||||
//
|
||||
//public:
|
||||
// static void Load(const std::string& filename = "config.toml") {
|
||||
// std::lock_guard<std::mutex> lock(configMutex);
|
||||
//
|
||||
// if (!std::filesystem::exists(filename)) {
|
||||
// std::cerr << "[Config] Config file " << filename << " does not exist. Using defaults." << std::endl;
|
||||
// configTable = toml::table{};
|
||||
// initialized = true;
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try {
|
||||
// configTable = toml::parse_file(filename);
|
||||
// }
|
||||
// catch (const toml::parse_error& err) {
|
||||
// std::cerr << "[Config] Failed to parse " << filename << ": " << err.description( ) << std::endl;
|
||||
// configTable = toml::table{};
|
||||
// }
|
||||
//
|
||||
// initialized = true;
|
||||
// }
|
||||
//
|
||||
// template<typename T>
|
||||
// static T Get(const std::string& key, const T& defaultValue) {
|
||||
// std::lock_guard<std::mutex> lock(configMutex);
|
||||
// if (!initialized) Load( );
|
||||
//
|
||||
// auto val = configTable[ key ];
|
||||
// if constexpr (std::is_same_v<T, std::string>) {
|
||||
// if (val && val.is_string( )) return val.value_or(defaultValue);
|
||||
// }
|
||||
// else if constexpr (std::is_same_v<T, int>) {
|
||||
// if (val && val.is_integer( )) return static_cast<int>(val.value_or(defaultValue));
|
||||
// }
|
||||
// else if constexpr (std::is_same_v<T, bool>) {
|
||||
// if (val && val.is_boolean( )) return val.value_or(defaultValue);
|
||||
// }
|
||||
// else if constexpr (std::is_same_v<T, double>) {
|
||||
// if (val && val.is_floating_point( )) return val.value_or(defaultValue);
|
||||
// }
|
||||
// else if constexpr (std::is_same_v<T, float>) {
|
||||
// if (val && val.is_floating_point( )) return static_cast<float>(val.value_or(defaultValue));
|
||||
// }
|
||||
// return defaultValue;
|
||||
// }
|
||||
//
|
||||
// static void Set(const std::string& key, const toml::node& value) {
|
||||
// std::lock_guard<std::mutex> lock(configMutex);
|
||||
// configTable.insert_or_assign(key, value);
|
||||
// }
|
||||
//
|
||||
// static void Save(const std::string& filename = "config.toml") {
|
||||
// std::lock_guard<std::mutex> lock(configMutex);
|
||||
// try {
|
||||
// std::ofstream file(filename);
|
||||
// file << configTable;
|
||||
// }
|
||||
// catch (...) {
|
||||
// std::cerr << "[Config] Failed to write config to " << filename << std::endl;
|
||||
// }
|
||||
// }
|
||||
//};
|
||||
//
|
||||
///*
|
||||
//Usage Example:
|
||||
//
|
||||
//#include "Config.h"
|
||||
//
|
||||
//int main() {
|
||||
// Config::Load("myproject_config.toml");
|
||||
//
|
||||
// bool enableLogging = Config::Get<bool>("Logger.EnableLogging", true);
|
||||
// int maxFPS = Config::Get<int>("Graphics.MaxFPS", 60);
|
||||
// std::string username = Config::Get<std::string>("User.Name", "Guest");
|
||||
// double gamma = Config::Get<double>("Graphics.Gamma", 2.2);
|
||||
//
|
||||
// Config::Set("User.LastLogin", toml::value("2025-06-30T20:30:00"));
|
||||
// Config::Save("myproject_config.toml");
|
||||
//}
|
||||
//*/
|
||||
@@ -1,77 +0,0 @@
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
// Function to extract the last folder name (project/module name)
|
||||
inline const char* RetrieveProjectName(const char* filePath) {
|
||||
const char* lastSlash = strrchr(filePath, '/'); // UNIX-like path
|
||||
if (!lastSlash) lastSlash = strrchr(filePath, '\\'); // Windows path
|
||||
|
||||
if (lastSlash) {
|
||||
const char* secondLastSlash = filePath; // Start from beginning
|
||||
while (secondLastSlash < lastSlash) { // Find second-to-last slash
|
||||
const char* temp = strpbrk(secondLastSlash + 1, "/\\");
|
||||
if (temp && temp < lastSlash) secondLastSlash = temp;
|
||||
else break;
|
||||
}
|
||||
|
||||
if (secondLastSlash != filePath) {
|
||||
static char projectName[ 256 ]; // Buffer to store project/module name
|
||||
size_t length = lastSlash - secondLastSlash - 1; // Get only folder name
|
||||
length = (length < sizeof(projectName) - 1) ? length : sizeof(projectName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(projectName, sizeof(projectName), secondLastSlash + 1, length); // MSVC-safe
|
||||
#else
|
||||
strncpy(projectName, secondLastSlash + 1, length); // GCC/Clang-safe
|
||||
projectName[ length ] = '\0'; // Null-terminate
|
||||
#endif
|
||||
return projectName;
|
||||
}
|
||||
}
|
||||
return "UnknownProject"; // Fallback if no directory structure found
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__) // GCC/Clang
|
||||
#define FUNCTION_NAME __PRETTY_FUNCTION__
|
||||
#elif defined(_MSC_VER) // MSVC
|
||||
#define FUNCTION_NAME __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_NAME __FUNCTION__
|
||||
#endif
|
||||
|
||||
// Function to extract only the function name from the full signature
|
||||
inline const char* RetrieveFunctionName(const char* fullSignature) {
|
||||
const char* paren = strchr(fullSignature, '('); // Find first '('
|
||||
if (paren) {
|
||||
static char functionName[ 256 ]; // Buffer to store function name
|
||||
size_t length = paren - fullSignature; // Length before '('
|
||||
length = (length < sizeof(functionName) - 1) ? length : sizeof(functionName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(functionName, sizeof(functionName), fullSignature, length); // Safe for MSVC
|
||||
#else
|
||||
strncpy(functionName, fullSignature, length); // Safe for GCC/Clang
|
||||
functionName[ length ] = '\0'; // Null-terminate
|
||||
#endif
|
||||
return functionName;
|
||||
}
|
||||
return fullSignature; // Fallback if '(' not found
|
||||
}
|
||||
|
||||
// Debug Print Macro (Basic)
|
||||
#define DEBUG_LOG() printf("Line: %d --> %s --> %s \r\n", __LINE__, RetrieveProjectName(__FILE__) ,RetrieveFunctionName(FUNCTION_NAME) )
|
||||
|
||||
// Debug Print Macro (Custom Message)
|
||||
#define DEBUGLOG(fmt, ...) printf("Line: %d --> %s --> %s " fmt "\r\n", __LINE__ , RetrieveProjectName(__FILE__), __FUNCTION__ , ##__VA_ARGS__)
|
||||
|
||||
#else
|
||||
#define DEBUG_LOG() // No-op in release mode
|
||||
#define DEBUGLOG(fmt, ...) // No-op in release mode
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_H
|
||||
314
dlls/common/Logger.h
Normal file
314
dlls/common/Logger.h
Normal file
@@ -0,0 +1,314 @@
|
||||
// Logger.h (header-only version, now with wchar support)
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <mutex>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
#include <windows.h>
|
||||
#include <source_location> // C++20 support
|
||||
|
||||
#ifndef DEBUG_LOGGER_H
|
||||
#define DEBUG_LOGGER_H
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define FUNCTION_NAME __PRETTY_FUNCTION__
|
||||
#elif defined(_MSC_VER)
|
||||
#define FUNCTION_NAME __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_NAME __FUNCTION__
|
||||
#endif
|
||||
|
||||
enum class LogLevel {
|
||||
Debug,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
NotImplemented
|
||||
};
|
||||
|
||||
class Logger {
|
||||
private:
|
||||
struct LoggerConfig {
|
||||
bool EnableLogging = true;
|
||||
bool EnableVerbose = false;
|
||||
bool DebuggerOnly = false;
|
||||
LogLevel MinimumLogLevel = LogLevel::Debug;
|
||||
};
|
||||
|
||||
static inline std::mutex logMutex;
|
||||
static inline LoggerConfig config;
|
||||
|
||||
static std::string GenerateLogFileName( ) {
|
||||
auto t = std::time(nullptr);
|
||||
std::tm tm{};
|
||||
localtime_s(&tm, &t);
|
||||
char buf[ 64 ];
|
||||
std::strftime(buf, sizeof(buf), "debug_%Y-%m-%d_%H-%M-%S.log", &tm);
|
||||
return buf;
|
||||
}
|
||||
static inline std::ofstream logFile{ GenerateLogFileName( ), std::ios::app };
|
||||
|
||||
static const char* ToString(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return "DEBUG";
|
||||
case LogLevel::Info: return "INFO";
|
||||
case LogLevel::Warning: return "WARNING";
|
||||
case LogLevel::Error: return "ERROR";
|
||||
case LogLevel::Fatal: return "FATAL";
|
||||
case LogLevel::NotImplemented: return "NOT_IMPLEMENTED";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
static std::string CurrentTime( ) {
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm timeinfo{};
|
||||
char buffer[ 32 ];
|
||||
if (localtime_s(&timeinfo, &now) == 0) {
|
||||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M:%S %p", &timeinfo);
|
||||
return buffer;
|
||||
}
|
||||
else {
|
||||
return "Unknown Time";
|
||||
}
|
||||
}
|
||||
|
||||
static std::wstring CurrentTimeW( ) {
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm timeinfo{};
|
||||
wchar_t buffer[ 32 ];
|
||||
if (localtime_s(&timeinfo, &now) == 0) {
|
||||
std::wcsftime(buffer, sizeof(buffer) / sizeof(wchar_t), L"%Y-%m-%d %I:%M:%S %p", &timeinfo);
|
||||
return buffer;
|
||||
}
|
||||
else {
|
||||
return L"Unknown Time";
|
||||
}
|
||||
}
|
||||
static void PrintWithContext(int line, const char* file, const char* function, const char* fmt, va_list args) {
|
||||
char formatted[ 1024 ];
|
||||
vsnprintf(formatted, sizeof(formatted), fmt, args);
|
||||
Log(LogLevel::NotImplemented, formatted, file, line, function);
|
||||
}
|
||||
public:
|
||||
static void NotImplemented(const char* file, int line, const char* function, const char* fmt = "", ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
PrintWithContext(line, file, function, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Narrow logging (std::string)
|
||||
// -------------------------------
|
||||
static void Log(LogLevel level, const std::string& message, const char* file, int line, const char* function) {
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
std::string timeStr = CurrentTime( );
|
||||
std::string func = ExtractFunctionName(function);
|
||||
const char* project = ExtractProjectName(file);
|
||||
const char* levelStr = ToString(level);
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
WORD originalAttributes = 0;
|
||||
if (GetConsoleScreenBufferInfo(hConsole, &csbi)) {
|
||||
originalAttributes = csbi.wAttributes;
|
||||
SetConsoleTextAttribute(hConsole, GetConsoleColor(level));
|
||||
}
|
||||
|
||||
std::cout << timeStr << " - " << levelStr << " - " << project << " - " << func;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
std::cout << " - Line " << line;
|
||||
if (!message.empty( ))
|
||||
std::cout << " - " << message;
|
||||
std::cout << std::endl;
|
||||
|
||||
if (hConsole) SetConsoleTextAttribute(hConsole, originalAttributes);
|
||||
|
||||
if (logFile.is_open( )) {
|
||||
logFile << timeStr << " - " << levelStr << " - " << project << " - " << func;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
logFile << " - Line " << line;
|
||||
if (!message.empty( ))
|
||||
logFile << " - " << message;
|
||||
logFile << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------
|
||||
// Wide logging (std::wstring)
|
||||
// -------------------------------
|
||||
static void Log(LogLevel level, const std::wstring& message, const wchar_t* file, int line, const wchar_t* function) {
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
std::wstring timeStr = CurrentTimeW( );
|
||||
std::wstring func = ExtractFunctionNameW(function);
|
||||
std::wstring project = ExtractProjectNameW(file);
|
||||
std::wstring levelStr = ConvertToWString(ToString(level));
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
WORD originalAttributes = 0;
|
||||
if (GetConsoleScreenBufferInfo(hConsole, &csbi)) {
|
||||
originalAttributes = csbi.wAttributes;
|
||||
SetConsoleTextAttribute(hConsole, GetConsoleColor(level));
|
||||
}
|
||||
|
||||
std::wcout << timeStr << L" - " << levelStr << L" - " << project << L" - " << func;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
std::wcout << L" - Line " << line;
|
||||
if (!message.empty( ))
|
||||
std::wcout << L" - " << message;
|
||||
std::wcout << std::endl;
|
||||
|
||||
if (hConsole) SetConsoleTextAttribute(hConsole, originalAttributes);
|
||||
|
||||
static std::wofstream logFileW{ L"debug_wide.log", std::ios::app };
|
||||
if (logFileW.is_open( )) {
|
||||
logFileW << timeStr << L" - " << levelStr << L" - " << project << L" - " << func;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
logFileW << L" - Line " << line;
|
||||
if (!message.empty( ))
|
||||
logFileW << L" - " << message;
|
||||
logFileW << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
// Utility: Convert const char* to std::wstring
|
||||
static std::wstring ConvertToWString(const char* str) {
|
||||
if (!str) return L"";
|
||||
int size = MultiByteToWideChar(CP_UTF8, 0, str, -1, nullptr, 0);
|
||||
std::wstring wstr(size, 0);
|
||||
MultiByteToWideChar(CP_UTF8, 0, str, -1, &wstr[ 0 ], size);
|
||||
wstr.pop_back( ); // remove null terminator
|
||||
return wstr;
|
||||
}
|
||||
static WORD GetColorForProject(const char* projectName) {
|
||||
size_t hash = 0;
|
||||
while (*projectName) {
|
||||
hash = hash * 101 + *projectName++;
|
||||
}
|
||||
WORD colors[] = {
|
||||
FOREGROUND_RED,
|
||||
FOREGROUND_GREEN,
|
||||
FOREGROUND_BLUE,
|
||||
FOREGROUND_RED | FOREGROUND_GREEN,
|
||||
FOREGROUND_RED | FOREGROUND_BLUE,
|
||||
FOREGROUND_GREEN | FOREGROUND_BLUE,
|
||||
FOREGROUND_INTENSITY
|
||||
};
|
||||
return colors[ hash % (sizeof(colors) / sizeof(colors[ 0 ])) ];
|
||||
}
|
||||
|
||||
static WORD GetConsoleColor(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return FOREGROUND_BLUE | FOREGROUND_GREEN;
|
||||
case LogLevel::Info: return FOREGROUND_GREEN;
|
||||
case LogLevel::Warning: return FOREGROUND_RED | FOREGROUND_GREEN;
|
||||
case LogLevel::Error: return FOREGROUND_RED;
|
||||
case LogLevel::Fatal: return BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
case LogLevel::NotImplemented: return FOREGROUND_RED | FOREGROUND_BLUE;
|
||||
default: return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
}
|
||||
}
|
||||
|
||||
// Extract function name (narrow)
|
||||
static std::string ExtractFunctionName(const char* fullSignature) {
|
||||
const char* paren = strchr(fullSignature, '(');
|
||||
if (!paren) return fullSignature;
|
||||
const char* end = paren;
|
||||
const char* lastColon = nullptr;
|
||||
for (const char* p = fullSignature; p < end; ++p) {
|
||||
if (p[ 0 ] == ':' && p[ 1 ] == ':')
|
||||
lastColon = p;
|
||||
}
|
||||
const char* start = lastColon ? lastColon + 2 : fullSignature;
|
||||
static char functionName[ 256 ];
|
||||
size_t length = static_cast<size_t>(end - start);
|
||||
length = (length < sizeof(functionName) - 1) ? length : sizeof(functionName) - 1;
|
||||
strncpy_s(functionName, sizeof(functionName), start, length);
|
||||
functionName[ length ] = '\0';
|
||||
return functionName;
|
||||
}
|
||||
|
||||
// Extract function name (wide)
|
||||
static std::wstring ExtractFunctionNameW(const wchar_t* fullSignature) {
|
||||
const wchar_t* paren = wcschr(fullSignature, L'(');
|
||||
if (!paren) return fullSignature;
|
||||
const wchar_t* end = paren;
|
||||
const wchar_t* lastColon = nullptr;
|
||||
for (const wchar_t* p = fullSignature; p < end; ++p) {
|
||||
if (p[ 0 ] == L':' && p[ 1 ] == L':')
|
||||
lastColon = p;
|
||||
}
|
||||
const wchar_t* start = lastColon ? lastColon + 2 : fullSignature;
|
||||
static wchar_t functionName[ 256 ];
|
||||
size_t length = static_cast<size_t>(end - start);
|
||||
length = (length < sizeof(functionName) / sizeof(wchar_t) - 1) ? length : sizeof(functionName) / sizeof(wchar_t) - 1;
|
||||
wcsncpy_s(functionName, start, length);
|
||||
functionName[ length ] = L'\0';
|
||||
return functionName;
|
||||
}
|
||||
|
||||
// Extract project name
|
||||
static const char* ExtractProjectName(const char* filePath) {
|
||||
const char* lastSlash = strrchr(filePath, '/');
|
||||
if (!lastSlash) lastSlash = strrchr(filePath, '\\');
|
||||
const char* fileName = lastSlash ? lastSlash + 1 : filePath;
|
||||
const char* dot = strrchr(fileName, '.');
|
||||
static char project[ 256 ];
|
||||
size_t length = dot ? static_cast<size_t>(dot - fileName) : strlen(fileName);
|
||||
length = (length < sizeof(project) - 1) ? length : sizeof(project) - 1;
|
||||
strncpy_s(project, sizeof(project), fileName, length);
|
||||
project[ length ] = '\0';
|
||||
return project;
|
||||
}
|
||||
|
||||
// Extract project name (wide)
|
||||
static std::wstring ExtractProjectNameW(const wchar_t* filePath) {
|
||||
const wchar_t* lastSlash = wcsrchr(filePath, L'/');
|
||||
if (!lastSlash) lastSlash = wcsrchr(filePath, L'\\');
|
||||
const wchar_t* fileName = lastSlash ? lastSlash + 1 : filePath;
|
||||
const wchar_t* dot = wcsrchr(fileName, L'.');
|
||||
static wchar_t project[ 256 ];
|
||||
size_t length = dot ? static_cast<size_t>(dot - fileName) : wcslen(fileName);
|
||||
length = (length < sizeof(project) / sizeof(wchar_t) - 1) ? length : sizeof(project) / sizeof(wchar_t) - 1;
|
||||
wcsncpy_s(project, fileName, length);
|
||||
project[ length ] = L'\0';
|
||||
return project;
|
||||
}
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Macro-based log wrappers (captures callsite info)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define LOG_DEBUG(msg) Logger::Log(LogLevel::Debug, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_INFO(msg) Logger::Log(LogLevel::Info, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_WARNING(msg) Logger::Log(LogLevel::Warning, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_ERROR(msg) Logger::Log(LogLevel::Error, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_FATAL(msg) Logger::Log(LogLevel::Fatal, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_NOT_IMPLEMENTED(...) Logger::NotImplemented(__FILE__, __LINE__, FUNCTION_NAME, ##__VA_ARGS__)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Macro-based log wrappers (captures callsite info) WIDE CHARACTER VERSION
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define LOG_DEBUG_W(msg) Logger::Log(LogLevel::Debug, msg, _CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME))
|
||||
#define LOG_INFO_W(msg) Logger::Log(LogLevel::Info, msg, _CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME))
|
||||
#define LOG_WARNING_W(msg) Logger::Log(LogLevel::Warning, msg, _CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME))
|
||||
#define LOG_ERROR_W(msg) Logger::Log(LogLevel::Error, msg, _CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME))
|
||||
#define LOG_FATAL_W(msg) Logger::Log(LogLevel::Fatal, msg, _CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME))
|
||||
#define LOG_NOT_IMPLEMENTED_W(...) Logger::NotImplementedW(_CRT_WIDE(__FILE__), __LINE__, _CRT_WIDE(FUNCTION_NAME), ##__VA_ARGS__)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Debug-only short macros (auto-disables in Release)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG_PRINT() Logger::Debug()
|
||||
#define DEBUGPRINT(fmt, ...) Logger::Debug(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT()
|
||||
#define DEBUGPRINT(fmt, ...)
|
||||
#endif
|
||||
#endif // DEBUG_LOGGER_H
|
||||
@@ -150,7 +150,8 @@
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="DebugLogger.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="logfmtxx.hpp" />
|
||||
<ClInclude Include="toml.hpp" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="toml.hpp" />
|
||||
<ClInclude Include="logfmtxx.hpp" />
|
||||
<ClInclude Include="DebugLogger.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="Config.h" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -1,189 +0,0 @@
|
||||
#include "Logger.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <windows.h>
|
||||
#include "../common/DebugLogger.h"
|
||||
|
||||
static std::mutex logMutex;
|
||||
static std::ofstream logFile("debug.log", std::ios::app);
|
||||
|
||||
static const char* ToString(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return "DEBUG";
|
||||
case LogLevel::Info: return "INFO";
|
||||
case LogLevel::Warning: return "WARNING";
|
||||
case LogLevel::Error: return "ERROR";
|
||||
case LogLevel::Fatal: return "FATAL";
|
||||
case LogLevel::NotImplemented: return "NOT_IMPLEMENTED";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
WORD GetConsoleColor(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return FOREGROUND_BLUE | FOREGROUND_GREEN;
|
||||
case LogLevel::Info: return FOREGROUND_GREEN;
|
||||
case LogLevel::Warning: return FOREGROUND_RED | FOREGROUND_GREEN;
|
||||
case LogLevel::Error: return FOREGROUND_RED;
|
||||
case LogLevel::Fatal: return BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
case LogLevel::NotImplemented: return FOREGROUND_RED | FOREGROUND_BLUE;
|
||||
default: return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string CurrentTime( ) {
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm timeinfo{};
|
||||
char buffer[ 32 ];
|
||||
|
||||
if (localtime_s(&timeinfo, &now) == 0) {
|
||||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M:%S %p", &timeinfo);
|
||||
return buffer;
|
||||
}
|
||||
else {
|
||||
return "Unknown Time";
|
||||
}
|
||||
}
|
||||
void Logger::Log(LogLevel level, const std::string& message, const char* file, int line, const char* function) {
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
|
||||
std::string timeStr = CurrentTime( );
|
||||
std::string func = Logger::ExtractFunctionName(function);
|
||||
const char* project = Logger::ExtractProjectName(file);
|
||||
const char* levelStr = ToString(level);
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
WORD originalAttributes = 0;
|
||||
if (GetConsoleScreenBufferInfo(hConsole, &csbi)) {
|
||||
originalAttributes = csbi.wAttributes;
|
||||
SetConsoleTextAttribute(hConsole, GetConsoleColor(level));
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case LogLevel::Debug:
|
||||
std::cout << timeStr << " - Debug - " << project << " - " << func;
|
||||
break;
|
||||
case LogLevel::Info:
|
||||
std::cout << timeStr << " - Info";
|
||||
break;
|
||||
case LogLevel::Warning:
|
||||
std::cout << timeStr << " - Warning - " << project << " - " << func;
|
||||
break;
|
||||
case LogLevel::Error:
|
||||
case LogLevel::Fatal:
|
||||
std::cout << timeStr << " - " << levelStr << " - " << project << " - " << func << " - Line " << line;
|
||||
break;
|
||||
case LogLevel::NotImplemented:
|
||||
std::cout << timeStr << " - " << project << " - " << func << " - NOT_IMPLEMENTED";
|
||||
break;
|
||||
default:
|
||||
std::cout << timeStr << " - " << levelStr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!message.empty( )) std::cout << " - " << message;
|
||||
std::cout << std::endl;
|
||||
|
||||
if (hConsole) SetConsoleTextAttribute(hConsole, originalAttributes);
|
||||
|
||||
// File log (flat format)
|
||||
if (logFile.is_open( )) {
|
||||
logFile << timeStr
|
||||
<< " - " << project
|
||||
<< " - " << func
|
||||
<< " - " << levelStr;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
logFile << " - Line " << line;
|
||||
if (!message.empty( ))
|
||||
logFile << " - " << message;
|
||||
logFile << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
#if __cpp_lib_source_location >= 201907L
|
||||
#include <source_location>
|
||||
|
||||
void Logger::Log(LogLevel level, const std::string& message, const std::source_location& location) {
|
||||
Logger::Log(level, message,
|
||||
location.file_name( ),
|
||||
static_cast<int>(location.line( )),
|
||||
location.function_name( ));
|
||||
}
|
||||
#endif
|
||||
|
||||
void Logger::LogNotImplemented(LogLevel level, int line, const char* file, const char* function) {
|
||||
Logger::Log(level, "Feature not implemented", file, line, function);
|
||||
}
|
||||
|
||||
void Logger::Debug(const char* message) { Logger::Log(LogLevel::Debug, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Info(const char* message) { Logger::Log(LogLevel::Info, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Warning(const char* message) { Logger::Log(LogLevel::Warning, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Error(const char* message) { Logger::Log(LogLevel::Error, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Fatal(const char* message) { Logger::Log(LogLevel::Fatal, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
|
||||
void Logger::PrintWithContext(int line, const char* file, const char* function, const char* fmt, va_list args) {
|
||||
char formatted[ 1024 ];
|
||||
vsnprintf(formatted, sizeof(formatted), fmt, args);
|
||||
Logger::Log(LogLevel::NotImplemented, formatted, file, line, function);
|
||||
}
|
||||
|
||||
void Logger::NotImplemented(const char* file, int line, const char* function, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
Logger::PrintWithContext(line, file, function, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
const char* Logger::ExtractProjectName(const char* filePath) {
|
||||
const char* lastSlash = strrchr(filePath, '/');
|
||||
if (!lastSlash) lastSlash = strrchr(filePath, '\\');
|
||||
const char* fileName = lastSlash ? lastSlash + 1 : filePath;
|
||||
|
||||
const char* dot = strrchr(fileName, '.');
|
||||
static char project[ 256 ];
|
||||
size_t length = dot ? (size_t) (dot - fileName) : strlen(fileName);
|
||||
length = (length < sizeof(project) - 1) ? length : sizeof(project) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(project, sizeof(project), fileName, length);
|
||||
#else
|
||||
strncpy(project, fileName, length);
|
||||
project[ length ] = '\0';
|
||||
#endif
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
const char* Logger::ExtractFunctionName(const char* fullSignature) {
|
||||
const char* paren = strchr(fullSignature, '(');
|
||||
if (!paren)
|
||||
return fullSignature;
|
||||
|
||||
const char* end = paren;
|
||||
const char* lastColon = nullptr;
|
||||
|
||||
for (const char* p = fullSignature; p < end; ++p) {
|
||||
if (p[ 0 ] == ':' && p[ 1 ] == ':')
|
||||
lastColon = p;
|
||||
}
|
||||
|
||||
const char* start = lastColon ? lastColon + 2 : fullSignature;
|
||||
|
||||
static char functionName[ 256 ];
|
||||
size_t length = (size_t) (end - start);
|
||||
length = (length < sizeof(functionName) - 1) ? length : sizeof(functionName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(functionName, sizeof(functionName), start, length);
|
||||
#else
|
||||
strncpy(functionName, start, length);
|
||||
functionName[ length ] = '\0';
|
||||
#endif
|
||||
|
||||
return functionName;
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <source_location> // C++20 support
|
||||
|
||||
#ifndef DEBUG_LOGGER_H
|
||||
#define DEBUG_LOGGER_H
|
||||
|
||||
enum class LogLevel {
|
||||
Debug,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
NotImplemented
|
||||
};
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
// Main logging entry point
|
||||
static void Log(LogLevel level, const std::string& message, const char* file, int line, const char* function);
|
||||
|
||||
// Optional C++20 overload using std::source_location
|
||||
#if __cpp_lib_source_location >= 201907L
|
||||
static void Log(LogLevel level,
|
||||
const std::string& message,
|
||||
const std::source_location& location = std::source_location::current( ));
|
||||
#endif
|
||||
|
||||
// Helper for NotImplemented logging
|
||||
static void LogNotImplemented(LogLevel level, int line, const char* file, const char* function);
|
||||
|
||||
// Convenience logging APIs
|
||||
static void Debug(const char* message = "");
|
||||
static void Info(const char* message = "");
|
||||
static void Warning(const char* message = "");
|
||||
static void Error(const char* message = "");
|
||||
static void Fatal(const char* message = "");
|
||||
|
||||
// NotImplemented (with formatting)
|
||||
static void NotImplemented(const char* file, int line, const char* function, const char* fmt = "", ...);
|
||||
|
||||
static void PrintWithContext(int line, const char* file, const char* function, const char* fmt, va_list args);
|
||||
|
||||
// Internal helpers
|
||||
static const char* ExtractFunctionName(const char* fullSignature);
|
||||
static const char* ExtractProjectName(const char* filePath);
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Compiler-specific macro for full function signature
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define FUNCTION_NAME __PRETTY_FUNCTION__
|
||||
#elif defined(_MSC_VER)
|
||||
#define FUNCTION_NAME __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_NAME __FUNCTION__
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Macro-based log wrappers (captures callsite info)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define LOG_DEBUG(msg, ...) Logger::Log(LogLevel::Debug, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_INFO(msg, ...) Logger::Log(LogLevel::Info, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_WARNING(msg, ...) Logger::Log(LogLevel::Warning, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_ERROR(msg, ...) Logger::Log(LogLevel::Error, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_FATAL(msg, ...) Logger::Log(LogLevel::Fatal, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_NOT_IMPLEMENTED(...) Logger::NotImplemented(__FILE__, __LINE__, FUNCTION_NAME, ##__VA_ARGS__)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Debug-only short macros (auto-disables in Release)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG_PRINT() Logger::Debug()
|
||||
#define DEBUGPRINT(fmt, ...) Logger::Debug(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT()
|
||||
#define DEBUGPRINT(fmt, ...)
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_LOGGER_H
|
||||
@@ -5,8 +5,7 @@
|
||||
#include <d3d11.h>
|
||||
#include "device_context_x.h"
|
||||
#include "device_x.h"
|
||||
#include "../common/DebugLogger.h"
|
||||
#include "Logger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
HRESULT CreateDevice(UINT Flags, wdi::ID3D11Device** ppDevice, wdi::ID3D11DeviceContext** ppImmediateContext)
|
||||
{
|
||||
@@ -49,7 +48,6 @@ HRESULT CreateDevice(UINT Flags, wdi::ID3D11Device** ppDevice, wdi::ID3D11Device
|
||||
}
|
||||
HRESULT __stdcall D3DMapEsramMemory_X(UINT Flags, VOID* pVirtualAddress, UINT NumPages, const UINT* pPageList)
|
||||
{
|
||||
DEBUGLOG( );
|
||||
HANDLE hDevice = INVALID_HANDLE_VALUE;
|
||||
HRESULT result = 0;
|
||||
DWORD accessFlags = 0;
|
||||
|
||||
@@ -115,7 +115,6 @@
|
||||
<ClCompile Include="dxgi_swapchain.cpp" />
|
||||
<ClCompile Include="dxguid.cpp" />
|
||||
<ClCompile Include="graphics_unknown.cpp" />
|
||||
<ClCompile Include="Logger.cpp" />
|
||||
<ClCompile Include="overlay\overlay.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -137,7 +136,6 @@
|
||||
<ClInclude Include="dxgi_object.hpp" />
|
||||
<ClInclude Include="dxgi_swapchain.h" />
|
||||
<ClInclude Include="graphics_unknown.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="overlay\overlay.h" />
|
||||
<ClInclude Include="resource.hpp" />
|
||||
<ClInclude Include="view.hpp" />
|
||||
|
||||
@@ -57,9 +57,6 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="dxgi_object.cpp" />
|
||||
<ClCompile Include="dxguid.cpp" />
|
||||
<ClCompile Include="Logger.cpp">
|
||||
<Filter>Logger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="d3d11_x.h" />
|
||||
@@ -123,9 +120,6 @@
|
||||
<ClInclude Include="dxgi_object.hpp">
|
||||
<Filter>wrappers\shared</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logger.h">
|
||||
<Filter>Logger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="imgui">
|
||||
@@ -164,8 +158,5 @@
|
||||
<Filter Include="overlay">
|
||||
<UniqueIdentifier>{c54987f8-e8bd-47e3-8940-2740f44a8f49}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Logger">
|
||||
<UniqueIdentifier>{3bb4479b-5009-4411-b1cf-b73fc7eda530}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "d3d11_x.h"
|
||||
#include "graphics_unknown.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
namespace wdi
|
||||
{
|
||||
@@ -30,7 +31,7 @@ namespace wd
|
||||
|
||||
void STDMETHODCALLTYPE GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: device_child_x::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: device_child_x::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <d3d11.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include "Logger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
void wd::device_context_x::GetDevice(ID3D11Device** ppDevice)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "device_child_x.h"
|
||||
#include "device_x.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
static std::map<UINT64, int> D3D11X_HARDWARE_TO_TOPOLOGY_MAP = {
|
||||
{0x000001ffc0009e00, 0}, {0x000003ffc0009e00, 1}, {0x000005ffc0009e00, 2}, {0x000007ffc0009e00, 3},
|
||||
@@ -675,7 +676,7 @@ namespace wd
|
||||
m_ShaderUserDataManagerDraw.m_DirtyFlags &= ~0x46;
|
||||
int topology = D3D11X_HARDWARE_TO_TOPOLOGY_MAP.at(m_ShaderUserDataManagerDraw.m_Topology);
|
||||
if (topology == 6 || topology == 17 || topology == 18 || topology == 19 || topology == 20)
|
||||
printf("WARN: device_context_x::ProcessDirtyFlags: unsupported topology %d\n", topology);
|
||||
LOG_WARNING("WARN: device_context_x::ProcessDirtyFlags: unsupported topology %d\n", topology);
|
||||
|
||||
wrapped_interface->IASetPrimitiveTopology(static_cast<D3D11_PRIMITIVE_TOPOLOGY>(topology));
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#include <stdexcept>
|
||||
#include "resource.hpp"
|
||||
#include "view.hpp"
|
||||
#include "../winrt_x/Logger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
HRESULT wd::device_x::CreateBuffer(const D3D11_BUFFER_DESC* pDesc, const D3D11_SUBRESOURCE_DATA* pInitialData,
|
||||
ID3D11Buffer** ppBuffer)
|
||||
@@ -24,7 +24,7 @@ HRESULT wd::device_x::CreateTexture1D(const D3D11_TEXTURE1D_DESC* pDesc, const D
|
||||
ID3D11Texture1D* texture1d = nullptr;
|
||||
HRESULT hr = wrapped_interface->CreateTexture1D(pDesc, pInitialData, &texture1d);
|
||||
|
||||
printf("[CreateTexture1D] created texture at 0x%llX\n", texture1d);
|
||||
LOG_INFO("[CreateTexture1D] created texture at 0x%llX\n", texture1d);
|
||||
|
||||
if (ppTexture1D != nullptr)
|
||||
{
|
||||
@@ -50,12 +50,12 @@ HRESULT wd::device_x::CreateTexture2D(
|
||||
|
||||
if (SUCCEEDED(hr) && texture2d)
|
||||
{
|
||||
printf("[CreateTexture2D] created texture at 0x%p\n", texture2d);
|
||||
LOG_INFO("[CreateTexture2D] created texture at 0x%p\n", texture2d);
|
||||
*ppTexture2D = reinterpret_cast<ID3D11Texture2D*>(new texture_2d(texture2d));
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("[CreateTexture2D] failed (HRESULT: 0x%08X)\n", static_cast<unsigned int>(hr));
|
||||
LOG_INFO("[CreateTexture2D] failed (HRESULT: 0x%08X)\n", static_cast<unsigned int>(hr));
|
||||
*ppTexture2D = nullptr;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ HRESULT wd::device_x::CreateTexture3D(const D3D11_TEXTURE3D_DESC* pDesc, const D
|
||||
ID3D11Texture3D* texture3d = nullptr;
|
||||
HRESULT hr = wrapped_interface->CreateTexture3D(pDesc, pInitialData, &texture3d);
|
||||
|
||||
printf("[CreateTexture3D] created texture at 0x%llX\n", texture3d);
|
||||
LOG_INFO("[CreateTexture3D] created texture at 0x%llX\n", texture3d);
|
||||
|
||||
if (ppTexture3D != nullptr)
|
||||
{
|
||||
@@ -361,12 +361,22 @@ UINT wd::device_x::GetDebugFlags( )
|
||||
LOG_NOT_IMPLEMENTED( );
|
||||
throw std::logic_error("Not implemented");
|
||||
}
|
||||
|
||||
void wd::device_x::SetHangCallbacks(wdi::D3D11XHANGBEGINCALLBACK pBeginCallback, wdi::D3D11XHANGPRINTCALLBACK pPrintCallback,
|
||||
wdi::D3D11XHANGDUMPCALLBACK pDumpCallback)
|
||||
wdi::D3D11XHANGBEGINCALLBACK m_HangBeginCallback = nullptr;
|
||||
wdi::D3D11XHANGPRINTCALLBACK m_HangPrintCallback = nullptr;
|
||||
wdi::D3D11XHANGDUMPCALLBACK m_HangDumpCallback = nullptr;
|
||||
void wd::device_x::SetHangCallbacks(
|
||||
wdi::D3D11XHANGBEGINCALLBACK pBeginCallback,
|
||||
wdi::D3D11XHANGPRINTCALLBACK pPrintCallback,
|
||||
wdi::D3D11XHANGDUMPCALLBACK pDumpCallback)
|
||||
{
|
||||
LOG_NOT_IMPLEMENTED( );
|
||||
throw std::logic_error("Not implemented");
|
||||
m_HangBeginCallback = pBeginCallback;
|
||||
m_HangPrintCallback = pPrintCallback;
|
||||
m_HangDumpCallback = pDumpCallback;
|
||||
|
||||
LOG_INFO("SetHangCallbacks called: BeginCallback=%p, PrintCallback=%p, DumpCallback=%p",
|
||||
pBeginCallback, pPrintCallback, pDumpCallback);
|
||||
|
||||
// No-op on PC, but you may simulate hang behavior in testing by manually calling these.
|
||||
}
|
||||
|
||||
void wd::device_x::ReportGpuHang(UINT Flags)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "dxgi_adapter.h"
|
||||
#include "dxgi_factory.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
HRESULT wd::dxgi_adapter::GetParent(const IID& riid, void** ppParent)
|
||||
{
|
||||
@@ -31,6 +32,6 @@ HRESULT wd::dxgi_adapter::GetDesc(DXGI_ADAPTER_DESC* pDesc)
|
||||
|
||||
HRESULT wd::dxgi_adapter::CheckInterfaceSupport(const GUID& InterfaceName, LARGE_INTEGER* pUMDVersion)
|
||||
{
|
||||
printf("WARN: dxgi_adapter::CheckInterfaceSupport is likely to fail due no support for d3d11.x!!!\n");
|
||||
LOG_WARNING("WARN: dxgi_adapter::CheckInterfaceSupport is likely to fail due no support for d3d11.x!!!\n");
|
||||
return wrapped_interface->CheckInterfaceSupport(InterfaceName, pUMDVersion);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "../kernelx/CoreWindowWrapperX.h"
|
||||
#include "overlay/overlay.h"
|
||||
#include <d3d11_2.h>
|
||||
#include "../common/Logger.h"
|
||||
|
||||
#define DXGI_SWAPCHAIN_FLAG_MASK DXGI_SWAP_CHAIN_FLAG_NONPREROTATED | DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH | DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE \
|
||||
| DXGI_SWAP_CHAIN_FLAG_RESTRICTED_CONTENT | DXGI_SWAP_CHAIN_FLAG_RESTRICT_SHARED_RESOURCE_DRIVER | DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY | DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT \
|
||||
@@ -49,7 +50,7 @@ HRESULT wd::dxgi_factory::CreateSwapChainForCoreWindow(IGraphicsUnknown* pDevice
|
||||
hr = pDevice->QueryInterface(__uuidof(wdi::IGraphicsUnwrap), (void**)&pRealDevice);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
printf("CRITICAL: dxgi_factory::CreateSwapChainForCoreWindow -> failed to unwrap device, this is a critical leak!\n");
|
||||
LOG_FATAL("CRITICAL: dxgi_factory::CreateSwapChainForCoreWindow -> failed to unwrap device, this is a critical leak!\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
@@ -132,7 +133,7 @@ BOOL wd::dxgi_factory::IsWindowedStereoEnabled()
|
||||
|
||||
HRESULT wd::dxgi_factory::EnumAdapters(UINT Adapter, wdi::IDXGIAdapter** ppAdapter)
|
||||
{
|
||||
printf("WARN: dxgi_factory::EnumAdapters does not wrap IDXGIAdapter!!!\n");
|
||||
LOG_WARNING("WARN: dxgi_factory::EnumAdapters does not wrap IDXGIAdapter!!!\n");
|
||||
return wrapped_interface->EnumAdapters(Adapter, reinterpret_cast<IDXGIAdapter**>(ppAdapter));
|
||||
}
|
||||
|
||||
@@ -154,6 +155,6 @@ HRESULT wd::dxgi_factory::CreateSwapChain(IGraphicsUnknown* pDevice, DXGI_SWAP_C
|
||||
|
||||
HRESULT wd::dxgi_factory::CreateSoftwareAdapter(HMODULE Module, wdi::IDXGIAdapter** ppAdapter)
|
||||
{
|
||||
printf("WARN: dxgi_factory::CreateSoftwareAdapter does not wrap IDXGIAdapter!!!\n");
|
||||
LOG_WARNING("WARN: dxgi_factory::CreateSoftwareAdapter does not wrap IDXGIAdapter!!!\n");
|
||||
return wrapped_interface->CreateSoftwareAdapter(Module, reinterpret_cast<IDXGIAdapter**>(ppAdapter));
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "device_child_x.h"
|
||||
#include "device_context_x.h"
|
||||
#include "Logger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
namespace wdi
|
||||
{
|
||||
@@ -136,7 +136,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: texture_1d::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: texture_1d::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: texture_2d::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: texture_2d::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -300,7 +300,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: texture_3d::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: texture_3d::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -381,7 +381,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: buffer::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: buffer::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: render_target_view::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: render_target_view::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: depth_stencil_view::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: depth_stencil_view::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: shader_resource_view::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: shader_resource_view::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
@@ -330,7 +330,7 @@ namespace wd
|
||||
|
||||
void GetDevice(ID3D11Device** ppDevice) override
|
||||
{
|
||||
printf("WARN: depth_stencil_view::GetDevice returns a PC device!!\n");
|
||||
LOG_WARNING("WARN: depth_stencil_view::GetDevice returns a PC device!!\n");
|
||||
wrapped_interface->GetDevice(ppDevice);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,22 +1,20 @@
|
||||
#include "EtwPlus.h"
|
||||
#include "pch.h"
|
||||
#include <stdio.h>
|
||||
#include "../common/common.h"
|
||||
#include "../common/DebugLogger.h"
|
||||
|
||||
#include "../common/Logger.h"
|
||||
|
||||
VOID __stdcall EtxFillCommonFields_v7_X(EVENT_DATA_DESCRIPTOR* eventDataDescriptors, UINT8* buffer, UINT32 bufferSize) {
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxFillCommonFields_v7_X] Not implemented yet.");
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
ULONG __stdcall EtxRegister_X(EVENT_PROVIDER_DESCRIPTOR* provider, REGHANDLE* handle) {
|
||||
// Implementation here
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxRegister_X] Not implemented yet.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
ULONG __stdcall EtxUnregister_X(EVENT_PROVIDER_DESCRIPTOR* provider, REGHANDLE* handle) {
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxUnregister_X] Not implemented yet.");
|
||||
REGHANDLE v3; // rcx
|
||||
|
||||
v3 = *handle;
|
||||
@@ -36,18 +34,18 @@ ULONG __stdcall EtxEventWrite_X(
|
||||
__in ULONG dataCount,
|
||||
__in const EVENT_DATA_DESCRIPTOR* eventData
|
||||
) {
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxEventWrite_X] Not implemented yet.");
|
||||
// Implementation here
|
||||
return 0;
|
||||
}
|
||||
|
||||
void __stdcall EtxSuspendUploading_X( ) {
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxSuspendUploading_X] Not implemented yet.");
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
void __stdcall
|
||||
EtxResumeUploading_X( ) {
|
||||
DEBUG_LOG();
|
||||
LOG_NOT_IMPLEMENTED("[EtxResumeUploading_X] Not implemented yet.");
|
||||
// Implementation here
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// pch.cpp: source file corresponding to the pre-compiled header
|
||||
|
||||
#include "pch.h"
|
||||
#include "../common/DebugLogger.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
// When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
|
||||
|
||||
@@ -1,49 +1,51 @@
|
||||
#include "pch.h"
|
||||
#include "CoreApplicationWrapperX.h"
|
||||
#include "FrameworkViewSourceWrapper.h"
|
||||
#include "../common/Logger.h"
|
||||
|
||||
using namespace ABI::Windows::ApplicationModel::Core;
|
||||
|
||||
HRESULT CoreApplicationWrapperX::GetIids(ULONG* iidCount, IID** iids)
|
||||
{
|
||||
printf("GetIids\n");
|
||||
LOG_INFO("GetIids\n");
|
||||
return m_realFactory->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationWrapperX::GetRuntimeClassName(HSTRING* className)
|
||||
{
|
||||
printf("GetRuntimeClassName\n");
|
||||
LOG_INFO("GetRuntimeClassName\n");
|
||||
return m_realFactory->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationWrapperX::GetTrustLevel(TrustLevel* trustLevel)
|
||||
{
|
||||
printf("GetTrustLevel\n");
|
||||
LOG_INFO("GetTrustLevel\n");
|
||||
return m_realFactory->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_add_Resuming(__FIEventHandler_1_IInspectable* handler, EventRegistrationToken* token)
|
||||
{
|
||||
printf("_abi_add_Resuming\n");
|
||||
LOG_INFO("_abi_add_Resuming\n");
|
||||
//return m_realCoreApplication->add_Resuming(handler, token);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_remove_Resuming(EventRegistrationToken token)
|
||||
{
|
||||
printf("_abi_remove_Resuming\n");
|
||||
LOG_INFO("_abi_remove_Resuming\n");
|
||||
return m_realCoreApplication->remove_Resuming(token);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_add_Suspending(__FIEventHandler_1_Windows__CApplicationModel__CSuspendingEventArgs* handler, EventRegistrationToken* token)
|
||||
{
|
||||
printf("_abi_add_Suspending\n");
|
||||
LOG_INFO("_abi_add_Suspending\n");
|
||||
//return m_realCoreApplication->add_Suspending(handler, token);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_remove_Suspending(EventRegistrationToken token)
|
||||
{
|
||||
printf("_abi_remove_Suspending\n");
|
||||
LOG_INFO("_abi_remove_Suspending\n");
|
||||
return m_realCoreApplication->remove_Suspending(token);
|
||||
}
|
||||
|
||||
@@ -51,20 +53,20 @@ HRESULT CoreApplicationWrapperX::_abi_get_ResourceAvailability(ResourceAvailabil
|
||||
{
|
||||
// TODO: Stubbed for now.
|
||||
*resourceAvailability = ResourceAvailability_Full;
|
||||
printf("_abi_get_ResourceAvailability\n");
|
||||
LOG_INFO("_abi_get_ResourceAvailability\n");
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationWrapperX::_abi_add_ResourceAvailabilityChanged(winrt::Windows::Foundation::EventHandler<IInspectable>* handler, EventRegistrationToken* token)
|
||||
{
|
||||
printf("_abi_add_ResourceAvailabilityChanged\n");
|
||||
LOG_INFO("_abi_add_ResourceAvailabilityChanged\n");
|
||||
//Stubbed at this moment.
|
||||
return 0;
|
||||
}
|
||||
|
||||
HRESULT CoreApplicationWrapperX::_abi_remove_ResourceAvailabilityChanged(EventRegistrationToken token)
|
||||
{
|
||||
printf("_abi_remove_ResourceAvailabilityChanged\n");
|
||||
LOG_INFO("_abi_remove_ResourceAvailabilityChanged\n");
|
||||
//Stubbed at this moment.
|
||||
return 0;
|
||||
}
|
||||
@@ -83,13 +85,13 @@ HRESULT CoreApplicationWrapperX::set_DisableKinectGpuReservation(bool value)
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_GetCurrentView(ABI::Windows::ApplicationModel::Core::ICoreApplicationView** value)
|
||||
{
|
||||
printf("[CoreApplicationWrapperX] ---> _abi_GetCurrentView\n");
|
||||
LOG_INFO("[CoreApplicationWrapperX] ---> _abi_GetCurrentView\n");
|
||||
return m_realCoreApplication->GetCurrentView(value);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_Run(ABI::Windows::ApplicationModel::Core::IFrameworkViewSource* viewSource)
|
||||
{
|
||||
printf("_abi_Run\n");
|
||||
LOG_INFO("_abi_Run\n");
|
||||
|
||||
// Wrap the ViewSource and pass it to the original function
|
||||
FrameworkViewSourceWrapper* wrappedViewSource = new FrameworkViewSourceWrapper(viewSource);
|
||||
@@ -98,13 +100,13 @@ INT32 CoreApplicationWrapperX::_abi_Run(ABI::Windows::ApplicationModel::Core::IF
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_get_Id(HSTRING* value)
|
||||
{
|
||||
printf("_abi_get_Id\n");
|
||||
LOG_INFO("_abi_get_Id\n");
|
||||
return m_realCoreApplication->get_Id(value);
|
||||
}
|
||||
|
||||
INT32 CoreApplicationWrapperX::_abi_get_Properties(ABI::Windows::Foundation::Collections::IPropertySet** value)
|
||||
{
|
||||
printf("_abi_get_Properties\n");
|
||||
LOG_INFO("_abi_get_Properties\n");
|
||||
return m_realCoreApplication->get_Properties(value);
|
||||
}
|
||||
|
||||
@@ -113,9 +115,16 @@ HRESULT CoreApplicationWrapperX::QueryInterface(const IID& riid, void** ppvObjec
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"CoreApplicationWrapperX [QI] IID Requested: %s\n", str);
|
||||
LOG_INFO_W(L"CoreApplicationWrapperX [QI] IID Requested: %s\n", str);
|
||||
CoTaskMemFree(str);
|
||||
if (riid == __uuidof(ICoreApplicationExit))
|
||||
{
|
||||
LOG_ERROR_W(L"CoreApplicationWrapperX [QI] IID Requested: Patched\n", str);
|
||||
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
if (riid == __uuidof(IActivationFactory) || riid == __uuidof(IUnknown))
|
||||
{
|
||||
*ppvObject = static_cast<IActivationFactory*>(this);
|
||||
@@ -129,12 +138,7 @@ HRESULT CoreApplicationWrapperX::QueryInterface(const IID& riid, void** ppvObjec
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
if (riid == __uuidof(ICoreApplicationExit))
|
||||
{
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ICoreApplicationResourceAvailabilityX)) // allow ICoreApplicationResourceAvailabilityX interface
|
||||
{
|
||||
*ppvObject = static_cast<ICoreApplicationResourceAvailabilityX*>(this);
|
||||
@@ -150,7 +154,7 @@ HRESULT CoreApplicationWrapperX::QueryInterface(const IID& riid, void** ppvObjec
|
||||
}
|
||||
|
||||
if (riid == __uuidof(ICoreApplicationExit)) {
|
||||
printf("ICoreApplicationExit CALLED - GAME OVER BRO\n");
|
||||
LOG_ERROR("ICoreApplicationExit CALLED - GAME OVER BRO\n");
|
||||
*ppvObject = this;
|
||||
AddRef();
|
||||
return S_OK;
|
||||
|
||||
@@ -4,49 +4,49 @@ using namespace ABI::Windows::ApplicationModel::Core;
|
||||
|
||||
HRESULT CoreWindowWrapperX::GetIids(ULONG* iidCount, IID** iids)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> GetIids\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> GetIids\n");
|
||||
return m_realWindow->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowWrapperX::GetRuntimeClassName(HSTRING* className)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> GetRuntimeClassName\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> GetRuntimeClassName\n");
|
||||
return m_realWindow->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowWrapperX::GetTrustLevel(TrustLevel* trustLevel)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> GetTrustLevel\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> GetTrustLevel\n");
|
||||
return m_realWindow->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_Bounds(Rect* rect)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_get_Bounds\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_get_Bounds\n");
|
||||
return m_realWindow->get_Bounds(rect);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_Dispatcher(ICoreDispatcher** dispatcher)
|
||||
{
|
||||
//printf("[CoreWindowWrapperX] --> _abi_get_Dispatcher\n");
|
||||
//LOG_INFO("[CoreWindowWrapperX] --> _abi_get_Dispatcher\n");
|
||||
return m_realWindow->get_Dispatcher(dispatcher);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_IsInputEnabled(boolean* value)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_get_IsInputEnabled\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_get_IsInputEnabled\n");
|
||||
return m_realWindow->get_IsInputEnabled(value);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_set_IsInputEnabled(boolean value)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_set_IsInputEnabled\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_set_IsInputEnabled\n");
|
||||
return m_realWindow->put_IsInputEnabled(value);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_Visible(boolean* value)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_get_Visible\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_get_Visible\n");
|
||||
return m_realWindow->get_Visible(value);
|
||||
}
|
||||
|
||||
@@ -56,45 +56,45 @@ INT32 CoreWindowWrapperX::_abi_Activate()
|
||||
//view.TryEnterFullScreenMode();
|
||||
view.PreferredLaunchWindowingMode(winrt::Windows::UI::ViewManagement::ApplicationViewWindowingMode::PreferredLaunchViewSize);
|
||||
|
||||
printf("[CoreWindowWrapperX] --> _abi_Activate\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_Activate\n");
|
||||
return m_realWindow->Activate();
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_Close()
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_Close\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_Close\n");
|
||||
return m_realWindow->Close();
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_AsyncKeyState(VirtualKey key, CoreVirtualKeyStates* value)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_get_AsyncKeyState\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_get_AsyncKeyState\n");
|
||||
return m_realWindow->GetAsyncKeyState(key, value);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_get_KeyState(VirtualKey key, CoreVirtualKeyStates* value)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_get_KeyState\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_get_KeyState\n");
|
||||
return m_realWindow->GetKeyState(key, value);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_Activated(ITypedEventHandler<CoreWindow*, WindowActivatedEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_Activated\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_Activated\n");
|
||||
return m_realWindow->add_Activated(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_Activated(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_Activated\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_Activated\n");
|
||||
return m_realWindow->remove_Activated(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_CharacterReceived(ITypedEventHandler<CoreWindow*, CharacterReceivedEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_CharacterReceived\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_CharacterReceived\n");
|
||||
|
||||
// STUB
|
||||
*token = EventRegistrationToken();
|
||||
@@ -105,14 +105,14 @@ INT32 CoreWindowWrapperX::_abi_add_CharacterReceived(ITypedEventHandler<CoreWind
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_CharacterReceived(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_CharacterReceived\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_CharacterReceived\n");
|
||||
return m_realWindow->remove_CharacterReceived(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_Closed(ITypedEventHandler<CoreWindow*, CoreWindowEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_Closed\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_Closed\n");
|
||||
|
||||
// STUB
|
||||
*token = EventRegistrationToken();
|
||||
@@ -123,27 +123,27 @@ INT32 CoreWindowWrapperX::_abi_add_Closed(ITypedEventHandler<CoreWindow*, CoreWi
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_Closed(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_Closed\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_Closed\n");
|
||||
return m_realWindow->remove_Closed(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_InputEnabled(ITypedEventHandler<CoreWindow*, InputEnabledEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_InputEnabled\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_InputEnabled\n");
|
||||
return m_realWindow->add_InputEnabled(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_InputEnabled(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_InputEnabled\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_InputEnabled\n");
|
||||
return m_realWindow->remove_InputEnabled(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_KeyDown\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_KeyDown\n");
|
||||
|
||||
// STUB
|
||||
*token = EventRegistrationToken();
|
||||
@@ -154,14 +154,14 @@ INT32 CoreWindowWrapperX::_abi_add_KeyDown(ITypedEventHandler<CoreWindow*, KeyEv
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_KeyDown(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_KeyDown\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_KeyDown\n");
|
||||
return m_realWindow->remove_KeyDown(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_KeyUp\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_KeyUp\n");
|
||||
|
||||
// STUB
|
||||
*token = EventRegistrationToken();
|
||||
@@ -172,78 +172,78 @@ INT32 CoreWindowWrapperX::_abi_add_KeyUp(ITypedEventHandler<CoreWindow*, KeyEven
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_KeyUp(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_KeyUp\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_KeyUp\n");
|
||||
return m_realWindow->remove_KeyUp(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_PointerMoved(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_PointerMoved\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_PointerMoved\n");
|
||||
return m_realWindow->add_PointerMoved(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_PointerMoved(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_PointerMoved\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_PointerMoved\n");
|
||||
return m_realWindow->remove_PointerMoved(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_PointerEntered(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_PointerEntered\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_PointerEntered\n");
|
||||
return m_realWindow->add_PointerEntered(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_PointerEntered(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_PointerEntered\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_PointerEntered\n");
|
||||
return m_realWindow->remove_PointerEntered(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_PointerExited(ITypedEventHandler<CoreWindow*, PointerEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_PointerExited\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_PointerExited\n");
|
||||
return m_realWindow->add_PointerExited(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_PointerExited(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_PointerExited\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_PointerExited\n");
|
||||
return m_realWindow->remove_PointerExited(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_SizeChanged(ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_SizeChanged\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_SizeChanged\n");
|
||||
return m_realWindow->add_SizeChanged(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_SizeChanged(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_SizeChanged\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_SizeChanged\n");
|
||||
return m_realWindow->remove_SizeChanged(token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_add_VisibilityChanged(ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*>* handler,
|
||||
EventRegistrationToken* token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_add_VisibilityChanged\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_add_VisibilityChanged\n");
|
||||
return m_realWindow->add_VisibilityChanged(handler, token);
|
||||
}
|
||||
|
||||
INT32 CoreWindowWrapperX::_abi_remove_VisibilityChanged(EventRegistrationToken token)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> _abi_remove_VisibilityChanged\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> _abi_remove_VisibilityChanged\n");
|
||||
return m_realWindow->remove_VisibilityChanged(token);
|
||||
}
|
||||
|
||||
HRESULT CoreWindowWrapperX::QueryInterface(const IID& riid, void** ppvObject)
|
||||
{
|
||||
printf("[CoreWindowWrapperX] --> QueryInterface\n");
|
||||
LOG_INFO("[CoreWindowWrapperX] --> QueryInterface\n");
|
||||
if (riid == __uuidof(IUnknown) ||
|
||||
riid == __uuidof(ICoreApplicationExit) ||
|
||||
riid == __uuidof(IInspectable) ||
|
||||
@@ -263,13 +263,13 @@ HRESULT CoreWindowWrapperX::QueryInterface(const IID& riid, void** ppvObject)
|
||||
|
||||
ULONG CoreWindowWrapperX::AddRef()
|
||||
{
|
||||
//printf("[CoreWindowWrapperX] --> AddRef\n");
|
||||
//LOG_INFO("[CoreWindowWrapperX] --> AddRef\n");
|
||||
return InterlockedIncrement(&m_RefCount);
|
||||
}
|
||||
|
||||
ULONG CoreWindowWrapperX::Release()
|
||||
{
|
||||
//printf("[CoreWindowWrapperX] --> Release\n");
|
||||
//LOG_INFO("[CoreWindowWrapperX] --> Release\n");
|
||||
ULONG refCount = InterlockedDecrement(&m_RefCount);
|
||||
if (refCount == 0) delete this;
|
||||
return refCount;
|
||||
|
||||
@@ -5,7 +5,7 @@ HRESULT XboxUserLicenseInformationWrapperX::QueryInterface(const IID& riid, void
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"XboxUserLicenseInformationWrapperX: [QI] IID Requested: %s\n", str);
|
||||
LOG_INFO_W(L"XboxUserLicenseInformationWrapperX: [QI] IID Requested: %s\n", str);
|
||||
CoTaskMemFree(str);
|
||||
|
||||
if (riid == __uuidof(IXboxUserLicenseInformation))
|
||||
@@ -51,7 +51,7 @@ HRESULT XboxUserLicenseInformationWrapperX::GetTrustLevel(TrustLevel* trustLevel
|
||||
|
||||
HRESULT XboxUserLicenseInformationWrapperX::get_CurrentLicenseUserXuid(winrt::hstring* value)
|
||||
{
|
||||
printf("[XboxUserLicenseInformationWrapperX] get_CurrentLicenseUserXuid\n");
|
||||
LOG_INFO("[XboxUserLicenseInformationWrapperX] get_CurrentLicenseUserXuid\n");
|
||||
*value = winrt::to_hstring(123);
|
||||
return S_OK;
|
||||
}
|
||||
@@ -60,7 +60,7 @@ HRESULT LicenseInformationWrapperX::QueryInterface(const IID& riid, void** ppvOb
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"LicenseInformationWrapperX: [QI] IID Requested: %s\n", str);
|
||||
LOG_INFO_W(L"LicenseInformationWrapperX: [QI] IID Requested: %s\n", str);
|
||||
CoTaskMemFree(str);
|
||||
|
||||
if (riid == __uuidof(ILicenseInformationX))
|
||||
@@ -84,7 +84,7 @@ HRESULT LicenseInformationWrapperX::QueryInterface(const IID& riid, void** ppvOb
|
||||
OLECHAR iidwstr[sizeof(iidstr)];
|
||||
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
|
||||
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
|
||||
printf("[LicenseInformationWrapperX] Interface Not Implemented: %s\n", iidstr);
|
||||
LOG_FATAL("[LicenseInformationWrapperX] Interface Not Implemented: %s\n", iidstr);
|
||||
}
|
||||
|
||||
*ppvObject = nullptr;
|
||||
@@ -126,27 +126,27 @@ HRESULT LicenseInformationWrapperX::get_ProductLicenses(
|
||||
ABI::Windows::Foundation::Collections::__FIMapView_2_HSTRING_Windows__CApplicationModel__CStore__CProductLicense_t**
|
||||
value)
|
||||
{
|
||||
printf("[LicenseInformationWrapperX] get_ProductLicenses\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] get_ProductLicenses\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT LicenseInformationWrapperX::get_IsActive(boolean* value)
|
||||
{
|
||||
printf("[LicenseInformationWrapperX] get_IsActive\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] get_IsActive\n");
|
||||
*value = true;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT LicenseInformationWrapperX::get_IsTrial(boolean* value)
|
||||
{
|
||||
printf("[LicenseInformationWrapperX] get_IsTrial\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] get_IsTrial\n");
|
||||
*value = false;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT LicenseInformationWrapperX::get_ExpirationDate(ABI::Windows::Foundation::DateTime* value)
|
||||
{
|
||||
printf("[LicenseInformationWrapperX] get_ExpirationDate\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] get_ExpirationDate\n");
|
||||
DateTime time;
|
||||
time.UniversalTime = UINT64_MAX;
|
||||
|
||||
@@ -158,7 +158,7 @@ HRESULT LicenseInformationWrapperX::add_LicenseChanged(
|
||||
ABI::Windows::ApplicationModel::Store::ILicenseChangedEventHandler* handler, EventRegistrationToken* cookie)
|
||||
{
|
||||
HRESULT hr = m_realLicenseInformation->add_LicenseChanged(handler, cookie);
|
||||
printf("[LicenseInformationWrapperX] add_LicenseChanged\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] add_LicenseChanged\n");
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
handler->Invoke();
|
||||
@@ -168,7 +168,7 @@ HRESULT LicenseInformationWrapperX::add_LicenseChanged(
|
||||
|
||||
HRESULT LicenseInformationWrapperX::remove_LicenseChanged(EventRegistrationToken cookie)
|
||||
{
|
||||
printf("[LicenseInformationWrapperX] remove_LicenseChanged\n");
|
||||
LOG_INFO("[LicenseInformationWrapperX] remove_LicenseChanged\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ HRESULT __stdcall CurrentAppWrapperX::QueryInterface(REFIID riid, void** ppvObje
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"CurrentAppWrapperX [QI] IID Requested: %s\n", str);
|
||||
LOG_INFO_W(L"CurrentAppWrapperX [QI] IID Requested: %s\n", str);
|
||||
CoTaskMemFree(str);
|
||||
|
||||
if (riid == __uuidof(ICurrentAppX))
|
||||
@@ -193,7 +193,7 @@ HRESULT __stdcall CurrentAppWrapperX::QueryInterface(REFIID riid, void** ppvObje
|
||||
OLECHAR iidwstr[sizeof(iidstr)];
|
||||
StringFromGUID2(riid, iidwstr, ARRAYSIZE(iidwstr));
|
||||
WideCharToMultiByte(CP_UTF8, 0, iidwstr, -1, iidstr, sizeof(iidstr), nullptr, nullptr);
|
||||
printf("[CurrentAppWrapperX] Interface Not Implemented: %s\n", iidstr);
|
||||
LOG_FATAL("[CurrentAppWrapperX] Interface Not Implemented: %s\n", iidstr);
|
||||
}
|
||||
|
||||
*ppvObject = nullptr;
|
||||
@@ -218,25 +218,25 @@ ULONG __stdcall CurrentAppWrapperX::Release()
|
||||
|
||||
HRESULT CurrentAppWrapperX::GetIids(ULONG* iidCount, IID** iids)
|
||||
{
|
||||
printf("[CurrentAppWrapperX] GetIids\n");
|
||||
LOG_INFO("[CurrentAppWrapperX] GetIids\n");
|
||||
return m_realCurrentApp->GetIids(iidCount, iids);
|
||||
}
|
||||
|
||||
HRESULT CurrentAppWrapperX::GetRuntimeClassName(HSTRING* className)
|
||||
{
|
||||
printf("[CurrentAppWrapperX] GetRuntimeClassName\n");
|
||||
LOG_INFO("[CurrentAppWrapperX] GetRuntimeClassName\n");
|
||||
return m_realCurrentApp->GetRuntimeClassName(className);
|
||||
}
|
||||
|
||||
HRESULT CurrentAppWrapperX::GetTrustLevel(TrustLevel* trustLevel)
|
||||
{
|
||||
printf("[CurrentAppWrapperX] GetTrustLevel\n");
|
||||
LOG_INFO("[CurrentAppWrapperX] GetTrustLevel\n");
|
||||
return m_realCurrentApp->GetTrustLevel(trustLevel);
|
||||
}
|
||||
|
||||
HRESULT CurrentAppWrapperX::get_LicenseInformation(ABI::Windows::ApplicationModel::Store::ILicenseInformation** value)
|
||||
{
|
||||
printf("[CurrentAppWrapperX] get_LicenseInformation\n");
|
||||
LOG_INFO("[CurrentAppWrapperX] get_LicenseInformation\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@ HRESULT __stdcall FrameworkViewWrapper::Load(HSTRING entryPoint)
|
||||
|
||||
HRESULT __stdcall FrameworkViewWrapper::Run(void)
|
||||
{
|
||||
|
||||
return m_realView->Run();
|
||||
}
|
||||
|
||||
@@ -35,7 +36,7 @@ HRESULT FrameworkViewWrapper::QueryInterface(const IID& riid, void** ppvObject)
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"FrameworkViewWrapper [QI] IID Requested: %s\n", str);
|
||||
LOG_INFO_W(L"FrameworkViewWrapper [QI] IID Requested: %s\n", str);
|
||||
CoTaskMemFree(str);
|
||||
|
||||
if (riid == __uuidof(IFrameworkView) ||
|
||||
|
||||
@@ -13,7 +13,7 @@ HRESULT STDMETHODCALLTYPE MMDeviceCollectionWrapper::QueryInterface(REFIID riid,
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
LOG_INFO_W(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
CoTaskMemFree(str);
|
||||
if (!ppvObject) return E_POINTER;
|
||||
|
||||
@@ -45,7 +45,7 @@ ULONG STDMETHODCALLTYPE MMDeviceCollectionWrapper::Release()
|
||||
|
||||
HRESULT STDMETHODCALLTYPE MMDeviceCollectionWrapper::GetCount(UINT* pcDevices)
|
||||
{
|
||||
printf("[MMDeviceCollectionWrapper] GetCount called\n");
|
||||
LOG_INFO("[MMDeviceCollectionWrapper] GetCount called\n");
|
||||
return m_realCollection->GetCount(pcDevices);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ void DumpStackTrace() {
|
||||
|
||||
DWORD64 displacement;
|
||||
if (SymFromAddr(process, addr, &displacement, symbol)) {
|
||||
printf("[STACK %02d] %s (0x%llx)\n", i, symbol->Name, symbol->Address);
|
||||
LOG_INFO("[STACK %02d] %s (0x%llx)\n", i, symbol->Name, symbol->Address);
|
||||
}
|
||||
else {
|
||||
printf("[STACK %02d] Unknown Addr (0x%llx)\n", i, addr);
|
||||
LOG_INFO("[STACK %02d] Unknown Addr (0x%llx)\n", i, addr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,13 +42,13 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::QueryInterface(REFIID riid, void**
|
||||
{
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
LOG_INFO_W(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
CoTaskMemFree(str);
|
||||
//DumpStackTrace();
|
||||
printf("[MMDeviceEnumeratorWrapper] QueryInterface called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] QueryInterface called\n");
|
||||
if (riid == __uuidof(IMMXboxDeviceEnumerator))
|
||||
{
|
||||
printf("[MMDeviceEnumeratorWrapper] QueryInterface called and is an Xbox Device Enum\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] QueryInterface called and is an Xbox Device Enum\n");
|
||||
*ppvObject = new MMXboxDeviceEnumerator(this);
|
||||
this->AddRef();
|
||||
return S_OK;
|
||||
@@ -59,13 +59,13 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::QueryInterface(REFIID riid, void**
|
||||
|
||||
ULONG __stdcall MMDeviceEnumeratorWrapper::AddRef(void)
|
||||
{
|
||||
printf("[MMDeviceEnumeratorWrapper] AddRef called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] AddRef called\n");
|
||||
return InterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
ULONG __stdcall MMDeviceEnumeratorWrapper::Release(void)
|
||||
{
|
||||
printf("[MMDeviceEnumeratorWrapper] Release called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] Release called\n");
|
||||
ULONG count = InterlockedDecrement(&m_refCount);
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -82,14 +82,14 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::EnumAudioEndpoints(EDataFlow dataFl
|
||||
if (!ppDevices)
|
||||
return E_POINTER;
|
||||
|
||||
printf("[MMDeviceEnumeratorWrapper] EnumAudioEndpoints called with dataFlow=%d, dwStateMask=0x%08lX\n", dataFlow, static_cast<unsigned long>(dwStateMask));
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] EnumAudioEndpoints called with dataFlow=%d, dwStateMask=0x%08lX\n", dataFlow, static_cast<unsigned long>(dwStateMask));
|
||||
DWORD validMask = DEVICE_STATE_ACTIVE | DEVICE_STATE_DISABLED | DEVICE_STATE_NOTPRESENT | DEVICE_STATE_UNPLUGGED;
|
||||
dwStateMask = dwStateMask & validMask;
|
||||
if (dwStateMask == 0)
|
||||
dwStateMask = 0x0000000F;
|
||||
IMMDeviceCollection* realCollection = nullptr;
|
||||
HRESULT hr = m_realEnumerator->EnumAudioEndpoints(dataFlow, dwStateMask, &realCollection);
|
||||
printf("[MMDeviceEnumeratorWrapper] EnumAudioEndpoints HRESULT: 0x%08X, realCollection: %p\n", hr, realCollection);
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] EnumAudioEndpoints HRESULT: 0x%08X, realCollection: %p\n", hr, realCollection);
|
||||
|
||||
if (FAILED(hr) || !realCollection)
|
||||
{
|
||||
@@ -104,19 +104,19 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::EnumAudioEndpoints(EDataFlow dataFl
|
||||
|
||||
HRESULT __stdcall MMDeviceEnumeratorWrapper::GetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role, IMMDevice** ppEndpoint)
|
||||
{
|
||||
printf("[MMDeviceEnumeratorWrapper] GetDefaultAudioEndpoint called with dataFlow=%d, role=%d\n", dataFlow, role);
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] GetDefaultAudioEndpoint called with dataFlow=%d, role=%d\n", dataFlow, role);
|
||||
IMMDevice* realDevice = nullptr;
|
||||
HRESULT hr = m_realEnumerator->GetDefaultAudioEndpoint(dataFlow, role, &realDevice);
|
||||
printf("[Wrapper] GetDefaultAudioEndpoint HRESULT: 0x%08X, realDevice: %p, ppEndpoint: %p\n", hr, realDevice, ppEndpoint);
|
||||
LOG_INFO("[Wrapper] GetDefaultAudioEndpoint HRESULT: 0x%08X, realDevice: %p, ppEndpoint: %p\n", hr, realDevice, ppEndpoint);
|
||||
|
||||
if (SUCCEEDED(hr) && realDevice && ppEndpoint)
|
||||
{
|
||||
printf("SUCCESS: Creating MMDeviceWrapper\n");
|
||||
LOG_INFO("SUCCESS: Creating MMDeviceWrapper\n");
|
||||
*ppEndpoint = new MMDeviceWrapper(realDevice);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("FAILED: hr=0x%08X, realDevice=%p, ppEndpoint=%p\n", hr, realDevice, ppEndpoint);
|
||||
LOG_ERROR("FAILED: hr=0x%08X, realDevice=%p, ppEndpoint=%p\n", hr, realDevice, ppEndpoint);
|
||||
if (ppEndpoint) *ppEndpoint = nullptr;
|
||||
}
|
||||
|
||||
@@ -125,7 +125,7 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::GetDefaultAudioEndpoint(EDataFlow d
|
||||
|
||||
HRESULT __stdcall MMDeviceEnumeratorWrapper::GetDevice(LPCWSTR pwstrId, IMMDevice** ppDevice)
|
||||
{
|
||||
printf("[MMDeviceEnumeratorWrapper] GetDevice called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] GetDevice called\n");
|
||||
|
||||
IMMDevice* realDevice = nullptr;
|
||||
HRESULT hr = m_realEnumerator->GetDevice(pwstrId, &realDevice);
|
||||
@@ -145,13 +145,13 @@ HRESULT __stdcall MMDeviceEnumeratorWrapper::GetDevice(LPCWSTR pwstrId, IMMDevic
|
||||
HRESULT __stdcall MMDeviceEnumeratorWrapper::RegisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
//DumpStackTrace();
|
||||
printf("[MMDeviceEnumeratorWrapper] RegisterEndpointNotificationCallback called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] RegisterEndpointNotificationCallback called\n");
|
||||
return m_realEnumerator->RegisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMDeviceEnumeratorWrapper::UnregisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
//DumpStackTrace();
|
||||
printf("[MMDeviceEnumeratorWrapper] UnregisterEndpointNotificationCallback called\n");
|
||||
LOG_INFO("[MMDeviceEnumeratorWrapper] UnregisterEndpointNotificationCallback called\n");
|
||||
return m_realEnumerator->UnregisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
@@ -9,10 +9,10 @@ MMDeviceWrapper::MMDeviceWrapper(IMMDevice* realDevice) : m_realDevice(realDevic
|
||||
|
||||
HRESULT __stdcall MMDeviceWrapper::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
printf("[MMDeviceWrapper] QueryInterface called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] QueryInterface called\n");
|
||||
LPOLESTR str = nullptr;
|
||||
StringFromIID(riid, &str);
|
||||
wprintf(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
LOG_INFO_W(L"[QueryInterface] IID requested: %ls\n", str);
|
||||
CoTaskMemFree(str);
|
||||
|
||||
return m_realDevice->QueryInterface(riid, ppvObject);
|
||||
@@ -20,13 +20,13 @@ HRESULT __stdcall MMDeviceWrapper::QueryInterface(REFIID riid, void** ppvObject)
|
||||
|
||||
ULONG __stdcall MMDeviceWrapper::AddRef(void)
|
||||
{
|
||||
printf("[MMDeviceWrapper] AddRef called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] AddRef called\n");
|
||||
return InterlockedIncrement(&m_refCount);
|
||||
}
|
||||
|
||||
ULONG __stdcall MMDeviceWrapper::Release(void)
|
||||
{
|
||||
printf("[MMDeviceWrapper] Release called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] Release called\n");
|
||||
ULONG count = InterlockedDecrement(&m_refCount);
|
||||
if (count == 0)
|
||||
{
|
||||
@@ -39,7 +39,7 @@ ULONG __stdcall MMDeviceWrapper::Release(void)
|
||||
|
||||
HRESULT __stdcall MMDeviceWrapper::Activate(REFIID iid, DWORD dwClsCtx, PROPVARIANT* pActivationParams, void** ppInterface)
|
||||
{
|
||||
printf("[MMDeviceWrapper] Activate called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] Activate called\n");
|
||||
return m_realDevice->Activate(iid, dwClsCtx, pActivationParams, ppInterface);
|
||||
|
||||
}
|
||||
@@ -47,18 +47,18 @@ HRESULT __stdcall MMDeviceWrapper::Activate(REFIID iid, DWORD dwClsCtx, PROPVARI
|
||||
|
||||
HRESULT __stdcall MMDeviceWrapper::OpenPropertyStore(DWORD stgmAccess, IPropertyStore** ppProperties)
|
||||
{
|
||||
printf("[MMDeviceWrapper] OpenPropertyStore called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] OpenPropertyStore called\n");
|
||||
return m_realDevice->OpenPropertyStore(stgmAccess, ppProperties);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMDeviceWrapper::GetId(LPWSTR* ppstrId)
|
||||
{
|
||||
printf("[MMDeviceWrapper] GetId called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] GetId called\n");
|
||||
return m_realDevice->GetId(ppstrId);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMDeviceWrapper::GetState(DWORD* pdwState)
|
||||
{
|
||||
printf("[MMDeviceWrapper] GetState called\n");
|
||||
LOG_INFO("[MMDeviceWrapper] GetState called\n");
|
||||
return m_realDevice->GetState(pdwState);
|
||||
}
|
||||
@@ -3,66 +3,66 @@
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::QueryInterface\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::QueryInterface\n");
|
||||
return m_realEnumerator->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG __stdcall MMXboxDeviceEnumerator::AddRef(void)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::AddRef\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::AddRef\n");
|
||||
return m_realEnumerator->AddRef();
|
||||
}
|
||||
|
||||
ULONG __stdcall MMXboxDeviceEnumerator::Release(void)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::Release\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::Release\n");
|
||||
return m_realEnumerator->Release();
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::EnumAudioEndpoints(EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection** ppDevices)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::EnumAudioEndpoints\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::EnumAudioEndpoints\n");
|
||||
return m_realEnumerator->EnumAudioEndpoints(dataFlow, dwStateMask, ppDevices);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role, IMMDevice** ppEndpoint)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetDefaultAudioEndpoint\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::GetDefaultAudioEndpoint\n");
|
||||
return m_realEnumerator->GetDefaultAudioEndpoint(dataFlow, role, ppEndpoint);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetDevice(LPCWSTR pwstrId, IMMDevice** ppDevice)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetDevice\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::GetDevice\n");
|
||||
return m_realEnumerator->GetDevice(pwstrId, ppDevice);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::RegisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::RegisterEndpointNotificationCallback\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::RegisterEndpointNotificationCallback\n");
|
||||
return m_realEnumerator->RegisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::UnregisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::UnregisterEndpointNotificationCallback\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::UnregisterEndpointNotificationCallback\n");
|
||||
return m_realEnumerator->UnregisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetHdAudioChannelCounts(unsigned int* pHdmiChannelCount, unsigned int* pSpdifChannelCount)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetHdAudioChannelCount\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::GetHdAudioChannelCount\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::RegisterChannelCountNotificationCallback(uint32_t* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::RegisterChannelCountNotificationCallback\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::RegisterChannelCountNotificationCallback\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::UnregisterChannelCountNotificationCallback(uint32_t* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::UnregisterChannelCountNotificationCallback\n");
|
||||
LOG_INFO("MMXboxDeviceEnumerator::UnregisterChannelCountNotificationCallback\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@@ -33,7 +33,7 @@ inline void LoadMods()
|
||||
if (!ret)
|
||||
{
|
||||
DWORD error = GetLastError();
|
||||
printf("Error creating Mods directory: %d\n", error);
|
||||
LOG_INFO("Error creating Mods directory: %d\n", error);
|
||||
}
|
||||
|
||||
}*/
|
||||
@@ -59,7 +59,7 @@ inline void LoadMods()
|
||||
if (loadedModule != nullptr)
|
||||
{
|
||||
loadedMods.push_back(loadedModule);
|
||||
printf("Loaded mod: %S\n", modPath);
|
||||
LOG_INFO("Loaded mod: %S\n", modPath);
|
||||
}
|
||||
}
|
||||
} while (FindNextFileW(hFind, &findData));
|
||||
@@ -98,7 +98,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
//Rodrigo Todescatto: Forza Horizon 2 Demo.
|
||||
if (GamePackage == L"265E1020-Anthem_8wekyb3d8bbwe")
|
||||
{
|
||||
printf("Forza Horizon 2 Demo\n");
|
||||
LOG_INFO("Forza Horizon 2 Demo\n");
|
||||
*(void**)&P_StartForzaThread_X = (char*)GetModuleHandleW(nullptr) + 0xFE6920;
|
||||
RETURN_IF_FAILED(HRESULT_FROM_WIN32(DetourTransactionBegin()));
|
||||
RETURN_IF_FAILED(HRESULT_FROM_WIN32(DetourAttach((void**)&P_StartForzaThread_X, &D_StartForzaThread_X)));
|
||||
@@ -107,7 +107,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
//Rodrigo Todescatto: Forza Horizon 2.
|
||||
if (GamePackage == L"Anthem_8wekyb3d8bbwe")
|
||||
{
|
||||
printf("Forza Horizon 2\n");
|
||||
LOG_INFO("Forza Horizon 2\n");
|
||||
*(void**)&P_StartForzaThread_X = (char*)GetModuleHandleW(nullptr) + 0x1081A90;
|
||||
RETURN_IF_FAILED(HRESULT_FROM_WIN32(DetourTransactionBegin()));
|
||||
RETURN_IF_FAILED(HRESULT_FROM_WIN32(DetourAttach((void**)&P_StartForzaThread_X, &D_StartForzaThread_X)));
|
||||
@@ -120,21 +120,21 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
//Rodrigo Todescatto: Forza Motorsport 5.
|
||||
if (GamePackage == L"Forza_8wekyb3d8bbwe")
|
||||
{
|
||||
printf("Forza Motorsport 5");
|
||||
LOG_INFO("Forza Motorsport 5");
|
||||
}
|
||||
//Rodrigo Todescatto: Forza Horizon 2 Presents Fast & Furious.
|
||||
if (GamePackage == L"Spire_8wekyb3d8bbwe")
|
||||
{
|
||||
printf("Forza Horizon 2 Presents Fast & Furious");
|
||||
LOG_INFO("Forza Horizon 2 Presents Fast & Furious");
|
||||
}
|
||||
if (GamePackage == L"HappyDungeons_zyyfzks419954")
|
||||
{
|
||||
printf("Happy Happy Happy Dungeons Dungeons Dungeons\n");
|
||||
LOG_INFO("Happy Dungeons\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
#if WINDURANGO_WAIT_FOR_DEBUGGER
|
||||
printf("Waiting for debugger...\n");
|
||||
LOG_INFO("Waiting for debugger...\n");
|
||||
while (!IsDebuggerPresent())
|
||||
Sleep(1);
|
||||
#endif
|
||||
|
||||
@@ -187,7 +187,7 @@ HRESULT PatchNeededImports(_In_opt_ HMODULE Module, _In_ HMODULE ImportModule, _
|
||||
|
||||
HMODULE WINAPI LoadLibraryExW_X(LPCWSTR lpLibFileName, HANDLE hFile, DWORD dwFlags)
|
||||
{
|
||||
printf("LoadLibraryExW_X: %S\n", lpLibFileName);
|
||||
LOG_INFO("LoadLibraryExW_X: %S\n", lpLibFileName);
|
||||
if (wcscmp(lpLibFileName, L"xaudio2_9.dll") == 0 ||
|
||||
wcscmp(lpLibFileName, L"xaudio2_9d.dll") == 0)
|
||||
{
|
||||
@@ -270,7 +270,10 @@ HANDLE CreateFile2_Hook(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShare
|
||||
DWORD dwCreationDisposition, LPCREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
|
||||
{
|
||||
FixRelativePath(lpFileName);
|
||||
|
||||
if (_DEBUG)
|
||||
{
|
||||
LOG_INFO("CreateFile2_Hook: %ls", lpFileName);
|
||||
}
|
||||
return TrueCreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, pCreateExParams);
|
||||
}
|
||||
|
||||
@@ -299,7 +302,7 @@ HMODULE WINAPI LoadLibraryExA_Hook(LPCSTR lpLibFileName, _Reserved_ HANDLE hFile
|
||||
lpLibFileName = convert.c_str();
|
||||
}
|
||||
|
||||
printf("LoadLibraryExA_Hook-: %s\n", lpLibFileName);
|
||||
LOG_INFO("LoadLibraryExA_Hook-: %s\n", lpLibFileName);
|
||||
|
||||
|
||||
|
||||
@@ -308,7 +311,7 @@ HMODULE WINAPI LoadLibraryExA_Hook(LPCSTR lpLibFileName, _Reserved_ HANDLE hFile
|
||||
// Print last error if failed
|
||||
if (result == NULL)
|
||||
{
|
||||
printf("LoadLibraryExA_Hook failed: %d\n", GetLastError());
|
||||
LOG_ERROR("LoadLibraryExA_Hook failed: %d\n", GetLastError());
|
||||
}
|
||||
|
||||
PatchNeededImports(result, GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect);
|
||||
@@ -333,7 +336,7 @@ HMODULE WINAPI LoadLibraryW_Hook(LPCWSTR lpLibFileName)
|
||||
|
||||
lpLibFileName = convert.data();
|
||||
}
|
||||
printf("LoadLibraryW_Hook: %ls\n", lpLibFileName);
|
||||
LOG_INFO("LoadLibraryW_Hook: %ls\n", lpLibFileName);
|
||||
|
||||
HMODULE result = TrueLoadLibraryW(lpLibFileName);
|
||||
PatchNeededImports(result, GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect);
|
||||
@@ -422,16 +425,16 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
|
||||
|
||||
// Get the raw buffer from the HSTRING
|
||||
const wchar_t* rawString = WindowsGetStringRawBuffer(classId, nullptr);
|
||||
printf("WinRT Class Activated: %S\n", rawString);
|
||||
LOG_INFO("WinRT Class Activated: %S\n", rawString);
|
||||
// this might be a lil expensive? evaluate later
|
||||
if (wcscmp(rawString, L"Windows.UI.Core.CoreWindow") != 0)
|
||||
wprintf(L"%ls\n", rawString);
|
||||
LOG_INFO_W(L"%ls\n", rawString);
|
||||
|
||||
auto hr = 0;
|
||||
|
||||
if (IsClassName(classId, "Windows.ApplicationModel.Store.CurrentApp"))
|
||||
{
|
||||
printf("CLASS: Windows.ApplicationModel.Store.CurrentApp\n");
|
||||
LOG_INFO("CLASS: Windows.ApplicationModel.Store.CurrentApp\n");
|
||||
hr = TrueRoGetActivationFactory(classId, iid, factory);
|
||||
|
||||
if (FAILED(hr))
|
||||
@@ -448,7 +451,7 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
|
||||
|
||||
if (IsClassName(classId, "Windows.ApplicationModel.Core.CoreApplication"))
|
||||
{
|
||||
printf("CLASS: Windows.ApplicationModel.Core.CoreApplication\n");
|
||||
LOG_INFO("CLASS: Windows.ApplicationModel.Core.CoreApplication\n");
|
||||
ComPtr<IActivationFactory> realFactory;
|
||||
|
||||
hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_ApplicationModel_Core_CoreApplication).Get(), IID_PPV_ARGS(&realFactory));
|
||||
@@ -463,7 +466,7 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
|
||||
|
||||
if (IsClassName(classId, "Windows.UI.Core.CoreWindow"))
|
||||
{
|
||||
printf("CLASS: Windows.UI.Core.CoreWindow\n");
|
||||
LOG_INFO("CLASS: Windows.UI.Core.CoreWindow\n");
|
||||
//
|
||||
// for now we just hook GetForCurrentThread to get the CoreWindow but i'll change it later to
|
||||
// wrap ICoreWindowStatic or as zombie said another thing that works is by hooking IFrameworkView::SetWindow
|
||||
@@ -472,7 +475,7 @@ inline HRESULT WINAPI RoGetActivationFactory_Hook(HSTRING classId, REFIID iid, v
|
||||
ComPtr<ICoreWindowStatic> coreWindowStatic;
|
||||
hr = TrueRoGetActivationFactory(HStringReference(RuntimeClass_Windows_UI_Core_CoreWindow).Get(), IID_PPV_ARGS(&coreWindowStatic));
|
||||
if (FAILED(hr)) {
|
||||
printf("FAILEDDDDDD\n");
|
||||
LOG_ERROR("FAILEDDDDDD\n");
|
||||
return hr;
|
||||
}
|
||||
|
||||
@@ -525,7 +528,7 @@ HRESULT WINAPI GetActivationFactoryRedirect(PCWSTR str, REFIID riid, void** ppFa
|
||||
if (FAILED(hr = WindowsCreateStringReference(str, wcslen(str), &classNameHeader, &className)))
|
||||
return hr;
|
||||
|
||||
printf("GetActivationFactoryRedirect: %S\n", str);
|
||||
LOG_INFO("GetActivationFactoryRedirect: %S\n", str);
|
||||
|
||||
hr = RoGetActivationFactory_Hook(className, riid, ppFactory);
|
||||
WindowsDeleteString(className);
|
||||
|
||||
@@ -82,7 +82,6 @@ BOOL __stdcall WaitOnAddress_X(volatile void* Address, PVOID CompareAddress, SIZ
|
||||
BOOL JobTitleMemoryStatus_X(void* pJob, LPTITLEMEMORYSTATUS Buffer) {
|
||||
__int64 jobInfo[7]; // Buffer to store job object memory information
|
||||
NTSTATUS status;
|
||||
DEBUG_LOG();
|
||||
// Validate input parameters
|
||||
if (!pJob || !Buffer || Buffer->dwLength != sizeof(TITLEMEMORYSTATUS)) {
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
@@ -337,26 +336,26 @@ LPVOID VirtualAllocEx_X(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD
|
||||
flProtect &= PROTECT_FLAGS_MASK;
|
||||
flAllocationType &= ALLOCATION_FLAGS_MASK;
|
||||
|
||||
DEBUGLOG("VirtualAllocEx_X: %p, %zu, %x, %x\n", lpAddress, dwSize, flAllocationType, flProtect);
|
||||
LOG_DEBUG("VirtualAllocEx_X: %p, %zu, %x, %x\n", lpAddress, dwSize, flAllocationType, flProtect);
|
||||
|
||||
LPVOID ret = VirtualAllocEx(hProcess, lpAddress, dwSize, flAllocationType, flProtect);
|
||||
if (!ret) {
|
||||
DWORD err = GetLastError();
|
||||
DEBUGLOG("VirtualAllocEx failed with error %lu\n", err);
|
||||
LOG_ERROR("VirtualAllocEx failed with error %lu\n", err);
|
||||
|
||||
if (err == ERROR_PRIVILEGE_NOT_HELD) {
|
||||
DEBUGLOG("VirtualAllocEx failed due to missing privileges (SeDebugPrivilege).\n");
|
||||
LOG_ERROR("VirtualAllocEx failed due to missing privileges (SeDebugPrivilege).\n");
|
||||
}
|
||||
|
||||
// Fallback only if allocating into self
|
||||
if (hProcess == GetCurrentProcess() || hProcess == NULL) {
|
||||
DEBUGLOG("Attempting fallback with VirtualAlloc...\n");
|
||||
LOG_WARNING("Attempting fallback with VirtualAlloc...\n");
|
||||
|
||||
if ((flAllocationType & (MEM_RESERVE | MEM_COMMIT)) != 0) {
|
||||
ret = VirtualAlloc(lpAddress, dwSize, flAllocationType, flProtect);
|
||||
if (!ret) {
|
||||
DWORD fallbackErr = GetLastError();
|
||||
DEBUGLOG("VirtualAlloc fallback also failed: %lu\n", fallbackErr);
|
||||
LOG_ERROR("VirtualAlloc fallback also failed: %lu\n", fallbackErr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -364,7 +363,7 @@ LPVOID VirtualAllocEx_X(HANDLE hProcess, LPVOID lpAddress, SIZE_T dwSize, DWORD
|
||||
|
||||
// Final safety: log if still null
|
||||
if (!ret) {
|
||||
DEBUGLOG("VirtualAllocEx_X ultimately failed to allocate %zu bytes.\n", dwSize);
|
||||
LOG_ERROR("VirtualAllocEx_X ultimately failed to allocate %zu bytes.\n", dwSize);
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -382,7 +381,6 @@ LPVOID VirtualAlloc_X(
|
||||
}
|
||||
BOOL ToolingMemoryStatus_X(LPTOOLINGMEMORYSTATUS buffer)
|
||||
{
|
||||
DEBUG_LOG();
|
||||
__int64 SystemInformation[4];
|
||||
|
||||
if (buffer->dwLength != 40)
|
||||
|
||||
@@ -6,9 +6,8 @@
|
||||
|
||||
#include "CoreWindowWrapperX.h"
|
||||
#include "ICoreWindowX.h"
|
||||
#include "../common/DebugLogger.h"
|
||||
#include "../../Thirdparty/Detours/src/detours.h"
|
||||
|
||||
#include "..\common\Logger.h"
|
||||
#include <intrin.h>
|
||||
#include <winternl.h>
|
||||
#include <cstdint>
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::CreateContainer(winrt::hstring name) const
|
||||
{
|
||||
// Logger::Warning("[ConnectedStorage] Container %S requested creation\n", name.c_str());
|
||||
// LOG_WARNING("[ConnectedStorage] Container %S requested creation\n", name.c_str());
|
||||
|
||||
if (!co_await DoesFolderExist(m_storagePath + L"\\" + name))
|
||||
{
|
||||
@@ -20,7 +20,7 @@ winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Cre
|
||||
co_await folder.CreateFolderAsync(name);
|
||||
}
|
||||
|
||||
//Logger::Warning("[ConnectedStorage] Container %S created\n", name.c_str());
|
||||
//LOG_WARNING("[ConnectedStorage] Container %S created\n", name.c_str());
|
||||
}
|
||||
|
||||
winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Read(
|
||||
@@ -28,7 +28,7 @@ winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Rea
|
||||
{
|
||||
if (!co_await DoesFolderExist(m_storagePath + L"\\" + containerName)) {
|
||||
co_await CreateContainer(containerName);
|
||||
printf("[ConnectedStorage] Container %S created\n", containerName.c_str( ));
|
||||
LOG_INFO("[ConnectedStorage] Container %S created\n", containerName.c_str( ));
|
||||
}
|
||||
|
||||
auto folder = co_await winrt::Windows::Storage::StorageFolder::GetFolderFromPathAsync(m_storagePath + L"\\" + containerName);
|
||||
@@ -36,7 +36,7 @@ winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Rea
|
||||
for (auto const& pair : data)
|
||||
{
|
||||
auto fileName = pair.Key();
|
||||
//printf("FileName -> %ls | folder -> %ls\n", fileName.c_str(), folder.Path().c_str());
|
||||
//LOG_INFO("FileName -> %ls | folder -> %ls\n", fileName.c_str(), folder.Path().c_str());
|
||||
auto file = co_await folder.GetFileAsync(fileName);
|
||||
auto fileBuffer = co_await winrt::Windows::Storage::FileIO::ReadBufferAsync(file);
|
||||
auto bufferByteAccess = fileBuffer.as<Windows::Storage::Streams::IBufferByteAccess>();
|
||||
@@ -58,7 +58,7 @@ winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Upl
|
||||
{
|
||||
if (!co_await DoesFolderExist(m_storagePath + L"\\" + containerName)) {
|
||||
co_await CreateContainer(containerName);
|
||||
printf("[ConnectedStorage] Container %S created\n", containerName.c_str( ));
|
||||
LOG_INFO("[ConnectedStorage] Container %S created\n", containerName.c_str( ));
|
||||
}
|
||||
|
||||
// if a displayName is provided, inside the folder create a txt called wd_displayname.txt with the displayName
|
||||
@@ -193,7 +193,7 @@ winrt::Windows::Foundation::IAsyncOperation<bool> WinDurango::impl::ConnectedSto
|
||||
else
|
||||
{
|
||||
// Log unexpected errors for debugging
|
||||
printf("Unexpected error while checking file existence: %ls\n", ex.message( ).c_str( ));
|
||||
LOG_ERROR("Unexpected error while checking file existence: %ls\n", ex.message( ).c_str( ));
|
||||
throw; // Re-throw unexpected exceptions
|
||||
}
|
||||
}
|
||||
@@ -230,5 +230,5 @@ winrt::Windows::Foundation::IAsyncAction WinDurango::impl::ConnectedStorage::Ini
|
||||
{
|
||||
co_await CreateDirectories(name, m_storagePath);
|
||||
|
||||
printf("[ConnectedStorage] User storage initialized at %S\n", m_storagePath.c_str());
|
||||
LOG_INFO("[ConnectedStorage] User storage initialized at %S\n", m_storagePath.c_str());
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace winrt::Microsoft::Xbox::Services::Presence::implementation
|
||||
{
|
||||
PresenceData::PresenceData(hstring const& serviceConfigurationId, hstring const& presenceId)
|
||||
{
|
||||
Logger::Warning("[PresenceData] PresenceData::PresenceData(hstring const& serviceConfigurationId, hstring const& presenceId) called\n");
|
||||
LOG_WARNING("[PresenceData] PresenceData::PresenceData(hstring const& serviceConfigurationId, hstring const& presenceId) called\n");
|
||||
}
|
||||
PresenceData::PresenceData(hstring const& serviceConfigurationId, hstring const& presenceId, winrt::Windows::Foundation::Collections::IVectorView<hstring> const& presenceTokenIds)
|
||||
{
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace winrt::Microsoft::Xbox::Services::Presence::implementation
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction PresenceService::SetPresenceAsync(bool isUserActiveInTitle, winrt::Microsoft::Xbox::Services::Presence::PresenceData presenceData)
|
||||
{
|
||||
Logger::Warning("[PresenceService] SetPresenceAsync called\n");
|
||||
LOG_WARNING("[PresenceService] SetPresenceAsync called\n");
|
||||
co_return;
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Microsoft::Xbox::Services::Presence::PresenceRecord> PresenceService::GetPresenceAsync(hstring xboxUserId)
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace winrt::Microsoft::Xbox::Services::RealTimeActivity::implementation
|
||||
}
|
||||
void RealTimeActivityService::Deactivate()
|
||||
{
|
||||
Logger::Warning("[RealTimeActivityService] Deactivate (function is stubbed)\n");
|
||||
LOG_WARNING("[RealTimeActivityService] Deactivate (function is stubbed)\n");
|
||||
}
|
||||
winrt::event_token RealTimeActivityService::RealTimeActivityConnectionStateChange(winrt::Windows::Foundation::EventHandler<winrt::Microsoft::Xbox::Services::RealTimeActivity::RealTimeActivityConnectionState> const& __param0)
|
||||
{
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace winrt::Microsoft::Xbox::Services::UserStatistics::implementation
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVectorView<winrt::Microsoft::Xbox::Services::UserStatistics::UserStatisticsResult>> UserStatisticsService::GetMultipleUserStatisticsAsync(winrt::Windows::Foundation::Collections::IVectorView<hstring> xboxUserIds, hstring serviceConfigurationId, winrt::Windows::Foundation::Collections::IVectorView<hstring> statisticNames)
|
||||
{
|
||||
for (uint32_t i = 0; i < statisticNames.Size( ); i++) {
|
||||
printf("[UserStatisticsService] GetMultipleUserStatisticsAsync [Statistic (%u)] [%ls]\n", i, statisticNames.GetAt(i).c_str( ));
|
||||
LOG_INFO("[UserStatisticsService] GetMultipleUserStatisticsAsync [Statistic (%u)] [%ls]\n", i, statisticNames.GetAt(i).c_str( ));
|
||||
}
|
||||
|
||||
co_return winrt::single_threaded_vector<UserStatisticsResult>( ).GetView( );
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace winrt::Microsoft::Xbox::Services::implementation
|
||||
{
|
||||
XboxLiveContext::XboxLiveContext(winrt::Windows::Xbox::System::User const& user) : m_user(user)
|
||||
{
|
||||
Logger::Info("[Microsoft::Xbox::Services::XboxLiveContext] Constructor called\n");
|
||||
LOG_INFO("[Microsoft::Xbox::Services::XboxLiveContext] Constructor called\n");
|
||||
}
|
||||
|
||||
winrt::Windows::Xbox::System::User XboxLiveContext::User( )
|
||||
|
||||
@@ -23,20 +23,20 @@ namespace winrt::Windows::Kinect::implementation
|
||||
}
|
||||
void KinectSensor::Open()
|
||||
{
|
||||
Logger::Warning("[KinectSensor] Open\n");
|
||||
LOG_WARNING("[KinectSensor] Open\n");
|
||||
}
|
||||
void KinectSensor::Close()
|
||||
{
|
||||
Logger::Warning("[KinectSensor] Close\n");
|
||||
LOG_WARNING("[KinectSensor] Close\n");
|
||||
}
|
||||
bool KinectSensor::IsOpen()
|
||||
{
|
||||
Logger::Warning("[KinectSensor] IsOpen\n");
|
||||
LOG_WARNING("[KinectSensor] IsOpen\n");
|
||||
return false;
|
||||
}
|
||||
bool KinectSensor::IsPaused()
|
||||
{
|
||||
Logger::Warning("[KinectSensor] IsPaused\n");
|
||||
LOG_WARNING("[KinectSensor] IsPaused\n");
|
||||
return false;
|
||||
}
|
||||
winrt::Windows::Kinect::ColorFrameSource KinectSensor::ColorFrameSource()
|
||||
|
||||
@@ -21,57 +21,57 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
}
|
||||
winrt::event_token Controller::ControllerAdded(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::ControllerAddedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Controller || Controller Added!\n");
|
||||
LOG_INFO_W(L"Controller || Controller Added!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
void Controller::ControllerAdded(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Controller || Controller Added!\n");
|
||||
LOG_INFO_W(L"Controller || Controller Added!\n");
|
||||
throw hresult_not_implemented( );
|
||||
}
|
||||
winrt::event_token Controller::ControllerRemoved(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::ControllerRemovedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Controller || Controller Removed!\n");
|
||||
LOG_INFO_W(L"Controller || Controller Removed!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
void Controller::ControllerRemoved(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Controller || Controller Removed!\n");
|
||||
LOG_INFO_W(L"Controller || Controller Removed!\n");
|
||||
throw hresult_not_implemented( );
|
||||
}
|
||||
winrt::event_token Controller::ControllerPairingChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::ControllerPairingChangedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Controller || ControllerPairingChanged!\n");
|
||||
LOG_INFO_W(L"Controller || ControllerPairingChanged!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
void Controller::ControllerPairingChanged(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Controller || ControllerPairingChanged!\n");
|
||||
LOG_INFO_W(L"Controller || ControllerPairingChanged!\n");
|
||||
throw hresult_not_implemented( );
|
||||
}
|
||||
winrt::event_token Controller::ControllerOrderChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::ControllerOrderChangedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Controller || ControllerOrderChanged!\n");
|
||||
LOG_INFO_W(L"Controller || ControllerOrderChanged!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
void Controller::ControllerOrderChanged(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Controller || ControllerOrderChanged!\n");
|
||||
LOG_INFO_W(L"Controller || ControllerOrderChanged!\n");
|
||||
throw hresult_not_implemented( );
|
||||
}
|
||||
winrt::Windows::Xbox::Input::IController Controller::GetControllerById(uint64_t controllerId)
|
||||
{
|
||||
wprintf(L"Controller || GetControllerById!\n");
|
||||
LOG_INFO_W(L"Controller || GetControllerById!\n");
|
||||
return newController;
|
||||
}
|
||||
void Controller::GetControllerMetadata(uint64_t controllerId, winrt::Windows::Xbox::Input::MetadataVersion const& metadataVersion, com_array<uint8_t>& ppMetadata)
|
||||
{
|
||||
wprintf(L"Controller || GetControllerMetadata!\n");
|
||||
LOG_INFO_W(L"Controller || GetControllerMetadata!\n");
|
||||
throw hresult_not_implemented( );
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Input::IController> Controller::GetControllersOrderedLeftToRight(winrt::Windows::Xbox::Input::ControllerOrderFilter const& orderFilter)
|
||||
{
|
||||
wprintf(L"Controller || GetControllersOrderedLeftToRight!\n");
|
||||
LOG_INFO_W(L"Controller || GetControllersOrderedLeftToRight!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
|
||||
}
|
||||
@@ -85,12 +85,12 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
}
|
||||
winrt::Windows::Xbox::System::User Controller::User( )
|
||||
{
|
||||
wprintf(L"Controller || User Queried!\n");
|
||||
LOG_INFO_W(L"Controller || User Queried!\n");
|
||||
return System::implementation::User::Users( ).GetAt(Id( ));
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::System::IAudioDeviceInfo> Controller::AudioDevices( )
|
||||
{
|
||||
Logger::Warning("[AudioDevices] STUBBED\n");
|
||||
LOG_WARNING("[AudioDevices] STUBBED\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
winrt::Windows::Xbox::Input::GameControllerVersionInfo Controller::FirmwareVersionInfo( )
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
{
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Input::IGamepad> Gamepad::Gamepads()
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepads Queried!\n");
|
||||
LOG_INFO_W(L"Gamepad || Gamepads Queried!\n");
|
||||
|
||||
if (staticGamepads == Foundation::Collections::IVector<winrt::Windows::Xbox::Input::IGamepad>(nullptr) || staticGamepads.Size( ) == 0) {
|
||||
staticGamepads = winrt::single_threaded_vector<Input::IGamepad>( );
|
||||
@@ -21,7 +21,7 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
XINPUT_CAPABILITIES capabilities;
|
||||
if (XInputGetCapabilities(gamepad, XINPUT_FLAG_GAMEPAD, &capabilities) == ERROR_SUCCESS)
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad %d Created!\n", gamepad);
|
||||
LOG_INFO_W(L"Gamepad || Gamepad %d Created!\n", gamepad);
|
||||
IGamepad newGamepad = winrt::make<Gamepad>(gamepad);
|
||||
staticGamepads.Append(newGamepad);
|
||||
continue;
|
||||
@@ -30,7 +30,7 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
}
|
||||
|
||||
if (staticGamepads.Size( ) == 0) {
|
||||
wprintf(L"Gamepad || No Gamepads Found!\n");
|
||||
LOG_INFO_W(L"Gamepad || No Gamepads Found!\n");
|
||||
IGamepad dummyGamepad = winrt::make<Gamepad>(0);
|
||||
staticGamepads.Append(dummyGamepad);
|
||||
}
|
||||
@@ -39,27 +39,28 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
}
|
||||
winrt::event_token Gamepad::GamepadAdded(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::GamepadAddedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad Added!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
LOG_INFO_W(L"Gamepad || Gamepad Added!\n");
|
||||
LOG_WARNING("Gamepad || GamepadAdded event is not implemented, returning empty token.");
|
||||
return {};
|
||||
}
|
||||
void Gamepad::GamepadAdded(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad Added!\n");
|
||||
LOG_INFO_W(L"Gamepad || Gamepad Added!\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::event_token Gamepad::GamepadRemoved(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Input::GamepadRemovedEventArgs> const& handler)
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad Removed!\n");
|
||||
LOG_INFO_W(L"Gamepad || Gamepad Removed!\n");
|
||||
LOG_NOT_IMPLEMENTED(); return {};
|
||||
}
|
||||
void Gamepad::GamepadRemoved(winrt::event_token const& token) noexcept
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad Removed!\n");
|
||||
LOG_INFO_W(L"Gamepad || Gamepad Removed!\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
uint64_t Gamepad::Id()
|
||||
{
|
||||
wprintf(L"Gamepad || Gamepad ID ( %d ) Queried!\n", m_id);
|
||||
LOG_INFO_W(L"Gamepad || Gamepad ID ( %d ) Queried!\n", m_id);
|
||||
return m_id;
|
||||
}
|
||||
hstring Gamepad::Type()
|
||||
@@ -68,7 +69,7 @@ namespace winrt::Windows::Xbox::Input::implementation
|
||||
}
|
||||
winrt::Windows::Xbox::System::User Gamepad::User()
|
||||
{
|
||||
wprintf(L"Gamepad || User Queried!\n");
|
||||
LOG_INFO_W(L"Gamepad || User Queried!\n");
|
||||
return System::implementation::User::Users( ).GetAt(Id());
|
||||
}
|
||||
winrt::Windows::Xbox::Input::INavigationReading Gamepad::GetNavigationReading()
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "Windows.Xbox.Input.NavigationController.h"
|
||||
#include "Windows.Xbox.Input.NavigationController.g.cpp"
|
||||
|
||||
|
||||
namespace winrt::Windows::Xbox::Input::implementation
|
||||
{
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Input::INavigationController> NavigationController::NavigationControllers()
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
static_manager = winrt::make<PackageTransferManager>( );
|
||||
}
|
||||
|
||||
Logger::Info("PackageTransferManager::Current()\n");
|
||||
LOG_INFO("PackageTransferManager::Current()\n");
|
||||
return static_manager;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
}
|
||||
bool PackageTransferManager::IsChunkInstalled(uint32_t chunkId)
|
||||
{
|
||||
Logger::Warning("PackageTransferManager::IsChunkInstalled() STUBBED\n");
|
||||
LOG_WARNING("PackageTransferManager::IsChunkInstalled() STUBBED\n");
|
||||
return true;
|
||||
}
|
||||
bool PackageTransferManager::AreChunksInstalled(winrt::Windows::Foundation::Collections::IIterable<uint32_t> const& chunkIds)
|
||||
@@ -53,7 +53,7 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferManager::TransferStatus( )
|
||||
{
|
||||
Logger::Warning("PackageTransferManager::TransferStatus() STUBBED\n");
|
||||
LOG_WARNING("PackageTransferManager::TransferStatus() STUBBED\n");
|
||||
return winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus::None;
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferType PackageTransferManager::TransferType()
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
{
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher PackageTransferWatcher::Create(winrt::Windows::ApplicationModel::Package const& package, winrt::Windows::Foundation::Collections::IIterable<uint32_t> const& chunkIds)
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::Create\n");
|
||||
LOG_WARNING("PackageTransferWatcher::Create\n");
|
||||
return winrt::make<winrt::Windows::Xbox::Management::Deployment::implementation::PackageTransferWatcher>();
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher PackageTransferWatcher::Create(winrt::Windows::ApplicationModel::Package const& package)
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::Create\n");
|
||||
LOG_WARNING("PackageTransferWatcher::Create\n");
|
||||
return winrt::make<winrt::Windows::Xbox::Management::Deployment::implementation::PackageTransferWatcher>();
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher PackageTransferWatcher::CreateForChunkSpecifiers(winrt::Windows::ApplicationModel::Package const& package, winrt::Windows::Xbox::Management::Deployment::ChunkSpecifiers const& specifiers)
|
||||
@@ -44,34 +44,34 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
}
|
||||
void PackageTransferWatcher::ProgressChanged(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::ProgressChanged\n");
|
||||
LOG_WARNING("PackageTransferWatcher::ProgressChanged\n");
|
||||
}
|
||||
winrt::event_token PackageTransferWatcher::TransferCompleted(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher, winrt::Windows::Xbox::Management::Deployment::TransferCompletedEventArgs> const& handler)
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferCompleted\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferCompleted\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
void PackageTransferWatcher::TransferCompleted(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferCompleted\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferCompleted\n");
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferWatcher::TransferStatus()
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferStatus\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferStatus\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferType PackageTransferWatcher::TransferType()
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferType\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferType\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::event_token PackageTransferWatcher::TransferStatusChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher, winrt::Windows::Xbox::Management::Deployment::TransferStatusChangedEventArgs> const& handler)
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferStatusChanged\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferStatusChanged\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
void PackageTransferWatcher::TransferStatusChanged(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
Logger::Warning("PackageTransferWatcher::TransferStatusChanged\n");
|
||||
LOG_WARNING("PackageTransferWatcher::TransferStatusChanged\n");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace winrt::Windows::Xbox::Media::implementation
|
||||
winrt::Windows::Xbox::Media::GameTransportControlsPropertyChangedEventArgs> const& handler)
|
||||
{
|
||||
// Optional debug logging
|
||||
wprintf(L"[GameTransportControls] PropertyChanged handler added\n");
|
||||
LOG_INFO_W(L"[GameTransportControls] PropertyChanged handler added\n");
|
||||
|
||||
return m_gameTransportControlsPropertyChangedEventArgs.add(handler);
|
||||
}
|
||||
|
||||
@@ -13,73 +13,73 @@ namespace winrt::Windows::Xbox::Multiplayer::implementation
|
||||
|
||||
winrt::Windows::Foundation::IAsyncAction Party::RegisterGameSessionAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Xbox::Multiplayer::MultiplayerSessionReference sessionReference)
|
||||
{
|
||||
Logger::Info("Registering game session for user\n");
|
||||
LOG_INFO("Registering game session for user\n");
|
||||
co_await winrt::resume_background( );
|
||||
Logger::Info("Game session registered successfully.\n");
|
||||
LOG_INFO("Game session registered successfully.\n");
|
||||
co_return;
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction Party::RegisterMatchSessionAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Xbox::Multiplayer::MultiplayerSessionReference sessionReference)
|
||||
{
|
||||
Logger::Info("Registering match session for user\n");
|
||||
LOG_INFO("Registering match session for user\n");
|
||||
co_await winrt::resume_background();
|
||||
Logger::Info("Match session registered successfully.\n");
|
||||
LOG_INFO("Match session registered successfully.\n");
|
||||
co_return;
|
||||
}
|
||||
|
||||
winrt::Windows::Foundation::IAsyncAction Party::InviteToPartyAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Foundation::Collections::IVectorView<hstring> usersToInvite)
|
||||
{
|
||||
Logger::Info("Inviting users to party\n");
|
||||
LOG_INFO("Inviting users to party\n");
|
||||
co_await winrt::resume_background();
|
||||
for (auto const& userId : usersToInvite)
|
||||
{
|
||||
printf("Inviting user: %ls\n", userId.c_str());
|
||||
LOG_INFO("Inviting user: %ls\n", userId.c_str());
|
||||
}
|
||||
Logger::Info("Invitations sent successfully.\n");
|
||||
LOG_INFO("Invitations sent successfully.\n");
|
||||
co_return;
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Xbox::Multiplayer::PartyView> Party::GetPartyViewAsync()
|
||||
{
|
||||
Logger::Info("Retrieving party view\n");
|
||||
LOG_INFO("Retrieving party view\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction Party::AddLocalUsersAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::System::User> localUsersToAdd)
|
||||
{
|
||||
Logger::Info("Adding local users to party\n");
|
||||
LOG_INFO("Adding local users to party\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction Party::PullInactivePlayersAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Xbox::Multiplayer::MultiplayerSessionReference sessionReference)
|
||||
{
|
||||
Logger::Info("Pulling inactive players from session\n");
|
||||
LOG_INFO("Pulling inactive players from session\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction Party::PullReservedPlayersAsync(winrt::Windows::Xbox::System::User actingUser, winrt::Windows::Xbox::Multiplayer::MultiplayerSessionReference sessionReference)
|
||||
{
|
||||
Logger::Info("Pulling reserved players from session\n");
|
||||
LOG_INFO("Pulling reserved players from session\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Multiplayer::GamePlayer>> Party::GetAvailableGamePlayersAsync(winrt::Windows::Xbox::System::User actingUser)
|
||||
{
|
||||
Logger::Info("Retrieving available game players for user\n");
|
||||
LOG_INFO("Retrieving available game players for user\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Multiplayer::GamePlayerDeviceGroup>> Party::GetAvailableGamePlayersGroupedByDeviceAsync(winrt::Windows::Xbox::System::User actingUser)
|
||||
{
|
||||
Logger::Info("Retrieving available game players grouped by device for user\n");
|
||||
LOG_INFO("Retrieving available game players grouped by device for user\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction Party::SwitchPartyTitleAsync(winrt::Windows::Xbox::System::User actingUser)
|
||||
{
|
||||
Logger::Info("Switching party title for user\n");
|
||||
LOG_INFO("Switching party title for user\n");
|
||||
LOG_NOT_IMPLEMENTED(); throw hresult_not_implemented();
|
||||
}
|
||||
winrt::event_token Party::GameSessionReady(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Multiplayer::GameSessionReadyEventArgs> const& handler)
|
||||
{
|
||||
Logger::Info("Subscribing to GameSessionReady event\n");
|
||||
LOG_INFO("Subscribing to GameSessionReady event\n");
|
||||
return m_gameSessionReadyEvent.add(handler);
|
||||
}
|
||||
void Party::GameSessionReady(winrt::event_token const& token) noexcept
|
||||
{
|
||||
Logger::Info("Unsubscribing from GameSessionReady event\n");
|
||||
LOG_INFO("Unsubscribing from GameSessionReady event\n");
|
||||
m_gameSessionReadyEvent.remove(token);
|
||||
}
|
||||
winrt::event_token Party::PartyStateChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::Multiplayer::PartyStateChangedEventArgs> const& handler)
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace winrt::Windows::Xbox::Networking::implementation
|
||||
{
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceAssociationTemplate SecureDeviceAssociationTemplate::GetTemplateByName(hstring const& name)
|
||||
{
|
||||
Logger::Info("SecureDeviceAssociationTemplate::GetTemplateByName\n");
|
||||
LOG_INFO("SecureDeviceAssociationTemplate::GetTemplateByName\n");
|
||||
return winrt::make<SecureDeviceAssociationTemplate>();
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Networking::SecureDeviceAssociationTemplate> SecureDeviceAssociationTemplate::Templates()
|
||||
@@ -44,7 +44,7 @@ namespace winrt::Windows::Xbox::Networking::implementation
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceSocketDescription SecureDeviceAssociationTemplate::InitiatorSocketDescription()
|
||||
{
|
||||
Logger::Info("SecureDeviceAssociationTemplate::InitiatorSocketDescription\n");
|
||||
LOG_INFO("SecureDeviceAssociationTemplate::InitiatorSocketDescription\n");
|
||||
return winrt::make<SecureDeviceSocketDescription>();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceSocketDescription SecureDeviceAssociationTemplate::AcceptorSocketDescription()
|
||||
|
||||
@@ -7,17 +7,17 @@ namespace winrt::Windows::Xbox::Services::implementation
|
||||
{
|
||||
hstring XboxLiveConfiguration::TitleId()
|
||||
{
|
||||
Logger::Warning("TODO: XboxLiveConfiguration::TitleId\n");
|
||||
LOG_WARNING("TODO: XboxLiveConfiguration::TitleId\n");
|
||||
return L"0";
|
||||
}
|
||||
hstring XboxLiveConfiguration::PrimaryServiceConfigId()
|
||||
{
|
||||
Logger::Warning("TODO: XboxLiveConfiguration::PrimaryServiceConfigId\n");
|
||||
LOG_WARNING("TODO: XboxLiveConfiguration::PrimaryServiceConfigId\n");
|
||||
return L"000013";
|
||||
}
|
||||
hstring XboxLiveConfiguration::SandboxId()
|
||||
{
|
||||
Logger::Warning("TODO: XboxLiveConfiguration::SandboxId\n");
|
||||
LOG_WARNING("TODO: XboxLiveConfiguration::SandboxId\n");
|
||||
return L"0";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace winrt::Windows::Xbox::Speech::Recognition::implementation
|
||||
{
|
||||
winrt::Windows::Xbox::Speech::Recognition::SpeechRecognizer SpeechRecognizerFactory::CreateSpeechRecognizerForLocale(uint16_t requestedLanguageId)
|
||||
{
|
||||
Logger::Info("SpeechRecognizerFactory::CreateSpeechRecognizerForLocale\n");
|
||||
LOG_INFO("SpeechRecognizerFactory::CreateSpeechRecognizerForLocale\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace winrt::Windows::Xbox::Storage::implementation
|
||||
{
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Storage::BlobInfo>> BlobInfoQueryResult::GetBlobInfoAsync(uint32_t startIndex, uint32_t maxNumberOfItems)
|
||||
{
|
||||
Logger::Warning("GetBlobInfoAsync");
|
||||
LOG_WARNING("GetBlobInfoAsync");
|
||||
co_await winrt::resume_background( );
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Storage::BlobInfo>> BlobInfoQueryResult::GetBlobInfoAsync()
|
||||
@@ -20,7 +20,7 @@ namespace winrt::Windows::Xbox::Storage::implementation
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<uint32_t> BlobInfoQueryResult::GetItemCountAsync()
|
||||
{
|
||||
Logger::Warning("GetItemCountAsync");
|
||||
LOG_WARNING("GetItemCountAsync");
|
||||
co_await winrt::resume_background( );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace winrt::Windows::Xbox::System::implementation
|
||||
}
|
||||
winrt::event_token User::OnlineStateChanged(winrt::Windows::Foundation::EventHandler<winrt::Windows::Xbox::System::OnlineStateChangedEventArgs> const& handler)
|
||||
{
|
||||
Logger::Info("User::OnlineStateChanged() called");
|
||||
LOG_INFO("User::OnlineStateChanged() called");
|
||||
return m_onlineStateChangedEvent.add(handler);
|
||||
}
|
||||
void User::OnlineStateChanged(winrt::event_token const& token) noexcept
|
||||
@@ -22,13 +22,13 @@ namespace winrt::Windows::Xbox::System::implementation
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::System::User> User::Users()
|
||||
{
|
||||
wprintf(L"User || Users Queried!\n");
|
||||
LOG_INFO_W(L"User || Users Queried!\n");
|
||||
if (staticUsers == Foundation::Collections::IVector<winrt::Windows::Xbox::System::User>(nullptr) || staticUsers.Size( ) == 0) {
|
||||
staticUsers = winrt::single_threaded_vector<System::User>( );
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
wprintf(L"User || User %d Created!\n", i);
|
||||
LOG_INFO_W(L"User || User %d Created!\n", i);
|
||||
staticUser = winrt::make<User>(i);
|
||||
staticUsers.Append(staticUser);
|
||||
continue;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace winrt::Windows::Xbox::UI::implementation
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Xbox::UI::AccountPickerResult> SystemUI::ShowAccountPickerAsync(winrt::Windows::Xbox::Input::IController controller, winrt::Windows::Xbox::UI::AccountPickerOptions options)
|
||||
{
|
||||
Logger::Warning("TODO: SystemUI::ShowAccountPickerAsync (this function just returns the first user in User::Users)\n");
|
||||
LOG_WARNING("TODO: SystemUI::ShowAccountPickerAsync (this function just returns the first user in User::Users)\n");
|
||||
co_return winrt::make<implementation::AccountPickerResult>( );
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<hstring> SystemUI::ShowVirtualKeyboardAsync(hstring defaultText, hstring titleText, hstring descriptionText, winrt::Windows::Xbox::UI::VirtualKeyboardInputScope inputScope)
|
||||
|
||||
@@ -1,190 +0,0 @@
|
||||
#include "Logger.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <mutex>
|
||||
#include <windows.h>
|
||||
#include "../common/DebugLogger.h"
|
||||
|
||||
static std::mutex logMutex;
|
||||
static std::ofstream logFile("debug.log", std::ios::app);
|
||||
|
||||
static const char* ToString(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return "DEBUG";
|
||||
case LogLevel::Info: return "INFO";
|
||||
case LogLevel::Warning: return "WARNING";
|
||||
case LogLevel::Error: return "ERROR";
|
||||
case LogLevel::Fatal: return "FATAL";
|
||||
case LogLevel::NotImplemented: return "NOT_IMPLEMENTED";
|
||||
default: return "UNKNOWN";
|
||||
}
|
||||
}
|
||||
|
||||
WORD GetConsoleColor(LogLevel level) {
|
||||
switch (level) {
|
||||
case LogLevel::Debug: return FOREGROUND_BLUE | FOREGROUND_GREEN;
|
||||
case LogLevel::Info: return FOREGROUND_GREEN;
|
||||
case LogLevel::Warning: return FOREGROUND_RED | FOREGROUND_GREEN;
|
||||
case LogLevel::Error: return FOREGROUND_RED;
|
||||
case LogLevel::Fatal: return BACKGROUND_RED | FOREGROUND_RED | FOREGROUND_INTENSITY;
|
||||
case LogLevel::NotImplemented: return FOREGROUND_RED | FOREGROUND_BLUE;
|
||||
default: return FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
|
||||
}
|
||||
}
|
||||
|
||||
static std::string CurrentTime( ) {
|
||||
std::time_t now = std::time(nullptr);
|
||||
std::tm timeinfo{};
|
||||
char buffer[ 32 ];
|
||||
|
||||
if (localtime_s(&timeinfo, &now) == 0) {
|
||||
std::strftime(buffer, sizeof(buffer), "%Y-%m-%d %I:%M:%S %p", &timeinfo);
|
||||
return buffer;
|
||||
}
|
||||
else {
|
||||
return "Unknown Time";
|
||||
}
|
||||
}
|
||||
|
||||
void Logger::Log(LogLevel level, const std::string& message, const char* file, int line, const char* function) {
|
||||
std::lock_guard<std::mutex> lock(logMutex);
|
||||
|
||||
std::string timeStr = CurrentTime( );
|
||||
std::string func = Logger::ExtractFunctionName(function);
|
||||
const char* project = Logger::ExtractProjectName(file);
|
||||
const char* levelStr = ToString(level);
|
||||
|
||||
HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||
CONSOLE_SCREEN_BUFFER_INFO csbi;
|
||||
WORD originalAttributes = 0;
|
||||
if (GetConsoleScreenBufferInfo(hConsole, &csbi)) {
|
||||
originalAttributes = csbi.wAttributes;
|
||||
SetConsoleTextAttribute(hConsole, GetConsoleColor(level));
|
||||
}
|
||||
|
||||
switch (level) {
|
||||
case LogLevel::Debug:
|
||||
std::cout << timeStr << " - Debug - " << project << " - " << func;
|
||||
break;
|
||||
case LogLevel::Info:
|
||||
std::cout << timeStr << " - Info";
|
||||
break;
|
||||
case LogLevel::Warning:
|
||||
std::cout << timeStr << " - Warning - " << project << " - " << func;
|
||||
break;
|
||||
case LogLevel::Error:
|
||||
case LogLevel::Fatal:
|
||||
std::cout << timeStr << " - " << levelStr << " - " << project << " - " << func << " - Line " << line;
|
||||
break;
|
||||
case LogLevel::NotImplemented:
|
||||
std::cout << timeStr << " - " << project << " - " << func << " - NOT_IMPLEMENTED";
|
||||
break;
|
||||
default:
|
||||
std::cout << timeStr << " - " << levelStr;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!message.empty( )) std::cout << " - " << message;
|
||||
std::cout << std::endl;
|
||||
|
||||
if (hConsole) SetConsoleTextAttribute(hConsole, originalAttributes);
|
||||
|
||||
// File log (flat format)
|
||||
if (logFile.is_open( )) {
|
||||
logFile << timeStr
|
||||
<< " - " << project
|
||||
<< " - " << func
|
||||
<< " - " << levelStr;
|
||||
if (level == LogLevel::Error || level == LogLevel::Fatal)
|
||||
logFile << " - Line " << line;
|
||||
if (!message.empty( ))
|
||||
logFile << " - " << message;
|
||||
logFile << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
#if __cpp_lib_source_location >= 201907L
|
||||
#include <source_location>
|
||||
|
||||
void Logger::Log(LogLevel level, const std::string& message, const std::source_location& location) {
|
||||
Logger::Log(level, message,
|
||||
location.file_name( ),
|
||||
static_cast<int>(location.line( )),
|
||||
location.function_name( ));
|
||||
}
|
||||
#endif
|
||||
|
||||
void Logger::LogNotImplemented(LogLevel level, int line, const char* file, const char* function) {
|
||||
Logger::Log(level, "Feature not implemented", file, line, function);
|
||||
}
|
||||
|
||||
void Logger::Debug(const char* message) { Logger::Log(LogLevel::Debug, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Info(const char* message) { Logger::Log(LogLevel::Info, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Warning(const char* message) { Logger::Log(LogLevel::Warning, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Error(const char* message) { Logger::Log(LogLevel::Error, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
void Logger::Fatal(const char* message) { Logger::Log(LogLevel::Fatal, message, __FILE__, __LINE__, FUNCTION_NAME); }
|
||||
|
||||
void Logger::PrintWithContext(int line, const char* file, const char* function, const char* fmt, va_list args) {
|
||||
char formatted[ 1024 ];
|
||||
vsnprintf(formatted, sizeof(formatted), fmt, args);
|
||||
Logger::Log(LogLevel::NotImplemented, formatted, file, line, function);
|
||||
}
|
||||
|
||||
void Logger::NotImplemented(const char* file, int line, const char* function, const char* fmt, ...) {
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
Logger::PrintWithContext(line, file, function, fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
const char* Logger::ExtractProjectName(const char* filePath) {
|
||||
const char* lastSlash = strrchr(filePath, '/');
|
||||
if (!lastSlash) lastSlash = strrchr(filePath, '\\');
|
||||
const char* fileName = lastSlash ? lastSlash + 1 : filePath;
|
||||
|
||||
const char* dot = strrchr(fileName, '.');
|
||||
static char project[ 256 ];
|
||||
size_t length = dot ? (size_t) (dot - fileName) : strlen(fileName);
|
||||
length = (length < sizeof(project) - 1) ? length : sizeof(project) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(project, sizeof(project), fileName, length);
|
||||
#else
|
||||
strncpy(project, fileName, length);
|
||||
project[ length ] = '\0';
|
||||
#endif
|
||||
return project;
|
||||
}
|
||||
|
||||
|
||||
const char* Logger::ExtractFunctionName(const char* fullSignature) {
|
||||
const char* paren = strchr(fullSignature, '(');
|
||||
if (!paren)
|
||||
return fullSignature;
|
||||
|
||||
const char* end = paren;
|
||||
const char* lastColon = nullptr;
|
||||
|
||||
for (const char* p = fullSignature; p < end; ++p) {
|
||||
if (p[ 0 ] == ':' && p[ 1 ] == ':')
|
||||
lastColon = p;
|
||||
}
|
||||
|
||||
const char* start = lastColon ? lastColon + 2 : fullSignature;
|
||||
|
||||
static char functionName[ 256 ];
|
||||
size_t length = (size_t) (end - start);
|
||||
length = (length < sizeof(functionName) - 1) ? length : sizeof(functionName) - 1;
|
||||
|
||||
#ifdef _MSC_VER
|
||||
strncpy_s(functionName, sizeof(functionName), start, length);
|
||||
#else
|
||||
strncpy(functionName, start, length);
|
||||
functionName[ length ] = '\0';
|
||||
#endif
|
||||
|
||||
return functionName;
|
||||
}
|
||||
|
||||
@@ -1,83 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <cstdarg>
|
||||
#include <source_location> // C++20 support
|
||||
|
||||
#ifndef DEBUG_LOGGER_H
|
||||
#define DEBUG_LOGGER_H
|
||||
|
||||
enum class LogLevel {
|
||||
Debug,
|
||||
Info,
|
||||
Warning,
|
||||
Error,
|
||||
Fatal,
|
||||
NotImplemented
|
||||
};
|
||||
|
||||
class Logger {
|
||||
public:
|
||||
// Main logging entry point
|
||||
static void Log(LogLevel level, const std::string& message, const char* file, int line, const char* function);
|
||||
|
||||
// Optional C++20 overload using std::source_location
|
||||
#if __cpp_lib_source_location >= 201907L
|
||||
static void Log(LogLevel level,
|
||||
const std::string& message,
|
||||
const std::source_location& location = std::source_location::current( ));
|
||||
#endif
|
||||
|
||||
// Helper for NotImplemented logging
|
||||
static void LogNotImplemented(LogLevel level, int line, const char* file, const char* function);
|
||||
|
||||
// Convenience logging APIs
|
||||
static void Debug(const char* message = "");
|
||||
static void Info(const char* message = "");
|
||||
static void Warning(const char* message = "");
|
||||
static void Error(const char* message = "");
|
||||
static void Fatal(const char* message = "");
|
||||
|
||||
// NotImplemented (with formatting)
|
||||
static void NotImplemented(const char* file, int line, const char* function, const char* fmt = "", ...);
|
||||
|
||||
static void PrintWithContext(int line, const char* file, const char* function, const char* fmt, va_list args);
|
||||
|
||||
// Internal helpers
|
||||
static const char* ExtractFunctionName(const char* fullSignature);
|
||||
static const char* ExtractProjectName(const char* filePath);
|
||||
};
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Compiler-specific macro for full function signature
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define FUNCTION_NAME __PRETTY_FUNCTION__
|
||||
#elif defined(_MSC_VER)
|
||||
#define FUNCTION_NAME __FUNCSIG__
|
||||
#else
|
||||
#define FUNCTION_NAME __FUNCTION__
|
||||
#endif
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Macro-based log wrappers (captures callsite info)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#define LOG_DEBUG(msg, ...) Logger::Log(LogLevel::Debug, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_INFO(msg, ...) Logger::Log(LogLevel::Info, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_WARNING(msg, ...) Logger::Log(LogLevel::Warning, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_ERROR(msg, ...) Logger::Log(LogLevel::Error, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_FATAL(msg, ...) Logger::Log(LogLevel::Fatal, msg, __FILE__, __LINE__, FUNCTION_NAME)
|
||||
#define LOG_NOT_IMPLEMENTED(...) Logger::NotImplemented(__FILE__, __LINE__, FUNCTION_NAME, ##__VA_ARGS__)
|
||||
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
// Debug-only short macros (auto-disables in Release)
|
||||
// ------------------------------------------------------------------------------------------------
|
||||
#ifdef _DEBUG
|
||||
#define DEBUG_PRINT() Logger::Debug()
|
||||
#define DEBUGPRINT(fmt, ...) Logger::Debug(fmt, ##__VA_ARGS__)
|
||||
#else
|
||||
#define DEBUG_PRINT()
|
||||
#define DEBUGPRINT(fmt, ...)
|
||||
#endif
|
||||
|
||||
#endif // DEBUG_LOGGER_H
|
||||
@@ -24,7 +24,7 @@ DWORD WINAPI ThreadProc(LPVOID lpParam)
|
||||
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH) {
|
||||
Logger::Info("[winrt_x] DllMain invoked");
|
||||
LOG_INFO("[winrt_x] DllMain invoked");
|
||||
CreateThread(nullptr, 0, ThreadProc, nullptr, 0, nullptr);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
#include <unknwn.h>
|
||||
#include <winrt/Windows.Foundation.h>
|
||||
#include <winrt/Windows.Foundation.Collections.h>
|
||||
#include "Logger.h"
|
||||
#include "../../common/Logger.h"
|
||||
|
||||
@@ -164,7 +164,6 @@
|
||||
<ItemGroup>
|
||||
<ClInclude Include="common.h" />
|
||||
<ClInclude Include="ConnectedStorage\ConnectedStorage.h" />
|
||||
<ClInclude Include="Logger.h" />
|
||||
<ClInclude Include="Implementation\Microsoft.Xbox.GameChat.AccessibilitySettingsChangedEventArgs.h" />
|
||||
<ClInclude Include="Implementation\Microsoft.Xbox.GameChat.ChannelUpdatedEventArgs.h" />
|
||||
<ClInclude Include="Implementation\Microsoft.Xbox.GameChat.ChatManager.h" />
|
||||
@@ -555,10 +554,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="ConnectedStorage\ConnectedStorage.cpp" />
|
||||
<ClCompile Include="Logger.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">NotUsing</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">NotUsing</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Implementation\Microsoft.Xbox.GameChat.AccessibilitySettingsChangedEventArgs.cpp" />
|
||||
<ClCompile Include="Implementation\Microsoft.Xbox.GameChat.ChannelUpdatedEventArgs.cpp" />
|
||||
<ClCompile Include="Implementation\Microsoft.Xbox.GameChat.ChatManager.cpp" />
|
||||
|
||||
@@ -161,9 +161,6 @@
|
||||
<Filter Include="Implementation\Windows\Xbox\SmartGlass">
|
||||
<UniqueIdentifier>{a9003d68-6bbb-43e4-ab6e-f1243e316c7c}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="Logger">
|
||||
<UniqueIdentifier>{4b531b63-769a-4159-9dd6-10ef56d7f838}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp" />
|
||||
@@ -1330,9 +1327,6 @@
|
||||
<ClCompile Include="Implementation\Windows.Xbox.Multiplayer.MultiplayerSessionReference.cpp">
|
||||
<Filter>Implementation\Windows\Xbox\Multiplayer</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="Logger.cpp">
|
||||
<Filter>Logger</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="Implementation\Microsoft.Xbox.GameChat.TextMessageReceivedEventArgs.h">
|
||||
@@ -2498,9 +2492,6 @@
|
||||
<ClInclude Include="Implementation\Windows.Xbox.Multiplayer.MultiplayerSessionReference.h">
|
||||
<Filter>Implementation\Windows\Xbox\Multiplayer</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Logger.h">
|
||||
<Filter>Logger</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="winrt_x.def" />
|
||||
|
||||
Reference in New Issue
Block a user