*.o
*.d
*.elf
-*.bat
+*.vco
input
modules/template/src/symtab.h
# $uuid 00
# $flags require
+# Status: Working
+
# Anti-anti-downgrade fix.
# Relative to process9.
# $ver 01
# $uuid 01
+# Status: needs loader
+
find 0C18E1D8
set 0B1821C8
# $ver 01
# $uuid 02
+# Status: needs loader
+
find 30B5F1B0
set 002008607047
# $ver 01
# $uuid 03
+# Status: needs loader
+
find 25790B99
set E3A0
# $uuid 04
# $flags devmode
+# Status: needs loader
+
find 1400D0E5DB9A9FED
set 0000A0E3
# $uuid 05
# $flags noabort
+# Status: needs loader
+
find E01EFF2FE1010101
fwd 09
set 06
# $uuid 06
# $flags devmode
+# Status: needs assembler to be fixed
+
# Relative to NATIVE_FIRM, section index [1]
rel native_s1
# $ver 01
# $uuid 07
+# Status: needs loader
+
# u"Ver."
find 5600650072002e00
# $uuid 08
# $flags require
+# Status: Working
+
rel native_p9
# String: 'exe:'
find 6578653a
# $ver 01
# $uuid 09
+# Status: needs loader
+
find 000055E30110A0E3
# 16
back 11
# $ver 01
# $uuid 0a
+# Status: needs loader
+
find 30402DE90250A0E1
set 0000A0E31EFF2FE1
# $ver 01
# $uuid 0b
+# Status: needs loader
+
find 06461048FC
set 0026
# $uuid 0c
# $flags require
+# Status: Working
+
# Signature patch.
# Relative to exefs.
# $uuid 0d
# $flags devmode
+# Status: untested, but should work
+
rel native_s2
find 0110A013
fwd 03
#include "patch_file.h"
-/*
- rel p9_exefs
- find 6, 0x89, 0x0a, 0x81, 0x42, 0x02, 0xD2
- fwd 5
- set 1, 0xE0
- */
-
-extern exefs_h* firm_p9_exefs;
-
PATCH(aadowngrade)
{
- uint8_t* firm_mem = (uint8_t*)firm_p9_exefs + sizeof(exefs_h) +
- firm_p9_exefs->fileHeaders[0].offset;
- uint32_t size = firm_p9_exefs->fileHeaders[0].size;
-
- const uint8_t pattern[] = {0x89, 0x0A, 0x81, 0x42, 0x02, 0xD2};
-
- uint8_t *off = memfind(firm_mem, size, pattern, 6);
-
- if(off == NULL)
- return 1; // Not found.
-
- fprintf(stderr, "aadowngrade: %x\n", (uint32_t)off);
-
- off[5] = 0xE0;
+ execb(PATH_PATCHES "/aadowngrade.vco");
- return 0;
+ return 0;
}
+++ /dev/null
-#include "patch_file.h"
-
-// Do you like examples?
-
-PATCH(example)
-{
- fprintf(stderr, "Testing, testing, 1, 2, 3, 4..\n");
-
- return 0;
-}
// This patch applies the FIRM protection code needed for safe a9lh usage.
-/*
- rel p9_exefs
- find 4, "exe:"
- back 0x1
- back 0xff
- find 4, 0x00, 0x28, 0x01, 0xDA
- set 4, 0x00, 0x20, 0xC0, 0x46
- */
-
-extern exefs_h* firm_p9_exefs;
-
PATCH(firmprot)
{
- uint8_t* firm_mem = (uint8_t*)firm_p9_exefs + sizeof(exefs_h) +
- firm_p9_exefs->fileHeaders[0].offset;
- uint32_t size = firm_p9_exefs->fileHeaders[0].size;
-
- // We look for 'exe:' first; this string is close to what we patch
- uint8_t* off = memfind(firm_mem, size, (uint8_t*)"exe:", 4);
-
- if (off == NULL) {
- fprintf(stderr, "Couldn't find 'exe:' string.\n");
- return 1;
- }
-
- fprintf(stderr, "Firmprot: 'exe:' string @ %x\n", (uint32_t)off);
-
- uint8_t pattern[] = { 0x00, 0x28, 0x01, 0xDA };
-
- uint8_t* firmprot = memfind(off - 0x100, 0x100, pattern, 4);
-
- if (firmprot == NULL) {
- fprintf(stderr, "Couldn't find firmprot code.\n");
- return 2;
- }
-
- fprintf(stderr, "Firmprot: %x\n", (uint32_t)firmprot);
-
- uint8_t patch[] = { 0x00, 0x20, 0xC0, 0x46 };
- memcpy(firmprot, patch, 4);
-
- fprintf(stderr, "Applied firmprot patch.\n");
+ execb(PATH_PATCHES "/prot.vco");
return 0;
}
// This patch is responsible for fixing signature checks for the firmware.
-/*
- rel p9_exefs
- find 4, 0xc0, 0x1c, 0x76, 0xe7
- set 2, 0x00, 0x20
- rewind
- find 4, 0xb5, 0x22, 0x4d, 0x0c
- set 4, 0x00, 0x20, 0x70, 0x47
- */
-
-extern exefs_h* firm_p9_exefs;
-
PATCH(signatures)
{
-/*
- // Look for signature checks
-
- uint8_t pat1[] = { 0xC0, 0x1C, 0x76, 0xE7 };
- uint8_t pat2[] = { 0xB5, 0x22, 0x4D, 0x0C };
-
- // The code segment.
- uint8_t* firm_mem = (uint8_t*)firm_p9_exefs + sizeof(exefs_h) +
- firm_p9_exefs->fileHeaders[0].offset;
- uint32_t size = firm_p9_exefs->fileHeaders[0].size;
-
- uint8_t* off = memfind(firm_mem, size, pat1, 4);
-
- // We're subbing one because the code goes back 1.
- // Unique patterns, etc.
- uint8_t* off2 = memfind(firm_mem, size, pat2, 4) - 1;
-
- if (off == NULL) {
- fprintf(stderr, "Signature patch failed on P0.\n");
- return 1; // Failed to find sigpatch. Ugh.
- }
-
- if (off2 == NULL) {
- fprintf(stderr, "Signature patch failed on P1.\n");
- return 2; // Failed to find sigpatch. Ugh.
- }
-
- fprintf(stderr, "Signatures[0]: 0x%x\n", (uint32_t)off);
- fprintf(stderr, "Signatures[1]: 0x%x\n", (uint32_t)off2);
-
- // See asm/sigpatches.s for the code here
- uint8_t sigpatch[] = { 0x00, 0x20, 0x70, 0x47 };
-
- memcpy(off, sigpatch, 2);
- memcpy(off2, sigpatch, 4);
-
- fprintf(stderr, "Signature patch succeded.\n");
-*/
execb(PATH_PATCHES "/sig.vco");
return 0;