Skip to content

Commit

Permalink
Clarify detour creation errors (#1191)
Browse files Browse the repository at this point in the history
A logic error here meant that it wasn't printing the failing sig name in the common case
  • Loading branch information
SM9 authored and asherkin committed Feb 26, 2020
1 parent 7da2b89 commit bad0b51
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions public/CDetour/detours.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* This program is free software; you can redistribute it and/or modify it under * 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 * the terms of the GNU General Public License, version 3.0, as published by the
* Free Software Foundation. * Free Software Foundation.
* *
* This program is distributed in the hope that it will be useful, but WITHOUT * 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 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
Expand Down Expand Up @@ -182,20 +182,23 @@ bool CDetour::IsEnabled()


bool CDetour::CreateDetour() 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"); if (!gameconf->GetMemSig(signame, &detour_address))
return false; {
} 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; return false;
} }


Expand All @@ -209,7 +212,7 @@ bool CDetour::CreateDetour()
JitWriter wr; JitWriter wr;
JitWriter *jit = ≀ JitWriter *jit = ≀
jit_uint32_t CodeSize = 0; jit_uint32_t CodeSize = 0;

wr.outbase = NULL; wr.outbase = NULL;
wr.outptr = NULL; wr.outptr = NULL;


Expand Down

0 comments on commit bad0b51

Please sign in to comment.