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 {
|
||||
|
||||
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);
|
||||
|
|
|
@ -342,7 +342,7 @@ object_ref<UserModule> KernelState::LoadUserModule(const char* raw_name,
|
|||
global_lock.unlock();
|
||||
|
||||
// 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);
|
||||
if (XFAILED(status)) {
|
||||
object_table()->RemoveHandle(module->handle());
|
||||
|
|
|
@ -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> 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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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_; }
|
||||
|
|
Loading…
Reference in New Issue