diff --git a/README.md b/README.md index f7a398c..235ca43 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,8 @@ To use it, you will need a console capable of running homebrew software on the A ## Compiling 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. +To compile, you'll need [armips](https://github.com/Kingcom/armips) and a build of a recent commit of [makerom](https://github.com/profi200/Project_CTR) added to your PATH. +For now, you'll also need to update your [libctru](https://github.com/smealum/ctrulib) install, building from the latest commit. 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. diff --git a/injector/source/patcher.c b/injector/source/patcher.c index 922ca26..61f9e14 100644 --- a/injector/source/patcher.c +++ b/injector/source/patcher.c @@ -417,46 +417,25 @@ void patchCode(u64 progId, u8 *code, u32 size) { verStringSize = 8; u32 currentFirm = BOOTCFG_FIRM; - bool matchingFirm = (currentFirm != 0) == (currentNand != 0); - static u16 verStringEmu[] = u"Emu ", - verStringEmuSys[] = u"Em S", - verStringSysEmu[] = u"SyE "; + static u16 *verStringsNands[] = { u" Sys", + u" Emu", + u"Emu2", + u"Emu3", + u"Emu4" }, - switch(currentNand) - { - case 1: - verString = matchingFirm ? u" Emu" : u"EmuS"; - break; - case 2: - case 3: - case 4: - { - if(matchingFirm) - { - verStringEmu[3] = '0' + currentNand; - verString = verStringEmu; - } - else - { - verStringEmuSys[2] = '0' + currentNand; - verString = verStringEmuSys; - } - break; - } - default: - if(matchingFirm) verString = u" Sys"; - else - { - if(currentFirm == 1) verString = u"SysE"; - else - { - verStringSysEmu[3] = '0' + currentFirm; - verString = verStringSysEmu; - } - } - break; - } + *verStringsEmuSys[] = { u"EmuS", + u"Em2S", + u"Em3S", + u"Em4S" }, + + *verStringsSysEmu[] = { u"SysE", + u"SyE2", + u"SyE3", + u"SyE4" }; + + verString = (currentFirm != 0) == (currentNand != 0) ? verStringsNands[currentNand] : + (!currentNand ? verStringsSysEmu[currentFirm - 1] : verStringsEmuSys[currentNand - 1]); } //Patch Ver. string diff --git a/injector/source/strings.c b/injector/source/strings.c index 4f34404..f4dc6c7 100644 --- a/injector/source/strings.c +++ b/injector/source/strings.c @@ -11,7 +11,7 @@ size_t strnlen(const char *string, size_t maxlen) void progIdToStr(char *strEnd, u64 progId) { - while(progId) + while(progId > 0) { static const char hexDigits[] = "0123456789ABCDEF"; *strEnd-- = hexDigits[(u32)(progId & 0xF)]; diff --git a/source/emunand.c b/source/emunand.c index 3fc3fe2..c0a8e1c 100644 --- a/source/emunand.c +++ b/source/emunand.c @@ -112,20 +112,15 @@ static inline u32 getSdmmc(u8 *pos, u32 size) static inline void patchNandRw(u8 *pos, u32 size, u32 branchOffset) { - const u16 nandRedir[2] = {0x4C00, 0x47A0}; - //Look for read/write code const u8 pattern[] = {0x1E, 0x00, 0xC8, 0x05}; u16 *readOffset = (u16 *)memsearch(pos, pattern, size, sizeof(pattern)) - 3, *writeOffset = (u16 *)memsearch((u8 *)(readOffset + 5), pattern, 0x100, sizeof(pattern)) - 3; - *readOffset = nandRedir[0]; - readOffset[1] = nandRedir[1]; - ((u32 *)readOffset)[1] = branchOffset; - *writeOffset = nandRedir[0]; - writeOffset[1] = nandRedir[1]; - ((u32 *)writeOffset)[1] = branchOffset; + *readOffset = *writeOffset = 0x4C00; + readOffset[1] = writeOffset[1] = 0x47A0; + ((u32 *)writeOffset)[1] = ((u32 *)readOffset)[1] = branchOffset; } static inline void patchMpu(u8 *pos, u32 size) diff --git a/source/patches.c b/source/patches.c index 4abf55a..4a427ee 100644 --- a/source/patches.c +++ b/source/patches.c @@ -63,8 +63,6 @@ u32 *getKernel11Info(u8 *pos, u32 size, u32 *baseK11VA, u8 **freeK11Space, u32 * void patchSignatureChecks(u8 *pos, u32 size) { - const u16 sigPatch[2] = {0x2000, 0x4770}; - //Look for signature checks const u8 pattern[] = {0xC0, 0x1C, 0x76, 0xE7}, pattern2[] = {0xB5, 0x22, 0x4D, 0x0C}; @@ -72,9 +70,8 @@ void patchSignatureChecks(u8 *pos, u32 size) u16 *off = (u16 *)memsearch(pos, pattern, size, sizeof(pattern)), *off2 = (u16 *)(memsearch(pos, pattern2, size, sizeof(pattern2)) - 1); - *off = sigPatch[0]; - off2[0] = sigPatch[0]; - off2[1] = sigPatch[1]; + *off = off2[0] = 0x2000; + off2[1] = 0x4770; } void patchFirmlaunches(u8 *pos, u32 size, u32 process9MemAddr)