]> Chaos Git - corbenik/corbenik.git/commitdiff
Misc work
authorchaoskagami <chaos.kagami@gmail.com>
Sun, 14 Aug 2016 12:51:11 +0000 (08:51 -0400)
committerchaoskagami <chaos.kagami@gmail.com>
Sun, 14 Aug 2016 12:51:11 +0000 (08:51 -0400)
common.mk
source/interpreter.c
source/patch/reboot.c

index 8417af27f94eb3e8216eae555ceec00df9073b89..216f4a96d1545527141a116cd8325cd50ef3a93b 100644 (file)
--- 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)
 
 
index 9bd83ede698103db5d5f251a77f8bfddbb495119..bacfb72069160bbf1e327195364741bfad153e77 100644 (file)
@@ -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.
index 00765d0ea40be5c3e21c1f4a6bb75c16f3b7f30d..2c0ab057b85d1c45bfeef214d921fb8b7b961293 100644 (file)
@@ -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];