diff --git a/sys/Driver.cpp b/sys/Driver.cpp index d60f3d9..486e3b9 100644 --- a/sys/Driver.cpp +++ b/sys/Driver.cpp @@ -584,10 +584,48 @@ void Bus_EvtUserNotifyRequestComplete( { RtlCopyMemory(pNotify, pOutput, sizeof(DS4_AWAIT_OUTPUT)); + Util_DumpAsHex("NOTIFY_COMPLETE", pNotify, sizeof(DS4_AWAIT_OUTPUT)); + WdfRequestSetInformation(Request, sizeof(DS4_AWAIT_OUTPUT)); } WdfRequestComplete(Request, NtStatus); } +void Util_DumpAsHex(PCSTR Prefix, PVOID Buffer, ULONG BufferLength) +{ +#ifdef DBG + + size_t dumpBufferLength = ((BufferLength * sizeof(CHAR)) * 2) + 1; + PSTR dumpBuffer = static_cast(ExAllocatePoolZero( + NonPagedPoolNx, + dumpBufferLength, + '1234' + )); + if (dumpBuffer) + { + + RtlZeroMemory(dumpBuffer, dumpBufferLength); + + for (ULONG i = 0; i < BufferLength; i++) + { + sprintf(&dumpBuffer[i * 2], "%02X", static_cast(Buffer)[i]); + } + + TraceVerbose(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 +} + EXTERN_C_END diff --git a/sys/Driver.h b/sys/Driver.h index 989e1f6..f2513c1 100644 --- a/sys/Driver.h +++ b/sys/Driver.h @@ -124,6 +124,8 @@ void Bus_EvtUserNotifyRequestComplete( _In_ NTSTATUS NtStatus ); +void Util_DumpAsHex(PCSTR Prefix, PVOID Buffer, ULONG BufferLength); + #pragma region Bus enumeration-specific functions NTSTATUS diff --git a/sys/Ds4Pdo.cpp b/sys/Ds4Pdo.cpp index 280da8f..f558374 100644 --- a/sys/Ds4Pdo.cpp +++ b/sys/Ds4Pdo.cpp @@ -1032,6 +1032,11 @@ NTSTATUS ViGEm::Bus::Targets::EmulationTargetDS4::UsbBulkOrInterruptTransfer(_UR : sizeof(DS4_OUTPUT_BUFFER) ); + DumpAsHex("!! XUSB_REQUEST_NOTIFICATION", + &this->_AwaitOutputCache, + sizeof(DS4_AWAIT_OUTPUT) + ); + if (!NT_SUCCESS(status = DMF_NotifyUserWithRequestMultiple_DataBroadcast( this->_OutputReportNotify, &this->_AwaitOutputCache,