Fix max module size check, static-ify more strings
This commit is contained in:
parent
a7046909ec
commit
4d47d891d1
@ -484,7 +484,7 @@ static inline void twlConsoleInfoInit(void)
|
|||||||
aes_setkey(2, (u8 *)0x01FFD398, AES_KEYX, AES_INPUT_TWLNORMAL);
|
aes_setkey(2, (u8 *)0x01FFD398, AES_KEYX, AES_INPUT_TWLNORMAL);
|
||||||
if(CFG_TWLUNITINFO != 0)
|
if(CFG_TWLUNITINFO != 0)
|
||||||
{
|
{
|
||||||
__attribute__((aligned(4))) u8 key2YDev[AES_BLOCK_SIZE] = {0x3B, 0x06, 0x86, 0x57, 0x33, 0x04, 0x88, 0x11, 0x49, 0x04, 0x6B, 0x33, 0x12, 0x02, 0xAC, 0xF3},
|
__attribute__((aligned(4))) static const u8 key2YDev[AES_BLOCK_SIZE] = {0x3B, 0x06, 0x86, 0x57, 0x33, 0x04, 0x88, 0x11, 0x49, 0x04, 0x6B, 0x33, 0x12, 0x02, 0xAC, 0xF3},
|
||||||
key3YDev[AES_BLOCK_SIZE] = {0xAA, 0xBF, 0x76, 0xF1, 0x7A, 0xB8, 0xE8, 0x66, 0x97, 0x64, 0x6A, 0x26, 0x05, 0x00, 0xA0, 0xE1};
|
key3YDev[AES_BLOCK_SIZE] = {0xAA, 0xBF, 0x76, 0xF1, 0x7A, 0xB8, 0xE8, 0x66, 0x97, 0x64, 0x6A, 0x26, 0x05, 0x00, 0xA0, 0xE1};
|
||||||
|
|
||||||
k3X[1] = 0xEE7A4B1E;
|
k3X[1] = 0xEE7A4B1E;
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
|
|
||||||
bool loadSplash(void)
|
bool loadSplash(void)
|
||||||
{
|
{
|
||||||
const char *topSplashFile = "splash.bin",
|
static const char *topSplashFile = "splash.bin",
|
||||||
*bottomSplashFile = "splashbottom.bin";
|
*bottomSplashFile = "splashbottom.bin";
|
||||||
|
|
||||||
bool isTopSplashValid = getFileSize(topSplashFile) == SCREEN_TOP_FBSIZE,
|
bool isTopSplashValid = getFileSize(topSplashFile) == SCREEN_TOP_FBSIZE,
|
||||||
|
@ -60,15 +60,13 @@ void detectAndProcessExceptionDumps(void)
|
|||||||
const vu8 *stackDump = (vu8 *)regs + dumpHeader->registerDumpSize + dumpHeader->codeDumpSize;
|
const vu8 *stackDump = (vu8 *)regs + dumpHeader->registerDumpSize + dumpHeader->codeDumpSize;
|
||||||
const vu8 *additionalData = stackDump + dumpHeader->stackDumpSize;
|
const vu8 *additionalData = stackDump + dumpHeader->stackDumpSize;
|
||||||
|
|
||||||
const char *handledExceptionNames[] = {
|
static const char *handledExceptionNames[] = {
|
||||||
"FIQ", "undefined instruction", "prefetch abort", "data abort"
|
"FIQ", "undefined instruction", "prefetch abort", "data abort"
|
||||||
};
|
},
|
||||||
|
*specialExceptions[] = {
|
||||||
const char *specialExceptions[] = {
|
|
||||||
"kernel panic", "svcBreak"
|
"kernel panic", "svcBreak"
|
||||||
};
|
},
|
||||||
|
*registerNames[] = {
|
||||||
const char *registerNames[] = {
|
|
||||||
"R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12",
|
"R0", "R1", "R2", "R3", "R4", "R5", "R6", "R7", "R8", "R9", "R10", "R11", "R12",
|
||||||
"SP", "LR", "PC", "CPSR", "FPEXC"
|
"SP", "LR", "PC", "CPSR", "FPEXC"
|
||||||
};
|
};
|
||||||
|
@ -80,11 +80,9 @@ static inline bool loadFirmFromStorage(FirmwareType firmType)
|
|||||||
|
|
||||||
static inline void mergeSection0(FirmwareType firmType, bool loadFromStorage)
|
static inline void mergeSection0(FirmwareType firmType, bool loadFromStorage)
|
||||||
{
|
{
|
||||||
u32 srcModuleSize;
|
u32 srcModuleSize,
|
||||||
const char *extModuleSizeError = "The external FIRM modules are too large.";
|
nbModules = 0;
|
||||||
|
|
||||||
u32 nbModules = 0,
|
|
||||||
isCustomModule = false;
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
char name[8];
|
char name[8];
|
||||||
@ -108,24 +106,25 @@ static inline void mergeSection0(FirmwareType firmType, bool loadFromStorage)
|
|||||||
const char *name = ((Cxi *)src)->exHeader.systemControlInfo.appTitle;
|
const char *name = ((Cxi *)src)->exHeader.systemControlInfo.appTitle;
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for(i = 0; i < nbModules && memcmp(name, moduleList[i].name, 8) != 0; i++);
|
|
||||||
|
|
||||||
if(i == nbModules) isCustomModule = true;
|
for(i = 0; i < 5 && memcmp(name, moduleList[i].name, 8) != 0; i++);
|
||||||
|
|
||||||
|
if(i == 5)
|
||||||
|
{
|
||||||
|
nbModules++;
|
||||||
memcpy(moduleList[i].name, ((Cxi *)src)->exHeader.systemControlInfo.appTitle, 8);
|
memcpy(moduleList[i].name, ((Cxi *)src)->exHeader.systemControlInfo.appTitle, 8);
|
||||||
|
}
|
||||||
|
|
||||||
moduleList[i].src = src;
|
moduleList[i].src = src;
|
||||||
srcModuleSize = moduleList[i].size = ((Cxi *)src)->ncch.contentSize * 0x200;
|
srcModuleSize = moduleList[i].size = ((Cxi *)src)->ncch.contentSize * 0x200;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isCustomModule) nbModules++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//3) Read or copy the modules
|
//3) Read or copy the modules
|
||||||
u8 *dst = firm->section[0].address;
|
u8 *dst = firm->section[0].address;
|
||||||
for(u32 i = 0, dstModuleSize; i < nbModules; i++)
|
const char *extModuleSizeError = "The external FIRM modules are too large.";
|
||||||
|
for(u32 i = 0, dstModuleSize, maxModuleSize = 0x60000; i < nbModules; i++, dst += dstModuleSize, maxModuleSize -= dstModuleSize)
|
||||||
{
|
{
|
||||||
dstModuleSize = 0;
|
|
||||||
|
|
||||||
if(loadFromStorage)
|
if(loadFromStorage)
|
||||||
{
|
{
|
||||||
char fileName[24];
|
char fileName[24];
|
||||||
@ -137,7 +136,7 @@ static inline void mergeSection0(FirmwareType firmType, bool loadFromStorage)
|
|||||||
|
|
||||||
if(dstModuleSize != 0)
|
if(dstModuleSize != 0)
|
||||||
{
|
{
|
||||||
if(dstModuleSize > 0x60000) error(extModuleSizeError);
|
if(dstModuleSize > maxModuleSize) error(extModuleSizeError);
|
||||||
|
|
||||||
if(dstModuleSize <= sizeof(Cxi) + 0x200 ||
|
if(dstModuleSize <= sizeof(Cxi) + 0x200 ||
|
||||||
fileRead(dst, fileName, dstModuleSize) != dstModuleSize ||
|
fileRead(dst, fileName, dstModuleSize) != dstModuleSize ||
|
||||||
@ -145,19 +144,19 @@ static inline void mergeSection0(FirmwareType firmType, bool loadFromStorage)
|
|||||||
memcmp(moduleList[i].name, ((Cxi *)dst)->exHeader.systemControlInfo.appTitle, sizeof(((Cxi *)dst)->exHeader.systemControlInfo.appTitle)) != 0)
|
memcmp(moduleList[i].name, ((Cxi *)dst)->exHeader.systemControlInfo.appTitle, sizeof(((Cxi *)dst)->exHeader.systemControlInfo.appTitle)) != 0)
|
||||||
error("An external FIRM module is invalid or corrupted.");
|
error("An external FIRM module is invalid or corrupted.");
|
||||||
|
|
||||||
dst += dstModuleSize;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!dstModuleSize)
|
dstModuleSize = moduleList[i].size;
|
||||||
{
|
|
||||||
memcpy(dst, moduleList[i].src, moduleList[i].size);
|
if(dstModuleSize > maxModuleSize) error(extModuleSizeError);
|
||||||
dst += moduleList[i].size;
|
|
||||||
}
|
memcpy(dst, moduleList[i].src, dstModuleSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
//4) Patch NATIVE_FIRM if necessary
|
//4) Patch NATIVE_FIRM if necessary
|
||||||
if(isCustomModule)
|
if(nbModules == 6)
|
||||||
{
|
{
|
||||||
if(patchK11ModuleLoading(firm->section[0].size, dst - firm->section[0].address, (u8 *)firm + firm->section[1].offset, firm->section[1].size) != 0)
|
if(patchK11ModuleLoading(firm->section[0].size, dst - firm->section[0].address, (u8 *)firm + firm->section[1].offset, firm->section[1].size) != 0)
|
||||||
error("Failed to inject custom sysmodule");
|
error("Failed to inject custom sysmodule");
|
||||||
|
@ -72,7 +72,7 @@ void main(int argc, char **argv, u32 magicWord)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char argv[] = "firm0:";
|
static const char argv[] = "firm0:";
|
||||||
for(u32 i = 0; i < sizeof(argv); i++) //Copy and convert the path to UTF-16
|
for(u32 i = 0; i < sizeof(argv); i++) //Copy and convert the path to UTF-16
|
||||||
launchedPath[i] = argv[i];
|
launchedPath[i] = argv[i];
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@
|
|||||||
|
|
||||||
static char pinKeyToLetter(u32 pressed)
|
static char pinKeyToLetter(u32 pressed)
|
||||||
{
|
{
|
||||||
const char keys[] = "AB--RLUD--XY";
|
static const char *keys = "AB--RLUD--XY";
|
||||||
|
|
||||||
u32 i;
|
u32 i;
|
||||||
for(i = 31; pressed > 1; i--) pressed /= 2;
|
for(i = 31; pressed > 1; i--) pressed /= 2;
|
||||||
@ -151,7 +151,7 @@ bool verifyPin(u32 pinMode)
|
|||||||
|
|
||||||
drawFormattedString(true, 10, 10 + 3 * SPACING_Y, COLOR_WHITE, "PIN (%u digits): ", lengthBlock[0]);
|
drawFormattedString(true, 10, 10 + 3 * SPACING_Y, COLOR_WHITE, "PIN (%u digits): ", lengthBlock[0]);
|
||||||
|
|
||||||
const char *messageFile = "pinmessage.txt";
|
static const char *messageFile = "pinmessage.txt";
|
||||||
char message[801];
|
char message[801];
|
||||||
|
|
||||||
u32 messageSize = fileRead(message, messageFile, sizeof(message) - 1);
|
u32 messageSize = fileRead(message, messageFile, sizeof(message) - 1);
|
||||||
|
Reference in New Issue
Block a user