Merge pull request #198 from DrChat/module_entry
Initialize modules in XexLoadImage
This commit is contained in:
commit
ca2beb4f65
|
@ -15,6 +15,8 @@
|
|||
#include "xenia/kernel/xboxkrnl_private.h"
|
||||
#include "xenia/xbox.h"
|
||||
|
||||
#include "xenia/cpu/processor.h"
|
||||
|
||||
namespace xe {
|
||||
namespace kernel {
|
||||
|
||||
|
@ -226,6 +228,22 @@ SHIM_CALL XexLoadImage_shim(PPCContext* ppc_state, KernelState* state) {
|
|||
} else {
|
||||
XUserModule* usermod = state->LoadUserModule(module_name);
|
||||
if (usermod) {
|
||||
// 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,
|
||||
args, xe::countof(args));
|
||||
|
||||
ppc_state->thread_state->context()->lr = lr;
|
||||
}
|
||||
|
||||
result = X_STATUS_SUCCESS;
|
||||
|
||||
usermod->RetainHandle();
|
||||
|
|
Loading…
Reference in New Issue