mirror of
https://github.com/suchmememanyskill/TegraExplorer.git
synced 2024-12-26 19:36:03 +00:00
make fwdump.te significantly more cursed
This commit is contained in:
parent
5bd4dd3a48
commit
60eac955f6
3 changed files with 115 additions and 79 deletions
|
@ -1,77 +1,58 @@
|
|||
if (mountsys("SYSTEM")){
|
||||
print("SYSTEM MOUNT FAIL")
|
||||
exit()
|
||||
}
|
||||
|
||||
a = readsave("bis:/save/8000000000000120")
|
||||
b = a.readFile("/meta/imkvdb.arc")
|
||||
print(b.len(), "\n")
|
||||
|
||||
c = ["BYTE[]", 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01]
|
||||
|
||||
i = 1
|
||||
#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))
|
||||
min = ((ver >> 20) & ((1 << 6) - 1))
|
||||
maj = ((ver >> 26) & ((1 << 6) - 1))
|
||||
print("")
|
||||
println(ver.str(), " ", maj.str(), ".", min.str(), ".", pat.str(), ".", rev.str())
|
||||
|
||||
|
||||
# i = i + 1
|
||||
#}
|
||||
|
||||
|
||||
#REQUIRE KEYS
|
||||
p=println
|
||||
pe={pause() exit()}
|
||||
fwstr={fw=maj.str()+"."+min.str()+"."+pat.str()}
|
||||
fv={a=readsave("bis:/save/8000000000000120")
|
||||
b=a.readFile("/meta/imkvdb.arc")
|
||||
c=["BYTE[]",9,8,0,0,0,0,0,1]
|
||||
d=b.find(c)
|
||||
if(d>0){
|
||||
e=b.slice(d+8,4).project()
|
||||
ver=(e[3]<<24)|(e[2]<<16)|(e[1]<<8)|(e[0])
|
||||
pat=((ver>>16)&((1<<4)- 1))
|
||||
min=((ver>>20)&((1<<6)- 1))
|
||||
maj=((ver>>26)&((1<<6)- 1))
|
||||
}.else(){print("Fw not found")pe()}
|
||||
a=0 fwstr()}
|
||||
if(mountsys("SYSTEM")){print("SYSTEM MOUNT FAIL")pe()}
|
||||
fv()
|
||||
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/Firmware")
|
||||
baseSdPath = "sd:/tegraexplorer/Firmware/" + maj.str() + "." + min.str() + "." + pat.str()
|
||||
mkdir(baseSdPath)
|
||||
|
||||
contents = readdir("bis:/Contents/registered")
|
||||
if (contents.result != 0){
|
||||
println("Fail reading dir")
|
||||
exit()
|
||||
}
|
||||
|
||||
contents.files.foreach("x") {
|
||||
fullPath = "bis:/Contents/registered/" + x
|
||||
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()
|
||||
bsp = "sd:/tegraexplorer/Firmware/" + fw
|
||||
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)
|
||||
p("Dumping to",bsp)
|
||||
con=readdir("bis:/Contents/registered")
|
||||
if(con.result!=0){println("Fail reading dir")pe()}
|
||||
c=(con.files.len()+con.folders.len()).str()
|
||||
i=1 f=0 t=timer()
|
||||
dump={
|
||||
fi.foreach("x"){
|
||||
if(f){fp="bis:/Contents/registered/"+x+"/00"}
|
||||
.else(){fp="bis:/Contents/registered/"+x}
|
||||
name=x
|
||||
if(ncatype(fp)==1){name=name- 4+".cnmt.nca"}
|
||||
color(0x00FF00)
|
||||
print("\r["+i.str()+"/"+c+"]", x)
|
||||
if(filecopy(fp,bsp+"/"+name)){println("\nErr during copy")pe()}
|
||||
i=i+1
|
||||
}
|
||||
}
|
||||
|
||||
contents.folders.foreach("x") {
|
||||
fullPath = "bis:/Contents/registered/" + x + "/00"
|
||||
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")
|
||||
fi=con.files dump()
|
||||
f=1 fi=con.folders dump()
|
||||
p("\nDone! Took",timer()-t/1000,"s")
|
|
@ -80,6 +80,14 @@ ClassFunction(stringMinusInt){
|
|||
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 oneStringArg[] = { StringClass };
|
||||
|
||||
|
@ -90,6 +98,8 @@ ClassFunctionTableEntry_t stringFunctions[] = {
|
|||
{"bytes", stringBytes, 0, 0},
|
||||
{"get", stringIndexGet, 1, strOneIntArg},
|
||||
{"-", stringMinusInt, 1, strOneIntArg},
|
||||
{"==", stringEq, 1, oneStringArg},
|
||||
{"!=", stringInEq, 1, oneStringArg},
|
||||
};
|
||||
|
||||
Variable_t getStringMember(Variable_t* var, char* memberName) {
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#include "../hid/hid.h"
|
||||
#include "../gfx/menu.h"
|
||||
#include "../gfx/gfxutils.h"
|
||||
#include "../tegraexplorer/tconf.h"
|
||||
#include "../storage/emummc.h"
|
||||
#include <utils/util.h>
|
||||
#include "../fs/fsutils.h"
|
||||
#endif
|
||||
// Takes [int, function]. Returns elseable.
|
||||
ClassFunction(stdIf) {
|
||||
|
@ -74,6 +78,7 @@ ClassFunction(stdPrint) {
|
|||
Variable_t* res = callMemberFunctionDirect(args[i], "print", NULL, 0);
|
||||
if (res == NULL)
|
||||
return NULL;
|
||||
gfx_putc(' ');
|
||||
}
|
||||
|
||||
|
||||
|
@ -107,16 +112,29 @@ ClassFunction(stdDict) {
|
|||
}
|
||||
|
||||
#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
|
||||
ClassFunction(stdMountSysmmc){
|
||||
if (connectMMC(MMC_CONN_EMMC))
|
||||
return newIntVariablePtr(1);
|
||||
return newIntVariablePtr(mountMmc(MMC_CONN_EMMC, args[0]->string.value));
|
||||
}
|
||||
|
||||
Variable_t *arg = (*args);
|
||||
if (mountMMCPart(arg->string.value).err)
|
||||
return newIntVariablePtr(1); // Maybe change for error?
|
||||
ClassFunction(stdMountEmummc){
|
||||
if (!emu_cfg.enabled){
|
||||
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
|
||||
|
@ -312,6 +330,27 @@ ClassFunction(stdMenuFull){
|
|||
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
|
||||
#define STUBBED(name) ClassFunction(name) { return newIntVariablePtr(0); }
|
||||
|
||||
|
@ -365,6 +404,7 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
|
|||
{"print", stdPrint, VARARGCOUNT, 0},
|
||||
{"println", stdPrintLn, VARARGCOUNT, 0},
|
||||
{"mountsys", stdMountSysmmc, 1, oneStringArgStd},
|
||||
{"mountemu", stdMountEmummc, 1, oneStringArgStd},
|
||||
{"readsave", stdMountSave, 1, oneStringArgStd},
|
||||
{"exit", stdExit, 0, 0},
|
||||
{"break", stdBreak, 0, 0},
|
||||
|
@ -380,6 +420,11 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
|
|||
{"color", stdColor, 1, oneIntStd},
|
||||
{"menu", stdMenuFull, 3, 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) {
|
||||
|
|
Loading…
Reference in a new issue