From e772a8cb925dea7aea79e005c8bacecc4c688026 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Sun, 28 Jun 2015 12:07:13 -0700 Subject: [PATCH] Fixing module export. --- src/xenia/kernel/kernel_state.cc | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index d7e581775..d672cf6b4 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -180,28 +180,27 @@ void KernelState::SetExecutableModule(object_ref module) { return; } executable_module_ = std::move(module); - - if (executable_module_) { - auto header = executable_module_->xex_header(); - if (header) { - auto pib = memory_->TranslateVirtual( - process_info_block_address_); - pib->tls_data_size = header->tls_info.data_size; - pib->tls_raw_data_size = header->tls_info.raw_data_size; - pib->tls_slot_size = header->tls_info.slot_count * 4; - } + if (!executable_module_) { + return; } - // Setup the kernel's XexExecutableModuleHandle field - auto exp = processor()->export_resolver()->GetExportByOrdinal( + auto header = executable_module_->xex_header(); + if (header) { + auto pib = memory_->TranslateVirtual( + process_info_block_address_); + pib->tls_data_size = header->tls_info.data_size; + pib->tls_raw_data_size = header->tls_info.raw_data_size; + pib->tls_slot_size = header->tls_info.slot_count * 4; + } + + // Setup the kernel's XexExecutableModuleHandle field. + auto export = processor()->export_resolver()->GetExportByOrdinal( "xboxkrnl.exe", ordinals::XexExecutableModuleHandle); - - if (exp) { - auto variable_ptr = - memory()->TranslateVirtual*>(exp->variable_ptr); - - *variable_ptr = module->hmodule_ptr(); - } + assert_not_null(export); + assert_not_zero(export->variable_ptr); + auto variable_ptr = + memory()->TranslateVirtual*>(export->variable_ptr); + *variable_ptr = executable_module_->hmodule_ptr(); } void KernelState::LoadKernelModule(object_ref kernel_module) {