From 0f2b1491b756a38350c9d7e670aee9a39ec2d924 Mon Sep 17 00:00:00 2001 From: "Dr. Chat" Date: Fri, 8 May 2015 22:43:54 -0500 Subject: [PATCH] Call a DLL's entry-point function in XexLoadImage --- src/xenia/kernel/xboxkrnl_modules.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/xenia/kernel/xboxkrnl_modules.cc b/src/xenia/kernel/xboxkrnl_modules.cc index 082be2bc8..3afae32ca 100644 --- a/src/xenia/kernel/xboxkrnl_modules.cc +++ b/src/xenia/kernel/xboxkrnl_modules.cc @@ -231,8 +231,17 @@ SHIM_CALL XexLoadImage_shim(PPCContext* ppc_state, KernelState* state) { // If the module has an entry point function, we have to call it. const xe_xex2_header_t* header = usermod->xex_header(); if (header->exe_entry_point) { + // Return address + uint32_t lr = ppc_state->thread_state->context()->lr; + + // TODO: What are these args for? + // param 2: val 1 seems to make CRT initialize + uint64_t args[] = { 0, 1, 0 }; state->processor()->Execute(ppc_state->thread_state, - header->exe_entry_point); + header->exe_entry_point, + args, xe::countof(args)); + + ppc_state->thread_state->context()->lr = lr; } result = X_STATUS_SUCCESS;