Fixing module export.

This commit is contained in:
Ben Vanik 2015-06-28 12:07:13 -07:00
parent 0359184bc0
commit e772a8cb92
1 changed files with 18 additions and 19 deletions

View File

@ -180,8 +180,10 @@ void KernelState::SetExecutableModule(object_ref<XUserModule> module) {
return;
}
executable_module_ = std::move(module);
if (!executable_module_) {
return;
}
if (executable_module_) {
auto header = executable_module_->xex_header();
if (header) {
auto pib = memory_->TranslateVirtual<ProcessInfoBlock*>(
@ -190,18 +192,15 @@ void KernelState::SetExecutableModule(object_ref<XUserModule> module) {
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 exp = processor()->export_resolver()->GetExportByOrdinal(
// Setup the kernel's XexExecutableModuleHandle field.
auto export = processor()->export_resolver()->GetExportByOrdinal(
"xboxkrnl.exe", ordinals::XexExecutableModuleHandle);
if (exp) {
assert_not_null(export);
assert_not_zero(export->variable_ptr);
auto variable_ptr =
memory()->TranslateVirtual<xe::be<uint32_t>*>(exp->variable_ptr);
*variable_ptr = module->hmodule_ptr();
}
memory()->TranslateVirtual<xe::be<uint32_t>*>(export->variable_ptr);
*variable_ptr = executable_module_->hmodule_ptr();
}
void KernelState::LoadKernelModule(object_ref<XKernelModule> kernel_module) {