diff --git a/Makefile b/Makefile index e93d8f1..e3fb416 100644 --- a/Makefile +++ b/Makefile @@ -40,7 +40,7 @@ CFLAGS := -g -Wall -Wextra -O3 -mword-relocations \ -fomit-frame-pointer -ffast-math \ $(ARCH) -CFLAGS += $(INCLUDE) -DARM11 -D_3DS -DARM_ARCH -w +CFLAGS += $(INCLUDE) -DARM11 -D__3DS__ -DARM_ARCH -w ifdef PAYLOAD_PATH CFLAGS += -DPAYLOAD_PATH=\"$(PAYLOAD_PATH)\" diff --git a/include/brahma.h b/include/brahma.h index 78be584..12efde4 100644 --- a/include/brahma.h +++ b/include/brahma.h @@ -4,6 +4,7 @@ u32 brahma_init (void); u32 brahma_exit (void); +s32 load_arm9_payload (char *filename, u32 offset, u32 max_psize); s32 load_arm9_payload_offset (char *filename, u32 offset, u32 max_psize); s32 load_arm9_payload_from_mem (u8* data, u32 dsize); void redirect_codeflow (u32 *dst_addr, u32 *src_addr); diff --git a/include/utils.h b/include/utils.h new file mode 100644 index 0000000..065cf47 --- /dev/null +++ b/include/utils.h @@ -0,0 +1,7 @@ +#pragma once + +void InvalidateEntireInstructionCache(void); +void CleanEntireDataCache(void); +void dsb(void); +void DisableInterrupts(void); +void EnableInterrupts(void); diff --git a/source/brahma.c b/source/brahma.c index 87a09da..1ea546a 100644 --- a/source/brahma.c +++ b/source/brahma.c @@ -4,12 +4,14 @@ #include #include #include +#include #include #include #include #include #include "brahma.h" #include "exploitdata.h" +#include "utils.h" #include "libkhax/khax.h" static u8 *g_ext_arm9_buf; @@ -37,7 +39,7 @@ u32 brahma_exit (void) { /* overwrites two instructions (8 bytes in total) at src_addr with code that redirects execution to dst_addr */ void redirect_codeflow (u32 *dst_addr, u32 *src_addr) { - *(src_addr + 1) = dst_addr; + *(src_addr + 1) = (u32)dst_addr; *src_addr = ARM_JUMPOUT; } @@ -46,7 +48,7 @@ void redirect_codeflow (u32 *dst_addr, u32 *src_addr) { returns: 0 on failure, 1 on success */ s32 get_exploit_data (struct exploit_data *data) { u32 fversion = 0; - u8 isN3DS = 0; + bool isN3DS = false; s32 i; s32 result = 0; u32 sysmodel = SYS_MODEL_NONE; @@ -314,13 +316,13 @@ void exploit_arm9_race_condition (void) { /* patch ARM11 kernel to force it to execute our code (hook1 and hook2) as soon as a "firmlaunch" is triggered */ - redirect_codeflow(g_expdata.va_exc_handler_base_X + - OFFS_EXC_HANDLER_UNUSED, - g_expdata.va_patch_hook1); + redirect_codeflow((u32 *)(g_expdata.va_exc_handler_base_X + + OFFS_EXC_HANDLER_UNUSED), + (u32 *)g_expdata.va_patch_hook1); - redirect_codeflow(PA_EXC_HANDLER_BASE + - OFFS_EXC_HANDLER_UNUSED + 4, - g_expdata.va_patch_hook2); + redirect_codeflow((u32 *)(PA_EXC_HANDLER_BASE + + OFFS_EXC_HANDLER_UNUSED + 4), + (u32 *)g_expdata.va_patch_hook2); CleanEntireDataCache(); dsb(); diff --git a/source/hid.c b/source/hid.c index d8cb9e1..ea9e61d 100644 --- a/source/hid.c +++ b/source/hid.c @@ -1,4 +1,5 @@ #include <3ds.h> +#include /* loop until key is pressed */ u32 wait_key (void) {