aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshchmue <shchmue@gmail.com>2019-01-04 15:54:34 -0500
committershchmue <shchmue@gmail.com>2019-01-04 15:54:34 -0500
commitd4b4f868b12bc0e384fceaa5a0eb9dc294545af2 (patch)
tree25f2904a520b0e2e4939d3b8ca985f96dd061d35
parent352c39ae8a9f2ac59db274d0b1f47d1ee6003a17 (diff)
Make compatible with both libnx v2.0.0 and v1.6.0v1.2
-rw-r--r--Makefile2
-rw-r--r--README.md2
-rw-r--r--changelog.md10
-rw-r--r--source/Common.cpp42
-rw-r--r--source/Common.hpp6
-rw-r--r--source/KeyCollection.cpp6
6 files changed, 57 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index adf61ec..85d6ffe 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ include $(DEVKITPRO)/libnx/switch_rules
32#--------------------------------------------------------------------------------- 32#---------------------------------------------------------------------------------
33APP_TITLE := Lockpick 33APP_TITLE := Lockpick
34APP_AUTHOR := shchmue 34APP_AUTHOR := shchmue
35APP_VERSION := 1.1.1 35APP_VERSION := 1.2
36 36
37TARGET := $(subst $e ,_,$(notdir $(APP_TITLE))) 37TARGET := $(subst $e ,_,$(notdir $(APP_TITLE)))
38BUILD := build 38BUILD := build
diff --git a/README.md b/README.md
index 81b3648..d3a7ed8 100644
--- a/README.md
+++ b/README.md
@@ -34,7 +34,7 @@ Notes
34 34
35Building 35Building
36= 36=
37Release built with `libnx v1.6.0`. 37Release built with `libnx v2.0.0` but still builds and runs with `v1.6.0`.
38 38
39Uses `freetype` which comes with `switch-portlibs` via `devkitPro pacman`: 39Uses `freetype` which comes with `switch-portlibs` via `devkitPro pacman`:
40``` 40```
diff --git a/changelog.md b/changelog.md
index 63ef429..2710825 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,14 @@
1# Changelog 1# Changelog
2## Version 1.2
3* Update for libnx v2.0.0 compatibility and still runs when built with v1.6.0
4 * The binary got even smaller!
5* Accelerate finding FS keys
6 * No longer find BIS sources as they're hardcoded (whoops)
7 * Find all keys on first pass hashing FS instead of hashing the whole thing from the beginning repeatedly (__*whoops*__)
8
9## Version 1.1.1
10* No longer try to dump SD seed and ES keys on 1.0.0 as they're not available until 2.0.0
11
2## Version 1.1 12## Version 1.1
3* Changed titlekey dump methodology 13* Changed titlekey dump methodology
4 * No longer crashes sysmodule, reboot no longer needed 14 * No longer crashes sysmodule, reboot no longer needed
diff --git a/source/Common.cpp b/source/Common.cpp
index 2e1bdfd..41cc702 100644
--- a/source/Common.cpp
+++ b/source/Common.cpp
@@ -34,8 +34,16 @@
34 34
35#include "sha256.h" 35#include "sha256.h"
36 36
37#ifdef RGBX8
38 #define LIBNX_200
39#endif
40
37namespace Common { 41namespace Common {
38 static u32 framebuf_width = 0; 42 static u32 framebuf_width = 0;
43#ifdef LIBNX_200
44 static Framebuffer fb;
45 static u32 stride;
46#endif
39 static u32 *framebuf; 47 static u32 *framebuf;
40 // FreeType vars 48 // FreeType vars
41 static FT_Library library; 49 static FT_Library library;
@@ -111,7 +119,9 @@ namespace Common {
111 119
112 PlFontData font; 120 PlFontData font;
113 121
122#ifndef LIBNX_200
114 consoleInit(NULL); 123 consoleInit(NULL);
124#endif
115 125
116 plGetSharedFontByType(&font, PlSharedFontType_Standard); 126 plGetSharedFontByType(&font, PlSharedFontType_Standard);
117 127
@@ -119,10 +129,18 @@ namespace Common {
119 FT_New_Memory_Face(library, static_cast<FT_Byte *>(font.address), font.size, 0, &face); 129 FT_New_Memory_Face(library, static_cast<FT_Byte *>(font.address), font.size, 0, &face);
120 FT_Set_Char_Size(face, 0, 6*64, 300, 300); 130 FT_Set_Char_Size(face, 0, 6*64, 300, 300);
121 131
122 gfxSetMode(GfxMode_LinearDouble); // todo: update for nwindow/framebuffer 132#ifdef LIBNX_200
133 framebufferCreate(&fb, nwindowGetDefault(), FB_WIDTH, FB_HEIGHT, PIXEL_FORMAT_RGBA_8888, 2);
134 framebufferMakeLinear(&fb);
135 framebuf = (u32 *)framebufferBegin(&fb, &stride);
136 framebuf_width = stride / sizeof(u32);
137 memset(framebuf, 0, stride*FB_HEIGHT);
138 framebufferEnd(&fb);
139#else
140 gfxSetMode(GfxMode_LinearDouble);
123 framebuf = (u32 *)gfxGetFramebuffer(&framebuf_width, NULL); 141 framebuf = (u32 *)gfxGetFramebuffer(&framebuf_width, NULL);
124 memset(framebuf, 0, gfxGetFramebufferSize()); 142 memset(framebuf, 0, gfxGetFramebufferSize());
125 143#endif
126 draw_text(0x10, 0x020, YELLOW, "Lockpick! by shchmue"); 144 draw_text(0x10, 0x020, YELLOW, "Lockpick! by shchmue");
127 145
128 draw_set_rect(814, 452 + 42 * 0, 450, 42, FLAG_RED); 146 draw_set_rect(814, 452 + 42 * 0, 450, 42, FLAG_RED);
@@ -148,7 +166,7 @@ namespace Common {
148 draw_text(0x10, 0x0e0, CYAN, "Saving keys to keyfile..."); 166 draw_text(0x10, 0x0e0, CYAN, "Saving keys to keyfile...");
149 draw_text(0x10, 0x110, CYAN, "Total time elapsed:"); 167 draw_text(0x10, 0x110, CYAN, "Total time elapsed:");
150 168
151 consoleUpdate(NULL); 169 update_display();
152 } 170 }
153 171
154 void get_tegra_keys(Key &sbk, Key &tsec, Key &tsec_root) { 172 void get_tegra_keys(Key &sbk, Key &tsec, Key &tsec_root) {
@@ -206,17 +224,29 @@ namespace Common {
206 u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO); 224 u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
207 if (kDown & KEY_PLUS) break; 225 if (kDown & KEY_PLUS) break;
208 226
209 consoleUpdate(NULL); 227 update_display();
210 } 228 }
211 229
230#ifdef LIBNX_200
231 framebufferClose(&fb);
232#else
233 consoleExit(NULL);
234#endif
212 FT_Done_Face(face); 235 FT_Done_Face(face);
213 FT_Done_FreeType(library); 236 FT_Done_FreeType(library);
214 237
215 consoleExit(NULL);
216
217 appletUnlockExit(); 238 appletUnlockExit();
218 } 239 }
219 240
241 void update_display() {
242#ifdef LIBNX_200
243 framebufferBegin(&fb, &stride);
244 framebufferEnd(&fb);
245#else
246 consoleUpdate(NULL);
247#endif
248 }
249
220 void sha256(const u8 *data, u8 *hash, size_t length) { 250 void sha256(const u8 *data, u8 *hash, size_t length) {
221 struct sha256_state ctx; 251 struct sha256_state ctx;
222 sha256_init(&ctx); 252 sha256_init(&ctx);
diff --git a/source/Common.hpp b/source/Common.hpp
index 1d3f856..fe064ac 100644
--- a/source/Common.hpp
+++ b/source/Common.hpp
@@ -24,6 +24,9 @@
24 24
25#include <switch/types.h> 25#include <switch/types.h>
26 26
27#define FB_WIDTH 1280
28#define FB_HEIGHT 720
29
27#define GREEN RGBA8_MAXALPHA(0, 0xff, 0) 30#define GREEN RGBA8_MAXALPHA(0, 0xff, 0)
28#define RED RGBA8_MAXALPHA(0xff, 0, 0) 31#define RED RGBA8_MAXALPHA(0xff, 0, 0)
29#define CYAN RGBA8_MAXALPHA(0, 0xff, 0xff) 32#define CYAN RGBA8_MAXALPHA(0, 0xff, 0xff)
@@ -61,6 +64,9 @@ namespace Common {
61 // print exit 64 // print exit
62 void wait_to_exit(); 65 void wait_to_exit();
63 66
67 // refresh display
68 void update_display();
69
64 void sha256(const u8 *data, u8 *hash, size_t length); 70 void sha256(const u8 *data, u8 *hash, size_t length);
65 // reads "<keyname> = <hexkey>" and returns byte vector 71 // reads "<keyname> = <hexkey>" and returns byte vector
66 byte_vector key_string_to_byte_vector(std::string key_string); 72 byte_vector key_string_to_byte_vector(std::string key_string);
diff --git a/source/KeyCollection.cpp b/source/KeyCollection.cpp
index 3609805..ed87816 100644
--- a/source/KeyCollection.cpp
+++ b/source/KeyCollection.cpp
@@ -251,16 +251,16 @@ void KeyCollection::get_keys() {
251 char keys_str[32]; 251 char keys_str[32];
252 sprintf(keys_str, "Total keys found: %lu", Key::get_saved_key_count()); 252 sprintf(keys_str, "Total keys found: %lu", Key::get_saved_key_count());
253 Common::draw_text(0x2a0, 0x110, CYAN, keys_str); 253 Common::draw_text(0x2a0, 0x110, CYAN, keys_str);
254 Common::draw_text(0x80, 0x140, GREEN, "Keys saved to \"/switch/prod.keys\"!"); 254 Common::draw_text(0x80, 0x140, YELLOW, "Keys saved to \"/switch/prod.keys\"!");
255 255
256 Common::draw_text(0x10, 0x170, CYAN, "Dumping titlekeys..."); 256 Common::draw_text(0x10, 0x170, CYAN, "Dumping titlekeys...");
257 consoleUpdate(NULL); 257 Common::update_display();
258 profiler_time = profile(&KeyCollection::get_titlekeys, *this); 258 profiler_time = profile(&KeyCollection::get_titlekeys, *this);
259 Common::draw_text_with_time(0x10, 0x170, GREEN, "Dumping titlekeys...", profiler_time); 259 Common::draw_text_with_time(0x10, 0x170, GREEN, "Dumping titlekeys...", profiler_time);
260 sprintf(keys_str, "Titlekeys found: %lu", titlekeys_dumped); 260 sprintf(keys_str, "Titlekeys found: %lu", titlekeys_dumped);
261 Common::draw_text(0x2a0, 0x170, CYAN, keys_str); 261 Common::draw_text(0x2a0, 0x170, CYAN, keys_str);
262 if (titlekeys_dumped > 0) 262 if (titlekeys_dumped > 0)
263 Common::draw_text(0x80, 0x1a0, GREEN, "Titlekeys saved to \"/switch/title.keys\"!"); 263 Common::draw_text(0x80, 0x1a0, YELLOW, "Titlekeys saved to \"/switch/title.keys\"!");
264 else 264 else
265 Common::draw_text(0x80, 0x1a0, GREEN, "No titlekeys found. Either you've never played or installed a game or dump failed."); 265 Common::draw_text(0x80, 0x1a0, GREEN, "No titlekeys found. Either you've never played or installed a game or dump failed.");
266} 266}