Merge pull request #299 from DrChat/misc_fixes

Misc. fixes
This commit is contained in:
Ben Vanik 2015-06-27 15:27:54 -07:00
commit 246c47f923
3 changed files with 57 additions and 1 deletions

View File

@ -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<uint16_t> sa_family;
char sa_data[14];
};
struct XWSABUF {
xe::be<uint32_t> len;
xe::be<uint32_t> buf_ptr;
};
struct XWSAOVERLAPPED {
xe::be<uint32_t> internal;
xe::be<uint32_t> internal_high;
union {
struct {
xe::be<uint32_t> offset;
xe::be<uint32_t> offset_high;
};
xe::be<uint32_t> pointer;
};
xe::be<uint32_t> event_handle;
};
void LoadSockaddr(const uint8_t* ptr, sockaddr* out_addr) {
out_addr->sa_family = xe::load_and_swap<uint16_t>(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<XWSABUF> buffers_ptr,
dword_t buffer_count,
lpdword_t num_bytes_recv, lpdword_t flags_ptr,
pointer_t<Xsockaddr_t> from_addr,
pointer_t<XWSAOVERLAPPED> overlapped_ptr,
lpvoid_t completion_routine_ptr) {
if (overlapped_ptr) {
auto evt = kernel_state()->object_table()->LookupObject<XEvent>(
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<uint32_t>(socket_handle));
}

View File

@ -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;
}
}

View File

@ -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)