Handling imports when modules aren't found.

This commit is contained in:
Ben Vanik 2015-05-18 19:34:06 -07:00
parent dceb9550c9
commit 1c96941236
1 changed files with 14 additions and 12 deletions

View File

@ -123,8 +123,10 @@ bool XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) {
export_resolver->GetExportByOrdinal(library->name, info->ordinal);
} else {
XModule* module = kernel_state_->GetModule(library->name);
if (module) {
user_export_addr = module->GetProcAddressByOrdinal(info->ordinal);
}
}
if (kernel_export) {
if (info->thunk_address) {
@ -146,8 +148,8 @@ bool XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) {
var_info->set_status(SymbolInfo::STATUS_DEFINED);
// Grab, if available.
if (kernel_export) {
auto slot = memory_->TranslateVirtual<uint32_t*>(info->value_address);
if (kernel_export) {
if (kernel_export->type == KernelExport::Function) {
// Not exactly sure what this should be...
if (info->thunk_address) {
@ -170,19 +172,19 @@ bool XexModule::SetupLibraryImports(const xe_xex2_import_library_t* library) {
kernel_export->name);
}
}
} else {
auto slot = memory_->TranslateVirtual<uint32_t*>(info->value_address);
// Assuming this is correct...
} else if (user_export_addr) {
xe::store_and_swap<uint32_t>(slot, user_export_addr);
} else {
// Nothing.
XELOGE("kernel import not found: %.8X", info->value_address);
*slot = xe::byte_swap(0xF00DF00D);
}
if (info->thunk_address) {
if (kernel_export) {
snprintf(name, xe::countof(name), "%s", kernel_export->name);
} else if (user_export_addr) {
snprintf(name, xe::countof(name), "__%s_%.3X", libname,
info->ordinal);
snprintf(name, xe::countof(name), "__%s_%.3X", libname, info->ordinal);
} else {
snprintf(name, xe::countof(name), "__kernel_%s_%.3X", libname,
info->ordinal);