Lock inside FetchOrdinalNames just in case

* It's possible for two threads to hit GetProcAddress on the same module at
  once, try to late-fetch the ordinals, and clash. If we lock then only one
  thread will perform the fetch, the other thread can wait and bail out once it
  finds the ordinals already filled out.
This commit is contained in:
baldurk
2018-08-27 16:29:05 +01:00
parent 8ebd0c5d9b
commit 0352e50fe5
+7
View File
@@ -98,9 +98,16 @@ struct DllHookset
DWORD OrdinalBase = 0;
vector<string> OrdinalNames;
std::vector<FunctionLoadCallback> Callbacks;
Threading::CriticalSection ordinallock;
void FetchOrdinalNames()
{
SCOPED_LOCK(ordinallock);
// return if we already fetched the ordinals
if(!OrdinalNames.empty())
return;
byte *baseAddress = (byte *)module;
#if ENABLED(VERBOSE_DEBUG_HOOK)