From 4d38f11367659877e611cabd68cca00cab08bec5 Mon Sep 17 00:00:00 2001 From: SM9 <me@sm9.dev> Date: Wed, 26 Feb 2020 00:25:53 +0000 Subject: [PATCH] Clarify detour creation errors (#1191) A logic error here meant that it wasn't printing the failing sig name in the common case --- public/CDetour/detours.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/public/CDetour/detours.cpp b/public/CDetour/detours.cpp index 99f2ad57..822bba3c 100644 --- a/public/CDetour/detours.cpp +++ b/public/CDetour/detours.cpp @@ -8,7 +8,7 @@ * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License, version 3.0, as published by the * Free Software Foundation. -* +* * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more @@ -182,20 +182,23 @@ bool CDetour::IsEnabled() bool CDetour::CreateDetour() { - if (signame && !gameconf->GetMemSig(signame, &detour_address)) + if (signame) { - g_pSM->LogError(myself, "Could not locate %s - Disabling detour", signame); - return false; - } - else if(!detour_address) - { - g_pSM->LogError(myself, "Invalid detour address passed - Disabling detour to prevent crashes"); - return false; - } + if (!gameconf->GetMemSig(signame, &detour_address)) + { + g_pSM->LogError(myself, "Signature for %s not found in gamedata", signame); + return false; + } - if (!detour_address) + if (!detour_address) + { + g_pSM->LogError(myself, "Sigscan for %s failed", signame); + return false; + } + } + else if (!detour_address) { - g_pSM->LogError(myself, "Sigscan for %s failed - Disabling detour to prevent crashes", signame); + g_pSM->LogError(myself, "Invalid function address passed for detour"); return false; } @@ -209,7 +212,7 @@ bool CDetour::CreateDetour() JitWriter wr; JitWriter *jit = ≀ jit_uint32_t CodeSize = 0; - + wr.outbase = NULL; wr.outptr = NULL;