From daa8830b030ea1221199441c53a522ed370cbbcc Mon Sep 17 00:00:00 2001 From: chaoskagami Date: Sun, 14 Aug 2016 08:51:11 -0400 Subject: [PATCH] Misc work --- common.mk | 2 +- source/interpreter.c | 23 +++++++++++++++++++++++ source/patch/reboot.c | 8 ++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/common.mk b/common.mk index 8417af2..216f4a9 100644 --- a/common.mk +++ b/common.mk @@ -12,7 +12,7 @@ AM_CFLAGS= -std=gnu11 -Os -g -fomit-frame-pointer -ffast-math \ -Wmissing-include-dirs -Wredundant-decls \ -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default \ -Wundef -Wno-unused $(THUMBFLAGS) $(SIZE_OPTIMIZATION) $(INCPATHS) $(C9FLAGS) \ - -fshort-wchar -fno-builtin -std=gnu11 -DREVISION=\"$(REVISION)\" \ + -fno-builtin -std=gnu11 -DREVISION=\"$(REVISION)\" \ -DFW_NAME=\"corbenik\" $(PATHARGS) diff --git a/source/interpreter.c b/source/interpreter.c index 9bd83ed..bacfb72 100644 --- a/source/interpreter.c +++ b/source/interpreter.c @@ -43,6 +43,8 @@ #define OP_JMPF 0x77 #define OP_JMPNF 0x87 +#define OP_INJECT 0x90 + #define OP_NEXT 0xFF #ifdef LOADER @@ -519,6 +521,27 @@ exec_bytecode(uint8_t *bytecode, uint32_t len, uint8_t* stack, uint32_t stack_si offset = new_offset = 0; code = bytecode; break; + case OP_INJECT: // Read in data (from filename) + if (debug) { +#ifdef LOADER + log("set\n"); +#else + fprintf(stderr, "set %s\n", &code[1]); +#endif + } + + char* fname = (char*)&code[1]; +#ifdef LOADER + (void)fname; + // NYI +#else + FILE* f = fopen(fname, "r"); + fread(current_mode->memory + offset, 1, fsize(f), f); + offset += fsize(f); + code += strlen(fname); + fclose(f); +#endif + break; default: #ifndef LOADER // Panic; not proper opcode. diff --git a/source/patch/reboot.c b/source/patch/reboot.c index 00765d0..2c0ab05 100644 --- a/source/patch/reboot.c +++ b/source/patch/reboot.c @@ -6,7 +6,7 @@ int wait(); -uint8_t * +uint8_t* getProcess9(uint8_t *pos, uint32_t size, uint32_t *process9Size, uint32_t *process9MemAddr) { uint8_t *off = memfind(pos, size, "ess9", 4); @@ -76,7 +76,7 @@ patch_reboot() // it might be needed to replace a svc call to access it. I'm rather sure that NTR does this. *pos_native = (uint32_t)mem; - memcpy(mem, L"sdmc:", 10); + memcpy(mem, u"sdmc:", 10); mem += 10; for (size_t i = 0; i < sizeof(PATH_NATIVE_P); i++, mem += 2) { *mem = PATH_NATIVE_P[i]; @@ -84,7 +84,7 @@ patch_reboot() } *pos_twl = (uint32_t)mem; - memcpy(mem, L"sdmc:", 10); + memcpy(mem, u"sdmc:", 10); mem += 10; for (size_t i = 0; i < sizeof(PATH_TWL_P); i++, mem += 2) { *mem = PATH_TWL_P[i]; @@ -92,7 +92,7 @@ patch_reboot() } *pos_agb = (uint32_t)mem; - memcpy(mem, L"sdmc:", 10); + memcpy(mem, u"sdmc:", 10); mem += 10; for (size_t i = 0; i < sizeof(PATH_AGB_P); i++, mem += 2) { *mem = PATH_AGB_P[i]; -- 2.39.5