Allow unloading of user modules
This commit is contained in:
@@ -24,7 +24,7 @@ using namespace xe::cpu;
|
||||
XUserModule::XUserModule(KernelState* kernel_state, const char* path)
|
||||
: XModule(kernel_state, ModuleType::kUserModule, path) {}
|
||||
|
||||
XUserModule::~XUserModule() {}
|
||||
XUserModule::~XUserModule() { Unload(); }
|
||||
|
||||
X_STATUS XUserModule::LoadFromFile(std::string path) {
|
||||
X_STATUS result = X_STATUS_UNSUCCESSFUL;
|
||||
@@ -111,6 +111,15 @@ X_STATUS XUserModule::LoadFromMemory(const void* addr, const size_t length) {
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS XUserModule::Unload() {
|
||||
if (!xex_module()->Unload()) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
OnUnload();
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
uint32_t XUserModule::GetProcAddressByOrdinal(uint16_t ordinal) {
|
||||
return xex_module()->GetProcAddress(ordinal);
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ class XUserModule : public XModule {
|
||||
const xe::cpu::XexModule* xex_module() const {
|
||||
return reinterpret_cast<xe::cpu::XexModule*>(processor_module_);
|
||||
}
|
||||
xe::cpu::XexModule* xex_module() {
|
||||
return reinterpret_cast<xe::cpu::XexModule*>(processor_module_);
|
||||
}
|
||||
|
||||
const xex2_header* xex_header() const { return xex_module()->xex_header(); }
|
||||
uint32_t guest_xex_header() const { return guest_xex_header_; }
|
||||
@@ -39,6 +42,7 @@ class XUserModule : public XModule {
|
||||
|
||||
X_STATUS LoadFromFile(std::string path);
|
||||
X_STATUS LoadFromMemory(const void* addr, const size_t length);
|
||||
X_STATUS Unload();
|
||||
|
||||
uint32_t GetProcAddressByOrdinal(uint16_t ordinal) override;
|
||||
uint32_t GetProcAddressByName(const char* name) override;
|
||||
|
||||
Reference in New Issue
Block a user