From 4644a3bd16987cc07596210757a234197f455e7a Mon Sep 17 00:00:00 2001 From: Matthew Parlane Date: Tue, 27 Aug 2013 22:44:54 +1200 Subject: [PATCH] Fix for Just Dance 4 Some clean ups. --- .../Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp | 35 ++++--------------- .../IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp | 19 ++-------- .../Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h | 19 ++-------- Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp | 14 +++++--- Source/Core/Core/Src/IPC_HLE/WII_Socket.h | 20 +++++++++++ 5 files changed, 42 insertions(+), 65 deletions(-) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp index 657110f3bb..6947088352 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net.cpp @@ -2,32 +2,6 @@ // Licensed under GPLv2 // Refer to the license.txt file included. - -/* -The /dev/net/kd/request requests are part of what is called WiiConnect24, -it's used by for example SSBB, Mario Kart, Metroid Prime 3 - -0x01 SuspendScheduler (Input: none, Output: 32 bytes) -0x02 ExecTrySuspendScheduler (Input: 32 bytes, Output: 32 bytes) // Sounds like it will -check if it should suspend the updates scheduler or not. If I returned -(OutBuffer: 0, Ret: -1) to Metroid Prime 3 it got stuck in an endless loops of -requests, probably harmless but I changed it to (OutBuffer: 1, Ret: 0) to stop -the calls. However then it also calls 0x3 and then changes its error message -to a Wii Memory error message from just a general Error message. - -0x03 ? (Input: none, Output: 32 bytes) // This is only called if 0x02 -does not return -1 -0x0f NWC24iRequestGenerateUserId (Input: none, Output: 32 bytes) - -Requests are made in this order by these games -Mario Kart: 2, 1, f, 3 -SSBB: 2, 3 - -For Mario Kart I had to return -1 from at least 2, f and 3 to convince it that the network -was unavailable and prevent if from looking for shared2/wc24 files (and do a PPCHalt when -it failed) -*/ - #include "WII_IPC_HLE_Device_es.h" #include "WII_IPC_HLE_Device_net.h" #include "../ConfigManager.h" @@ -225,9 +199,7 @@ bool CWII_IPC_HLE_Device_net_kd_request::IOCtl(u32 _CommandAddress) break; } - // g_ReplyQueueLater.push(std::pair(_CommandAddress, GetDeviceName())); Memory::Write_U32(ReturnValue, _CommandAddress + 4); - return true; } @@ -1313,7 +1285,7 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress) int ret = getaddrinfo(pNodeName, pServiceName, BufferInSize3 ? &hints : NULL, &result); u32 addr = _BufferOut; u32 sockoffset = addr + 0x460; - if (ret >= 0) + if (ret == 0) { while (result != NULL) { @@ -1350,6 +1322,11 @@ bool CWII_IPC_HLE_Device_net_ip_top::IOCtlV(u32 CommandAddress) result = result->ai_next; } } + else + { + // Host not found + ret = -305; + } WARN_LOG(WII_IPC_NET, "IOCTLV_SO_GETADDRINFO " "(BufferIn: (%08x, %i), BufferOut: (%08x, %i)", diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp index 0fb400d2db..ee89dc5eab 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.cpp @@ -1,19 +1,6 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. #include "FileUtil.h" #include "WII_IPC_HLE_Device_net_ssl.h" diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h index 8615eeef34..b8494d43d0 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_net_ssl.h @@ -1,19 +1,6 @@ -// Copyright (C) 2003 Dolphin Project. - -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, version 2.0. - -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License 2.0 for more details. - -// A copy of the GPL 2.0 should have been included with the program. -// If not, see http://www.gnu.org/licenses/ - -// Official SVN repository and contact information can be found at -// http://code.google.com/p/dolphin-emu/ +// Copyright 2013 Dolphin Emulator Project +// Licensed under GPLv2 +// Refer to the license.txt file included. #ifndef _WII_IPC_HLE_DEVICE_NET_SSL_H_ #define _WII_IPC_HLE_DEVICE_NET_SSL_H_ diff --git a/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp b/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp index 677f762732..2ed615de25 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_Socket.cpp @@ -72,8 +72,14 @@ s32 WiiSockMan::getNetErrorCode(s32 ret, std::string caller, bool isRW) return -SO_EALREADY; case ERRORCODE(EACCES): return -SO_EACCES; + case ERRORCODE(ECONNREFUSED): + return -SO_ECONNREFUSED; + case ERRORCODE(ENETUNREACH): + return -SO_ENETUNREACH; + case ERRORCODE(EHOSTUNREACH): + return -SO_EHOSTUNREACH; case EITHER(WSAEWOULDBLOCK, EAGAIN): - if(isRW){ + if (isRW){ return -SO_EAGAIN; // EAGAIN }else{ return -SO_EINPROGRESS; // EINPROGRESS @@ -347,7 +353,7 @@ void WiiSocket::update(bool read, bool write, bool except) #ifdef DEBUG_SSL if (ret > 0) { - File::IOFile("ssl_read.bin", "ab").WriteBytes(Memory::GetPointer(_BufferIn2), ret); + File::IOFile("ssl_read.bin", "ab").WriteBytes(Memory::GetPointer(BufferIn2), ret); } #endif if (ret >= 0) @@ -448,7 +454,7 @@ void WiiSocket::update(bool read, bool write, bool except) // recv/recvfrom only handles PEEK flags &= SO_MSG_PEEK | SO_MSG_OOB; #ifdef _WIN32 - if(flags & MSG_PEEK){ + if (flags & MSG_PEEK){ unsigned long totallen = 0; ioctlsocket(sock, FIONREAD, &totallen); ReturnValue = totallen; @@ -565,7 +571,7 @@ void WiiSockMan::Update() } s32 ret = select(nfds, &read_fds, &write_fds, &except_fds, &t); - if(ret >= 0) + if (ret >= 0) { for (auto it = WiiSockets.begin(); it != WiiSockets.end(); ++it) { diff --git a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h index f3d850433e..b473af6bf8 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_Socket.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_Socket.h @@ -139,6 +139,26 @@ enum { SO_EXDEV }; +struct WiiInAddr +{ + u32 addr; +}; + +struct WiiSockAddr +{ + u8 len; + u8 family; + u8 data[6]; +}; + +struct WiiSockAddrIn +{ + u8 len; + u8 family; + u16 port; + WiiInAddr addr; +}; + class WiiSocket { struct sockop{