diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index 12af982f0..d39d334e6 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -15,6 +15,7 @@ #include "xenia/base/clock.h" #include "xenia/base/logging.h" #include "xenia/kernel/kernel_state.h" +#include "xenia/kernel/objects/xevent.h" #include "xenia/kernel/util/shim_utils.h" #include "xenia/kernel/xam_private.h" #include "xenia/xbox.h" @@ -42,6 +43,29 @@ typedef struct { uint8_t abOnline[20]; // Online identification } XNADDR; +struct Xsockaddr_t { + xe::be sa_family; + char sa_data[14]; +}; + +struct XWSABUF { + xe::be len; + xe::be buf_ptr; +}; + +struct XWSAOVERLAPPED { + xe::be internal; + xe::be internal_high; + union { + struct { + xe::be offset; + xe::be offset_high; + }; + xe::be pointer; + }; + xe::be event_handle; +}; + void LoadSockaddr(const uint8_t* ptr, sockaddr* out_addr) { out_addr->sa_family = xe::load_and_swap(ptr + 0); switch (out_addr->sa_family) { @@ -206,6 +230,27 @@ SHIM_CALL NetDll_WSAGetLastError_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(err); } +dword_result_t NetDll_WSARecvFrom(dword_t caller, dword_t socket, + pointer_t buffers_ptr, + dword_t buffer_count, + lpdword_t num_bytes_recv, lpdword_t flags_ptr, + pointer_t from_addr, + pointer_t overlapped_ptr, + lpvoid_t completion_routine_ptr) { + if (overlapped_ptr) { + auto evt = kernel_state()->object_table()->LookupObject( + overlapped_ptr->event_handle); + + if (evt) { + evt->Set(0, false); + } + } + + return 0; +} +DECLARE_XAM_EXPORT(NetDll_WSARecvFrom, + ExportTag::kNetworking | ExportTag::kStub); + struct XnAddrStatus { // Address acquisition is not yet complete const static uint32_t XNET_GET_XNADDR_PENDING = 0x00000000; @@ -304,6 +349,8 @@ SHIM_CALL NetDll_socket_shim(PPCContext* ppc_context, SOCKET socket_handle = socket(af, type, protocol); assert_true(socket_handle >> 32 == 0); + XELOGD("NetDll_socket = %.8X", socket_handle); + SHIM_SET_RETURN_32(static_cast(socket_handle)); } diff --git a/src/xenia/kernel/xboxkrnl_rtl.cc b/src/xenia/kernel/xboxkrnl_rtl.cc index 869409c9e..1045506e9 100644 --- a/src/xenia/kernel/xboxkrnl_rtl.cc +++ b/src/xenia/kernel/xboxkrnl_rtl.cc @@ -409,6 +409,12 @@ SHIM_CALL RtlImageXexHeaderField_shim(PPCContext* ppc_context, assert_true(xex_header_base == 0x80101100); auto module = kernel_state->GetExecutableModule(); + // Special case. + if (image_field == XEX_HEADER_EXECUTION_INFO) { + SHIM_SET_RETURN_32(module->execution_info_ptr()); + return; + } + const xe_xex2_header_t* xex_header = module->xex_header(); for (size_t n = 0; n < xex_header->header_count; n++) { if (xex_header->headers[n].key == image_field) { @@ -425,7 +431,7 @@ SHIM_CALL RtlImageXexHeaderField_shim(PPCContext* ppc_context, SHIM_SET_RETURN_32(0); break; default: - SHIM_SET_RETURN_32(0xC0000225); + SHIM_SET_RETURN_32(X_STATUS_NOT_FOUND); break; } } diff --git a/src/xenia/xbox.h b/src/xenia/xbox.h index a14616631..8479c307e 100644 --- a/src/xenia/xbox.h +++ b/src/xenia/xbox.h @@ -59,10 +59,13 @@ typedef uint32_t X_STATUS; #define X_STATUS_OBJECT_NAME_COLLISION ((X_STATUS)0xC0000035L) #define X_STATUS_INVALID_PAGE_PROTECTION ((X_STATUS)0xC0000045L) #define X_STATUS_MUTANT_NOT_OWNED ((X_STATUS)0xC0000046L) +#define X_STATUS_INSUFFICIENT_RESOURCES ((X_STATUS)0xC000009AL) #define X_STATUS_MEMORY_NOT_ALLOCATED ((X_STATUS)0xC00000A0L) #define X_STATUS_INVALID_PARAMETER_1 ((X_STATUS)0xC00000EFL) #define X_STATUS_INVALID_PARAMETER_2 ((X_STATUS)0xC00000F0L) #define X_STATUS_INVALID_PARAMETER_3 ((X_STATUS)0xC00000F1L) +#define X_STATUS_DLL_NOT_FOUND ((X_STATUS)0xC0000135L) +#define X_STATUS_NOT_FOUND ((X_STATUS)0xC0000225L) #define X_STATUS_DRIVER_ORDINAL_NOT_FOUND ((X_STATUS)0xC0000262L) #define X_STATUS_DRIVER_ENTRYPOINT_NOT_FOUND ((X_STATUS)0xC0000263L)