SocksOverRDP-Plugin/SocksOverRDP-Plugin.cpp
// Look up thread and return a pointer to it by ThreadId
Look up thread and return a pointer to it by ThreadId
Look up thread and return a pointer to it by ThreadId
struct threads *SocksOverRDPPlugin::LookupThread(DWORD dwThreadId)
{
	struct threads *rolling;
	DWORD dwWaitResult = WaitForSingleObject(ghLLMutex, INFINITE);
	switch (dwWaitResult)
	{
	case WAIT_OBJECT_0:
		rolling = ThreadHead;
		while (rolling)
		{
			if (rolling->dwThreadId == dwThreadId)
			{
				if (!ReleaseMutex(ghLLMutex))
				{
					if (bVerbose) DebugPrint(0, L"[*] lookupThread Release failed0: %08X", GetCurrentThreadId());
				}
				return rolling;
			}
			rolling = rolling->next;
		}
		if (!ReleaseMutex(ghLLMutex))
		{
			if (bVerbose) DebugPrint(0, L"[*] lookupThread Release failed1: %08X", GetCurrentThreadId());
		}
		return NULL;
		break;
	case WAIT_ABANDONED:
		if (bVerbose) DebugPrint(0, L"[*] lookupThread abandoned: %08X", GetCurrentThreadId());
		return NULL;
	}
	return NULL;
}
struct threads * SocksOverRDPPlugin :: LookupThread ( DWORD dwThreadId ) { struct threads * rolling ; DWORD dwWaitResult = WaitForSingleObject ( ghLLMutex , INFINITE ) ; switch ( dwWaitResult ) { case WAIT_OBJECT_0 : rolling = ThreadHead ; while ( rolling ) { if ( rolling -> dwThreadId == dwThreadId ) { if ( ! ReleaseMutex ( ghLLMutex ) ) { if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; } return rolling ; } rolling = rolling -> next ; } if ( ! ReleaseMutex ( ghLLMutex ) ) { if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; } return NULL ; break ; case WAIT_ABANDONED : if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; return NULL ; } return NULL ; }
Look up thread and return a pointer to it by ThreadId
Look up thread and return a pointer to it by ThreadId