From a4849ca83ebfe9c530995dbf7e673345daa09dbb Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Tue, 21 Jul 2015 22:05:56 -0500 Subject: [PATCH] XNetSetSystemLinkPort / respect optional pointers in accept --- src/xenia/kernel/xam_net.cc | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index cd2935bc0..35b545454 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -350,6 +350,14 @@ dword_result_t NetDll_XNetGetDebugXnAddr(dword_t caller, DECLARE_XAM_EXPORT(NetDll_XNetGetDebugXnAddr, ExportTag::kNetworking | ExportTag::kStub); +// http://www.google.com/patents/WO2008112448A1?cl=en +// Reserves a port for use by system link +dword_result_t NetDll_XNetSetSystemLinkPort(dword_t caller, dword_t port) { + return 1; +} +DECLARE_XAM_EXPORT(NetDll_XNetSetSystemLinkPort, + ExportTag::kNetworking | ExportTag::kStub); + SHIM_CALL NetDll_XNetGetEthernetLinkStatus_shim(PPCContext* ppc_context, KernelState* kernel_state) { // Games seem to call this before *Startup. If we return 0, they don't even @@ -513,13 +521,25 @@ SHIM_CALL NetDll_accept_shim(PPCContext* ppc_context, SOCKET ret_socket = accept(socket_handle, &addr, &addrlen); if (ret_socket == INVALID_SOCKET) { - std::memset(SHIM_MEM_ADDR(addr_ptr), 0, sizeof(addr)); - SHIM_SET_MEM_32(addrlen_ptr, sizeof(addr)); + if (addr_ptr) { + std::memset(SHIM_MEM_ADDR(addr_ptr), 0, sizeof(addr)); + } + + if (addrlen_ptr) { + SHIM_SET_MEM_32(addrlen_ptr, sizeof(addr)); + } + SHIM_SET_RETURN_32(-1); } else { assert_true(ret_socket >> 32 == 0); - StoreSockaddr(addr, SHIM_MEM_ADDR(addr_ptr)); - SHIM_SET_MEM_32(addrlen_ptr, addrlen); + if (addr_ptr) { + StoreSockaddr(addr, SHIM_MEM_ADDR(addr_ptr)); + } + + if (addrlen_ptr) { + SHIM_SET_MEM_32(addrlen_ptr, addrlen); + } + SHIM_SET_RETURN_32(static_cast(ret_socket)); } }