diff --git a/sys/CRTCPP.hpp b/sys/CRTCPP.hpp index 0ff6735..4f87ccd 100644 --- a/sys/CRTCPP.hpp +++ b/sys/CRTCPP.hpp @@ -2,6 +2,8 @@ constexpr auto cpp_pool_tag = 'EGiV'; +#ifdef _AMD64_ + void* operator new ( size_t size @@ -62,3 +64,68 @@ void operator delete[] ExFreePoolWithTag(what, cpp_pool_tag); } + +#else + +void* __CRTDECL operator new +( + size_t size + ) +{ + return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag); +} + +void* __CRTDECL operator new[] +( + size_t size + ) +{ + return ExAllocatePoolWithTag(NonPagedPoolNx, size, cpp_pool_tag); +} + +void __CRTDECL operator delete +( + void* what + ) +{ + if (what == nullptr) + { + return; + } + + ExFreePoolWithTag(what, cpp_pool_tag); +} + +void __CRTDECL operator delete +( + void* what, + size_t size + ) +{ + UNREFERENCED_PARAMETER(size); + + if (what == nullptr) + { + return; + } + + ExFreePoolWithTag(what, cpp_pool_tag); +} + +void __CRTDECL operator delete[] +( + void* what, + size_t size + ) +{ + UNREFERENCED_PARAMETER(size); + + if (what == nullptr) + { + return; + } + + ExFreePoolWithTag(what, cpp_pool_tag); +} + +#endif diff --git a/sys/Ds4Pdo.cpp b/sys/Ds4Pdo.cpp index 3cbe1c6..df50ddb 100644 --- a/sys/Ds4Pdo.cpp +++ b/sys/Ds4Pdo.cpp @@ -6,12 +6,15 @@ #include -using namespace ViGEm::Bus::Targets; -PCWSTR EmulationTargetDS4::_deviceDescription = L"Virtual DualShock 4 Controller"; +PCWSTR ViGEm::Bus::Targets::EmulationTargetDS4::_deviceDescription = L"Virtual DualShock 4 Controller"; -NTSTATUS EmulationTargetDS4::PrepareDevice(PWDFDEVICE_INIT DeviceInit, - PUNICODE_STRING DeviceId, PUNICODE_STRING DeviceDescription) +ViGEm::Bus::Targets::EmulationTargetDS4::EmulationTargetDS4() : EmulationTargetPDO(0x054C, 0x05C4) +{ +} + +NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::PrepareDevice(PWDFDEVICE_INIT DeviceInit, + PUNICODE_STRING DeviceId, PUNICODE_STRING DeviceDescription) { NTSTATUS status; UNICODE_STRING buffer; @@ -94,7 +97,7 @@ NTSTATUS EmulationTargetDS4::PrepareDevice(PWDFDEVICE_INIT DeviceInit, return STATUS_SUCCESS; } -NTSTATUS EmulationTargetDS4::PrepareHardware(WDFDEVICE Device) +NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::PrepareHardware(WDFDEVICE Device) { WDF_QUERY_INTERFACE_CONFIG ifaceCfg; INTERFACE devinterfaceHid; @@ -147,7 +150,7 @@ NTSTATUS EmulationTargetDS4::PrepareHardware(WDFDEVICE Device) return STATUS_SUCCESS; } -NTSTATUS EmulationTargetDS4::InitContext(WDFDEVICE Device) +NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::InitContext(WDFDEVICE Device) { NTSTATUS status; @@ -322,7 +325,7 @@ NTSTATUS EmulationTargetDS4::InitContext(WDFDEVICE Device) return STATUS_SUCCESS; } -VOID EmulationTargetDS4::GetConfigurationDescriptorType(PUCHAR Buffer, ULONG Length) +VOID ViGEm::Bus::Targets::EmulationTargetDS4::GetConfigurationDescriptorType(PUCHAR Buffer, ULONG Length) { UCHAR Ds4DescriptorData[DS4_DESCRIPTOR_SIZE] = { @@ -375,7 +378,7 @@ VOID EmulationTargetDS4::GetConfigurationDescriptorType(PUCHAR Buffer, ULONG Len RtlCopyBytes(Buffer, Ds4DescriptorData, Length); } -VOID EmulationTargetDS4::GetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) +VOID ViGEm::Bus::Targets::EmulationTargetDS4::GetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescriptor) { pDescriptor->bLength = 0x12; pDescriptor->bDescriptorType = USB_DEVICE_DESCRIPTOR_TYPE; @@ -393,7 +396,7 @@ VOID EmulationTargetDS4::GetDeviceDescriptorType(PUSB_DEVICE_DESCRIPTOR pDescrip pDescriptor->bNumConfigurations = 0x01; } -VOID EmulationTargetDS4::SelectConfiguration(PUSBD_INTERFACE_INFORMATION pInfo) +VOID ViGEm::Bus::Targets::EmulationTargetDS4::SelectConfiguration(PUSBD_INTERFACE_INFORMATION pInfo) { TraceEvents(TRACE_LEVEL_VERBOSE, TRACE_DS4, @@ -426,7 +429,7 @@ VOID EmulationTargetDS4::SelectConfiguration(PUSBD_INTERFACE_INFORMATION pInfo) pInfo->Pipes[1].PipeFlags = 0x00; } -VOID EmulationTargetDS4::PendingUsbRequestsTimerFunc( +VOID ViGEm::Bus::Targets::EmulationTargetDS4::PendingUsbRequestsTimerFunc( _In_ WDFTIMER Timer ) { diff --git a/sys/Ds4Pdo.hpp b/sys/Ds4Pdo.hpp index 88cea3f..984061a 100644 --- a/sys/Ds4Pdo.hpp +++ b/sys/Ds4Pdo.hpp @@ -1,6 +1,5 @@ #pragma once - #include "EmulationTargetPDO.hpp" #include #include "Util.h" @@ -10,7 +9,7 @@ namespace ViGEm::Bus::Targets class EmulationTargetDS4 : public Core::EmulationTargetPDO { public: - EmulationTargetDS4() = default; + EmulationTargetDS4(); ~EmulationTargetDS4() = default; NTSTATUS PrepareDevice(PWDFDEVICE_INIT DeviceInit, diff --git a/sys/XusbPdo.hpp b/sys/XusbPdo.hpp index 8f0bd24..08c2d5f 100644 --- a/sys/XusbPdo.hpp +++ b/sys/XusbPdo.hpp @@ -1,6 +1,5 @@ #pragma once - #include "EmulationTargetPDO.hpp" #include @@ -24,7 +23,7 @@ namespace ViGEm::Bus::Targets EmulationTargetXUSB(); ~EmulationTargetXUSB() = default; - NTSTATUS PrepareDevice(PWDFDEVICE_INIT DeviceInit, + NTSTATUS PrepareDevice(PWDFDEVICE_INIT DeviceInit, PUNICODE_STRING DeviceId, PUNICODE_STRING DeviceDescription) override; NTSTATUS PrepareHardware(WDFDEVICE Device) override;