1
0
Fork 0

DBG: Fix a bug in ThreadGetList (totally wasn't my fault)

This commit is contained in:
Nukem 2015-07-11 22:55:57 -04:00
parent bcc488f93e
commit 1cb2217a7a
1 changed files with 14 additions and 11 deletions

View File

@ -80,7 +80,7 @@ void ThreadGetList(THREADLIST* List)
SHARED_ACQUIRE(LockThreads);
//
// This function converts a C++ std::vector to a C-style THREADLIST[].
// This function converts a C++ std::unordered_map to a C-style THREADLIST[].
// Also assume BridgeAlloc zeros the returned buffer.
//
int count = (int)threadList.size();
@ -92,21 +92,24 @@ void ThreadGetList(THREADLIST* List)
List->list = (THREADALLINFO*)BridgeAlloc(count * sizeof(THREADALLINFO));
// Fill out the list data
for(int i = 0; i < count; i++)
int index = 0;
for(auto & itr : threadList)
{
HANDLE threadHandle = threadList[i].Handle;
HANDLE threadHandle = itr.second.Handle;
// Get the debugger's current thread index
// Get the debugger's active thread index
if(threadHandle == hActiveThread)
List->CurrentThread = i;
List->CurrentThread = index;
memcpy(&List->list[i].BasicInfo, &threadList[i], sizeof(THREADINFO));
memcpy(&List->list[index].BasicInfo, &itr.second, sizeof(THREADINFO));
List->list[i].ThreadCip = GetContextDataEx(threadHandle, UE_CIP);
List->list[i].SuspendCount = ThreadGetSuspendCount(threadHandle);
List->list[i].Priority = ThreadGetPriority(threadHandle);
List->list[i].WaitReason = ThreadGetWaitReason(threadHandle);
List->list[i].LastError = getLastErrorFromTeb(threadList[i].ThreadLocalBase);
List->list[index].ThreadCip = GetContextDataEx(threadHandle, UE_CIP);
List->list[index].SuspendCount = ThreadGetSuspendCount(threadHandle);
List->list[index].Priority = ThreadGetPriority(threadHandle);
List->list[index].WaitReason = ThreadGetWaitReason(threadHandle);
List->list[index].LastError = getLastErrorFromTeb(itr.second.ThreadLocalBase);
index++;
}
}