Assign XModule path on load rather than in the constructor
This commit is contained in:
parent
c242a01043
commit
4e7dfa477b
|
@ -19,11 +19,17 @@ namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
KernelModule::KernelModule(KernelState* kernel_state, const char* path)
|
KernelModule::KernelModule(KernelState* kernel_state, const char* path)
|
||||||
: XModule(kernel_state, ModuleType::kKernelModule, path) {
|
: XModule(kernel_state, ModuleType::kKernelModule) {
|
||||||
emulator_ = kernel_state->emulator();
|
emulator_ = kernel_state->emulator();
|
||||||
memory_ = emulator_->memory();
|
memory_ = emulator_->memory();
|
||||||
export_resolver_ = kernel_state->emulator()->export_resolver();
|
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!
|
// HACK: Allocates memory where xboxkrnl.exe would be!
|
||||||
// TODO: Need to free this memory when necessary.
|
// TODO: Need to free this memory when necessary.
|
||||||
auto heap = memory()->LookupHeap(0x80040000);
|
auto heap = memory()->LookupHeap(0x80040000);
|
||||||
|
|
|
@ -342,7 +342,7 @@ object_ref<UserModule> KernelState::LoadUserModule(const char* raw_name,
|
||||||
global_lock.unlock();
|
global_lock.unlock();
|
||||||
|
|
||||||
// Module wasn't loaded, so load it.
|
// Module wasn't loaded, so load it.
|
||||||
module = object_ref<UserModule>(new UserModule(this, path.c_str()));
|
module = object_ref<UserModule>(new UserModule(this));
|
||||||
X_STATUS status = module->LoadFromFile(path);
|
X_STATUS status = module->LoadFromFile(path);
|
||||||
if (XFAILED(status)) {
|
if (XFAILED(status)) {
|
||||||
object_table()->RemoveHandle(module->handle());
|
object_table()->RemoveHandle(module->handle());
|
||||||
|
|
|
@ -23,8 +23,8 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
UserModule::UserModule(KernelState* kernel_state, const char* path)
|
UserModule::UserModule(KernelState* kernel_state)
|
||||||
: XModule(kernel_state, ModuleType::kUserModule, path) {}
|
: XModule(kernel_state, ModuleType::kUserModule) {}
|
||||||
|
|
||||||
UserModule::~UserModule() { Unload(); }
|
UserModule::~UserModule() { Unload(); }
|
||||||
|
|
||||||
|
@ -39,6 +39,9 @@ X_STATUS UserModule::LoadFromFile(std::string path) {
|
||||||
return X_STATUS_NO_SUCH_FILE;
|
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 the FS supports mapping, map the file in and load from that.
|
||||||
if (fs_entry->can_map()) {
|
if (fs_entry->can_map()) {
|
||||||
// Map.
|
// Map.
|
||||||
|
@ -320,7 +323,7 @@ bool UserModule::Save(ByteStream* stream) {
|
||||||
object_ref<UserModule> UserModule::Restore(KernelState* kernel_state,
|
object_ref<UserModule> UserModule::Restore(KernelState* kernel_state,
|
||||||
ByteStream* stream,
|
ByteStream* stream,
|
||||||
std::string path) {
|
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...
|
// XModule::Save took care of this earlier...
|
||||||
// TODO: Find a nicer way to represent that here.
|
// TODO: Find a nicer way to represent that here.
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace kernel {
|
||||||
|
|
||||||
class UserModule : public XModule {
|
class UserModule : public XModule {
|
||||||
public:
|
public:
|
||||||
UserModule(KernelState* kernel_state, const char* path);
|
UserModule(KernelState* kernel_state);
|
||||||
~UserModule() override;
|
~UserModule() override;
|
||||||
|
|
||||||
enum ModuleFormat {
|
enum ModuleFormat {
|
||||||
|
|
|
@ -18,15 +18,11 @@
|
||||||
namespace xe {
|
namespace xe {
|
||||||
namespace kernel {
|
namespace kernel {
|
||||||
|
|
||||||
XModule::XModule(KernelState* kernel_state, ModuleType module_type,
|
XModule::XModule(KernelState* kernel_state, ModuleType module_type)
|
||||||
const std::string& path)
|
|
||||||
: XObject(kernel_state, kTypeModule),
|
: XObject(kernel_state, kTypeModule),
|
||||||
module_type_(module_type),
|
module_type_(module_type),
|
||||||
path_(path),
|
|
||||||
processor_module_(nullptr),
|
processor_module_(nullptr),
|
||||||
hmodule_ptr_(0) {
|
hmodule_ptr_(0) {
|
||||||
name_ = NameFromPath(path);
|
|
||||||
|
|
||||||
// Loader data (HMODULE)
|
// Loader data (HMODULE)
|
||||||
hmodule_ptr_ = memory()->SystemHeapAlloc(sizeof(X_LDR_DATA_TABLE_ENTRY));
|
hmodule_ptr_ = memory()->SystemHeapAlloc(sizeof(X_LDR_DATA_TABLE_ENTRY));
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,7 @@ class XModule : public XObject {
|
||||||
|
|
||||||
static const Type kType = kTypeModule;
|
static const Type kType = kTypeModule;
|
||||||
|
|
||||||
XModule(KernelState* kernel_state, ModuleType module_type,
|
XModule(KernelState* kernel_state, ModuleType module_type);
|
||||||
const std::string& path);
|
|
||||||
virtual ~XModule();
|
virtual ~XModule();
|
||||||
|
|
||||||
ModuleType module_type() const { return module_type_; }
|
ModuleType module_type() const { return module_type_; }
|
||||||
|
|
Loading…
Reference in New Issue