mirror of
https://github.com/shchmue/Lockpick.git
synced 2024-11-05 05:05:11 +01:00
Make compatible with both libnx v2.0.0 and v1.6.0
This commit is contained in:
parent
352c39ae8a
commit
d4b4f868b1
2
Makefile
2
Makefile
@ -32,7 +32,7 @@ include $(DEVKITPRO)/libnx/switch_rules
|
||||
#---------------------------------------------------------------------------------
|
||||
APP_TITLE := Lockpick
|
||||
APP_AUTHOR := shchmue
|
||||
APP_VERSION := 1.1.1
|
||||
APP_VERSION := 1.2
|
||||
|
||||
TARGET := $(subst $e ,_,$(notdir $(APP_TITLE)))
|
||||
BUILD := build
|
||||
|
@ -34,7 +34,7 @@ Notes
|
||||
|
||||
Building
|
||||
=
|
||||
Release built with `libnx v1.6.0`.
|
||||
Release built with `libnx v2.0.0` but still builds and runs with `v1.6.0`.
|
||||
|
||||
Uses `freetype` which comes with `switch-portlibs` via `devkitPro pacman`:
|
||||
```
|
||||
|
10
changelog.md
10
changelog.md
@ -1,4 +1,14 @@
|
||||
# Changelog
|
||||
## Version 1.2
|
||||
* Update for libnx v2.0.0 compatibility and still runs when built with v1.6.0
|
||||
* The binary got even smaller!
|
||||
* Accelerate finding FS keys
|
||||
* No longer find BIS sources as they're hardcoded (whoops)
|
||||
* Find all keys on first pass hashing FS instead of hashing the whole thing from the beginning repeatedly (__*whoops*__)
|
||||
|
||||
## Version 1.1.1
|
||||
* No longer try to dump SD seed and ES keys on 1.0.0 as they're not available until 2.0.0
|
||||
|
||||
## Version 1.1
|
||||
* Changed titlekey dump methodology
|
||||
* No longer crashes sysmodule, reboot no longer needed
|
||||
|
@ -34,8 +34,16 @@
|
||||
|
||||
#include "sha256.h"
|
||||
|
||||
#ifdef RGBX8
|
||||
#define LIBNX_200
|
||||
#endif
|
||||
|
||||
namespace Common {
|
||||
static u32 framebuf_width = 0;
|
||||
#ifdef LIBNX_200
|
||||
static Framebuffer fb;
|
||||
static u32 stride;
|
||||
#endif
|
||||
static u32 *framebuf;
|
||||
// FreeType vars
|
||||
static FT_Library library;
|
||||
@ -111,7 +119,9 @@ namespace Common {
|
||||
|
||||
PlFontData font;
|
||||
|
||||
#ifndef LIBNX_200
|
||||
consoleInit(NULL);
|
||||
#endif
|
||||
|
||||
plGetSharedFontByType(&font, PlSharedFontType_Standard);
|
||||
|
||||
@ -119,10 +129,18 @@ namespace Common {
|
||||
FT_New_Memory_Face(library, static_cast<FT_Byte *>(font.address), font.size, 0, &face);
|
||||
FT_Set_Char_Size(face, 0, 6*64, 300, 300);
|
||||
|
||||
gfxSetMode(GfxMode_LinearDouble); // todo: update for nwindow/framebuffer
|
||||
#ifdef LIBNX_200
|
||||
framebufferCreate(&fb, nwindowGetDefault(), FB_WIDTH, FB_HEIGHT, PIXEL_FORMAT_RGBA_8888, 2);
|
||||
framebufferMakeLinear(&fb);
|
||||
framebuf = (u32 *)framebufferBegin(&fb, &stride);
|
||||
framebuf_width = stride / sizeof(u32);
|
||||
memset(framebuf, 0, stride*FB_HEIGHT);
|
||||
framebufferEnd(&fb);
|
||||
#else
|
||||
gfxSetMode(GfxMode_LinearDouble);
|
||||
framebuf = (u32 *)gfxGetFramebuffer(&framebuf_width, NULL);
|
||||
memset(framebuf, 0, gfxGetFramebufferSize());
|
||||
|
||||
#endif
|
||||
draw_text(0x10, 0x020, YELLOW, "Lockpick! by shchmue");
|
||||
|
||||
draw_set_rect(814, 452 + 42 * 0, 450, 42, FLAG_RED);
|
||||
@ -148,7 +166,7 @@ namespace Common {
|
||||
draw_text(0x10, 0x0e0, CYAN, "Saving keys to keyfile...");
|
||||
draw_text(0x10, 0x110, CYAN, "Total time elapsed:");
|
||||
|
||||
consoleUpdate(NULL);
|
||||
update_display();
|
||||
}
|
||||
|
||||
void get_tegra_keys(Key &sbk, Key &tsec, Key &tsec_root) {
|
||||
@ -206,17 +224,29 @@ namespace Common {
|
||||
u64 kDown = hidKeysDown(CONTROLLER_P1_AUTO);
|
||||
if (kDown & KEY_PLUS) break;
|
||||
|
||||
consoleUpdate(NULL);
|
||||
update_display();
|
||||
}
|
||||
|
||||
#ifdef LIBNX_200
|
||||
framebufferClose(&fb);
|
||||
#else
|
||||
consoleExit(NULL);
|
||||
#endif
|
||||
FT_Done_Face(face);
|
||||
FT_Done_FreeType(library);
|
||||
|
||||
consoleExit(NULL);
|
||||
|
||||
appletUnlockExit();
|
||||
}
|
||||
|
||||
void update_display() {
|
||||
#ifdef LIBNX_200
|
||||
framebufferBegin(&fb, &stride);
|
||||
framebufferEnd(&fb);
|
||||
#else
|
||||
consoleUpdate(NULL);
|
||||
#endif
|
||||
}
|
||||
|
||||
void sha256(const u8 *data, u8 *hash, size_t length) {
|
||||
struct sha256_state ctx;
|
||||
sha256_init(&ctx);
|
||||
|
@ -24,6 +24,9 @@
|
||||
|
||||
#include <switch/types.h>
|
||||
|
||||
#define FB_WIDTH 1280
|
||||
#define FB_HEIGHT 720
|
||||
|
||||
#define GREEN RGBA8_MAXALPHA(0, 0xff, 0)
|
||||
#define RED RGBA8_MAXALPHA(0xff, 0, 0)
|
||||
#define CYAN RGBA8_MAXALPHA(0, 0xff, 0xff)
|
||||
@ -61,6 +64,9 @@ namespace Common {
|
||||
// print exit
|
||||
void wait_to_exit();
|
||||
|
||||
// refresh display
|
||||
void update_display();
|
||||
|
||||
void sha256(const u8 *data, u8 *hash, size_t length);
|
||||
// reads "<keyname> = <hexkey>" and returns byte vector
|
||||
byte_vector key_string_to_byte_vector(std::string key_string);
|
||||
|
@ -251,16 +251,16 @@ void KeyCollection::get_keys() {
|
||||
char keys_str[32];
|
||||
sprintf(keys_str, "Total keys found: %lu", Key::get_saved_key_count());
|
||||
Common::draw_text(0x2a0, 0x110, CYAN, keys_str);
|
||||
Common::draw_text(0x80, 0x140, GREEN, "Keys saved to \"/switch/prod.keys\"!");
|
||||
Common::draw_text(0x80, 0x140, YELLOW, "Keys saved to \"/switch/prod.keys\"!");
|
||||
|
||||
Common::draw_text(0x10, 0x170, CYAN, "Dumping titlekeys...");
|
||||
consoleUpdate(NULL);
|
||||
Common::update_display();
|
||||
profiler_time = profile(&KeyCollection::get_titlekeys, *this);
|
||||
Common::draw_text_with_time(0x10, 0x170, GREEN, "Dumping titlekeys...", profiler_time);
|
||||
sprintf(keys_str, "Titlekeys found: %lu", titlekeys_dumped);
|
||||
Common::draw_text(0x2a0, 0x170, CYAN, keys_str);
|
||||
if (titlekeys_dumped > 0)
|
||||
Common::draw_text(0x80, 0x1a0, GREEN, "Titlekeys saved to \"/switch/title.keys\"!");
|
||||
Common::draw_text(0x80, 0x1a0, YELLOW, "Titlekeys saved to \"/switch/title.keys\"!");
|
||||
else
|
||||
Common::draw_text(0x80, 0x1a0, GREEN, "No titlekeys found. Either you've never played or installed a game or dump failed.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user