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