diff --git a/src/xenia/kernel/kernel_module.cc b/src/xenia/kernel/kernel_module.cc index 98dec1fa1..3126543ce 100644 --- a/src/xenia/kernel/kernel_module.cc +++ b/src/xenia/kernel/kernel_module.cc @@ -19,11 +19,17 @@ namespace xe { namespace kernel { KernelModule::KernelModule(KernelState* kernel_state, const char* path) - : XModule(kernel_state, ModuleType::kKernelModule, path) { + : XModule(kernel_state, ModuleType::kKernelModule) { emulator_ = kernel_state->emulator(); memory_ = emulator_->memory(); export_resolver_ = kernel_state->emulator()->export_resolver(); + path_ = path; + name_ = NameFromPath(path); + + // Persist this object through reloads. + host_object_ = true; + // HACK: Allocates memory where xboxkrnl.exe would be! // TODO: Need to free this memory when necessary. auto heap = memory()->LookupHeap(0x80040000); diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index 94265d1c0..ba85ad8fb 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -342,7 +342,7 @@ object_ref KernelState::LoadUserModule(const char* raw_name, global_lock.unlock(); // Module wasn't loaded, so load it. - module = object_ref(new UserModule(this, path.c_str())); + module = object_ref(new UserModule(this)); X_STATUS status = module->LoadFromFile(path); if (XFAILED(status)) { object_table()->RemoveHandle(module->handle()); diff --git a/src/xenia/kernel/user_module.cc b/src/xenia/kernel/user_module.cc index ba38bf551..739e0e3b1 100644 --- a/src/xenia/kernel/user_module.cc +++ b/src/xenia/kernel/user_module.cc @@ -23,8 +23,8 @@ namespace xe { namespace kernel { -UserModule::UserModule(KernelState* kernel_state, const char* path) - : XModule(kernel_state, ModuleType::kUserModule, path) {} +UserModule::UserModule(KernelState* kernel_state) + : XModule(kernel_state, ModuleType::kUserModule) {} UserModule::~UserModule() { Unload(); } @@ -39,6 +39,9 @@ X_STATUS UserModule::LoadFromFile(std::string path) { return X_STATUS_NO_SUCH_FILE; } + path_ = fs_entry->absolute_path(); + name_ = NameFromPath(path_); + // If the FS supports mapping, map the file in and load from that. if (fs_entry->can_map()) { // Map. @@ -320,7 +323,7 @@ bool UserModule::Save(ByteStream* stream) { object_ref UserModule::Restore(KernelState* kernel_state, ByteStream* stream, std::string path) { - auto module = new UserModule(kernel_state, path.c_str()); + auto module = new UserModule(kernel_state); // XModule::Save took care of this earlier... // TODO: Find a nicer way to represent that here. diff --git a/src/xenia/kernel/user_module.h b/src/xenia/kernel/user_module.h index 769abb9b4..ff18e9bd7 100644 --- a/src/xenia/kernel/user_module.h +++ b/src/xenia/kernel/user_module.h @@ -33,7 +33,7 @@ namespace kernel { class UserModule : public XModule { public: - UserModule(KernelState* kernel_state, const char* path); + UserModule(KernelState* kernel_state); ~UserModule() override; enum ModuleFormat { diff --git a/src/xenia/kernel/xmodule.cc b/src/xenia/kernel/xmodule.cc index 9b567fb80..bde32fb7a 100644 --- a/src/xenia/kernel/xmodule.cc +++ b/src/xenia/kernel/xmodule.cc @@ -18,15 +18,11 @@ namespace xe { namespace kernel { -XModule::XModule(KernelState* kernel_state, ModuleType module_type, - const std::string& path) +XModule::XModule(KernelState* kernel_state, ModuleType module_type) : XObject(kernel_state, kTypeModule), module_type_(module_type), - path_(path), processor_module_(nullptr), hmodule_ptr_(0) { - name_ = NameFromPath(path); - // Loader data (HMODULE) hmodule_ptr_ = memory()->SystemHeapAlloc(sizeof(X_LDR_DATA_TABLE_ENTRY)); diff --git a/src/xenia/kernel/xmodule.h b/src/xenia/kernel/xmodule.h index 22b7b053a..0e559e4f3 100644 --- a/src/xenia/kernel/xmodule.h +++ b/src/xenia/kernel/xmodule.h @@ -59,8 +59,7 @@ class XModule : public XObject { static const Type kType = kTypeModule; - XModule(KernelState* kernel_state, ModuleType module_type, - const std::string& path); + XModule(KernelState* kernel_state, ModuleType module_type); virtual ~XModule(); ModuleType module_type() const { return module_type_; }