diff --git a/sys/EmulationTargetPDO.cpp b/sys/EmulationTargetPDO.cpp index 1a23c27..c7eb880 100644 --- a/sys/EmulationTargetPDO.cpp +++ b/sys/EmulationTargetPDO.cpp @@ -657,6 +657,42 @@ VOID ViGEm::Bus::Core::EmulationTargetPDO::PluginRequestCompletionWorkerRoutine( (void)PsTerminateSystemThread(0); } +VOID ViGEm::Bus::Core::EmulationTargetPDO::DumpAsHex(PCSTR Prefix, PVOID Buffer, ULONG BufferLength) +{ +#ifdef DBG + + size_t dumpBufferLength = ((BufferLength * sizeof(CHAR)) * 2) + 1; + PSTR dumpBuffer = static_cast(ExAllocatePoolWithTag( + NonPagedPoolNx, + dumpBufferLength, + '1234' + )); + if (dumpBuffer) + { + + RtlZeroMemory(dumpBuffer, dumpBufferLength); + + for (ULONG i = 0; i < BufferLength; i++) + { + sprintf(&dumpBuffer[i * 2], "%02X", static_cast(Buffer)[i]); + } + + TraceDbg(TRACE_BUSPDO, + "%s - Buffer length: %04d, buffer content: %s\n", + Prefix, + BufferLength, + dumpBuffer + ); + + ExFreePoolWithTag(dumpBuffer, '1234'); + } +#else + UNREFERENCED_PARAMETER(Prefix); + UNREFERENCED_PARAMETER(Buffer); + UNREFERENCED_PARAMETER(BufferLength); +#endif +} + void ViGEm::Bus::Core::EmulationTargetPDO::UsbAbortPipe() { this->AbortPipe(); diff --git a/sys/EmulationTargetPDO.hpp b/sys/EmulationTargetPDO.hpp index c5a79a8..65b8896 100644 --- a/sys/EmulationTargetPDO.hpp +++ b/sys/EmulationTargetPDO.hpp @@ -163,6 +163,8 @@ namespace ViGEm::Bus::Core virtual void AbortPipe() = 0; virtual NTSTATUS SubmitReportImpl(PVOID NewReport) = 0; + + static VOID DumpAsHex(PCSTR Prefix, PVOID Buffer, ULONG BufferLength); // // Unique serial number of the device on the bus