mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-05 12:13:50 +01:00
Expose PSPModule (so the debugger can access it later)
This commit is contained in:
1 parent
ce87560c95
commit
644f5e4e6c
9 files changed
+342
-315
No files matched your search
+169
-2
@@ -20,7 +20,13 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
#include <set>
|
||||
|
||||
#include "Core/HLE/sceKernel.h"
|
||||
#include "Core/MemMap.h"
|
||||
|
||||
class PointerWrap;
|
||||
struct SceKernelSMOption;
|
||||
|
||||
struct PspModuleInfo {
|
||||
u16_le moduleAttrs; //0x0000 User Mode, 0x1000 Kernel Mode
|
||||
@@ -34,8 +40,169 @@ struct PspModuleInfo {
|
||||
u32_le libstubend; // ptr to end of .lib.stub section
|
||||
};
|
||||
|
||||
class PointerWrap;
|
||||
struct SceKernelSMOption;
|
||||
enum NativeModuleStatus {
|
||||
MODULE_STATUS_STARTING = 4,
|
||||
MODULE_STATUS_STARTED = 5,
|
||||
MODULE_STATUS_STOPPING = 6,
|
||||
MODULE_STATUS_STOPPED = 7,
|
||||
MODULE_STATUS_UNLOADING = 8,
|
||||
};
|
||||
|
||||
const char *NativeModuleStatusToString(NativeModuleStatus status);
|
||||
|
||||
struct NativeModule {
|
||||
u32_le next;
|
||||
u16_le attribute;
|
||||
u8 version[2];
|
||||
char name[28];
|
||||
u32_le status;
|
||||
u32_le unk1;
|
||||
u32_le modid; // 0x2C
|
||||
u32_le usermod_thid;
|
||||
u32_le memid;
|
||||
u32_le mpidtext;
|
||||
u32_le mpiddata;
|
||||
u32_le ent_top;
|
||||
u32_le ent_size;
|
||||
u32_le stub_top;
|
||||
u32_le stub_size;
|
||||
u32_le module_start_func;
|
||||
u32_le module_stop_func;
|
||||
u32_le module_bootstart_func;
|
||||
u32_le module_reboot_before_func;
|
||||
u32_le module_reboot_phase_func;
|
||||
u32_le entry_addr;
|
||||
u32_le gp_value;
|
||||
u32_le text_addr;
|
||||
u32_le text_size;
|
||||
u32_le data_size;
|
||||
u32_le bss_size;
|
||||
u32_le nsegment;
|
||||
u32_le segmentaddr[4];
|
||||
u32_le segmentsize[4];
|
||||
u32_le module_start_thread_priority;
|
||||
u32_le module_start_thread_stacksize;
|
||||
u32_le module_start_thread_attr;
|
||||
u32_le module_stop_thread_priority;
|
||||
u32_le module_stop_thread_stacksize;
|
||||
u32_le module_stop_thread_attr;
|
||||
u32_le module_reboot_before_thread_priority;
|
||||
u32_le module_reboot_before_thread_stacksize;
|
||||
u32_le module_reboot_before_thread_attr;
|
||||
};
|
||||
|
||||
struct VarSymbolImport {
|
||||
char moduleName[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
u32 nid;
|
||||
u32 stubAddr;
|
||||
u8 type;
|
||||
};
|
||||
|
||||
struct VarSymbolExport {
|
||||
bool Matches(const VarSymbolImport &other) const {
|
||||
return nid == other.nid && !strncmp(moduleName, other.moduleName, KERNELOBJECT_MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
char moduleName[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
u32 nid;
|
||||
u32 symAddr;
|
||||
};
|
||||
|
||||
struct FuncSymbolImport {
|
||||
char moduleName[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
u32 stubAddr;
|
||||
u32 nid;
|
||||
};
|
||||
|
||||
struct FuncSymbolExport {
|
||||
bool Matches(const FuncSymbolImport &other) const {
|
||||
return nid == other.nid && !strncmp(moduleName, other.moduleName, KERNELOBJECT_MAX_NAME_LENGTH);
|
||||
}
|
||||
|
||||
char moduleName[KERNELOBJECT_MAX_NAME_LENGTH + 1];
|
||||
u32 symAddr;
|
||||
u32 nid;
|
||||
};
|
||||
|
||||
struct WriteVarSymbolState;
|
||||
|
||||
struct ModuleWaitingThread {
|
||||
SceUID threadID;
|
||||
u32 statusPtr;
|
||||
};
|
||||
|
||||
class PSPModule : public KernelObject {
|
||||
public:
|
||||
~PSPModule();
|
||||
const char *GetName() override { return nm.name; }
|
||||
const char *GetTypeName() override { return GetStaticTypeName(); }
|
||||
static const char *GetStaticTypeName() { return "Module"; }
|
||||
void GetQuickInfo(char *ptr, int size) override;
|
||||
void GetLongInfo(char *ptr, int bufSize) const override;
|
||||
static u32 GetMissingErrorCode();
|
||||
static int GetStaticIDType() { return PPSSPP_KERNEL_TMID_Module; }
|
||||
int GetIDType() const override { return PPSSPP_KERNEL_TMID_Module; }
|
||||
|
||||
u32 GetDataAddr() const {
|
||||
return nm.text_addr + nm.text_size;
|
||||
}
|
||||
u32 GetBSSAddr() const {
|
||||
return nm.text_addr + nm.text_size + nm.data_size;
|
||||
}
|
||||
|
||||
void DoState(PointerWrap &p) override;
|
||||
|
||||
// We don't do this in the destructor to avoid annoying messages on game shutdown.
|
||||
void Cleanup();
|
||||
|
||||
void ImportFunc(const FuncSymbolImport &func, bool reimporting);
|
||||
void ImportVar(WriteVarSymbolState &state, const VarSymbolImport &var);
|
||||
void ExportFunc(const FuncSymbolExport &func);
|
||||
void ExportVar(const VarSymbolExport &var);
|
||||
|
||||
template <typename T>
|
||||
void RebuildImpExpList(const std::vector<T> &list) {
|
||||
for (size_t i = 0; i < list.size(); ++i) {
|
||||
impExpModuleNames.insert(list[i].moduleName);
|
||||
}
|
||||
}
|
||||
|
||||
void RebuildImpExpModuleNames() {
|
||||
impExpModuleNames.clear();
|
||||
RebuildImpExpList(exportedFuncs);
|
||||
RebuildImpExpList(importedFuncs);
|
||||
RebuildImpExpList(exportedVars);
|
||||
RebuildImpExpList(importedVars);
|
||||
}
|
||||
|
||||
bool ImportsOrExportsModuleName(const std::string &moduleName) {
|
||||
return impExpModuleNames.find(moduleName) != impExpModuleNames.end();
|
||||
}
|
||||
|
||||
NativeModule nm{};
|
||||
std::vector<ModuleWaitingThread> waitingThreads;
|
||||
|
||||
std::vector<FuncSymbolExport> exportedFuncs;
|
||||
std::vector<FuncSymbolImport> importedFuncs;
|
||||
std::vector<VarSymbolExport> exportedVars;
|
||||
std::vector<VarSymbolImport> importedVars;
|
||||
std::set<std::string> impExpModuleNames;
|
||||
|
||||
// Keep track of the code region so we can throw out analysis results
|
||||
// when unloaded.
|
||||
u32 textStart = 0;
|
||||
u32 textEnd = 0;
|
||||
|
||||
// Keep track of the libstub pointers so we can recheck on load state.
|
||||
u32 libstub = 0;
|
||||
u32 libstubend = 0;
|
||||
|
||||
u32 memoryBlockAddr = 0;
|
||||
u32 memoryBlockSize = 0;
|
||||
u32 crc = 0;
|
||||
PSPPointer<NativeModule> modulePtr{};
|
||||
bool isFake = false;
|
||||
};
|
||||
|
||||
KernelObject *__KernelModuleObject();
|
||||
void __KernelModuleDoState(PointerWrap &p);
|
||||
|
||||
Reference in new issue
Block a user