From d25a8bb6cb57b4ae3d14a5f6320262955ab88514 Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Sat, 7 Sep 2013 13:01:59 +1200 Subject: [PATCH] Fix reply after shutdown error. Fixes Issue 6577 --- .../Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp | 20 +++++++++++++++++++ .../Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h | 1 + 2 files changed, 21 insertions(+) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp index 243696f652..e663d737c2 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.cpp @@ -37,6 +37,7 @@ void CWII_IPC_HLE_Device_hid::checkUsbUpdates(CWII_IPC_HLE_Device_hid* hid) static u16 timeToFill = 0; if (timeToFill == 0) { + std::lock_guard lk(hid->s_device_list_reply); if (hid->deviceCommandAddress != 0){ hid->FillOutDevices(Memory::Read_U32(hid->deviceCommandAddress + 0x18), Memory::Read_U32(hid->deviceCommandAddress + 0x1C)); @@ -255,6 +256,25 @@ bool CWII_IPC_HLE_Device_hid::IOCtl(u32 _CommandAddress) return false; break; } + case IOCTL_HID_SHUTDOWN: + { + std::lock_guard lk(s_device_list_reply); + if (deviceCommandAddress != 0){ + Memory::Write_U32(0xFFFFFFFF, Memory::Read_U32(deviceCommandAddress + 0x18)); + + Memory::Write_U32(8, deviceCommandAddress); + // IOS seems to write back the command that was responded to + Memory::Write_U32(/*COMMAND_IOCTL*/ 6, deviceCommandAddress + 8); + + // Return value + Memory::Write_U32(-1, deviceCommandAddress + 4); + WII_IPC_HLE_Interface::EnqueReplyCallback(deviceCommandAddress); + deviceCommandAddress = 0; + } + DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(Shutdown) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", + BufferIn, BufferInSize, BufferOut, BufferOutSize); + break; + } default: { DEBUG_LOG(WII_IPC_HID, "HID::IOCtl(0x%x) (BufferIn: (%08x, %i), BufferOut: (%08x, %i)", diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h index a8c2604edf..74169a50b3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_hid.h @@ -123,6 +123,7 @@ private: struct libusb_device_handle * GetDeviceByDevNum(u32 devNum); std::map open_devices; std::mutex s_open_devices; + std::mutex s_device_list_reply; std::map device_identifiers; std::thread usb_thread;