mirror of
https://github.com/WinDurango/WinDurango.git
synced 2026-05-02 15:29:13 -05:00
Important Changes
More file/folder creation hooking.
This commit is contained in:
@@ -3,55 +3,66 @@
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::QueryInterface(REFIID riid, void** ppvObject)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::QueryInterface\n");
|
||||
return m_realEnumerator->QueryInterface(riid, ppvObject);
|
||||
}
|
||||
|
||||
ULONG __stdcall MMXboxDeviceEnumerator::AddRef(void)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::AddRef\n");
|
||||
return m_realEnumerator->AddRef();
|
||||
}
|
||||
|
||||
ULONG __stdcall MMXboxDeviceEnumerator::Release(void)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::Release\n");
|
||||
return m_realEnumerator->Release();
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::EnumAudioEndpoints(EDataFlow dataFlow, DWORD dwStateMask, IMMDeviceCollection** ppDevices)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::EnumAudioEndpoints\n");
|
||||
return m_realEnumerator->EnumAudioEndpoints(dataFlow, dwStateMask, ppDevices);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetDefaultAudioEndpoint(EDataFlow dataFlow, ERole role, IMMDevice** ppEndpoint)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetDefaultAudioEndpoint\n");
|
||||
return m_realEnumerator->GetDefaultAudioEndpoint(dataFlow, role, ppEndpoint);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetDevice(LPCWSTR pwstrId, IMMDevice** ppDevice)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetDevice\n");
|
||||
return m_realEnumerator->GetDevice(pwstrId, ppDevice);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::RegisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::RegisterEndpointNotificationCallback\n");
|
||||
return m_realEnumerator->RegisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::UnregisterEndpointNotificationCallback(IMMNotificationClient* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::UnregisterEndpointNotificationCallback\n");
|
||||
return m_realEnumerator->UnregisterEndpointNotificationCallback(pClient);
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::GetHdAudioChannelCounts(unsigned int* pHdmiChannelCount, unsigned int* pSpdifChannelCount)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::GetHdAudioChannelCount\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::RegisterChannelCountNotificationCallback(uint32_t* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::RegisterChannelCountNotificationCallback\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
HRESULT __stdcall MMXboxDeviceEnumerator::UnregisterChannelCountNotificationCallback(uint32_t* pClient)
|
||||
{
|
||||
printf("MMXboxDeviceEnumerator::UnregisterChannelCountNotificationCallback\n");
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
@@ -144,7 +144,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
XWinePatchImport(GetModuleHandleW(nullptr), GetRuntimeModule(), "?GetActivationFactoryByPCWSTR@@YAJPEAXAEAVGuid@Platform@@PEAPEAX@Z", GetActivationFactoryRedirect);
|
||||
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueOpenFile), OpenFile_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueCreateDirectoryA), CreateDirectoryA_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueCreateFileW), CreateFileW_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueCreateFile2), CreateFile2_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueGetFileAttributesW), GetFileAttributesW_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueGetFileAttributesExW), GetFileAttributesExW_Hook);
|
||||
DetourAttach(&reinterpret_cast<PVOID&>(TrueFindFirstFileW), FindFirstFileW_Hook);
|
||||
@@ -166,7 +168,9 @@ BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID reserved)
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueRoGetActivationFactory), RoGetActivationFactory_Hook);
|
||||
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueOpenFile), OpenFile_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueCreateDirectoryA), CreateDirectoryA_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueCreateFileW), CreateFileW_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueCreateFile2), CreateFile2_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueGetFileAttributesW), GetFileAttributesW_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueGetFileAttributesExW), GetFileAttributesExW_Hook);
|
||||
DetourDetach(&reinterpret_cast<PVOID&>(TrueFindFirstFileW), FindFirstFileW_Hook);
|
||||
|
||||
+38
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
#include "CurrentAppWrapper.hpp"
|
||||
#include "MMDeviceEnumeratorWrapper.h"
|
||||
#include <winrt/windows.storage.provider.h>
|
||||
|
||||
#define RETURN_HR(hr) return hr
|
||||
#define RETURN_LAST_ERROR_IF(cond) if (cond) return HRESULT_FROM_WIN32(GetLastError())
|
||||
@@ -65,6 +66,11 @@ HFILE(WINAPI* TrueOpenFile)(LPCSTR lpFileName, LPOFSTRUCT lpReOpenBuff, UINT uSt
|
||||
HANDLE(WINAPI* TrueCreateFileW)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes,
|
||||
DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile) = CreateFileW;
|
||||
|
||||
HANDLE(WINAPI* TrueCreateFile2)(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
DWORD dwCreationDisposition, LPCREATEFILE2_EXTENDED_PARAMETERS pCreateExParams) = CreateFile2;
|
||||
|
||||
BOOL(WINAPI* TrueCreateDirectoryA)(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes) = CreateDirectoryA;
|
||||
|
||||
DWORD(WINAPI* TrueGetFileAttributesW)(LPCWSTR lpFileName) = GetFileAttributesW;
|
||||
BOOL(WINAPI* TrueGetFileAttributesExW)(LPCWSTR lpFileName, GET_FILEEX_INFO_LEVELS fInfoLevelId, LPVOID lpFileInformation) = GetFileAttributesExW;
|
||||
|
||||
@@ -235,7 +241,7 @@ void FixRelativePath(LPCWSTR& lpFileName)
|
||||
|
||||
lpFileName = convert.data();
|
||||
}
|
||||
else if (fileName[0] == 'G' && fileName[1] == ':')
|
||||
else if ((fileName[0] == 'G' || fileName[0] == 'g') && fileName[1] == ':')
|
||||
{
|
||||
|
||||
static std::wstring trimPath{};
|
||||
@@ -244,10 +250,41 @@ void FixRelativePath(LPCWSTR& lpFileName)
|
||||
convert = std::filesystem::current_path().c_str();
|
||||
convert.append(fileName);
|
||||
|
||||
lpFileName = convert.data();
|
||||
}
|
||||
else if ((fileName[0] == 'T' || fileName[0] == 't') && fileName[1] == ':')
|
||||
{
|
||||
|
||||
static std::wstring trimPath{};
|
||||
trimPath = fileName.substr(2);
|
||||
fileName = trimPath.data();
|
||||
convert = winrt::Windows::Storage::ApplicationData::Current().TemporaryFolder().Path();
|
||||
convert.append(fileName);
|
||||
|
||||
lpFileName = convert.data();
|
||||
}
|
||||
}
|
||||
|
||||
#include <atlbase.h>
|
||||
|
||||
HANDLE CreateFile2_Hook(LPCWSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode,
|
||||
DWORD dwCreationDisposition, LPCREATEFILE2_EXTENDED_PARAMETERS pCreateExParams)
|
||||
{
|
||||
FixRelativePath(lpFileName);
|
||||
|
||||
return TrueCreateFile2(lpFileName, dwDesiredAccess, dwShareMode, dwCreationDisposition, pCreateExParams);
|
||||
}
|
||||
|
||||
BOOL CreateDirectoryA_Hook(LPCSTR lpPathName, LPSECURITY_ATTRIBUTES lpSecurityAttributes)
|
||||
{
|
||||
USES_CONVERSION;
|
||||
|
||||
LPCWSTR PathName = A2W(lpPathName);
|
||||
|
||||
FixRelativePath(PathName);
|
||||
|
||||
return CreateDirectoryW(PathName, lpSecurityAttributes);
|
||||
}
|
||||
|
||||
HMODULE WINAPI LoadLibraryExA_Hook(LPCSTR lpLibFileName, _Reserved_ HANDLE hFile, _In_ DWORD dwFlags)
|
||||
{
|
||||
|
||||
@@ -258,50 +258,10 @@ PVOID XMemAllocDefault_X(SIZE_T dwSize, uint64_t flags) {
|
||||
}
|
||||
|
||||
BOOLEAN __stdcall XMemFreeDefault_X(PVOID pAddress, uint64_t dwAllocAttributes) {
|
||||
if (!pAddress) {
|
||||
return FALSE; // Avoid processing NULL pointers
|
||||
}
|
||||
DEBUGPRINT();
|
||||
uint64_t allocTypeIndex = (dwAllocAttributes >> 29) & 0xF;
|
||||
PVOID baseAddress = pAddress;
|
||||
ULONG_PTR regionSize = 0;
|
||||
|
||||
free(pAddress);
|
||||
|
||||
// Case 1: Freeing memory allocated using the title heap
|
||||
if (!XmpHeapAllocationTypes[allocTypeIndex] &&
|
||||
(dwAllocAttributes & 0x1F000000u) <= 0x4000000u &&
|
||||
!(dwAllocAttributes & 0xC000))
|
||||
{
|
||||
static HANDLE XmpTitleHeap = NULL;
|
||||
if (!XmpTitleHeap) {
|
||||
XmpTitleHeap = HeapCreate(0, 0, 0x80002u);
|
||||
}
|
||||
return (XmpTitleHeap && pAddress) ? HeapFree(XmpTitleHeap, 0, pAddress) : FALSE;
|
||||
}
|
||||
|
||||
// Case 2: Try to locate the correct heap in XmpHeaps
|
||||
void* heapRegion = XmpHeaps[allocTypeIndex];
|
||||
if (!heapRegion ||
|
||||
!(*(PVOID*)((uintptr_t)heapRegion + 48)) ||
|
||||
(*(PVOID*)((uintptr_t)heapRegion + 48) > pAddress) ||
|
||||
(*(PVOID*)((uintptr_t)heapRegion + 56) < pAddress))
|
||||
{
|
||||
heapRegion = XmpHeaps[allocTypeIndex + 16];
|
||||
if (!heapRegion ||
|
||||
!(*(PVOID*)((uintptr_t)heapRegion + 48)) ||
|
||||
(*(PVOID*)((uintptr_t)heapRegion + 48) > pAddress) ||
|
||||
(*(PVOID*)((uintptr_t)heapRegion + 56) < pAddress))
|
||||
{
|
||||
heapRegion = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Case 3: If a valid heap was found, free the memory using HeapFree
|
||||
if (heapRegion) {
|
||||
return HeapFree(heapRegion, 0, pAddress);
|
||||
}
|
||||
|
||||
// Case 4: If no heap was found, free virtual memory using VirtualFree
|
||||
return VirtualFree(baseAddress, 0, MEM_RELEASE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -60,11 +60,11 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
}
|
||||
bool PackageTransferManager::AreChunksInstalled(winrt::Windows::Foundation::Collections::IIterable<uint32_t> const& chunkIds)
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
return true;
|
||||
}
|
||||
uint32_t PackageTransferManager::FindChunkFromFile(hstring const& path)
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
return 0;
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferManager::TransferStatus()
|
||||
{
|
||||
|
||||
+3
-4
@@ -56,15 +56,16 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
winrt::event_token PackageTransferWatcher::ChunkCompleted(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher, winrt::Windows::Xbox::Management::Deployment::ChunkCompletedEventArgs> const& handler)
|
||||
{
|
||||
printf("PackageTransferWatcher::ChunkCompleted\n");
|
||||
throw hresult_not_implemented();
|
||||
return {};
|
||||
}
|
||||
void PackageTransferWatcher::ChunkCompleted(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
printf("PackageTransferWatcher::ChunkCompleted\n");
|
||||
throw hresult_not_implemented();
|
||||
//throw hresult_not_implemented();
|
||||
}
|
||||
winrt::event_token PackageTransferWatcher::ProgressChanged(winrt::Windows::Foundation::TypedEventHandler<winrt::Windows::Xbox::Management::Deployment::PackageTransferWatcher, winrt::Windows::Xbox::Management::Deployment::ProgressChangedEventArgs> const& handler)
|
||||
{
|
||||
printf("PackageTransferWatcher::ProgressChanged\n");
|
||||
return {};
|
||||
}
|
||||
void PackageTransferWatcher::ProgressChanged(winrt::event_token const& cookie) noexcept
|
||||
@@ -79,7 +80,6 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
void PackageTransferWatcher::TransferCompleted(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
printf("PackageTransferWatcher::TransferCompleted\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Management::Deployment::PackageTransferStatus PackageTransferWatcher::TransferStatus()
|
||||
{
|
||||
@@ -99,6 +99,5 @@ namespace winrt::Windows::Xbox::Management::Deployment::implementation
|
||||
void PackageTransferWatcher::TransferStatusChanged(winrt::event_token const& cookie) noexcept
|
||||
{
|
||||
printf("PackageTransferWatcher::TransferStatusChanged\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
}
|
||||
|
||||
+15
-2
@@ -1,5 +1,6 @@
|
||||
#include "pch.h"
|
||||
#include "Windows.Xbox.Networking.SecureDeviceAssociationTemplate.h"
|
||||
#include "Windows.Xbox.Networking.SecureDeviceSocketDescription.h"
|
||||
#include "Windows.Xbox.Networking.SecureDeviceAssociationTemplate.g.cpp"
|
||||
|
||||
// WARNING: This file is automatically generated by a tool. Do not directly
|
||||
@@ -25,7 +26,8 @@ namespace winrt::Windows::Xbox::Networking::implementation
|
||||
{
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceAssociationTemplate SecureDeviceAssociationTemplate::GetTemplateByName(hstring const& name)
|
||||
{
|
||||
return nullptr;
|
||||
printf("SecureDeviceAssociationTemplate::GetTemplateByName\n");
|
||||
return winrt::make<SecureDeviceAssociationTemplate>();
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Networking::SecureDeviceAssociationTemplate> SecureDeviceAssociationTemplate::Templates()
|
||||
{
|
||||
@@ -49,46 +51,57 @@ namespace winrt::Windows::Xbox::Networking::implementation
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::Streams::IBuffer> SecureDeviceAssociationTemplate::CreateCertificateRequestAsync(hstring subjectName)
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::CreateCertificateRequestAsynv\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::IAsyncAction SecureDeviceAssociationTemplate::InstallCertificateAsync(winrt::Windows::Storage::Streams::IBuffer certificateBuffer)
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::InstallCertificateAsync\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
hstring SecureDeviceAssociationTemplate::Name()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::Name\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceSocketDescription SecureDeviceAssociationTemplate::InitiatorSocketDescription()
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
printf("SecureDeviceAssociationTemplate::InitiatorSocketDescription\n");
|
||||
return winrt::make<SecureDeviceSocketDescription>();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceSocketDescription SecureDeviceAssociationTemplate::AcceptorSocketDescription()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::AcceptorSocketDescription\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceAssociationUsage SecureDeviceAssociationTemplate::AllowedUsages()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::AllowedUsages\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
hstring SecureDeviceAssociationTemplate::RelyingParty()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::RelyingParty\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Networking::ProtocolParserDescription> SecureDeviceAssociationTemplate::ProtocolParserDescriptions()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::ProtocolParserDescriptions\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Networking::QualityOfServiceMetric> SecureDeviceAssociationTemplate::QualityOfServiceMetricPathPriorities()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::QualityOfServiceMetricPathPriorities\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::MultiplayerSessionRequirement SecureDeviceAssociationTemplate::MultiplayerSessionRequirement()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::MultiplayerSessionRequirement\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Foundation::Collections::IVectorView<winrt::Windows::Xbox::Networking::SecureDeviceAssociation> SecureDeviceAssociationTemplate::Associations()
|
||||
{
|
||||
printf("SecureDeviceAssociationTemplate::Associations\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
}
|
||||
|
||||
+7
-2
@@ -25,22 +25,27 @@ namespace winrt::Windows::Xbox::Networking::implementation
|
||||
{
|
||||
hstring SecureDeviceSocketDescription::Name()
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
printf("SecureDeviceSocketDescription::Name\n");
|
||||
return L"";
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureIpProtocol SecureDeviceSocketDescription::IpProtocol()
|
||||
{
|
||||
printf("SecureDeviceSocketDescription::IpProtocol\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
uint16_t SecureDeviceSocketDescription::BoundPortRangeLower()
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
printf("SecureDeviceSocketDescription::BoundPortRangeLower\n");
|
||||
return 0;
|
||||
}
|
||||
uint16_t SecureDeviceSocketDescription::BoundPortRangeUpper()
|
||||
{
|
||||
printf("SecureDeviceSocketDescription::BoundPortRangeUpper\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
winrt::Windows::Xbox::Networking::SecureDeviceSocketUsage SecureDeviceSocketDescription::AllowedUsages()
|
||||
{
|
||||
printf("SecureDeviceSocketDescription::AllowedUsages\n");
|
||||
throw hresult_not_implemented();
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -25,6 +25,7 @@ namespace winrt::Windows::Xbox::Speech::Recognition::implementation
|
||||
{
|
||||
winrt::Windows::Xbox::Speech::Recognition::SpeechRecognizer SpeechRecognizerFactory::CreateSpeechRecognizerForLocale(uint16_t requestedLanguageId)
|
||||
{
|
||||
throw hresult_not_implemented();
|
||||
printf("SpeechRecognizerFactory::CreateSpeechRecognizerForLocale\n");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user