[Kernel] Implemented XexLoadImageFromMemory
This commit is contained in:
@@ -443,7 +443,7 @@ object_ref<UserModule> KernelState::LoadUserModule(
|
||||
|
||||
// See if we've already loaded it
|
||||
for (auto& existing_module : user_modules_) {
|
||||
if (existing_module->path() == path) {
|
||||
if (existing_module->Matches(path)) {
|
||||
return existing_module;
|
||||
}
|
||||
}
|
||||
@@ -466,6 +466,39 @@ object_ref<UserModule> KernelState::LoadUserModule(
|
||||
return module;
|
||||
}
|
||||
|
||||
object_ref<UserModule> KernelState::LoadUserModuleFromMemory(
|
||||
const std::string_view raw_name, const void* addr, const size_t length) {
|
||||
auto name = xe::utf8::find_base_name_from_guest_path(raw_name);
|
||||
|
||||
object_ref<UserModule> module;
|
||||
{
|
||||
auto global_lock = global_critical_region_.Acquire();
|
||||
|
||||
// See if we've already loaded it
|
||||
for (auto& existing_module : user_modules_) {
|
||||
if (existing_module->Matches(name)) {
|
||||
return existing_module;
|
||||
}
|
||||
}
|
||||
|
||||
global_lock.unlock();
|
||||
|
||||
// Module wasn't loaded, so load it.
|
||||
module = object_ref<UserModule>(new UserModule(this));
|
||||
X_STATUS status = module->LoadFromMemoryNamed(name, addr, length);
|
||||
if (XFAILED(status)) {
|
||||
object_table()->ReleaseHandle(module->handle());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
global_lock.lock();
|
||||
|
||||
// Putting into the listing automatically retains.
|
||||
user_modules_.push_back(module);
|
||||
}
|
||||
return module;
|
||||
}
|
||||
|
||||
X_RESULT KernelState::FinishLoadingUserModule(
|
||||
const object_ref<UserModule> module, bool call_entry) {
|
||||
// TODO(Gliniak): Apply custom patches here
|
||||
|
||||
Reference in New Issue
Block a user