Compare commits
13 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5a9d0e2569 | ||
|
|
041ca8451e | ||
|
|
2382e6d82c | ||
|
|
f9a1f1a79b | ||
|
|
a736e4602a | ||
|
|
5202ba8826 | ||
|
|
0f1bc98bb7 | ||
|
|
d40722af53 | ||
|
|
c9781ab626 | ||
|
|
4cbf4e93e7 | ||
|
|
1f68c2da42 | ||
|
|
d786c292f3 | ||
|
|
ada3e09784 |
2
CakeHax
2
CakeHax
Submodule CakeHax updated: 6b8fca0b37...5245c7b9dc
11
README.md
11
README.md
@@ -3,8 +3,10 @@
|
||||
|
||||
**Compiling:**
|
||||
|
||||
You'll need armips, [bin2c](https://sourceforge.net/projects/bin2c/), and a recent build of [makerom](https://github.com/profi200/Project_CTR) added to your PATH. [HERE](http://www91.zippyshare.com/v/ePGpjk9r/file.html) is a pre-compiled version of armips for Windows.
|
||||
Then, just run "make" and everything should work!
|
||||
First you need to clone the repository recursively with: 'git clone --recursive https://github.com/AuroraWright/Luma3DS.git'
|
||||
To compile, you'll need [armips](https://github.com/Kingcom/armips), [bin2c](https://sourceforge.net/projects/bin2c/), and a recent build of [makerom](https://github.com/profi200/Project_CTR) added to your PATH.
|
||||
For your convenience, here are [Windows](http://www91.zippyshare.com/v/ePGpjk9r/file.html) and [Linux](https://mega.nz/#!uQ1T1IAD!Q91O0e12LXKiaXh_YjXD3D5m8_W3FuMI-hEa6KVMRDQ) builds of armips (thanks to who compiled them!).
|
||||
Finally just run 'make' and everything should work!
|
||||
You can find the compiled files in the 'out' folder.
|
||||
|
||||
**Setup / Usage / Features:**
|
||||
@@ -14,3 +16,8 @@ See https://github.com/AuroraWright/Luma3DS/wiki
|
||||
**Credits:**
|
||||
|
||||
See https://github.com/AuroraWright/Luma3DS/wiki/Credits
|
||||
|
||||
**Licensing:**
|
||||
|
||||
This software is licensed under the terms of the GPLv3.
|
||||
You can find a copy of the license in the LICENSE.txt file.
|
||||
@@ -143,7 +143,7 @@ static int loadTitleLocaleConfig(u64 progId, u8 *regionId, u8 *languageId)
|
||||
|
||||
u32 i = 29;
|
||||
|
||||
while(progId > 0)
|
||||
while(progId)
|
||||
{
|
||||
static const char hexDigits[] = "0123456789ABCDEF";
|
||||
path[i--] = hexDigits[(u32)(progId & 0xF)];
|
||||
@@ -336,12 +336,6 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
static const u8 blockAutoUpdatesPatch[] = {
|
||||
0xE3, 0xA0
|
||||
};
|
||||
static const u8 skipEshopUpdateCheckPattern[] = {
|
||||
0x30, 0xB5, 0xF1, 0xB0
|
||||
};
|
||||
static const u8 skipEshopUpdateCheckPatch[] = {
|
||||
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
|
||||
};
|
||||
|
||||
//Block silent auto-updates
|
||||
patchMemory(code, size,
|
||||
@@ -351,6 +345,16 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
sizeof(blockAutoUpdatesPatch), 1
|
||||
);
|
||||
|
||||
//Apply only if the updated NAND hasn't been booted
|
||||
if((BOOTCONFIG(0, 3) != 0) == (BOOTCONFIG(3, 1) && CONFIG(1)))
|
||||
{
|
||||
static const u8 skipEshopUpdateCheckPattern[] = {
|
||||
0x30, 0xB5, 0xF1, 0xB0
|
||||
};
|
||||
static const u8 skipEshopUpdateCheckPatch[] = {
|
||||
0x00, 0x20, 0x08, 0x60, 0x70, 0x47
|
||||
};
|
||||
|
||||
//Skip update checks to access the EShop
|
||||
patchMemory(code, size,
|
||||
skipEshopUpdateCheckPattern,
|
||||
@@ -358,6 +362,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
skipEshopUpdateCheckPatch,
|
||||
sizeof(skipEshopUpdateCheckPatch), 1
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -388,7 +393,7 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
case 0x0004001000027000LL: // KOR MSET
|
||||
case 0x0004001000028000LL: // TWN MSET
|
||||
{
|
||||
if(CONFIG(6))
|
||||
if(CONFIG(5))
|
||||
{
|
||||
static const u16 verPattern[] = u"Ver.";
|
||||
const u32 currentNand = BOOTCONFIG(0, 3);
|
||||
@@ -504,8 +509,8 @@ void patchCode(u64 progId, u8 *code, u32 size)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@
|
||||
#define BUTTON_LEFT (1 << 5)
|
||||
#define BUTTON_UP (1 << 6)
|
||||
#define BUTTON_DOWN (1 << 7)
|
||||
#define BUTTON_A 1
|
||||
#define BUTTON_X (1 << 10)
|
||||
#define BUTTON_Y (1 << 11)
|
||||
#define BUTTON_R1 (1 << 8)
|
||||
|
||||
@@ -51,6 +51,7 @@ void main(void)
|
||||
((pressed & BUTTON_X) && LOAD_PAYLOAD("x")) ||
|
||||
((pressed & BUTTON_Y) && LOAD_PAYLOAD("y")) ||
|
||||
((pressed & BUTTON_R1) && LOAD_PAYLOAD("r")) ||
|
||||
((pressed & BUTTON_A) && LOAD_PAYLOAD("a")) ||
|
||||
((pressed & BUTTON_SELECT) && LOAD_PAYLOAD("sel")) ||
|
||||
LOAD_PAYLOAD("def"))
|
||||
((void (*)())PAYLOAD_ADDRESS)();
|
||||
|
||||
40
pathchanger/pathchanger.py
Normal file
40
pathchanger/pathchanger.py
Normal file
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env python
|
||||
# Requires Python >= 3.2 or >= 2.7
|
||||
|
||||
# This is part of Luma3DS
|
||||
|
||||
__author__ = "TuxSH"
|
||||
__copyright__ = "Copyright (c) 2016 TuxSH"
|
||||
__license__ = "GPLv3"
|
||||
__version__ = "v1.0"
|
||||
|
||||
import argparse
|
||||
|
||||
if __name__ == "__main__":
|
||||
parser = argparse.ArgumentParser(description="Changes the path to Luma3DS for reboot patches")
|
||||
parser.add_argument("payload", help="Path to the Luma3DS payload")
|
||||
parser.add_argument("new_path", help="New Luma3DS payload path")
|
||||
args = parser.parse_args()
|
||||
data = b""
|
||||
|
||||
if len(args.new_path) > 37:
|
||||
raise SystemExit("The new payload path is too large (37 characters max.)")
|
||||
|
||||
with open(args.payload, "rb") as f: data = bytearray(f.read())
|
||||
|
||||
if len(data) == 0: raise SystemExit("Could not read {0}".format(args.payload))
|
||||
|
||||
if len(data) > 0x20000:
|
||||
raise SystemExit("The input file is too large, are you sure you're using a Luma3DS payload?")
|
||||
|
||||
found_index = data.find("sdmc:/".encode("utf-16-le"))
|
||||
|
||||
if found_index == -1:
|
||||
raise SystemExit("The pattern was not found, are you sure you're usinga a Luma3DS payload?")
|
||||
|
||||
namebuf = args.new_path.encode("utf-16-le")
|
||||
namebuf += b'\x00' * (74 - len(namebuf))
|
||||
|
||||
data[found_index + 12 : found_index + 12 + 74] = namebuf
|
||||
|
||||
with open(args.payload, "wb+") as f: f.write(data)
|
||||
@@ -19,9 +19,8 @@
|
||||
#define BUTTON_LEFT (1 << 5)
|
||||
#define BUTTON_UP (1 << 6)
|
||||
#define BUTTON_DOWN (1 << 7)
|
||||
#define BUTTON_L1R1 (BUTTON_R1 | BUTTON_L1)
|
||||
#define SAFE_MODE (BUTTON_L1R1 | BUTTON_A | BUTTON_UP)
|
||||
#define SAFE_MODE (BUTTON_R1 | BUTTON_L1 | BUTTON_A | BUTTON_UP)
|
||||
#define OVERRIDE_BUTTONS (BUTTON_B ^ 0xFFF)
|
||||
#define SINGLE_PAYLOAD_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_START | BUTTON_X | BUTTON_Y)
|
||||
#define L_PAYLOAD_BUTTONS (BUTTON_R1 | BUTTON_SELECT)
|
||||
#define L_PAYLOAD_BUTTONS (BUTTON_R1 | BUTTON_A | BUTTON_SELECT)
|
||||
#define MENU_BUTTONS (BUTTON_LEFT | BUTTON_RIGHT | BUTTON_UP | BUTTON_DOWN | BUTTON_A | BUTTON_START)
|
||||
@@ -20,11 +20,10 @@ void configureCFW(const char *configPath)
|
||||
"New 3DS CPU: Off( ) Clock( ) L2( ) Clock+L2( )" };
|
||||
|
||||
const char *singleOptionsText[] = { "( ) Autoboot SysNAND",
|
||||
"( ) Use SysNAND FIRM as default (A9LH-only)",
|
||||
"( ) SysNAND is updated (A9LH-only)",
|
||||
"( ) Force A9LH detection",
|
||||
"( ) Use second EmuNAND as default",
|
||||
"( ) Enable region/language emulation",
|
||||
"( ) Use developer UNITINFO",
|
||||
"( ) Show current NAND in System Settings",
|
||||
"( ) Show GBA boot screen in patched AGB_FIRM",
|
||||
"( ) Enable splash screen with no screen-init" };
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include "fatfs/sdmmc/sdmmc.h"
|
||||
|
||||
/****************************************************************
|
||||
* Crypto Libs
|
||||
* Crypto libs
|
||||
****************************************************************/
|
||||
|
||||
/* original version by megazig */
|
||||
@@ -271,7 +271,7 @@ static void sha(void *res, const void *src, u32 size, u32 mode)
|
||||
}
|
||||
|
||||
/****************************************************************
|
||||
* Nand/FIRM Crypto stuff
|
||||
* NAND/FIRM crypto
|
||||
****************************************************************/
|
||||
|
||||
static u8 nandCTR[0x10],
|
||||
@@ -348,9 +348,9 @@ void decryptExeFs(u8 *inbuf)
|
||||
void arm9Loader(u8 *arm9Section, u32 mode)
|
||||
{
|
||||
//Firm keys
|
||||
u8 keyY[0x10];
|
||||
u8 arm9BinCTR[0x10];
|
||||
u8 arm9BinSlot = mode ? 0x16 : 0x15;
|
||||
u8 keyY[0x10],
|
||||
arm9BinCTR[0x10],
|
||||
arm9BinSlot = mode ? 0x16 : 0x15;
|
||||
|
||||
//Setup keys needed for arm9bin decryption
|
||||
memcpy(keyY, arm9Section + 0x10, 0x10);
|
||||
@@ -384,8 +384,8 @@ void arm9Loader(u8 *arm9Section, u32 mode)
|
||||
//Set >=9.6 KeyXs
|
||||
if(mode)
|
||||
{
|
||||
u8 keyData[0x10] = {0xDD, 0xDA, 0xA4, 0xC6, 0x2C, 0xC4, 0x50, 0xE9, 0xDA, 0xB6, 0x9B, 0x0D, 0x9D, 0x2A, 0x21, 0x98};
|
||||
u8 decKey[0x10];
|
||||
u8 keyData[0x10] = {0xDD, 0xDA, 0xA4, 0xC6, 0x2C, 0xC4, 0x50, 0xE9, 0xDA, 0xB6, 0x9B, 0x0D, 0x9D, 0x2A, 0x21, 0x98},
|
||||
decKey[0x10];
|
||||
|
||||
//Set keys 0x19..0x1F keyXs
|
||||
aes_use_keyslot(0x11);
|
||||
|
||||
@@ -22,6 +22,7 @@ static const struct fb {
|
||||
static inline int strlen(const char *string)
|
||||
{
|
||||
char *stringEnd = (char *)string;
|
||||
|
||||
while(*stringEnd) stringEnd++;
|
||||
|
||||
return stringEnd - string;
|
||||
@@ -43,7 +44,7 @@ void loadSplash(void)
|
||||
fileRead(fb->bottom, "/luma/splashbottom.bin", 0x38400))
|
||||
{
|
||||
u64 i = 0x1400000;
|
||||
while(--i) __asm("mov r0, r0"); //Less Ghetto sleep func
|
||||
while(i--) __asm("mov r0, r0"); //Less Ghetto sleep func
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
#include "types.h"
|
||||
|
||||
#define NCSD_MAGIC (0x4453434E)
|
||||
#define NCSD_MAGIC 0x4453434E
|
||||
|
||||
void getEmunandSect(u32 *off, u32 *head, u32 *emuNAND);
|
||||
u32 getSDMMC(u8 *pos, u32 size);
|
||||
|
||||
@@ -136,9 +136,8 @@ void main(void)
|
||||
configureCFW(configPath);
|
||||
|
||||
//If screens are inited or the corresponding option is set, load splash screen
|
||||
if(PDN_GPU_CNT != 1 || CONFIG(8)) loadSplash();
|
||||
if(PDN_GPU_CNT != 1 || CONFIG(7)) loadSplash();
|
||||
|
||||
//Determine if we need to autoboot sysNAND
|
||||
u32 autoBootSys = CONFIG(0);
|
||||
|
||||
//Determine if we need to boot an emuNAND or sysNAND
|
||||
@@ -187,7 +186,6 @@ void main(void)
|
||||
launchFirm(bootType);
|
||||
}
|
||||
|
||||
//Load FIRM into FCRAM
|
||||
static inline void loadFirm(u32 firmType, u32 externalFirm)
|
||||
{
|
||||
section = firm->section;
|
||||
@@ -257,13 +255,6 @@ static inline void patchNativeFirm(u32 nandType, u32 emuHeader, u32 a9lhInstalle
|
||||
*(u16 *)sigOffset2 = sigPatch[0];
|
||||
*((u16 *)sigOffset2 + 1) = sigPatch[1];
|
||||
|
||||
if(CONFIG(5))
|
||||
{
|
||||
//Apply UNITINFO patch
|
||||
u8 *unitInfoOffset = getUnitInfoValueSet(arm9Section, section[2].size);
|
||||
*unitInfoOffset = unitInfoPatch;
|
||||
}
|
||||
|
||||
//Replace the FIRM loader with the injector
|
||||
injectLoader();
|
||||
}
|
||||
@@ -368,7 +359,7 @@ static inline void patchTwlAgbFirm(u32 firmType)
|
||||
/* Calculate the amount of patches to apply. Only count the boot screen patch for AGB_FIRM
|
||||
if the matching option was enabled (keep it as last) */
|
||||
u32 numPatches = firmType == 1 ? (sizeof(twlPatches) / sizeof(patchData)) :
|
||||
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG(7));
|
||||
(sizeof(agbPatches) / sizeof(patchData) - !CONFIG(6));
|
||||
const patchData *patches = firmType == 1 ? twlPatches : agbPatches;
|
||||
|
||||
//Patch
|
||||
@@ -390,7 +381,7 @@ static inline void patchTwlAgbFirm(u32 firmType)
|
||||
|
||||
static inline void launchFirm(u32 bootType)
|
||||
{
|
||||
//Copy firm partitions to respective memory locations
|
||||
//Copy FIRM sections to respective memory locations
|
||||
for(u32 i = 0; i < 4 && section[i].size; i++)
|
||||
memcpy(section[i].address, (u8 *)firm + section[i].offset, section[i].size);
|
||||
|
||||
@@ -406,6 +397,6 @@ static inline void launchFirm(u32 bootType)
|
||||
//Set ARM11 kernel entrypoint
|
||||
*arm11 = (u32)firm->arm11Entry;
|
||||
|
||||
//Final jump to arm9 kernel
|
||||
//Final jump to ARM9 kernel
|
||||
((void (*)())firm->arm9Entry)();
|
||||
}
|
||||
10
source/fs.c
10
source/fs.c
@@ -71,7 +71,7 @@ void firmRead(void *dest, const char *firmFolder)
|
||||
|
||||
f_opendir(&dir, path);
|
||||
|
||||
u32 id = 0;
|
||||
u32 id = 0xFFFFFFFF;
|
||||
|
||||
//Parse the target directory
|
||||
while(f_readdir(&dir, &info) == FR_OK && info.fname[0])
|
||||
@@ -87,8 +87,8 @@ void firmRead(void *dest, const char *firmFolder)
|
||||
tempId += *tmp > '9' ? *tmp - 'A' + 10 : *tmp - '0';
|
||||
}
|
||||
|
||||
//Found a newer cxi
|
||||
if(tempId > id) id = tempId;
|
||||
//Found an older cxi
|
||||
if(tempId < id) id = tempId;
|
||||
}
|
||||
|
||||
f_closedir(&dir);
|
||||
@@ -96,12 +96,12 @@ void firmRead(void *dest, const char *firmFolder)
|
||||
//Complete the string with the .app name
|
||||
memcpy(&path[34], "/00000000.app", 14);
|
||||
|
||||
//Last digit of the .app
|
||||
u32 i = 42;
|
||||
|
||||
//Convert back the .app name from integer to array
|
||||
while(id > 0)
|
||||
while(id)
|
||||
{
|
||||
//Last digit of the .app
|
||||
static const char hexDigits[] = "0123456789ABCDEF";
|
||||
path[i--] = hexDigits[id & 0xF];
|
||||
id >>= 4;
|
||||
|
||||
@@ -11,13 +11,9 @@
|
||||
|
||||
const u32 mpuPatch[3] = {0x00360003, 0x00200603, 0x001C0603};
|
||||
|
||||
const u16 nandRedir[2] = {0x4C00, 0x47A0};
|
||||
|
||||
const u16 sigPatch[2] = {0x2000, 0x4770};
|
||||
|
||||
const u16 writeBlock[2] = {0x2000, 0x46C0};
|
||||
|
||||
const u8 unitInfoPatch = 0xE3;
|
||||
const u16 nandRedir[2] = {0x4C00, 0x47A0},
|
||||
sigPatch[2] = {0x2000, 0x4770},
|
||||
writeBlock[2] = {0x2000, 0x46C0};
|
||||
|
||||
/**************************************************
|
||||
* Functions
|
||||
@@ -67,14 +63,6 @@ u16 *getFirmWrite(u8 *pos, u32 size)
|
||||
return (u16 *)memsearch(off - 0x100, pattern, 0x100, 4);
|
||||
}
|
||||
|
||||
u8 *getUnitInfoValueSet(u8 *pos, u32 size)
|
||||
{
|
||||
//Look for UNITINFO value being set
|
||||
const u8 pattern[] = {0x01, 0x10, 0xA0, 0x13};
|
||||
|
||||
return memsearch(pos, pattern, size, 4) + 3;
|
||||
}
|
||||
|
||||
void *getLoader(u8 *pos, u32 size, u32 *loaderSize)
|
||||
{
|
||||
u8 *const off = memsearch(pos, "loade", size, 5);
|
||||
|
||||
@@ -10,10 +10,9 @@
|
||||
* Patches
|
||||
**************************************************/
|
||||
const u32 mpuPatch[3];
|
||||
const u16 nandRedir[2];
|
||||
const u16 sigPatch[2];
|
||||
const u16 writeBlock[2];
|
||||
const u8 unitInfoPatch;
|
||||
const u16 nandRedir[2],
|
||||
sigPatch[2],
|
||||
writeBlock[2];
|
||||
|
||||
/**************************************************
|
||||
* Functions
|
||||
@@ -23,5 +22,4 @@ void getSigChecks(u8 *pos, u32 size, u32 *off, u32 *off2);
|
||||
void *getReboot(u8 *pos, u32 size);
|
||||
u32 getfOpen(u8 *proc9Offset, void *rebootOffset);
|
||||
u16 *getFirmWrite(u8 *pos, u32 size);
|
||||
u8 *getUnitInfoValueSet(u8 *pos, u32 size);
|
||||
void *getLoader(u8 *pos, u32 size, u32 *loaderSize);
|
||||
Reference in New Issue
Block a user