// I don't want to delete it since I'm working on it though,
// so it's temporarliy #if'd 0.
#include <3ds.h>
+#include <stdlib.h>
#include "patcher.h"
#include "exheader.h"
#include "fsldr.h"
#include <option.h>
#include <patch_format.h>
-// Patches must consist of fewer bytes than this.
-// 16K is reasonable, IMO, and doesn't cause issues.
-
-// I'm too lazy to implement file buffering here,
-// and 16K is large enough for anything.
-
-#define MAX_PATCHSIZE 16384
-
// Yes, we're including a C file. Problem?
#include "../../../source/interpreter.c"
hexdump_titleid(tid, cache_path);
- static uint8_t patch_dat[MAX_PATCHSIZE];
+ static uint8_t *patch_mem;
Handle file;
u32 total;
return 1;
}
- if (file_size > MAX_PATCHSIZE) {
- log(" too large (please report)\n");
+ patch_mem = malloc(file_size);
+ if (patch_mem == NULL) {
+ log(" out of memory on loading patch\n");
FSFILE_Close(file); // Read to memory.
}
// Read file.
- if (!R_SUCCEEDED(FSFILE_Read(file, &total, 0, patch_dat, file_size))) {
+ if (!R_SUCCEEDED(FSFILE_Read(file, &total, 0, patch_mem, file_size))) {
FSFILE_Close(file); // Read to memory.
// Failed to read.
log(" exec\n");
- uint8_t *patch_mem = (uint8_t *)patch_dat;
patch_len = file_size;
#else
// The WHOLE firm.
debug = 1;
}
- return exec_bytecode(patch_mem, patch_len, ver, debug);
+ int r = exec_bytecode(patch_mem, patch_len, ver, debug);
+
+ free(patch_mem);
+
+ return r;
}
#ifndef LOADER