From 514275fc50c1b1cb90d766f3ac5521859dc5ea0d Mon Sep 17 00:00:00 2001 From: Gabriel Date: Tue, 1 Oct 2019 21:53:55 -0700 Subject: [PATCH] Move keys location and check FILE instead of using exists --- source/Common.cpp | 4 ++-- source/KeyCollection.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/source/Common.cpp b/source/Common.cpp index 8fec2ff..ffc5e45 100644 --- a/source/Common.cpp +++ b/source/Common.cpp @@ -191,8 +191,8 @@ namespace Common { } } // support biskeydump v7 dump - if (std::filesystem::exists("/device.keys")) { - FILE *key_file = fopen("/device.keys", "r"); + FILE *key_file = fopen("/device.keys", "r"); + if (key_file) { char line[0x100]; while (fgets(line, sizeof(line), key_file) && !(sbk.found() && tsec.found())) { if (strncmp("secure_boot_key", line, 15) == 0) diff --git a/source/KeyCollection.cpp b/source/KeyCollection.cpp index 48ca9d9..2f57e41 100644 --- a/source/KeyCollection.cpp +++ b/source/KeyCollection.cpp @@ -245,10 +245,12 @@ void KeyCollection::get_keys() { // avoid crash on CFWs that don't use /switch folder if (!std::filesystem::exists("/switch")) std::filesystem::create_directory("/switch"); + if (!std::filesystem::exists("/switch/Lockpick")) + std::filesystem::create_directory("/switch/Lockpick"); // since Lockpick_RCM can dump newer keys, check for existing keyfile bool Lockpick_RCM_file_found = false; - if (std::filesystem::exists("/switch/prod.keys")) { - FILE *key_file = fopen("/switch/prod.keys", "r"); + FILE *key_file = fopen("/switch/Lockpick/prod.keys", "r"); + if (key_file) { char line[0x200]; while (fgets(line, sizeof(line), key_file)) { if (strncmp("master_key_07", line, 13) == 0) {