mirror of
https://github.com/Atmosphere-NX/Atmosphere
synced 2025-02-05 15:02:49 +00:00
Compare commits
1 commit
3e717c1215
...
042b9b4dd7
Author | SHA1 | Date | |
---|---|---|---|
|
042b9b4dd7 |
2 changed files with 53 additions and 26 deletions
|
@ -623,6 +623,11 @@ namespace ams::kern::arch::arm64 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read the first instruction. */
|
||||||
|
if (!ReadValue(std::addressof(temp_32), process, base_address)) {
|
||||||
|
return PrintAddress(address);
|
||||||
|
}
|
||||||
|
|
||||||
/* Get the module name. */
|
/* Get the module name. */
|
||||||
char module_name[0x20];
|
char module_name[0x20];
|
||||||
const bool has_module_name = GetModuleName(module_name, sizeof(module_name), process, base_address);
|
const bool has_module_name = GetModuleName(module_name, sizeof(module_name), process, base_address);
|
||||||
|
@ -632,32 +637,36 @@ namespace ams::kern::arch::arm64 {
|
||||||
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Locate .dyn using rocrt::ModuleHeader. */
|
if (temp_32 == 0) {
|
||||||
{
|
/* Module is dynamically loaded by rtld. */
|
||||||
/* Determine the ModuleHeader offset. */
|
|
||||||
u32 mod_offset;
|
u32 mod_offset;
|
||||||
if (!ReadValue(std::addressof(mod_offset), process, base_address + sizeof(u32))) {
|
if (!ReadValue(std::addressof(mod_offset), process, base_address + sizeof(u32))) {
|
||||||
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
if (!ReadValue(std::addressof(temp_32), process, base_address + mod_offset)) {
|
||||||
/* Read the signature. */
|
|
||||||
constexpr u32 SignatureFieldOffset = AMS_OFFSETOF(rocrt::ModuleHeader, signature);
|
|
||||||
if (!ReadValue(std::addressof(temp_32), process, base_address + mod_offset + SignatureFieldOffset)) {
|
|
||||||
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
if (temp_32 != 0x30444F4D) { /* MOD0 */
|
||||||
/* Check that the module signature is expected. */
|
|
||||||
if (temp_32 != rocrt::ModuleHeaderVersion) { /* MOD0 */
|
|
||||||
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
if (!ReadValue(std::addressof(temp_32), process, base_address + mod_offset + sizeof(u32))) {
|
||||||
/* Determine the dynamic offset. */
|
|
||||||
constexpr u32 DynamicFieldOffset = AMS_OFFSETOF(rocrt::ModuleHeader, dynamic_offset);
|
|
||||||
if (!ReadValue(std::addressof(temp_32), process, base_address + mod_offset + DynamicFieldOffset)) {
|
|
||||||
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
dyn_address = base_address + mod_offset + temp_32;
|
||||||
dyn_address = module.start_address + mod_offset + temp_32;
|
} else if (temp_32 == 0x14000002) {
|
||||||
|
/* Module embeds rtld. */
|
||||||
|
if (!ReadValue(std::addressof(temp_32), process, base_address + 0x5C)) {
|
||||||
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
|
}
|
||||||
|
if (temp_32 != 0x94000002) {
|
||||||
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
|
}
|
||||||
|
if (!ReadValue(std::addressof(temp_32), process, base_address + 0x60)) {
|
||||||
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
|
}
|
||||||
|
dyn_address = base_address + 0x60 + temp_32;
|
||||||
|
} else {
|
||||||
|
return PrintAddressWithModuleName(address, has_module_name, module_name, base_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Locate tables inside .dyn. */
|
/* Locate tables inside .dyn. */
|
||||||
|
|
|
@ -282,38 +282,56 @@ namespace ams::creport {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read the first instruction of .text. */
|
||||||
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address, sizeof(temp_32)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* We want to find the symbol table/.dynamic. */
|
/* We want to find the symbol table/.dynamic. */
|
||||||
uintptr_t dyn_address = 0;
|
uintptr_t dyn_address = 0;
|
||||||
uintptr_t sym_tab = 0;
|
uintptr_t sym_tab = 0;
|
||||||
uintptr_t str_tab = 0;
|
uintptr_t str_tab = 0;
|
||||||
size_t num_sym = 0;
|
size_t num_sym = 0;
|
||||||
|
|
||||||
/* Locate .dyn using rocrt::ModuleHeader. */
|
/* Detect module type. */
|
||||||
{
|
if (temp_32 == 0) {
|
||||||
/* Determine the ModuleHeader offset. */
|
/* Module is dynamically loaded by rtld. */
|
||||||
u32 mod_offset;
|
u32 mod_offset;
|
||||||
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(mod_offset)), m_debug_handle, module.start_address + sizeof(u32), sizeof(u32)))) {
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(mod_offset)), m_debug_handle, module.start_address + sizeof(u32), sizeof(u32)))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read the signature. */
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + mod_offset, sizeof(u32)))) {
|
||||||
constexpr u32 SignatureFieldOffset = AMS_OFFSETOF(rocrt::ModuleHeader, signature);
|
|
||||||
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + mod_offset + SignatureFieldOffset, sizeof(u32)))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check that the module signature is expected. */
|
|
||||||
if (temp_32 != rocrt::ModuleHeaderVersion) { /* MOD0 */
|
if (temp_32 != rocrt::ModuleHeaderVersion) { /* MOD0 */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Determine the dynamic offset. */
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + mod_offset + sizeof(u32), sizeof(u32)))) {
|
||||||
constexpr u32 DynamicFieldOffset = AMS_OFFSETOF(rocrt::ModuleHeader, dynamic_offset);
|
|
||||||
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + mod_offset + DynamicFieldOffset, sizeof(u32)))) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
dyn_address = module.start_address + mod_offset + temp_32;
|
dyn_address = module.start_address + mod_offset + temp_32;
|
||||||
|
} else if (temp_32 == 0x14000002) {
|
||||||
|
/* Module embeds rtld. */
|
||||||
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + 0x5C, sizeof(u32)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (temp_32 != 0x94000002) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (R_FAILED(svc::ReadDebugProcessMemory(reinterpret_cast<uintptr_t>(std::addressof(temp_32)), m_debug_handle, module.start_address + 0x60, sizeof(u32)))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
dyn_address = module.start_address + 0x60 + temp_32;
|
||||||
|
} else {
|
||||||
|
/* Module has unknown format. */
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue