From 23162ac7222b0900da1ab4d63f57c64a221c58e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 8 Jan 2017 20:52:48 +0100 Subject: [PATCH 1/3] IOS HLE: STM: Check if there is already an event hook For IOCTL_STM_EVENTHOOK, IOS checks if there is already an event hook to prevent overriding an existing event hook message with a new one, without first releasing it. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp index edc63221f2..07d2747ba0 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_stm.cpp @@ -106,6 +106,12 @@ IPCCommandResult CWII_IPC_HLE_Device_stm_eventhook::IOCtl(u32 command_address) return GetDefaultReply(); } + if (s_event_hook_address != 0) + { + Memory::Write_U32(FS_EEXIST, command_address + 4); + return GetDefaultReply(); + } + // IOCTL_STM_EVENTHOOK waits until the reset button or power button // is pressed. s_event_hook_address = command_address; From 45b59f01b8406216b4e1ee06397184aafd9de6cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 8 Jan 2017 20:54:13 +0100 Subject: [PATCH 2/3] IOS HLE: Allow up to 3 ES handles Confirmed by a hardware test and a quick diassembly of /dev/es. I'm not aware of anything that opens several ES handles, but technically, this fixes a small inaccuracy in IOS HLE. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp | 2 +- Source/Core/Core/State.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp index cb3e43fc51..3a40dfd28f 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE.cpp @@ -65,7 +65,7 @@ static std::mutex s_device_map_mutex; // STATE_TO_SAVE constexpr u8 IPC_MAX_FDS = 0x18; -constexpr u8 ES_MAX_COUNT = 2; +constexpr u8 ES_MAX_COUNT = 3; static std::shared_ptr s_fdmap[IPC_MAX_FDS]; static std::shared_ptr s_es_handles[ES_MAX_COUNT]; diff --git a/Source/Core/Core/State.cpp b/Source/Core/Core/State.cpp index 3d4a9b3744..36be7c6447 100644 --- a/Source/Core/Core/State.cpp +++ b/Source/Core/Core/State.cpp @@ -71,7 +71,7 @@ static Common::Event g_compressAndDumpStateSyncEvent; static std::thread g_save_thread; // Don't forget to increase this after doing changes on the savestate system -static const u32 STATE_VERSION = 66; // Last changed in PR 4607 +static const u32 STATE_VERSION = 67; // Last changed in PR 4634 // Maps savestate versions to Dolphin versions. // Versions after 42 don't need to be added to this list, From c761ac4f08d43e98820b7b7f1f847d52c61a6c77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Lam?= Date: Sun, 8 Jan 2017 20:58:52 +0100 Subject: [PATCH 3/3] IOS HLE: Set return value to EINVAL for unknown commands This matches IOS behaviour and allows getting rid of command handlers which merely set the return value to EINVAL. --- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp | 5 +++++ .../Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp | 8 -------- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h | 1 - .../Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp | 8 -------- Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h | 1 - 5 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp index 3e79ec5fe4..ef9ecd616c 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device.cpp @@ -81,30 +81,35 @@ IPCCommandResult IWII_IPC_HLE_Device::Close(u32 command_address, bool force) IPCCommandResult IWII_IPC_HLE_Device::Seek(u32 command_address) { WARN_LOG(WII_IPC_HLE, "%s does not support Seek()", m_name.c_str()); + Memory::Write_U32(IPC_EINVAL, command_address); return GetDefaultReply(); } IPCCommandResult IWII_IPC_HLE_Device::Read(u32 command_address) { WARN_LOG(WII_IPC_HLE, "%s does not support Read()", m_name.c_str()); + Memory::Write_U32(IPC_EINVAL, command_address); return GetDefaultReply(); } IPCCommandResult IWII_IPC_HLE_Device::Write(u32 command_address) { WARN_LOG(WII_IPC_HLE, "%s does not support Write()", m_name.c_str()); + Memory::Write_U32(IPC_EINVAL, command_address); return GetDefaultReply(); } IPCCommandResult IWII_IPC_HLE_Device::IOCtl(u32 command_address) { WARN_LOG(WII_IPC_HLE, "%s does not support IOCtl()", m_name.c_str()); + Memory::Write_U32(IPC_EINVAL, command_address); return GetDefaultReply(); } IPCCommandResult IWII_IPC_HLE_Device::IOCtlV(u32 command_address) { WARN_LOG(WII_IPC_HLE, "%s does not support IOCtlV()", m_name.c_str()); + Memory::Write_U32(IPC_EINVAL, command_address); return GetDefaultReply(); } diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp index 1c8192162c..4f6b9d77b0 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.cpp @@ -50,14 +50,6 @@ void RestoreBTInfoSection(SysConf* sysconf) File::Delete(filename); } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_base::IOCtl(u32 command_address) -{ - // NeoGamma (homebrew) is known to use this path. - ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl to /dev/usb/oh1/57e/305"); - Memory::Write_U32(IPC_EINVAL, command_address + 4); - return GetDefaultReply(); -} - CWII_IPC_HLE_Device_usb_oh1_57e_305_base::CtrlMessage::CtrlMessage(const SIOCtlVBuffer& cmd_buffer) { request_type = Memory::Read_U8(cmd_buffer.InBuffer[0].m_Address); diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h index ffc1a32286..07a3807b7f 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_base.h @@ -28,7 +28,6 @@ public: virtual IPCCommandResult Open(u32 command_address, u32 mode) override = 0; virtual IPCCommandResult Close(u32 command_address, bool force) override = 0; - IPCCommandResult IOCtl(u32 command_address) override; virtual IPCCommandResult IOCtlV(u32 command_address) override = 0; virtual void DoState(PointerWrap& p) override = 0; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp index 1de1e473d6..1750cbf703 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.cpp @@ -172,14 +172,6 @@ IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::Close(u32 _CommandAddr return GetDefaultReply(); } -IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtl(u32 _CommandAddress) -{ - // NeoGamma (homebrew) is known to use this path. - ERROR_LOG(WII_IPC_WIIMOTE, "Bad IOCtl in CWII_IPC_HLE_Device_usb_oh1_57e_305"); - Memory::Write_U32(IPC_EINVAL, _CommandAddress + 4); - return GetDefaultReply(); -} - IPCCommandResult CWII_IPC_HLE_Device_usb_oh1_57e_305_emu::IOCtlV(u32 _CommandAddress) { bool _SendReply = false; diff --git a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h index 0fb8a4ef75..8161819ed1 100644 --- a/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h +++ b/Source/Core/Core/IPC_HLE/WII_IPC_HLE_Device_usb_bt_emu.h @@ -47,7 +47,6 @@ public: IPCCommandResult Close(u32 _CommandAddress, bool _bForce) override; IPCCommandResult IOCtlV(u32 _CommandAddress) override; - IPCCommandResult IOCtl(u32 _CommandAddress) override; u32 Update() override;