Compare commits
5 Commits
script_dic
...
3.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb4361c991 | ||
|
|
e81e418b1e | ||
|
|
adc54c9881 | ||
|
|
347513a037 | ||
|
|
d8f0c714b6 |
2
Makefile
2
Makefile
@@ -11,7 +11,7 @@ include $(DEVKITARM)/base_rules
|
|||||||
IPL_LOAD_ADDR := 0x40003000
|
IPL_LOAD_ADDR := 0x40003000
|
||||||
LPVERSION_MAJOR := 3
|
LPVERSION_MAJOR := 3
|
||||||
LPVERSION_MINOR := 0
|
LPVERSION_MINOR := 0
|
||||||
LPVERSION_BUGFX := 2
|
LPVERSION_BUGFX := 5
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,8 @@ static const pkg1_id_t _pkg1_ids[] = {
|
|||||||
{ "20191021113848", 10}, //9.1.0
|
{ "20191021113848", 10}, //9.1.0
|
||||||
{ "20200303104606", 10}, //10.0.0 - 10.2.0
|
{ "20200303104606", 10}, //10.0.0 - 10.2.0
|
||||||
{ "20201030110855", 10}, //11.0.0
|
{ "20201030110855", 10}, //11.0.0
|
||||||
|
{ "20210129111626", 10}, //12.0.0
|
||||||
|
{ "20210422145837", 10}, //12.0.2
|
||||||
{ NULL } //End.
|
{ NULL } //End.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -240,7 +240,10 @@ static ALWAYS_INLINE u8 *_read_pkg1(const pkg1_id_t **pkg1_id) {
|
|||||||
*pkg1_id = pkg1_identify(pkg1 + pk1_offset);
|
*pkg1_id = pkg1_identify(pkg1 + pk1_offset);
|
||||||
if (!*pkg1_id) {
|
if (!*pkg1_id) {
|
||||||
DPRINTF("Unknown pkg1 version.\n Make sure you have the latest Lockpick_RCM.\n If a new firmware version just came out,\n Lockpick_RCM must be updated.\n Check Github for new release.");
|
DPRINTF("Unknown pkg1 version.\n Make sure you have the latest Lockpick_RCM.\n If a new firmware version just came out,\n Lockpick_RCM must be updated.\n Check Github for new release.");
|
||||||
gfx_hexdump(0, pkg1, 0x20);
|
//gfx_hexdump(0, pkg1, 0x20);
|
||||||
|
char pkg1txt[16] = {0};
|
||||||
|
memcpy(pkg1txt, pkg1 + pk1_offset + 0x10, 15);
|
||||||
|
gfx_printf("Unknown pkg1 version\nMake sure you have the latest version of TegraExplorer\n\nPKG1: '%s'\n", pkg1txt);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,24 +123,6 @@ Variable_t getVarFromToken(scriptCtx_t* ctx, lexarToken_t* tokens, int* index, u
|
|||||||
return ErrValue(ERRINVALIDTYPE);
|
return ErrValue(ERRINVALIDTYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ELIFTX(MemberVariable){
|
|
||||||
Variable_t* var = dictVectorFind(&ctx->varDict, tokens[i].text);
|
|
||||||
i++;
|
|
||||||
|
|
||||||
if (var == NULL)
|
|
||||||
return ErrValue(ERRNOVAR);
|
|
||||||
|
|
||||||
if (tokens[i].token == MemberVariable){
|
|
||||||
return ErrValue(ERRINVALIDTYPE); // Recursive members currently not supported!
|
|
||||||
}
|
|
||||||
|
|
||||||
Variable_t *find = dictVectorFind(&var->vectorType, tokens[i].text);
|
|
||||||
if (find == NULL)
|
|
||||||
return ErrValue(ERRNOVAR); // No member with that variable was found
|
|
||||||
|
|
||||||
val = *find;
|
|
||||||
val.free = 0;
|
|
||||||
}
|
|
||||||
ELIFTX(Function) {
|
ELIFTX(Function) {
|
||||||
i += 2;
|
i += 2;
|
||||||
|
|
||||||
|
|||||||
@@ -422,22 +422,6 @@ scriptFunction(funcLaunchPayload){
|
|||||||
return varInt(launch_payload(vars[0].stringType));
|
return varInt(launch_payload(vars[0].stringType));
|
||||||
}
|
}
|
||||||
|
|
||||||
scriptFunction(funcNewDict){
|
|
||||||
Variable_t dict = {0};
|
|
||||||
dict.varType = DictionaryType;
|
|
||||||
dict.free = 1;
|
|
||||||
dict.vectorType = newVec(sizeof(dict_t), 4);
|
|
||||||
dict.vectorPtr = &dict.vectorType;
|
|
||||||
return dict;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Args: Dict, Str, Var
|
|
||||||
scriptFunction(funcAddToDict){
|
|
||||||
Variable_t copy = copyVariable(vars[2]);
|
|
||||||
dictVectorAdd(vars[0].vectorPtr, newDict(CpyStr(vars[1].stringType), copy));
|
|
||||||
return NullVar;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 fiveInts[] = {IntType, IntType, IntType, IntType, IntType};
|
u8 fiveInts[] = {IntType, IntType, IntType, IntType, IntType};
|
||||||
u8 singleIntArray[] = { IntArrayType };
|
u8 singleIntArray[] = { IntArrayType };
|
||||||
u8 singleInt[] = { IntType };
|
u8 singleInt[] = { IntType };
|
||||||
@@ -448,7 +432,6 @@ u8 StrByteVec[] = { StringType, ByteArrayType};
|
|||||||
u8 MenuArgs[] = { StringArrayType, IntType, StringArrayType, IntArrayType};
|
u8 MenuArgs[] = { StringArrayType, IntType, StringArrayType, IntArrayType};
|
||||||
u8 twoStrings[] = { StringType, StringType };
|
u8 twoStrings[] = { StringType, StringType };
|
||||||
u8 mmcReadWrite[] = { StringType, StringType, IntType};
|
u8 mmcReadWrite[] = { StringType, StringType, IntType};
|
||||||
u8 dictAdd[] = {DictionaryType, StringType, varArgs};
|
|
||||||
|
|
||||||
functionStruct_t scriptFunctions[] = {
|
functionStruct_t scriptFunctions[] = {
|
||||||
{"if", funcIf, 1, singleInt},
|
{"if", funcIf, 1, singleInt},
|
||||||
@@ -493,8 +476,6 @@ functionStruct_t scriptFunctions[] = {
|
|||||||
{"saveSign", funcSignSave, 1, singleStr},
|
{"saveSign", funcSignSave, 1, singleStr},
|
||||||
{"timerMs", funcGetMs, 0, NULL},
|
{"timerMs", funcGetMs, 0, NULL},
|
||||||
{"launchPayload", funcLaunchPayload, 1, singleStr},
|
{"launchPayload", funcLaunchPayload, 1, singleStr},
|
||||||
{"dict", funcNewDict, 0, NULL},
|
|
||||||
{"dictAdd", funcAddToDict, 3, dictAdd},
|
|
||||||
// Left from old: keyboard(?)
|
// Left from old: keyboard(?)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -161,10 +161,6 @@ Vector_t runLexer(const char* in, u32 len) {
|
|||||||
|
|
||||||
vecAddElement(&vec, makeLexarToken(LSBracket, 0));
|
vecAddElement(&vec, makeLexarToken(LSBracket, 0));
|
||||||
}
|
}
|
||||||
ELIFC('.'){
|
|
||||||
if (lx[vec.count - 1].token == Variable)
|
|
||||||
lx[vec.count - 1].token = MemberVariable;
|
|
||||||
}
|
|
||||||
ELIFC('=') { // Do we need to keep = if the vars are assignments anyway?
|
ELIFC('=') { // Do we need to keep = if the vars are assignments anyway?
|
||||||
if (in[1] == '='){
|
if (in[1] == '='){
|
||||||
vecAddElement(&vec, makeLexarToken(EqualEqual, 0));
|
vecAddElement(&vec, makeLexarToken(EqualEqual, 0));
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ enum Tokens {
|
|||||||
Invalid = 0,
|
Invalid = 0,
|
||||||
Variable = 1,
|
Variable = 1,
|
||||||
ArrayVariable,
|
ArrayVariable,
|
||||||
MemberVariable,
|
|
||||||
Function,
|
Function,
|
||||||
LBracket,
|
LBracket,
|
||||||
StrLit,
|
StrLit,
|
||||||
@@ -71,7 +70,6 @@ enum Variables {
|
|||||||
IntArrayType,
|
IntArrayType,
|
||||||
StringArrayType,
|
StringArrayType,
|
||||||
ByteArrayType,
|
ByteArrayType,
|
||||||
DictionaryType,
|
|
||||||
JumpType,
|
JumpType,
|
||||||
DictType,
|
DictType,
|
||||||
NullType,
|
NullType,
|
||||||
@@ -105,7 +103,6 @@ typedef struct {
|
|||||||
char* stringType;
|
char* stringType;
|
||||||
Vector_t vectorType;
|
Vector_t vectorType;
|
||||||
};
|
};
|
||||||
Vector_t *vectorPtr;
|
|
||||||
} Variable_t;
|
} Variable_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mem/heap.h>
|
#include <mem/heap.h>
|
||||||
#include "../utils/utils.h"
|
|
||||||
|
|
||||||
void freeVariable(Variable_t dv) {
|
void freeVariable(Variable_t dv) {
|
||||||
if (!dv.free)
|
if (!dv.free)
|
||||||
@@ -23,27 +22,9 @@ void freeVariable(Variable_t dv) {
|
|||||||
case ByteArrayType:
|
case ByteArrayType:
|
||||||
vecFree(dv.vectorType);
|
vecFree(dv.vectorType);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DictionaryType:
|
|
||||||
freeDictVector(&dv.vectorType);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Variable_t copyVariable(Variable_t copy){
|
|
||||||
switch (copy.varType){
|
|
||||||
case IntType:
|
|
||||||
return copy;
|
|
||||||
case StringType:
|
|
||||||
return newVar(StringType, 1, .stringType = CpyStr(copy.stringType));
|
|
||||||
case IntArrayType:
|
|
||||||
case StringArrayType:
|
|
||||||
return newVar(copy.varType, 1, .vectorType = vecCopy(©.vectorType));
|
|
||||||
}
|
|
||||||
|
|
||||||
return NullVar; // Other types are not supported or whatever
|
|
||||||
}
|
|
||||||
|
|
||||||
void freeVariableVector(Vector_t *v) {
|
void freeVariableVector(Vector_t *v) {
|
||||||
Variable_t* vars = vecGetArrayPtr(v, Variable_t*);
|
Variable_t* vars = vecGetArrayPtr(v, Variable_t*);
|
||||||
for (int i = 0; i < v->count; i++) {
|
for (int i = 0; i < v->count; i++) {
|
||||||
@@ -88,10 +69,6 @@ void dictVectorAdd(Vector_t* v, dict_t add) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
vecAddElement(v, add);
|
vecAddElement(v, add);
|
||||||
dict_t *dict = vecGetArrayPtr(v, dict_t*);
|
|
||||||
for (int i = 0; i < v->count; i++){
|
|
||||||
dict[i].value.vectorPtr = &dict[i].value.vectorType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,6 @@ void freeDictVector(Vector_t* v);
|
|||||||
void freeVariableVector(Vector_t* v);
|
void freeVariableVector(Vector_t* v);
|
||||||
void freeVariable(Variable_t dv);
|
void freeVariable(Variable_t dv);
|
||||||
scriptCtx_t createScriptCtx();
|
scriptCtx_t createScriptCtx();
|
||||||
Variable_t copyVariable(Variable_t copy);
|
|
||||||
|
|
||||||
u8 setIndentInstruction(scriptCtx_t* ctx, u8 level, u8 skip, u8 func, int jumpLoc);
|
u8 setIndentInstruction(scriptCtx_t* ctx, u8 level, u8 skip, u8 func, int jumpLoc);
|
||||||
indentInstructor_t* getCurIndentInstruction(scriptCtx_t* ctx);
|
indentInstructor_t* getCurIndentInstruction(scriptCtx_t* ctx);
|
||||||
|
|||||||
@@ -12,10 +12,11 @@
|
|||||||
#include <storage/nx_sd.h>
|
#include <storage/nx_sd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../fs/fsutils.h"
|
#include "../fs/fsutils.h"
|
||||||
|
#include "nx_emmc_bis.h"
|
||||||
|
|
||||||
// Uses default storage in nx_emmc.c
|
// Uses default storage in nx_emmc.c
|
||||||
// Expects the correct mmc & partition to be set
|
// Expects the correct mmc & partition to be set
|
||||||
ErrCode_t EmmcDumpToFile(const char *path, u32 lba_start, u32 lba_end, u8 force){
|
ErrCode_t EmmcDumpToFile(const char *path, u32 lba_start, u32 lba_end, u8 force, u8 crypt){
|
||||||
FIL fp;
|
FIL fp;
|
||||||
u32 curLba = lba_start;
|
u32 curLba = lba_start;
|
||||||
u32 totalSectors = lba_end - lba_start + 1;
|
u32 totalSectors = lba_end - lba_start + 1;
|
||||||
@@ -41,7 +42,14 @@ ErrCode_t EmmcDumpToFile(const char *path, u32 lba_start, u32 lba_end, u8 force)
|
|||||||
|
|
||||||
while (totalSectors > 0){
|
while (totalSectors > 0){
|
||||||
u32 num = MIN(totalSectors, TConf.FSBuffSize / NX_EMMC_BLOCKSIZE);
|
u32 num = MIN(totalSectors, TConf.FSBuffSize / NX_EMMC_BLOCKSIZE);
|
||||||
if (!emummc_storage_read(&emmc_storage, curLba, num, buff)){
|
|
||||||
|
int readRes = 0;
|
||||||
|
if (crypt)
|
||||||
|
readRes = !nx_emmc_bis_read(curLba, num, buff);
|
||||||
|
else
|
||||||
|
readRes = emummc_storage_read(&emmc_storage, curLba, num, buff);
|
||||||
|
|
||||||
|
if (!readRes){
|
||||||
err = newErrCode(TE_ERR_EMMC_READ_FAIL);
|
err = newErrCode(TE_ERR_EMMC_READ_FAIL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -64,7 +72,7 @@ ErrCode_t EmmcDumpToFile(const char *path, u32 lba_start, u32 lba_end, u8 force)
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrCode_t EmmcRestoreFromFile(const char *path, u32 lba_start, u32 lba_end, u8 force){
|
ErrCode_t EmmcRestoreFromFile(const char *path, u32 lba_start, u32 lba_end, u8 force, u8 crypt){
|
||||||
FIL fp;
|
FIL fp;
|
||||||
u32 curLba = lba_start;
|
u32 curLba = lba_start;
|
||||||
u32 totalSectorsDest = lba_end - lba_start + 1;
|
u32 totalSectorsDest = lba_end - lba_start + 1;
|
||||||
@@ -99,7 +107,13 @@ ErrCode_t EmmcRestoreFromFile(const char *path, u32 lba_start, u32 lba_end, u8 f
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!emummc_storage_write(&emmc_storage, curLba, num, buff)){
|
int writeRes = 0;
|
||||||
|
if (crypt)
|
||||||
|
writeRes = !nx_emmc_bis_write(curLba, num, buff);
|
||||||
|
else
|
||||||
|
writeRes = emummc_storage_write(&emmc_storage, curLba, num, buff);
|
||||||
|
|
||||||
|
if (!writeRes){
|
||||||
err = newErrCode(TE_ERR_EMMC_WRITE_FAIL);
|
err = newErrCode(TE_ERR_EMMC_WRITE_FAIL);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -117,10 +131,24 @@ ErrCode_t EmmcRestoreFromFile(const char *path, u32 lba_start, u32 lba_end, u8 f
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int isSystemPartCrypt(emmc_part_t *part){
|
||||||
|
switch (part->index){
|
||||||
|
case 0:
|
||||||
|
case 1:
|
||||||
|
case 8:
|
||||||
|
case 9:
|
||||||
|
case 10:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ErrCode_t DumpOrWriteEmmcPart(const char *path, const char *part, u8 write, u8 force){
|
ErrCode_t DumpOrWriteEmmcPart(const char *path, const char *part, u8 write, u8 force){
|
||||||
const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17;
|
const u32 BOOT_PART_SIZE = emmc_storage.ext_csd.boot_mult << 17;
|
||||||
u32 lba_start = 0;
|
u32 lba_start = 0;
|
||||||
u32 lba_end = 0;
|
u32 lba_end = 0;
|
||||||
|
u8 crypt = false;
|
||||||
|
|
||||||
if (!sd_mount())
|
if (!sd_mount())
|
||||||
return newErrCode(TE_ERR_NO_SD);
|
return newErrCode(TE_ERR_NO_SD);
|
||||||
@@ -143,9 +171,17 @@ ErrCode_t DumpOrWriteEmmcPart(const char *path, const char *part, u8 write, u8 f
|
|||||||
if (!system_part)
|
if (!system_part)
|
||||||
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
|
return newErrCode(TE_ERR_PARTITION_NOT_FOUND);
|
||||||
|
|
||||||
|
if (isSystemPartCrypt(system_part)){
|
||||||
|
nx_emmc_bis_init(system_part);
|
||||||
|
crypt = true;
|
||||||
|
lba_start = 0;
|
||||||
|
lba_end = system_part->lba_end - system_part->lba_start;
|
||||||
|
}
|
||||||
|
else {
|
||||||
lba_start = system_part->lba_start;
|
lba_start = system_part->lba_start;
|
||||||
lba_end = system_part->lba_end;
|
lba_end = system_part->lba_end;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return ((write) ? EmmcRestoreFromFile(path, lba_start, lba_end, force) : EmmcDumpToFile(path, lba_start, lba_end, force));
|
|
||||||
|
return ((write) ? EmmcRestoreFromFile(path, lba_start, lba_end, force, crypt) : EmmcDumpToFile(path, lba_start, lba_end, force, crypt));
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,11 @@ void RebootToHekate(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MountOrUnmountSD(){
|
void MountOrUnmountSD(){
|
||||||
(sd_mounted) ? sd_unmount() : sd_mount();
|
gfx_clearscreen();
|
||||||
|
if (sd_mounted)
|
||||||
|
sd_unmount();
|
||||||
|
else if (!sd_mount())
|
||||||
|
hidWait();
|
||||||
}
|
}
|
||||||
|
|
||||||
menuPaths mainMenuPaths[] = {
|
menuPaths mainMenuPaths[] = {
|
||||||
|
|||||||
@@ -57,3 +57,4 @@ Vector_t vecCopyOffset(Vector_t* orig, u32 offset) {
|
|||||||
Vector_t vecCopy(Vector_t* orig) {
|
Vector_t vecCopy(Vector_t* orig) {
|
||||||
return vecCopyOffset(orig, 0);
|
return vecCopyOffset(orig, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user