From 6c18efef545c443b1f97d4a07255704530a41d4f Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 13 Jun 2020 13:17:46 +0200 Subject: [PATCH] Check function patcher data struct before patching a function --- source/function_patcher.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/function_patcher.cpp b/source/function_patcher.cpp index 57ac4f9..3da9967 100644 --- a/source/function_patcher.cpp +++ b/source/function_patcher.cpp @@ -35,10 +35,12 @@ void writeDataAndFlushIC(CThread *thread, void *arg) { ICInvalidateRange((void *) (effective_address), 4); } - void FunctionPatcherPatchFunction(function_replacement_data_t *replacements, uint32_t size) { for (uint32_t i = 0; i < size; i++) { function_replacement_data_t *function_data = &replacements[i]; + if (function_data->VERSION != FUNCTION_REPLACEMENT_DATA_STRUCT_VERSION) { + OSFatal("Failed to patch function. struct version mismatch"); + } /* Patch branches to it. */ volatile uint32_t *space = function_data->replace_data;