From 31a882496f1c86a0b0c8f6fe68ac5fd091449ccc Mon Sep 17 00:00:00 2001 From: shchmue Date: Sun, 16 Jun 2019 13:09:14 -0400 Subject: [PATCH] v1.2.4: Support emunand FS memory layout --- Makefile | 2 +- changelog.md | 4 ++++ source/KeyCollection.cpp | 1 - source/KeyLocation.cpp | 15 +++++++++++++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 47e5323..4fd0cc9 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ include $(DEVKITPRO)/libnx/switch_rules #--------------------------------------------------------------------------------- APP_TITLE := Lockpick APP_AUTHOR := shchmue -APP_VERSION := 1.2.3 +APP_VERSION := 1.2.4 TARGET := $(subst $e ,_,$(notdir $(APP_TITLE))) BUILD := build diff --git a/changelog.md b/changelog.md index adc96b4..2f9040b 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,8 @@ # Changelog +## Version 1.2.4 +* Support new emunand FS memory layout +* No longer save header_key if empty + ## Version 1.2.3 * Remove mbedtls dependency in favor of new libnx crypto library * Remove libnx 1.6.0 support since crypto requires later commit diff --git a/source/KeyCollection.cpp b/source/KeyCollection.cpp index 8c23f9a..b86856a 100644 --- a/source/KeyCollection.cpp +++ b/source/KeyCollection.cpp @@ -392,7 +392,6 @@ void KeyCollection::get_memory_keys() { } void KeyCollection::derive_keys() { - header_key = {"header_key", 0x20, {}}; if (header_kek_source.found() && header_key_source.found()) { u8 tempheaderkek[0x10], tempheaderkey[0x20]; splCryptoInitialize(); diff --git a/source/KeyLocation.cpp b/source/KeyLocation.cpp index ca4a513..d53c9dd 100644 --- a/source/KeyLocation.cpp +++ b/source/KeyLocation.cpp @@ -62,7 +62,22 @@ void KeyLocation::get_from_memory(u64 tid, u8 seg_mask) { u32 page_info; u64 addr = 0; + u64 last_text_addr = 0; + // locate "real" .text segment as Atmosphere emuNAND has two + for (;;) { + svcQueryDebugProcessMemory(&mem_info, &page_info, debug_handle, addr); + if ((mem_info.perm & Perm_X) && + ((mem_info.type & 0xff) >= MemType_CodeStatic) && + ((mem_info.type & 0xff) < MemType_Heap)) + { + last_text_addr = mem_info.addr; + } + addr = mem_info.addr + mem_info.size; + if (addr == 0) break; + } + + addr = last_text_addr; for (u8 segment = 1; segment < BIT(3); ) { svcQueryDebugProcessMemory(&mem_info, &page_info, debug_handle, addr);