Compare commits

..

9 Commits
v5.0 ... v5.1

Author SHA1 Message Date
Aurora
a76c943c01 Reinstated the L+SELECT payload 2016-04-17 19:35:29 +02:00
Aurora
3c64a3a234 Updated ReadME 2016-04-17 19:11:38 +02:00
Aurora
06060c67b5 Changed the chainloader to load payloads named "BUTTON_NAME.bin", to remember which payload is which. Original idea and code by @habbbe (many thanks!) 2016-04-17 18:57:25 +02:00
Aurora
0f64fd73ec Fix bug when quitting AGB_FIRM
The wrong config.bin section was used to remember the last-used FIRM
2016-04-16 20:27:52 +02:00
Aurora
2323528975 Merge pull request #29 from habbbe/master
Made define for payload paths (removes repeated parts of file paths t…
2016-04-16 18:39:22 +02:00
habbbe
22b38a0f88 Made define for payload paths (removes repeated parts of file paths to payloads) 2016-04-16 18:21:42 +02:00
Aurora
034c0f8d7c Updated ReadME 2016-04-15 19:46:25 +02:00
Aurora
b4cd67cb8c Merge pull request #24 from ericchu94/master
Fix buffer overflow due to null character
2016-04-15 19:32:10 +02:00
Eric Chu
be83d77187 Fix buffer overflow due to null character 2016-04-15 12:54:30 -04:00
11 changed files with 63 additions and 68 deletions

View File

@@ -3,34 +3,14 @@
**Compiling:**
You'll need armips and [bin2c](https://sourceforge.net/projects/bin2c/) added to your Path. [HERE](http://www91.zippyshare.com/v/ePGpjk9r/file.html) is a pre-compiled version of armips.
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!
You can find the compiled files in the 'out' folder.
You also need to have a recent build of makerom in your path for the injector to be built.
**Setup / Usage / Features:**
Lastly, just run Make and everything should work!
Copy everything in 'out' folder to SD root and run!
**Usage / Features:**
See https://github.com/Reisyukaku/ReiNand and http://gbatemp.net/threads/reinand-mod-o3ds-n3ds-sysnand.411110
The FIRMs you need are [HERE](http://www77.zippyshare.com/v/oXDn2Hes/file.html).
See https://github.com/AuroraWright/AuReiNand/wiki
**Credits:**
Rei as this is mostly his code.
The offset to detect the console, and to calculate the O3DS NAND CTR are from Decrypt9.
tiniVi suggested me a way to detect a A9LH environment, and figured out screen deinit.
Delebile provided me with the FIRM writes blocking patch.
A skilled reverser gave me the new reboot patch.
The screen init code is from dark_samus, bil1s, Normmatt, delebile and everyone who contributed.
The code for printing to the screen, and the heavy revision to the reboot patch to allow for AGB/TWL loading are from CakesFW.
ARM11 userland patching is only possible thanks to @yifanlu's 3ds_injector, which is bundled in the CFW.
See https://github.com/AuroraWright/AuReiNand/wiki/Credits

View File

@@ -382,8 +382,8 @@ void patchCode(u64 progId, u8 *code, u32 size)
patchMemory(code, size,
verPattern,
sizeof(verPattern) - sizeof(u16), 0,
!currentNand ? ((matchingFirm) ? u" Sys" : u"SysA") :
((currentNand == 1) ? (matchingFirm ? u" Emu" : u"EmuA") : ((matchingFirm) ? u"Emu2" : u"Em2A")),
!currentNand ? ((matchingFirm) ? u" Sys" : u"SysE") :
((currentNand == 1) ? (matchingFirm ? u" Emu" : u"EmuS") : ((matchingFirm) ? u"Emu2" : u"Em2S")),
sizeof(verPattern) - sizeof(u16), 1
);
}

View File

@@ -3,11 +3,11 @@
#include "types.h"
#define HID_PAD (*(vu32 *)0x10146000 ^ 0xFFF)
#define BUTTON_X (1 << 10)
#define BUTTON_Y (1 << 11)
#define BUTTON_R1 (1 << 8)
#define BUTTON_SELECT (1 << 2)
#define BUTTON_RIGHT (1 << 4)
#define BUTTON_LEFT (1 << 5)
#define BUTTON_UP (1 << 6)
#define BUTTON_DOWN (1 << 7)
#define BUTTON_X (1 << 10)
#define BUTTON_Y (1 << 11)
#define BUTTON_R1 (1 << 8)
#define BUTTON_SELECT (1 << 2)

View File

@@ -15,7 +15,7 @@
/ and optional writing functions as well. */
#define _FS_MINIMIZE 3
#define _FS_MINIMIZE 1
/* This option defines minimization level to remove some basic API functions.
/
/ 0: All basic functions are enabled.
@@ -34,7 +34,7 @@
/ 2: Enable with LF-CRLF conversion. */
#define _USE_FIND 0
#define _USE_FIND 1
/* This option switches filtered directory read feature and related functions,
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */

View File

@@ -3,21 +3,36 @@
#include "fatfs/ff.h"
#define PAYLOAD_ADDRESS 0x23F00000
#define LOAD_PAYLOAD(a) loadPayload(a "_*.bin")
static u32 loadPayload(const char *path)
static u32 loadPayload(const char *pattern)
{
char path[30] = "/aurei/payloads";
DIR dir;
FILINFO info = { .lfname = NULL };
FRESULT result = f_findfirst(&dir, &info, path, pattern);
f_closedir(&dir);
if(result != FR_OK || !info.fname[0])
return 0;
path[15] = '/';
u32 i;
for(i = 0; info.fname[i]; i++)
path[16 + i] = info.fname[i];
path[16 + i] = '\0';
FIL payload;
unsigned int br;
if(f_open(&payload, path, FA_READ) == FR_OK)
{
f_open(&payload, path, FA_READ);
f_read(&payload, (void *)PAYLOAD_ADDRESS, f_size(&payload), &br);
f_close(&payload);
return 1;
}
return 0;
}
void main(void)
@@ -29,14 +44,14 @@ void main(void)
//Get pressed buttons
u32 pressed = HID_PAD;
if(((pressed & BUTTON_RIGHT) && loadPayload("/aurei/payloads/right.bin")) ||
((pressed & BUTTON_LEFT) && loadPayload("/aurei/payloads/left.bin")) ||
((pressed & BUTTON_UP) && loadPayload("/aurei/payloads/up.bin")) ||
((pressed & BUTTON_DOWN) && loadPayload("/aurei/payloads/down.bin")) ||
((pressed & BUTTON_X) && loadPayload("/aurei/payloads/x.bin")) ||
((pressed & BUTTON_Y) && loadPayload("/aurei/payloads/y.bin")) ||
((pressed & BUTTON_SELECT) && loadPayload("/aurei/payloads/select.bin")) ||
((pressed & BUTTON_R1) && loadPayload("/aurei/payloads/r.bin")) ||
loadPayload("/aurei/payloads/default.bin"))
if(((pressed & BUTTON_RIGHT) && LOAD_PAYLOAD("right")) ||
((pressed & BUTTON_LEFT) && LOAD_PAYLOAD("left")) ||
((pressed & BUTTON_UP) && LOAD_PAYLOAD("up")) ||
((pressed & BUTTON_DOWN) && LOAD_PAYLOAD("down")) ||
((pressed & BUTTON_X) && LOAD_PAYLOAD("x")) ||
((pressed & BUTTON_Y) && LOAD_PAYLOAD("y")) ||
((pressed & BUTTON_R1) && LOAD_PAYLOAD("r")) ||
((pressed & BUTTON_SELECT) && LOAD_PAYLOAD("select")) ||
LOAD_PAYLOAD("def"))
((void (*)())PAYLOAD_ADDRESS)();
}

View File

@@ -76,14 +76,14 @@ int main(int argc, char **argv)
error(payload, "Pattern not found");
}
u8 input[37] = {0};
u8 payloadname[2 * sizeof(input)] = {0};
u8 input[38] = {0};
u8 payloadname[2 * (sizeof(input) - 1)] = {0};
printf("Enter the payload's path (37 characters max): ");
scanf("%37s", input);
unsigned int i;
for (i = 0; i < sizeof(input); i++)
for (i = 0; i < sizeof(input) - 1; i++)
payloadname[2 * i] = input[i];
memcpy(found + 12, payloadname, sizeof(payloadname));

View File

@@ -34,7 +34,7 @@
/ 2: Enable with LF-CRLF conversion. */
#define _USE_FIND 0
#define _USE_FIND 1
/* This option switches filtered directory read feature and related functions,
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */

View File

@@ -111,7 +111,7 @@ void main(void)
if(previousFirm == 7)
{
nandType = 0;
firmSource = updatedSys ? 0 : BOOTCONFIG(0, 3);
firmSource = updatedSys ? 0 : BOOTCONFIG(2, 1);
needConfig = 0;
//Flag to prevent multiple boot options-forcing
@@ -198,7 +198,7 @@ static inline void loadFirm(u32 firmType, u32 externalFirm)
if(externalFirm)
{
const char *path = "/aurei/firmware.bin";
const char path[] = "/aurei/firmware.bin";
firmSize = fileSize(path);
if(firmSize)

View File

@@ -64,16 +64,16 @@ u32 fileSize(const char *path)
return size;
}
u32 fileExists(const char *path)
u32 defPayloadExists(void)
{
FIL fp;
u32 exists = 0;
DIR dir;
FILINFO info = { .lfname = NULL };
if(f_open(&fp, path, FA_READ) == FR_OK) exists = 1;
FRESULT result = f_findfirst(&dir, &info, "/aurei/payloads", "def_*.bin");
f_close(&fp);
f_closedir(&dir);
return exists;
return (result == FR_OK && info.fname[0]);
}
void firmRead(void *dest, const char *firmFolder)

View File

@@ -12,5 +12,5 @@ u32 mountFs(void);
u32 fileRead(void *dest, const char *path, u32 size);
u32 fileWrite(const void *buffer, const char *path, u32 size);
u32 fileSize(const char *path);
u32 fileExists(const char *path);
u32 defPayloadExists(void);
void firmRead(void *dest, const char *firmFolder);

View File

@@ -14,7 +14,7 @@
void loadPayload(void)
{
if(fileExists("aurei/payloads/default.bin"))
if(defPayloadExists())
{
initScreens();
memcpy((void *)PAYLOAD_ADDRESS, loader, loader_size);