• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ ExitThread函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中ExitThread函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitThread函数的具体用法?C++ ExitThread怎么用?C++ ExitThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ExitThread函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: timer_thread_end

static void timer_thread_end(void)
{
  DIAGNOSTIC(2,"leaving timer thread",0,0);
  ExitThread(0);
}
开发者ID:Ravenbrook,项目名称:mlworks,代码行数:5,代码来源:native_threads.c


示例2: ExitThread

void *workThreadReceive( void *pObject )
#endif
{

#ifdef WIN32
    DWORD errorCode = 0;
#else
    int rv = 0;
#endif

    CPeakObj * pobj = ( CPeakObj *)pObject;
    if ( NULL == pobj ) {
#ifdef WIN32
        ExitThread( errorCode ); // Fail
#else
        pthread_exit( &rv );
#endif
    }

    PeakCanMsg peakMsg;

    while ( pobj->m_bRun ) {

        // Noting to do if we should end...
        if ( !pobj->m_bRun ) continue;

        LOCK_MUTEX( pobj->m_peakMutex );
        while ( 0 == ( pobj->m_procRead( &peakMsg ) & PEAK_CAN_ERR_QRCVEMPTY ) ) {

            // Check if this is a status message
            if ( PCAN_MSGTYPE_STATUS & peakMsg.msgType ) {

                continue; // TODO

            }

            // Write to the receive buffer
            if (  pobj->m_receiveList.nCount < PEAKDRV_MAX_RCVMSG ) {

                PCANALMSG pMsg	= new canalMsg;
                pMsg->flags = 0;

                if ( NULL != pMsg ) {

                    dllnode *pNode = new dllnode;
                    if ( NULL != pNode ) {

                        pMsg->timestamp = GetTickCount() * 1000;
                        pMsg->id = peakMsg.id;
                        pMsg->sizeData = peakMsg.len;
                        memcpy( pMsg->data, peakMsg.data, pMsg->sizeData );

                        // If extended set extended flag
                        if ( PCAN_MSGTYPE_EXTENDED & peakMsg.msgType ) {
                            pMsg->flags |= CANAL_IDFLAG_EXTENDED;
                        }

                        // Check for RTS package
                        if ( PCAN_MSGTYPE_RTR & peakMsg.msgType ) {
                            pMsg->flags |= CANAL_IDFLAG_RTR;
                        }

                        pNode->pObject = pMsg;
                        LOCK_MUTEX( pobj->m_receiveMutex );
                        dll_addNode( &pobj->m_receiveList, pNode );
                        UNLOCK_MUTEX( pobj->m_receiveMutex );

                        // Update statistics
                        pobj->m_stat.cntReceiveData += pMsg->sizeData;
                        pobj->m_stat.cntReceiveFrames += 1;

                    }
                    else {

                        delete pMsg;

                    }
                }
            }
            else {
                // Full buffer
                pobj->m_stat.cntOverruns++;
            }
        } // while rcv msg


        UNLOCK_MUTEX( pobj->m_peakMutex );
        SLEEP( 1 );

    } // while


#ifdef WIN32
    ExitThread( errorCode );
#else
    pthread_exit( &rv );
#endif

}
开发者ID:dinguluer,项目名称:vscp_software,代码行数:99,代码来源:peakobj.cpp


示例3: onThreadExit

void CALLBACK onThreadExit(ULONG_PTR dwParam)
{
	int err = onCleanSocket(threadStatus);
	ExitThread(err);
}
开发者ID:prasan5984,项目名称:JVMHeapScan,代码行数:5,代码来源:SocketOutputInterface.c


示例4: thread_error_exit

void thread_error_exit(const char *errmsg) 
{
    MessageBox (hwndDlg, errmsg, NULL, MB_OK);
    update_interface_state (NULL);
    ExitThread(0);
}
开发者ID:BGCX261,项目名称:zruijie4gzhu-svn-to-git,代码行数:6,代码来源:win_main.c


示例5: StreamLoop


//.........这里部分代码省略.........
						CopyMemory(lpBlockAdd1,lpSoundBuffer->leakBuff,lpSoundBuffer->leakSize);
						writeSize += lpSoundBuffer->leakSize;
						remainSize -= lpSoundBuffer->leakSize;
						lpSoundBuffer->leakSize = 0;
						my_deletes(lpSoundBuffer->leakBuff);
					}
					size = lpSoundBuffer->readFile->StreamReadFile(lpSoundBuffer->arcFileNum,lpSoundBuffer->streamNum,
						(char *)lpSoundBuffer->acmSrc.lpStream,lpSoundBuffer->acmSrc.dwStreamSize);
					if(size < lpSoundBuffer->acmSrc.dwStreamSize){	
						lpSoundBuffer->ash.cbSrcLength = lpSoundBuffer->ash.dwSrcUser = size;
						MMRESULT nError = acmStreamConvert(lpSoundBuffer->hAcm,&lpSoundBuffer->ash,0);
						lpSoundBuffer->ash.cbSrcLength = lpSoundBuffer->ash.dwSrcUser = lpSoundBuffer->acmSrc.dwStreamSize;
						if(1==lpSoundBuffer->repeat){	
							if(0==nError){
								if(remainSize >= lpSoundBuffer->ash.cbDstLengthUsed){
									CopyMemory(lpBlockAdd1+writeSize, lpSoundBuffer->acmDst.lpStream, lpSoundBuffer->ash.cbDstLengthUsed);
									writeSize  += lpSoundBuffer->ash.cbDstLengthUsed;
									remainSize -= lpSoundBuffer->ash.cbDstLengthUsed;
									ZeroMemory(lpBlockAdd1+writeSize, remainSize);
									if(blockSize2)ZeroMemory(lpBlockAdd2,blockSize2);
								}else{
									CopyMemory(lpBlockAdd1+writeSize, lpSoundBuffer->acmDst.lpStream, remainSize);
									CopyMemory(lpBlockAdd2, lpSoundBuffer->acmDst.lpStream +remainSize,lpSoundBuffer->ash.cbDstLengthUsed -remainSize);
									if(blockSize2 > lpSoundBuffer->ash.cbDstLengthUsed -remainSize){
										ZeroMemory(lpBlockAdd2 +(lpSoundBuffer->ash.cbDstLengthUsed -remainSize),blockSize2-(lpSoundBuffer->ash.cbDstLengthUsed -remainSize));
									}
								}
								lpSoundBuffer->repeat = 0;
								lpSoundBuffer->lpDSBuffer->Play(0,0,0);
							}
						}else{
							if(lpSoundBuffer->repeat) lpSoundBuffer->repeat --;
							lpSoundBuffer->readFile->StreamSeekFile(lpSoundBuffer->arcFileNum,lpSoundBuffer->streamNum,lpSoundBuffer->dataTopOffset,FILE_BEGIN);
							if(0==nError){
								while(remainSize>=lpSoundBuffer->ash.cbDstLengthUsed && remainSize>0){
									CopyMemory(lpBlockAdd1+writeSize,lpSoundBuffer->acmDst.lpStream,lpSoundBuffer->ash.cbDstLengthUsed);
									remainSize -= lpSoundBuffer->ash.cbDstLengthUsed;
									writeSize += lpSoundBuffer->ash.cbDstLengthUsed;
									if(remainSize > 0){
										size = lpSoundBuffer->readFile->StreamReadFile(lpSoundBuffer->arcFileNum,lpSoundBuffer->streamNum,
											(char *)lpSoundBuffer->acmSrc.lpStream,lpSoundBuffer->acmSrc.dwStreamSize);
										nError = acmStreamConvert(lpSoundBuffer->hAcm,&lpSoundBuffer->ash,ACM_STREAMCONVERTF_BLOCKALIGN);
									}
								}
								if(remainSize){
									CopyMemory(lpBlockAdd1+writeSize,lpSoundBuffer->acmDst.lpStream,remainSize);
									lpSoundBuffer->leakSize = lpSoundBuffer->ash.cbDstLengthUsed -remainSize;
									lpSoundBuffer->leakBuff = new BYTE[lpSoundBuffer->leakSize];
									CopyMemory(lpSoundBuffer->leakBuff,lpSoundBuffer->acmDst.lpStream +remainSize,lpSoundBuffer->leakSize);
								}
							}
						}
					}else{
						MMRESULT nError = acmStreamConvert(lpSoundBuffer->hAcm,&lpSoundBuffer->ash, ACM_STREAMCONVERTF_BLOCKALIGN);
						if(0==nError){
							while(remainSize>=lpSoundBuffer->ash.cbDstLengthUsed && remainSize>0){
								CopyMemory(lpBlockAdd1+writeSize,lpSoundBuffer->acmDst.lpStream,lpSoundBuffer->ash.cbDstLengthUsed);
								remainSize -= lpSoundBuffer->ash.cbDstLengthUsed;
								writeSize += lpSoundBuffer->ash.cbDstLengthUsed;
								if(remainSize > 0){
									size = lpSoundBuffer->readFile->StreamReadFile(lpSoundBuffer->arcFileNum,lpSoundBuffer->streamNum,
										(char *)lpSoundBuffer->acmSrc.lpStream,lpSoundBuffer->acmSrc.dwStreamSize);
									nError = acmStreamConvert(lpSoundBuffer->hAcm,&lpSoundBuffer->ash, ACM_STREAMCONVERTF_BLOCKALIGN);
								}
							}
							if(remainSize){
								CopyMemory(lpBlockAdd1+writeSize,lpSoundBuffer->acmDst.lpStream,remainSize);
								lpSoundBuffer->leakSize = lpSoundBuffer->ash.cbDstLengthUsed -remainSize;
								lpSoundBuffer->leakBuff = new BYTE[lpSoundBuffer->leakSize];
								CopyMemory(lpSoundBuffer->leakBuff,lpSoundBuffer->acmDst.lpStream +remainSize,lpSoundBuffer->leakSize);
							}
						}
					}
				}
				lpSoundBuffer->lpDSBuffer->Unlock(lpBlockAdd1, blockSize1, lpBlockAdd2, blockSize2);
			}
			break;
		  default:
SoundStop:
			lpSoundBuffer->repeat = 0;
			lpSoundBuffer->lpDSNotify->Release();
			lpSoundBuffer->lpDSNotify = NULL;
			CloseHandle(lpSoundBuffer->hEvent[0]);
			CloseHandle(lpSoundBuffer->hEvent[1]);
			CloseHandle(lpSoundBuffer->hEvent[2]);
			lpSoundBuffer->hEvent[0] = lpSoundBuffer->hEvent[1] = lpSoundBuffer->hEvent[2] = NULL;
			lpSoundBuffer->status = PCM_STOP;
			LeaveCriticalSection(&cr_section);
			DeleteCriticalSection(&cr_section);
			CloseHandle(lpSoundBuffer->hLoopThread);
			lpSoundBuffer->hLoopThread = NULL;
			ExitThread(TRUE);
			return 0L;
		}
		LeaveCriticalSection(&cr_section);
	}
	DeleteCriticalSection(&cr_section);
	ExitThread(TRUE);
	return 0L;
} // StreamLoop
开发者ID:autch,项目名称:aquaplus_gpl,代码行数:101,代码来源:soundDS.cpp


示例6: smartcard_thread_func


//.........这里部分代码省略.........
						WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
						goto out;
					}

					if (status == WAIT_TIMEOUT)
						break;

					irp = (IRP*) Queue_Dequeue(smartcard->CompletedIrpQueue);

					if (irp)
					{
						if (irp->thread)
						{
							status = WaitForSingleObject(irp->thread, INFINITE);

							if (status == WAIT_FAILED)
							{
								error = GetLastError();
								WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
								goto out;
							}

							CloseHandle(irp->thread);
							irp->thread = NULL;
						}

						if ((error = smartcard_complete_irp(smartcard, irp)))
						{
							WLog_ERR(TAG, "smartcard_complete_irp failed with error %lu!", error);
							goto out;
						}
					}
				}

				break;
			}

			irp = (IRP*) message.wParam;

			if (irp)
			{
				if ((error = smartcard_process_irp(smartcard, irp)))
				{
					WLog_ERR(TAG, "smartcard_process_irp failed with error %lu!", error);
					goto out;
				}
			}
		}

		status = WaitForSingleObject(Queue_Event(smartcard->CompletedIrpQueue), 0);

		if (status == WAIT_FAILED)
		{
			error = GetLastError();
			WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
			break;
		}

		if (status == WAIT_OBJECT_0)
		{

			irp = (IRP*) Queue_Dequeue(smartcard->CompletedIrpQueue);

			if (irp)
			{
				if (irp->thread)
				{
					status = WaitForSingleObject(irp->thread, INFINITE);

					if (status == WAIT_FAILED)
					{
						error = GetLastError();
						WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
						break;
					}

					CloseHandle(irp->thread);
					irp->thread = NULL;
				}

				if ((error = smartcard_complete_irp(smartcard, irp)))
				{
					if (error == CHANNEL_RC_NOT_CONNECTED)
					{
						error = CHANNEL_RC_OK;
						goto out;
					}
					WLog_ERR(TAG, "smartcard_complete_irp failed with error %lu!", error);
					goto out;
				}
			}
		}
	}
out:
	if (error && smartcard->rdpcontext)
		setChannelError(smartcard->rdpcontext, error, "smartcard_thread_func reported an error");

	ExitThread((DWORD)error);
	return NULL;
}
开发者ID:speidy,项目名称:FreeRDP,代码行数:101,代码来源:smartcard_main.c


示例7: ExitThread

void Thread::quit()
{
	mImpl->state = ThreadImpl::Stopped;
	ExitThread(0);
}
开发者ID:rudysnow,项目名称:SimbiconPlatform,代码行数:5,代码来源:PsWindowsThread.cpp


示例8: cliprdr_server_thread

static void* cliprdr_server_thread(void* arg)
{
	DWORD status;
	DWORD nCount;
	HANDLE events[8];
	HANDLE ChannelEvent;
	CliprdrServerContext* context = (CliprdrServerContext*) arg;
	CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
	UINT error;

	ChannelEvent = context->GetEventHandle(context);

	nCount = 0;
	events[nCount++] = cliprdr->StopEvent;
	events[nCount++] = ChannelEvent;

	if ((error = cliprdr_server_init(context)))
	{
		WLog_ERR(TAG, "cliprdr_server_init failed with error %lu!", error);
		goto out;
	}

	while (1)
	{
		status = WaitForMultipleObjects(nCount, events, FALSE, INFINITE);

		if (status == WAIT_FAILED)
		{
            error = GetLastError();
            WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu", error);
            goto out;
		}

        status = WaitForSingleObject(cliprdr->StopEvent, 0);

        if (status == WAIT_FAILED)
        {
            error = GetLastError();
            WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
            goto out;
        }

		if (status == WAIT_OBJECT_0)
			break;

        status = WaitForSingleObject(ChannelEvent, 0);

        if (status == WAIT_FAILED)
        {
            error = GetLastError();
            WLog_ERR(TAG, "WaitForSingleObject failed with error %lu", error);
            goto out;
        }

		if (status == WAIT_OBJECT_0)
		{
			if ((error = context->CheckEventHandle(context)))
			{
				WLog_ERR(TAG, "CheckEventHandle failed with error %lu!", error);
				break;
			}
		}
	}
out:
	if (error && context->rdpcontext)
		setChannelError(context->rdpcontext, error, "cliprdr_server_thread reported an error");

	ExitThread((DWORD)error);
	return NULL;
}
开发者ID:BUGgs,项目名称:FreeRDP,代码行数:70,代码来源:cliprdr_main.c


示例9: entry

void entry(){
	//MessageBoxA(0, "I'm payload", "test", 0);
	ExitThread(0);
}
开发者ID:0x37N0w4N,项目名称:malware,代码行数:4,代码来源:main.cpp


示例10: memset


//.........这里部分代码省略.........
				memset(buf, 0, sizeof(buf));

				ReadFile(m_hRead, buf, BUFSIZE, &m_bread, NULL);
				printf("%s", buf);
				if(!game.getTurn())
					parseAIMove(buf);

				Sleep(100);

				PeekNamedPipe(m_hRead, buf, BUFSIZE, &m_bread, &m_avail, NULL);
				if(m_bread > 0)
					continue;
				else
					break;
			}
		}

		if(m_engine == ENGINE_STOCKFISH){
			//sprintf(buf, (i == 0) ? "uci " : (i == 1) ? "isready " : (i == 2) ? "" : (i == 3) ? "" : "");
			sprintf(buf, (i == 0) ? "uci " : "");
		}
		else{
			sprintf(buf, (i == 0) ? "uci " : (i == 1) ? "isready " : (i == 2) ? "setoption name Hash value 512 " : (i == 3) ? "setoption name UCI_LimitStrength value true " : "");
		}
		if(m_sendMove == true){
			strcat(m_pos, m_lastUserMove);
			strcat(m_pos, " ");

			WriteFile(m_hWrite, m_pos, sizeof(m_pos), &m_bread, NULL);
			WriteFile(m_hWrite, "\n", 1, &m_bread, NULL);

			//sprintf(buf, "go wtime %ld btime %ld depth %d ", g_whiteTime, g_blackTime, m_searchDepth);
			while(game.isAnimating())
				Sleep(50);

			// calculate depth to search
			if(m_engine != ENGINE_STOCKFISH){
				if(aiLevel != game.getAILevel()){
					aiLevel = game.getAILevel();
					switch(aiLevel){
					case Game::CHILD:
						depth = 1;
						sprintf(buf, "setoption name UCI_Elo value 1000 "); // it's questionable whether or not this works
						break;

					case Game::WALRUS:
						depth = 3;
						sprintf(buf, "setoption name UCI_Elo value 1200 ");
						break;

					case Game::LION:
					default:
						depth = 5;
						sprintf(buf, "setoption name UCI_Elo value 1500 ");
						break;

					case Game::RAPTOR:
						depth = 10;
						sprintf(buf, "setoption name UCI_Elo value 1800 ");
						break;

					case Game::GRANDMASTER:
						depth = 15;
						sprintf(buf, "setoption name UCI_Elo value 2900 ");
						break;
					}

					WriteFile(m_hWrite, buf, sizeof(buf), &m_bread, NULL);
					WriteFile(m_hWrite, "\n", 1, &m_bread, NULL);
				}
			}

			//sprintf(buf, "go wtime %ld btime %ld ", game.getTime(WHITE), game.getTime(BLACK));
			sprintf(buf, "go wtime %ld btime %ld depth %d ", game.getTime(WHITE), game.getTime(BLACK), depth);
			WriteFile(m_hWrite, buf, sizeof(buf), &m_bread, NULL);
			WriteFile(m_hWrite, "\n", 1, &m_bread, NULL);

			//printf("NEW POS: [%s]\n", m_pos);

			m_sendMove = false;
			game.setTurn(BLACK);
		}
		else{
			WriteFile(m_hWrite, buf, sizeof(buf), &m_bread, NULL);
			WriteFile(m_hWrite, "\n", 1, &m_bread, NULL);

			if(i > 100000)
				i = 6;
		}

		Sleep(500);
		
		//if(game.getTurn() == WHITE)
			//;///printf("Waiting for user to move...\n");
	}

	cleanup();

	ExitThread(0);
}
开发者ID:ddugovic,项目名称:etherealchess,代码行数:101,代码来源:ai.cpp


示例11: SplashThread


//.........这里部分代码省略.........
				splashWithMarkers = false;
				break;
			}
		}
		int splashHeight = SplashBmp->getHeight();
		for (i = 0; splashWithMarkers && (i < splashHeight); ++i)
			if(SplashBmp->getRow(i)[0] & 0xFF000000)
			{
				if (y < 0)
				{
					y = i-1; // 1 pixel for marker line
					splashWithMarkers = true;
				} else
				{
					y = -1;
					splashWithMarkers = false;
					break;
				}
			}

			TCHAR verString[256] = {0};
			TCHAR* mirandaVerString = mir_a2t(szVersion);
			mir_sntprintf(verString, SIZEOF(verString), _T("%s%s"), szPrefix, mirandaVerString);
			mir_free(mirandaVerString);
			LOGFONT lf = {0};
			lf.lfHeight = 14;
			_tcscpy_s(lf.lfFaceName, _T("Verdana"));
			SelectObject(SplashBmp->getDC(), CreateFontIndirect(&lf));
			if (!splashWithMarkers)
			{
				SIZE v_sz = {0,0};
				GetTextExtentPoint32(SplashBmp->getDC(), verString, (int)_tcslen(verString), &v_sz);
				x = SplashBmp->getWidth()/2-(v_sz.cx/2);
				y = SplashBmp->getHeight()-(SplashBmp->getHeight()*(100-90)/100);
			}

			SetTextColor(SplashBmp->getDC(), (0xFFFFFFFFUL-SplashBmp->getRow(y)[x])&0x00FFFFFFUL);
			//SplashBmp->DrawText(verString,SplashBmp->getWidth()/2-(v_sz.cx/2),SplashBmp->getHeight()-30);	 
			SetBkMode(SplashBmp->getDC(), TRANSPARENT);
			SplashBmp->DrawText(verString, x, y);
			//free (ptr_verString);
	}

	SetWindowLongPtr(hwndSplash, GWL_EXSTYLE, GetWindowLongPtr(hwndSplash, GWL_EXSTYLE) | WS_EX_LAYERED);
	UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);

	ShowWindow(hwndSplash, SW_SHOWNORMAL);

	if (options.fadein)
	{
		// Fade in
		int i;
		for (i = 0; i < 255; i += options.fisteps)
		{
			blend.SourceConstantAlpha = i;
			UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);
			Sleep(1);
		}
	}
	blend.SourceConstantAlpha = 255;
	UpdateLayeredWindow(hwndSplash, NULL, &ptDst, &sz, SplashBmp->getDC(), &ptSrc, 0xffffffff, &blend, LWA_ALPHA);

	if (DWORD(arg) > 0)
	{
		if (SetTimer(hwndSplash, 6, DWORD(arg), 0))
		{
			#ifdef _DEBUG
				logMessage(_T("Timer TimeToShow"), _T("set"));
			#endif
		}
	}
	else
		if (bmodulesloaded)
		{
			if (SetTimer(hwndSplash, 8, 2000, 0))
			{
				#ifdef _DEBUG
					logMessage(_T("Timer Modules loaded"), _T("set"));
				#endif
			}
		}

	// The Message Pump
	MSG msg;
	while (GetMessage(&msg, NULL, 0, 0) == TRUE) //NULL means every window in the thread; == TRUE means a safe pump.
	{
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}

	if (options.playsnd)
	{
		pControl->Release();
		pGraph->Release();
		CoUninitialize();
	}

	ExitThread(0);
	return 1;
}
开发者ID:0xmono,项目名称:miranda-ng,代码行数:101,代码来源:splash.cpp


示例12: MyWndThread2

DWORD WINAPI MyWndThread2(LPVOID lpParameter)
{
    MSG msg;
    HANDLE hMemory;
    PWNDCLASS pWndClass;
    BOOL bSuccess;
    CHAR lpBuffer[128];
    HANDLE myEvent = *((HANDLE *)lpParameter);
    RECT windowRect;

    hMemory = LocalAlloc(LPTR, sizeof(WNDCLASS));
    if(!hMemory){
	return(FALSE);
    }

    pWndClass = (PWNDCLASS) LocalLock(hMemory);
    pWndClass->hCursor = LoadCursor(NULL, IDC_ARROW);
    pWndClass->hIcon = LoadIcon(NULL, IDI_APPLICATION);
    pWndClass->lpszMenuName = NULL;
    pWndClass->lpszClassName = (LPSTR) "ECE291Socket";
    pWndClass->hbrBackground = NULL;//GetStockObject(WHITE_BRUSH);
    pWndClass->hInstance = GetInstance();
    pWndClass->style = 0;
    pWndClass->lpfnWndProc = (WNDPROC)MyWndProc2;

    bSuccess = RegisterClass(pWndClass);

    LocalUnlock(hMemory);
    LocalFree(hMemory);

    hWnd = CreateWindowEx(0,
	"ECE291Socket",
	"ECE 291 Sockets Handler",
	WS_ICONIC,
	CW_USEDEFAULT,
	CW_USEDEFAULT,
	CW_USEDEFAULT,
	CW_USEDEFAULT,
	NULL,
	NULL,
	GetInstance(),
	NULL);

    if (!hWnd)
	return FALSE;

    SetEvent(myEvent);

    for(;;) {
	if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
	    TranslateMessage(&msg);
	    DispatchMessage(&msg);
	    if (msg.message == WM_CLOSE)
		break;
	}
    }

    DestroyWindow(hWnd);
    UnregisterClass("ECE291Socket", GetInstance());

    SetEvent(myEvent);

    ExitThread(0);
}
开发者ID:ece291,项目名称:ex291,代码行数:64,代码来源:mywindow2.c


示例13: drdynvc_virtual_channel_client_thread

static DWORD WINAPI drdynvc_virtual_channel_client_thread(LPVOID arg)
{
	wStream* data;
	wMessage message;
	UINT error = CHANNEL_RC_OK;
	drdynvcPlugin* drdynvc = (drdynvcPlugin*) arg;

	if (!drdynvc)
	{
		ExitThread((DWORD) CHANNEL_RC_BAD_CHANNEL_HANDLE);
		return CHANNEL_RC_BAD_CHANNEL_HANDLE;
	}

	while (1)
	{
		if (!MessageQueue_Wait(drdynvc->queue))
		{
			WLog_Print(drdynvc->log, WLOG_ERROR, "MessageQueue_Wait failed!");
			error = ERROR_INTERNAL_ERROR;
			break;
		}

		if (!MessageQueue_Peek(drdynvc->queue, &message, TRUE))
		{
			WLog_Print(drdynvc->log, WLOG_ERROR, "MessageQueue_Peek failed!");
			error = ERROR_INTERNAL_ERROR;
			break;
		}

		if (message.id == WMQ_QUIT)
			break;

		if (message.id == 0)
		{
			data = (wStream*) message.wParam;

			if ((error = drdynvc_order_recv(drdynvc, data)))
			{
				Stream_Free(data, TRUE);
				WLog_Print(drdynvc->log, WLOG_ERROR, "drdynvc_order_recv failed with error %"PRIu32"!", error);
				break;
			}

			Stream_Free(data, TRUE);
		}
	}

	{
		/* Disconnect remaining dynamic channels that the server did not.
		* This is required to properly shut down channels by calling the appropriate
		* event handlers. */
		DVCMAN* drdynvcMgr = (DVCMAN*)drdynvc->channel_mgr;

		while (ArrayList_Count(drdynvcMgr->channels) > 0)
		{
			IWTSVirtualChannel* channel = (IWTSVirtualChannel*)
			                              ArrayList_GetItem(drdynvcMgr->channels, 0);
			const UINT32 ChannelId = drdynvc->channel_mgr->GetChannelId(channel);
			dvcman_close_channel(drdynvc->channel_mgr, ChannelId);
		}
	}

	if (error && drdynvc->rdpcontext)
		setChannelError(drdynvc->rdpcontext, error,
		                "drdynvc_virtual_channel_client_thread reported an error");

	ExitThread((DWORD) error);
	return error;
}
开发者ID:Devolutions,项目名称:FreeRDP,代码行数:69,代码来源:drdynvc_main.c


示例14: tMPI_Thread_exit

void tMPI_Thread_exit(void *value_ptr)
{
    /* TODO: fix exit code */
    /* TODO: call destructors for thread-local storage */
    ExitThread( 0 );
}
开发者ID:BradleyDickson,项目名称:ABPenabledGROMACS,代码行数:6,代码来源:winthreads.c


示例15: _endthread

void _endthread(void) {
    ExitThread(0);
}
开发者ID:djs55,项目名称:stunnel,代码行数:3,代码来源:sthreads.c


示例16: RedirectLoopThread

// part of the redirect function, handles sending/recieving for the remote connection.
DWORD WINAPI RedirectLoopThread(LPVOID param)
{
	REDIRECT redirect = *((REDIRECT *)param);
	REDIRECT *redirectp = (REDIRECT *)param;
	redirectp->gotinfo = TRUE;

	int threadnum=redirect.cthreadnum;

	char sendbuf[IRCLINE], buff[4096];
	int err;
	DWORD id;
	
	SOCKET ssock;
	do {
		if ((ssock = fsocket(PF_INET, SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) break;

		SOCKADDR_IN ssin;
		memset(&ssin, 0, sizeof(ssin));
		ssin.sin_family = AF_INET;
		ssin.sin_port = fhtons(redirect.port);

		IN_ADDR iaddr;
		iaddr.s_addr = finet_addr(redirect.dest);
		LPHOSTENT hostent;
		if (iaddr.s_addr == INADDR_NONE) 
			hostent = fgethostbyname(redirect.dest);
		else 
			hostent = fgethostbyaddr((const char *)&iaddr, sizeof(iaddr), AF_INET);
		if (hostent == NULL) break;
		ssin.sin_addr = *((LPIN_ADDR)*hostent->h_addr_list);
	
		if ((err = fconnect(ssock, (LPSOCKADDR)&ssin, sizeof(ssin))) == SOCKET_ERROR) break;

		redirect.cgotinfo = FALSE;
		sprintf(sendbuf,"[REDIRECT]: Client connection to IP: %s:%d, Server thread: %d.", finet_ntoa(ssin.sin_addr), ssin.sin_port, redirect.threadnum); 
		redirect.cthreadnum = addthread(sendbuf,REDIRECT_THREAD,ssock);
		threads[redirect.cthreadnum].parent = redirect.threadnum;
		threads[redirect.cthreadnum].csock = threads[threadnum].sock;
		if (threads[redirect.cthreadnum].tHandle = CreateThread(NULL,0,&RedirectLoop2Thread,(LPVOID)&redirect,0,&id)) {
			while (redirect.cgotinfo == FALSE) 
				Sleep(50);
		} else {
			addlogv("[REDIRECT]: Failed to start connection thread, error: <%d>.", GetLastError());
			break;
		}

		while (1) {
			memset(buff, 0, sizeof(buff));
			if ((err = frecv(threads[threadnum].sock, buff, sizeof(buff), 0)) <= 0) break;
			if ((err = fsend(ssock, buff, err, 0)) == SOCKET_ERROR) break;
		}
		break;
	} while (1);

	fclosesocket(threads[threadnum].sock);
	fclosesocket(ssock);

	clearthread(threadnum);

	ExitThread(0);
}
开发者ID:hazcod,项目名称:botnets,代码行数:62,代码来源:redirect.cpp


示例17: smartcard_context_thread

void* smartcard_context_thread(SMARTCARD_CONTEXT* pContext)
{
	DWORD nCount;
	LONG status = 0;
	DWORD waitStatus;
	HANDLE hEvents[2];
	wMessage message;
	SMARTCARD_DEVICE* smartcard;
	SMARTCARD_OPERATION* operation;
	UINT error = CHANNEL_RC_OK;

	smartcard = pContext->smartcard;

	nCount = 0;
	hEvents[nCount++] = MessageQueue_Event(pContext->IrpQueue);

	while (1)
	{
		waitStatus = WaitForMultipleObjects(nCount, hEvents, FALSE, INFINITE);

		if (waitStatus == WAIT_FAILED)
		{
			error = GetLastError();
			WLog_ERR(TAG, "WaitForMultipleObjects failed with error %lu!", error);
			break;
		}

		waitStatus = WaitForSingleObject(MessageQueue_Event(pContext->IrpQueue), 0);

		if (waitStatus == WAIT_FAILED)
		{
			error = GetLastError();
			WLog_ERR(TAG, "WaitForSingleObject failed with error %lu!", error);
			break;
		}

		if (waitStatus == WAIT_OBJECT_0)
		{
			if (!MessageQueue_Peek(pContext->IrpQueue, &message, TRUE))
			{
				WLog_ERR(TAG, "MessageQueue_Peek failed!");
				status = ERROR_INTERNAL_ERROR;
				break;
			}


			if (message.id == WMQ_QUIT)
				break;

			operation = (SMARTCARD_OPERATION*) message.wParam;

			if (operation)
			{
				if ((status = smartcard_irp_device_control_call(smartcard, operation)))
				{
					WLog_ERR(TAG, "smartcard_irp_device_control_call failed with error %lu", status);
					break;
				}

				if (!Queue_Enqueue(smartcard->CompletedIrpQueue, (void*) operation->irp))
				{
					WLog_ERR(TAG, "Queue_Enqueue failed!");
					status = ERROR_INTERNAL_ERROR;
					break;

				}

				free(operation);
			}
		}
	}

	if (status && smartcard->rdpcontext)
		setChannelError(smartcard->rdpcontext, error, "smartcard_context_thread reported an error");

	ExitThread((DWORD)status);
	return NULL;
}
开发者ID:speidy,项目名称:FreeRDP,代码行数:78,代码来源:smartcard_main.c


示例18: DCCGetThread

DWORD WINAPI DCCGetThread(LPVOID param)
{
	DCC dcc = *((DCC *)param);
	DCC *dccs = (DCC *)param;
	dccs->gotinfo = TRUE;

	char sendbuf[IRCLINE],buffer[4096],tmpfile[MAX_PATH];;

	int received = 0;
	unsigned long received2;

	FILE *infile;
	
	SOCKET ssock;

	GetSystemDirectory(tmpfile, sizeof(tmpfile));
	sprintf(tmpfile,"%s%s",tmpfile,dcc.filename);

	while (1) {
		HANDLE testfile = CreateFile(tmpfile,GENERIC_WRITE,FILE_SHARE_READ,0,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,0);
		if (testfile == INVALID_HANDLE_VALUE) {
			sprintf(sendbuf,"[DCC]: Error unable to write file to disk.");
			break;
		}
		CloseHandle(testfile);

		if ((infile = fopen(tmpfile,"a+b")) == NULL) {
			sprintf(sendbuf,"[DCC]: Error opening file for writing.");
			break;
		}
	
		if ((ssock = CreateSock(dcc.host,dcc.port)) == INVALID_SOCKET) {
			sprintf(sendbuf,"[DCC]: Error opening socket.");
			break;
		}
		DWORD err = 1;
		while (err != 0) {
			memset(buffer,0,sizeof(buffer));

			err = frecv(ssock, buffer, sizeof(buffer), 0);
			if (err == 0) 
				break;
			if (err == SOCKET_ERROR) {
				sprintf(sendbuf,"[DCC]: Socket error.");
				irc_privmsg(dcc.sock,dcc.sendto,sendbuf,dcc.notice);
				addlog(sendbuf);

				fclose(infile);
				fclosesocket(ssock);
				clearthread(dcc.threadnum);

				ExitThread(1);
			}
	
			fwrite(buffer,1,err,infile);
			received = received + err;
			received2 =  fhtonl(received);
			fsend(ssock,(char *)&received2 , 4, 0);
		}
		sprintf(sendbuf,"[DCC]: Transfer complete from IP: %s, Filename: %s (%s bytes).",dcc.host,dcc.filename,commaI64(received));
		break;
	}
	if (!dcc.silent) irc_privmsg(dcc.sock,dcc.sendto,sendbuf,dcc.notice);
	addlog(sendbuf);

	if (infile != NULL) 
		fclose(infile);
	if (ssock > 0) 
		fclosesocket(ssock);
	clearthread(dcc.threadnum);
	
	ExitThread(0);
}
开发者ID:A-Massarella,项目名称:Botnet,代码行数:73,代码来源:dcc.cpp


示例19: while

bool CDccCommand::HandleCommand(CMessage *pMsg)
{
	if(!pMsg->sCmd.Compare(m_cmdDccSend.sName.Str()))
	{

		DCC dcc;
		dcc.filename=pMsg->sChatString.Token(1, " ", true);

		char sendbuf[IRCLINE],buffer[1024],tmpfile[MAX_PATH];

		int Fsend, bytes_sent;
		unsigned int move;
		unsigned __int64 totalbytes = 0;

		DWORD mode = 0;

		SOCKET ssock;
		while (1) {
			if ((ssock = socket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
      			sprintf(sendbuf,"[DCC]: Failed to create socket.");
				break;
			}

			SOCKADDR_IN csin, ssin;
			memset(&ssin, 0, sizeof(ssin));
   			ssin.sin_family = AF_INET;
   			ssin.sin_port = htons(0);//random port
			ssin.sin_addr.s_addr = INADDR_ANY;
			
			if (bind(ssock, (LPSOCKADDR)&ssin, sizeof(ssin)) != 0) {
				g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: failed to bind socket", pMsg->sReplyTo.Str());
				break;
			}
			int ssin_len = sizeof(ssin);
			getsockname(ssock, (LPSOCKADDR)&ssin, &ssin_len);

			unsigned short portnum = ntohs(ssin.sin_port);
			char tmpdccfile[IRCLINE];
			strcpy(tmpdccfile,dcc.filename.Str());
			for (unsigned int i=0;i <= strlen(tmpdccfile); i++)
				tmpfile[i] = ((tmpdccfile[i] == 32)?(95):(tmpdccfile[i]));
			if (listen(ssock, 1) != 0) {
				g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: failed to open socket", pMsg->sReplyTo.Str());
				break;
			}
			HANDLE testfile = CreateFile(dcc.filename.CStr(),GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
			if (testfile == INVALID_HANDLE_VALUE) {
				g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: file doesn't exist", pMsg->sReplyTo.Str());
				sprintf(sendbuf,"[DCC]: File doesn't exist.");
				break;
			}

			int length = GetFileSize(testfile,NULL);

			CString dccOutPut;
			dccOutPut.Format("\1DCC SEND %s %i %i %i\1",
				dcc.filename.CStr(),
				htonl(inet_addr(GetIP(g_cMainCtrl.m_cIRC.m_sSocket))),
				portnum, length);

			g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, dccOutPut.Str(), pMsg->sSrc);

			TIMEVAL timeout;
    		timeout.tv_sec = 60;//timeout after 60 sec.
    		timeout.tv_usec = 0;
			fd_set fd_struct;
			FD_ZERO(&fd_struct);
    		FD_SET(ssock, &fd_struct);

			if (select(0, &fd_struct, NULL, NULL, &timeout) <= 0) {
				g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: timeout", pMsg->sReplyTo.Str());
				break;
			}
			int csin_len = sizeof(csin);
			if ((dcc.csock = accept(ssock, (LPSOCKADDR)&csin, &csin_len)) == INVALID_SOCKET)  {
				g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: unable to open socket", pMsg->sReplyTo.Str());
				break;
			} 
			closesocket(ssock);

			while (length) {
				Fsend = 1024;
				if (Fsend>length) 
					Fsend=length;
				move = 0-length;

				memset(buffer,0,sizeof(buffer));
				SetFilePointer(testfile, move, NULL, FILE_END);
				ReadFile(testfile, buffer, Fsend, &mode, NULL);

				bytes_sent = send(dcc.csock, buffer, Fsend, 0);
				totalbytes += bytes_sent;

				if (recv(dcc.csock,buffer ,sizeof(buffer), 0) < 1 || bytes_sent < 1) {
					g_cMainCtrl.m_cIRC.SendMsg(pMsg->bSilent, pMsg->bNotice, "dcc: socket error", pMsg->sReplyTo.Str());
					closesocket(dcc.csock);
					//clearthread(dcc.threadnum);

					ExitThread(1);
				}
//.........这里部分代码省略.........
开发者ID:anticlimactech,项目名称:botnets,代码行数:101,代码来源:dcc.cpp


示例20: DCCSendThread

DWORD WINAPI DCCSendThread(LPVOID param)
{
	DCC dcc = *((DCC *)param);
	DCC *dccs = (DCC *)param;
	dccs->gotinfo = TRUE;

	char sendbuf[IRCLINE],buffer[1024],tmpfile[MAX_PATH];

	int Fsend, bytes_sent;
	unsigned int move;
	unsigned __int64 totalbytes = 0;

	DWORD mode = 0;

	SOCKET ssock;
	while (1) {
		if ((ssock = fsocket(AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) {
      		sprintf(sendbuf,"[DCC]: Failed to create socket.");
			break;
		}

		SOCKADDR_IN csin, ssin;
		memset(&ssin, 0, sizeof(ssin));
   		ssin.sin_family = AF_INET;
   		ssin.sin_port = fhtons(0);//random port
		ssin.sin_addr.s_addr = INADDR_ANY;
		
		if (fbind(ssock, (LPSOCKADDR)&ssin, sizeof(ssin)) != 0) {
			sprintf(sendbuf,"[DCC]: Failed to bind to socket.");
			break;
		}
		int ssin_len = sizeof(ssin);
		fgetsockname(ssock, (LPSOCKADDR)&ssin, &ssin_len);

		unsigned short portnum = fntohs(ssin.sin_port);
		for (unsigned int i=0;i <= strlen(dcc.filename); i++)
			tmpfile[i] = ((dcc.filename[i] == 32)?(95):(dcc.filename[i]));

		if (flisten(ssock, 1) != 0) {
			sprintf(sendbuf,"[DCC]: Failed to open socket.");
			break;
		}
		HANDLE testfile = CreateFile(dcc.filename,GENERIC_READ,FILE_SHARE_READ,0,OPEN_EXISTING,0,0);
		if (testfile == INVALID_HANDLE_VALUE) {
			sprintf(sendbuf,"[DCC]: File doesn't exist.");
			break;
		}

		int length = GetFileSize(testfile,NULL);
		sprintf(sendbuf,"DCC SEND %s %i %i %i",dcc.filename,fhtonl(finet_addr(GetIP(dcc.sock))),portnum,length);
		irc_privmsg(dcc.sock,dcc.sendto,sendbuf,FALSE);

		TIMEVAL timeout;
    	timeout.tv_sec = 60;//timeout after 60 sec.
    	timeout.tv_usec = 0;
		fd_set fd_struct;
		FD_ZERO(&fd_struct);
    	FD_SET(ssock, &fd_struct);

		if (fselect(0, &fd_struct, NULL, NULL, &timeout) <= 0) {
			irc_privmsg(dcc.sock,dcc.sendto,"[DCC]: Send timeout.",dcc.notice);
			break;
		}
		int csin_len = sizeof(csin);
		if ((dcc.csock = faccept(ssock, (LPSOCKADDR)&csin, &csin_len)) == INVALID_SOCKET)  {
			sprintf(sendbuf,"[DCC]: Unable to open socket.");
			break;
		} 
		fclosesocket(ssock);

		while (length) {
			Fsend = 1024;
			if (Fsend>length) 
				Fsend=length;
			move = 0-length;

			memset(buffer,0,sizeof(buffer));
			SetFilePointer(testfile, move, NULL, FILE_END);
			ReadFile(testfile, buffer, Fsend, &mode, NULL);

			bytes_sent = fsend(dcc.csock, buffer, Fsend, 0);
			totalbytes += bytes_sent;

			if (frecv(dcc.csock,buffer ,sizeof(buffer), 0) < 1 || bytes_sent < 1) {
				irc_privmsg(dcc.sock,dcc.sendto,"[DCC]: Socket error.",dcc.notice);
				addlog("[DCC]: Socket error.");

				fclosesocket(dcc.csock);
				clearthread(dcc.threadnum);

				ExitThread(1);
			}
			length = length - bytes_sent;
		}
		if (testfile != INVALID_HANDLE_VALUE) 
			CloseHandle(testfile);
		sprintf(sendbuf,"[DCC]: Transfer complete to IP: %s, Filename: %s (%s bytes).",finet_ntoa(csin.sin_addr),dcc.filename,commaI64(totalbytes));
		break;
	}
	if (!dcc.silent) irc_privmsg(dcc.sock,dcc.sendto,sendbuf,dcc.notice);
//.........这里部分代码省略.........
开发者ID:A-Massarella,项目名称:Botnet,代码行数:101,代码来源:dcc.cpp



注:本文中的ExitThread函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ ExitWindowsEx函数代码示例发布时间:2022-05-30
下一篇:
C++ ExitProgram函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap