1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +00:00

make fwdump.te significantly more cursed

This commit is contained in:
suchmememanyskill 2021-07-23 16:06:52 +02:00
parent 5bd4dd3a48
commit 60eac955f6
3 changed files with 115 additions and 79 deletions

View file

@ -1,77 +1,58 @@
if (mountsys("SYSTEM")){ #REQUIRE KEYS
print("SYSTEM MOUNT FAIL") p=println
exit() pe={pause() exit()}
} fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
fv={a=readsave("bis:/save/8000000000000120")
a = readsave("bis:/save/8000000000000120")
b=a.readFile("/meta/imkvdb.arc") b=a.readFile("/meta/imkvdb.arc")
print(b.len(), "\n") c=["BYTE[]",9,8,0,0,0,0,0,1]
d=b.find(c)
c = ["BYTE[]", 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01] if(d>0){
e=b.slice(d+8,4).project()
i = 1 ver=(e[3]<<24)|(e[2]<<16)|(e[1]<<8)|(e[0])
#while (i + c.len() < b.len()){
# if (b.slice(i, 8).project() == c) {\
fuck = b.find(c)
if (fuck < 0) {
print("Not found")
exit()
}
i = fuck
d = b.slice(i + 8, 4).project()
ver = (d[3] << 24) | (d[2] << 16) | (d[1] << 8) | (d[0])
rev = (ver & ((1 << 16) - 1))
pat=((ver>>16)&((1<<4)- 1)) pat=((ver>>16)&((1<<4)- 1))
min=((ver>>20)&((1<<6)- 1)) min=((ver>>20)&((1<<6)- 1))
maj=((ver>>26)&((1<<6)- 1)) maj=((ver>>26)&((1<<6)- 1))
print("") }.else(){print("Fw not found")pe()}
println(ver.str(), " ", maj.str(), ".", min.str(), ".", pat.str(), ".", rev.str()) a=0 fwstr()}
if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}
fv()
# i = i + 1 sysfw=fw
#} p("Sys' fw is",fw)
emufw=""
if (emu()){if(!mountemu("SYSTEM")){
fv()
emufw=fw
p("Emu's fw is",fw)}}
op=["Exit","Dump sysmmc"].copy()
if (emufw!=""){op+"Dump emummc"}
p()
r=menu(op,0)
if(r==0){exit()}
if(r==1){fw=sysfw if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
if(r==2){fw=emufw if(mountemu("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}}
clear()
mkdir("sd:/tegraexplorer") mkdir("sd:/tegraexplorer")
mkdir("sd:/tegraexplorer/Firmware") mkdir("sd:/tegraexplorer/Firmware")
baseSdPath = "sd:/tegraexplorer/Firmware/" + maj.str() + "." + min.str() + "." + pat.str() bsp = "sd:/tegraexplorer/Firmware/" + fw
mkdir(baseSdPath) if(fsexists(bsp)){p("Dir already exists! Press power to replace, any other key to exit") a=pause() if (!a.power){exit()} deldir(bsp)}
mkdir(bsp)
contents = readdir("bis:/Contents/registered") p("Dumping to",bsp)
if (contents.result != 0){ con=readdir("bis:/Contents/registered")
println("Fail reading dir") if(con.result!=0){println("Fail reading dir")pe()}
exit() c=(con.files.len()+con.folders.len()).str()
} i=1 f=0 t=timer()
dump={
contents.files.foreach("x") { fi.foreach("x"){
fullPath = "bis:/Contents/registered/" + x if(f){fp="bis:/Contents/registered/"+x+"/00"}
.else(){fp="bis:/Contents/registered/"+x}
name=x name=x
if (ncatype(fullPath) == 1){ if(ncatype(fp)==1){name=name- 4+".cnmt.nca"}
name = name - 4 + ".cnmt.nca" color(0x00FF00)
} print("\r["+i.str()+"/"+c+"]", x)
print("\r", x) if(filecopy(fp,bsp+"/"+name)){println("\nErr during copy")pe()}
fullSdPath = baseSdPath + "/" + name i=i+1
if (filecopy(fullPath, fullSdPath)){
println("\nErr during copy")
exit()
} }
} }
fi=con.files dump()
contents.folders.foreach("x") { f=1 fi=con.folders dump()
fullPath = "bis:/Contents/registered/" + x + "/00" p("\nDone! Took",timer()-t/1000,"s")
name = x
if (ncatype(fullPath) == 1){
name = name - 4 + ".cnmt.nca"
}
print("\r", x)
fullSdPath = baseSdPath + "/" + name
if (filecopy(fullPath, fullSdPath)){
println("\nErr during copy")
exit()
}
}
print("end")

View file

@ -80,6 +80,14 @@ ClassFunction(stringMinusInt){
return newStringVariablePtr(newStr, 0, 1); return newStringVariablePtr(newStr, 0, 1);
} }
ClassFunction(stringEq){
return newIntVariablePtr(!strcmp(caller->string.value, args[0]->string.value));
}
ClassFunction(stringInEq){
return newIntVariablePtr(strcmp(caller->string.value, args[0]->string.value));
}
u8 strOneIntArg[] = { IntClass }; u8 strOneIntArg[] = { IntClass };
u8 oneStringArg[] = { StringClass }; u8 oneStringArg[] = { StringClass };
@ -90,6 +98,8 @@ ClassFunctionTableEntry_t stringFunctions[] = {
{"bytes", stringBytes, 0, 0}, {"bytes", stringBytes, 0, 0},
{"get", stringIndexGet, 1, strOneIntArg}, {"get", stringIndexGet, 1, strOneIntArg},
{"-", stringMinusInt, 1, strOneIntArg}, {"-", stringMinusInt, 1, strOneIntArg},
{"==", stringEq, 1, oneStringArg},
{"!=", stringInEq, 1, oneStringArg},
}; };
Variable_t getStringMember(Variable_t* var, char* memberName) { Variable_t getStringMember(Variable_t* var, char* memberName) {

View file

@ -19,6 +19,10 @@
#include "../hid/hid.h" #include "../hid/hid.h"
#include "../gfx/menu.h" #include "../gfx/menu.h"
#include "../gfx/gfxutils.h" #include "../gfx/gfxutils.h"
#include "../tegraexplorer/tconf.h"
#include "../storage/emummc.h"
#include <utils/util.h>
#include "../fs/fsutils.h"
#endif #endif
// Takes [int, function]. Returns elseable. // Takes [int, function]. Returns elseable.
ClassFunction(stdIf) { ClassFunction(stdIf) {
@ -74,6 +78,7 @@ ClassFunction(stdPrint) {
Variable_t* res = callMemberFunctionDirect(args[i], "print", NULL, 0); Variable_t* res = callMemberFunctionDirect(args[i], "print", NULL, 0);
if (res == NULL) if (res == NULL)
return NULL; return NULL;
gfx_putc(' ');
} }
@ -107,16 +112,29 @@ ClassFunction(stdDict) {
} }
#ifndef WIN32 #ifndef WIN32
int mountMmc(u8 mmc, char *part){
if (connectMMC(mmc))
return 1;
if (mountMMCPart(part).err)
return 1;
return 0;
}
// Takes [str]. Returns int (0=success). str=partition to mount // Takes [str]. Returns int (0=success). str=partition to mount
ClassFunction(stdMountSysmmc){ ClassFunction(stdMountSysmmc){
if (connectMMC(MMC_CONN_EMMC)) return newIntVariablePtr(mountMmc(MMC_CONN_EMMC, args[0]->string.value));
return newIntVariablePtr(1); }
Variable_t *arg = (*args); ClassFunction(stdMountEmummc){
if (mountMMCPart(arg->string.value).err) if (!emu_cfg.enabled){
return newIntVariablePtr(1); // Maybe change for error? SCRIPT_FATAL_ERR("emummc is not enabled");
}
return newIntVariablePtr(0); return newIntVariablePtr(mountMmc(MMC_CONN_EMUMMC, args[0]->string.value));
} }
// Takes [str]. Returns int (0=success) str=path to save // Takes [str]. Returns int (0=success) str=path to save
@ -312,6 +330,27 @@ ClassFunction(stdMenuFull){
return newIntVariablePtr(res); return newIntVariablePtr(res);
} }
ClassFunction(stdHasEmu){
return newIntVariablePtr(emu_cfg.enabled);
}
ClassFunction(stdClear){
gfx_clearscreen();
return &emptyClass;
}
ClassFunction(stdRmDir){
return newIntVariablePtr(FolderDelete(args[0]->string.value).err);
}
ClassFunction(stdGetMs){
return newIntVariablePtr(get_tmr_ms());
}
ClassFunction(stdFileExists){
return newIntVariablePtr(FileExists(args[0]->string.value));
}
#else #else
#define STUBBED(name) ClassFunction(name) { return newIntVariablePtr(0); } #define STUBBED(name) ClassFunction(name) { return newIntVariablePtr(0); }
@ -365,6 +404,7 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
{"print", stdPrint, VARARGCOUNT, 0}, {"print", stdPrint, VARARGCOUNT, 0},
{"println", stdPrintLn, VARARGCOUNT, 0}, {"println", stdPrintLn, VARARGCOUNT, 0},
{"mountsys", stdMountSysmmc, 1, oneStringArgStd}, {"mountsys", stdMountSysmmc, 1, oneStringArgStd},
{"mountemu", stdMountEmummc, 1, oneStringArgStd},
{"readsave", stdMountSave, 1, oneStringArgStd}, {"readsave", stdMountSave, 1, oneStringArgStd},
{"exit", stdExit, 0, 0}, {"exit", stdExit, 0, 0},
{"break", stdBreak, 0, 0}, {"break", stdBreak, 0, 0},
@ -380,6 +420,11 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
{"color", stdColor, 1, oneIntStd}, {"color", stdColor, 1, oneIntStd},
{"menu", stdMenuFull, 3, menuArgsStd}, {"menu", stdMenuFull, 3, menuArgsStd},
{"menu", stdMenuFull, 2, menuArgsStd}, {"menu", stdMenuFull, 2, menuArgsStd},
{"emu", stdHasEmu, 0, 0},
{"clear", stdClear, 0, 0},
{"timer", stdGetMs, 0, 0},
{"deldir", stdRmDir, 1, oneStringArgStd},
{"fsexists", stdFileExists, 1, oneStringArgStd},
}; };
ClassFunctionTableEntry_t* searchStdLib(char* funcName, u8 *len) { ClassFunctionTableEntry_t* searchStdLib(char* funcName, u8 *len) {