SocksOverRDP-Plugin/SocksOverRDP-Plugin.cpp
// Stopping a specific thread gently by setting the loop condition to FALSE
Stopping a specific thread gently by setting the loop condition to FALSE
Stopping a specific thread gently by setting the loop condition to FALSE
VOID SocksOverRDPPlugin::StopThread(DWORD dwThreadId)
{
	struct threads *rolling;
	DWORD dwWaitResult = WaitForSingleObject(ghLLMutex, INFINITE);
	switch (dwWaitResult)
	{
	case WAIT_OBJECT_0:
		rolling = ThreadHead;
		while (rolling)
		{
			if (rolling->dwThreadId == dwThreadId)
			{
				rolling->run = FALSE;
				if (!ReleaseMutex(ghLLMutex))
				{
					if (bVerbose) DebugPrint(0, L"[*] StopThread Release failed0: %08X", GetCurrentThreadId());
				}
				return;
			}
			rolling = rolling->next;
		}
		if (!ReleaseMutex(ghLLMutex))
		{
			if (bVerbose) DebugPrint(0, L"[*] StopThread Release failed1: %08X", GetCurrentThreadId());
		}
		return;
		break;
	case WAIT_ABANDONED:
		if (bVerbose) DebugPrint(0, L"[*] lookupThread abandoned: %08X", GetCurrentThreadId());
		return;
	}
	return;
}
VOID SocksOverRDPPlugin :: StopThread ( DWORD dwThreadId ) { struct threads * rolling ; DWORD dwWaitResult = WaitForSingleObject ( ghLLMutex , INFINITE ) ; switch ( dwWaitResult ) { case WAIT_OBJECT_0 : rolling = ThreadHead ; while ( rolling ) { if ( rolling -> dwThreadId == dwThreadId ) { rolling -> run = FALSE ; if ( ! ReleaseMutex ( ghLLMutex ) ) { if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; } return ; } rolling = rolling -> next ; } if ( ! ReleaseMutex ( ghLLMutex ) ) { if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; } return ; break ; case WAIT_ABANDONED : if ( bVerbose ) DebugPrint ( 0 , L" " , GetCurrentThreadId ( ) ) ; return ; } return ; }
Stopping a specific thread gently by setting the loop condition to FALSE
Stopping a specific thread gently by setting the loop condition to FALSE