Rename and mark detour globals as static

Renamed to 'g_DetourVector' and 'g_DetourSet', marked as static.
This commit is contained in:
Kawe Mazidjatari 2023-04-01 13:17:23 +02:00
parent cc67739802
commit 7cc58a642f
2 changed files with 9 additions and 9 deletions

View File

@ -163,7 +163,7 @@ void Systems_Init()
DetourUpdateThread(GetCurrentThread());
// Hook functions
for (const IDetour* pDetour : vDetour)
for (const IDetour* pDetour : g_DetourVector)
{
pDetour->Attach();
}
@ -207,7 +207,7 @@ void Systems_Shutdown()
DetourUpdateThread(GetCurrentThread());
// Unhook functions
for (const IDetour* pDetour : vDetour)
for (const IDetour* pDetour : g_DetourVector)
{
pDetour->Detach();
}
@ -332,7 +332,7 @@ void DetourInit() // Run the sigscan
g_SigCache.SetDisabled((strstr(pCommandLine, "-nosmap") != nullptr));
g_SigCache.LoadCache(SIGDB_FILE);
for (const IDetour* pDetour : vDetour)
for (const IDetour* pDetour : g_DetourVector)
{
pDetour->GetCon(); // Constants.
pDetour->GetFun(); // Functions.
@ -362,7 +362,7 @@ void DetourInit() // Run the sigscan
void DetourAddress() // Test the sigscan results
{
spdlog::debug("+---------------------------------------------------------------------+\n");
for (const IDetour* pDetour : vDetour)
for (const IDetour* pDetour : g_DetourVector)
{
pDetour->GetAdr();
spdlog::debug("+---------------------------------------------------------------------+\n");

View File

@ -29,17 +29,17 @@ class VDetour : public IDetour
virtual void Detach(void) const { }
};
inline std::vector<IDetour*> vDetour;
inline std::unordered_set<IDetour*> sDetour;
inline static std::vector<IDetour*> g_DetourVector;
inline static std::unordered_set<IDetour*> g_DetourSet;
inline std::size_t AddDetour(IDetour* pDetour, const char* pszName)
{
IDetour* pVFTable = reinterpret_cast<IDetour**>(pDetour)[0];
auto p = sDetour.insert(pVFTable); // Only register if VFTable isn't already registered.
auto p = g_DetourSet.insert(pVFTable); // Only register if VFTable isn't already registered.
assert(p.second); // Code bug: duplicate registration!!! (called 'REGISTER(...)' from a header file?).
p.second ? vDetour.push_back(pDetour) : delete pDetour;
p.second ? g_DetourVector.push_back(pDetour) : delete pDetour;
return vDetour.size();
return g_DetourVector.size();
}
REGISTER(VDetour);