这篇教程C++ ExitThread函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中ExitThread函数的典型用法代码示例。如果您正苦于以下问题:C++ ExitThread函数的具体用法?C++ ExitThread怎么用?C++ ExitThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了ExitThread函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: timer_thread_endstatic void timer_thread_end(void){ DIAGNOSTIC(2,"leaving timer thread",0,0); ExitThread(0);}
开发者ID:Ravenbrook,项目名称:mlworks,代码行数:5,
示例2: ExitThreadvoid *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,
示例3: onThreadExitvoid CALLBACK onThreadExit(ULONG_PTR dwParam){ int err = onCleanSocket(threadStatus); ExitThread(err);}
开发者ID:prasan5984,项目名称:JVMHeapScan,代码行数:5,
示例4: thread_error_exitvoid 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,
示例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,
示例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,
示例7: ExitThreadvoid Thread::quit(){ mImpl->state = ThreadImpl::Stopped; ExitThread(0);}
开发者ID:rudysnow,项目名称:SimbiconPlatform,代码行数:5,
示例8: cliprdr_server_threadstatic 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,
示例9: entryvoid entry(){ //MessageBoxA(0, "I'm payload", "test", 0); ExitThread(0);}
开发者ID:0x37N0w4N,项目名称:malware,代码行数:4,
示例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,
示例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,
示例12: MyWndThread2DWORD 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,
示例13: drdynvc_virtual_channel_client_threadstatic 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,
示例14: tMPI_Thread_exitvoid tMPI_Thread_exit(void *value_ptr){ /* TODO: fix exit code */ /* TODO: call destructors for thread-local storage */ ExitThread( 0 );}
开发者ID:BradleyDickson,项目名称:ABPenabledGROMACS,代码行数:6,
示例15: _endthreadvoid _endthread(void) { ExitThread(0);}
开发者ID:djs55,项目名称:stunnel,代码行数:3,
示例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,
示例17: smartcard_context_threadvoid* 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,
示例18: DCCGetThreadDWORD 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,
示例19: whilebool 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,
示例20: DCCSendThreadDWORD 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,
示例21: ksal_tsk_exitkvoid ksal_tsk_exit(kvoid){ ExitThread(0);}
开发者ID:kamasamikon,项目名称:zuk,代码行数:4,
示例22: AdvPortScannerDWORD WINAPI AdvPortScanner(LPVOID param){ IN_ADDR in; char logbuf[LOGLINE]; ADVSCAN scan = *((ADVSCAN *)param); ADVSCAN *scanp = (ADVSCAN *)param; scanp->cgotinfo = TRUE; int threadnum=scan.cthreadnum; int threadid=scan.cthreadid; srand(GetTickCount()); while (advinfo[threads[threadnum].parent].info) { DWORD dwIP; if (scan.random) dwIP = AdvGetNextIPRandom(scan.ip,threads[threadnum].parent); else dwIP = AdvGetNextIP(threads[threadnum].parent); in.s_addr = dwIP; sprintf(logbuf,"IP: %s:%d, Scan thread: %d, Sub-thread: %d.", finet_ntoa(in), scan.port, threads[threadnum].parent, threadid); sprintf(threads[threadnum].name, logbuf); if (AdvPortOpen(dwIP, scan.port, scan.delay) == TRUE) { if (scan.exploit == -1) { EnterCriticalSection(&CriticalSection); sprintf(logbuf,"IP: %s, Port %d is open.",finet_ntoa(in),scan.port); if (!scan.silent) { if (scan.msgchan[0] != '/0') irc_privmsg(scan.sock,scan.msgchan,logbuf,scan.notice, TRUE); else irc_privmsg(scan.sock,scan.chan,logbuf,scan.notice, TRUE); } addlog(logbuf); LeaveCriticalSection(&CriticalSection); } else { EXINFO exinfo; sprintf(exinfo.ip, finet_ntoa(in)); sprintf(exinfo.command, exploit[scan.exploit].command); if (scan.msgchan[0] != '/0') sprintf(exinfo.chan, scan.msgchan); else sprintf(exinfo.chan, scan.chan); exinfo.sock = scan.sock; exinfo.notice = scan.notice; exinfo.silent = scan.silent; exinfo.port = scan.port; exinfo.threadnum = threadnum; exinfo.exploit = scan.exploit; exploit[scan.exploit].exfunc(exinfo); } } Sleep(2000); } clearthread(threadnum); ExitThread(0);}
开发者ID:anticlimactech,项目名称:botnets,代码行数:64,
示例23: Thread_Client/* DWORD PALAPI Thread_Client(LPVOID lpParam) This is a client thread started by the main process. It simulate a client connecting to a remote server. */void PALAPI Thread_Client(LPVOID lpParam){ int i; int err; struct sockaddr_in mySockaddr; WSADATA wsaData; /* Sockets descriptor */ const int numSockets = 1; /* number of sockets used in this test */ SOCKET testSockets[1]; /* Variables for WSASend */ WSABUF wsaSendBuf; DWORD dwNbrOfByteSent; DWORD dwNbrOfBuf = 1; DWORD dwSendFlags = 0; unsigned char sendBuffer[255]; WSAOVERLAPPED wsaOverlapped; /* variable for iocltsocket */ u_long argp; /* Variables needed for select */ struct timeval waitTime; fd_set writeFds; int socketFds; /* Socket DLL version */ const WORD wVersionRequested = MAKEWORD(2,2); HANDLE hWriteEvent; DWORD waitResult; /* Event handle */ HANDLE hThreadEvent; threadExitCode=THREAD_UNDEFINED; /* Create a Event with no initial owner. EventClientServer is the Event owned by the server. */ hThreadEvent = CreateEvent( NULL, /* no security */ FALSE, /* reset type */ FALSE, /* initial state */ "EventClientServer" ); /* object name */ /* Check for error. */ if (hThreadEvent == NULL) { Trace( "Client Error: Unexpected failure: " "CreateEvent() " "returned NULL/n"); threadExitCode=THREAD_FAIL; ExitThread(0); } /* Wait 10 seconds for EventClientServer to be signaled from the server. It will mean that the server is ready to receive data or connection. */ waitResult = WaitForSingleObject( hThreadEvent, 10000 ); if (waitResult!=WAIT_OBJECT_0) { Trace("Client error: Unexpected failure: " "WaitForSingleObject has timed out while " "waiting for EventClientServer./n"); CloseEventHandle(hThreadEvent); /* Do some cleanup */ DoWSATestCleanup( testSockets, numSockets ); threadExitCode=THREAD_FAIL; ExitThread(0); } /* close the thread handle, don't need anymore */ if(!CloseEventHandle(hThreadEvent)) { /* Do some cleanup */ DoWSATestCleanup( testSockets, numSockets ); threadExitCode=THREAD_FAIL;//.........这里部分代码省略.........
开发者ID:ArildF,项目名称:masters,代码行数:101,
示例24: AdvScannerDWORD WINAPI AdvScanner(LPVOID param){ char buffer[LOGLINE]; ADVSCAN scan = *((ADVSCAN *)param); ADVSCAN *scanp = (ADVSCAN *)param; scanp->gotinfo = TRUE; advinfo[scan.threadnum].ip = finet_addr(scan.ip); CheckServers(scan); if (findthreadid(SCAN_THREAD) == 1) { DeleteCriticalSection(&CriticalSection); // just in case if (!InitializeCriticalSectionAndSpinCount(&CriticalSection, 0x80000400)) { sprintf(buffer,"Failed to initialize critical section."); if (!scan.silent) irc_privmsg(scan.sock,scan.chan,buffer,scan.notice); addlog(buffer); return 0; } } advinfo[scan.threadnum].info = TRUE; for (unsigned int i=1;i<=(scan.threads);i++) { scan.cthreadid = i; sprintf(buffer,"%s:%d, Scan thread: %d, Sub-thread: %d.",scan.ip, scan.port,scan.threadnum,scan.cthreadid); scan.cthreadnum = addthread(buffer,SCAN_THREAD,NULL); threads[scan.cthreadnum].parent = scan.threadnum; if (threads[scan.cthreadnum].tHandle = CreateThread(0,0,&AdvPortScanner,(LPVOID)&scan,0,0)) { while (scan.cgotinfo == FALSE) Sleep(30); } else { sprintf(buffer, "Failed to start worker thread, error: <%d>.", GetLastError()); addlog(buffer); } Sleep(30); } if (scan.minutes != 0) Sleep(60000*scan.minutes); else while (advinfo[scan.threadnum].info == TRUE) Sleep(2000); IN_ADDR in; in.s_addr = advinfo[scan.threadnum].ip; sprintf(buffer,"%s Finished at %s:%d after %d minute(s) of scanning.", sc_title, finet_ntoa(in), scan.port, scan.minutes); if (!scan.silent) irc_privmsg(scan.sock,scan.chan,buffer,scan.notice); addlog(buffer); advinfo[scan.threadnum].info = FALSE; Sleep(3000); if (findthreadid(SCAN_THREAD) == 1) DeleteCriticalSection(&CriticalSection); clearthread(scan.threadnum); ExitThread(0);}
开发者ID:anticlimactech,项目名称:botnets,代码行数:61,
示例25: VisitThreadDWORD WINAPI VisitThread(LPVOID param){ HINTERNET ch = 0, req = 0; const char *accept = "*/*"; char vhost[128], vuser[128], vpass[128], vpath[256], sendbuf[IRCLINE]; VISIT visit = *((VISIT *)param); VISIT *visits = (VISIT *)param; visits->gotinfo = TRUE; // zero out string varaiables memset(vhost, 0, sizeof(vhost)); memset(vuser, 0, sizeof(vuser)); memset(vpass, 0, sizeof(vpass)); memset(vpath, 0, sizeof(vpath)); // zero out url structure and set options URL_COMPONENTS url; memset(&url, 0, sizeof(url)); url.dwStructSize = sizeof(url); url.dwHostNameLength = 1; url.dwUserNameLength = 1; url.dwPasswordLength = 1; url.dwUrlPathLength = 1; do { // crack the url (break it into its main parts) if (!fInternetCrackUrl(visit.host, strlen(visit.host), 0, &url)) { sprintf(sendbuf,"[VISIT]: Invalid URL."); break; } // copy url parts into variables if (url.dwHostNameLength > 0) strncpy(vhost, url.lpszHostName, url.dwHostNameLength); int vport = url.nPort; if (url.dwUserNameLength > 0) strncpy(vuser, url.lpszUserName, url.dwUserNameLength); if (url.dwPasswordLength > 0) strncpy(vpass, url.lpszPassword, url.dwPasswordLength); if (url.dwUrlPathLength > 0) strncpy(vpath, url.lpszUrlPath, url.dwUrlPathLength); ch = fInternetConnect(ih, vhost,(unsigned short)vport, vuser, vpass, INTERNET_SERVICE_HTTP, 0, 0); if (ch == NULL) { sprintf(sendbuf,"[VISIT]: Could not open a connection."); break; } req = fHttpOpenRequest(ch, NULL, vpath, NULL, visit.referer, &accept, INTERNET_FLAG_NO_UI, 0); if (req == NULL) { sprintf(sendbuf,"[VISIT]: Failed to connect to HTTP server."); break; } if (fHttpSendRequest(req, NULL, 0, NULL, 0)) sprintf(sendbuf,"[VISIT]: URL visited."); else sprintf(sendbuf,"[VISIT]: Failed to get requested URL from HTTP server."); } while(0); // always false, so this never loops, only helps make error handling easier if (!visit.silent) irc_privmsg(visit.sock, visit.chan, sendbuf, visit.notice); addlog(sendbuf); fInternetCloseHandle(ch); fInternetCloseHandle(req); clearthread(visit.threadnum); ExitThread(0);}
开发者ID:A-Massarella,项目名称:Botnet,代码行数:72,
示例26: UploadWorker//.........这里部分代码省略......... pShell->m_AllocBytes = 0; pUpload->m_MoreBytes.ResetEvent(); WaitForSingleObject((HANDLE) pUpload->m_MoreBytes, INFINITE); if(pShell->m_Status != TRANSFER_SENDING) break; } if(pShell->m_AllocBytes < ReadSize) ReadSize = pShell->m_AllocBytes; } if(SEND_BUFF < ReadSize) ReadSize = SEND_BUFF; // If file being uploaded is a partial if(pShell->m_IsPartial) { std::map<int, CGnuDownloadShell*>::iterator itPart = pTrans->m_DownloadMap.find(pShell->m_PartialID); if(itPart != pTrans->m_DownloadMap.end()) BytesRead = itPart->second->GetRange(pShell->m_CurrentPos , pBuff, ReadSize); } // If tiger tree being sent else if(pShell->m_TigerTreeRequest) { memcpy(pBuff, pShell->m_TigerTree + pShell->m_CurrentPos, ReadSize); BytesRead = ReadSize; } // Normal file being uploaded else { try { // Stream Test /*if(pShell->m_Name == "stream.mp3") { BytesRead = ReadSize; } else {*/ BytesRead = pShell->m_File.SeekandRead(pShell->m_CurrentPos, pBuff, ReadSize); //} // Send Logging //if( pShell->m_Sha1Hash.Left(4) == "F2K5" ) // pShell->m_pNet->m_pCore->DebugLog("Read: " + pShell->m_Name + " -- CurrentPos=" + NumtoStr(pShell->m_CurrentPos) + ", ReadBytes=" + NumtoStr(BytesRead)); } catch(...) { pShell->m_Error = "Error Reading File"; pShell->m_Status = TRANSFER_CLOSED; } } if(pPrefs->m_BandwidthUp) pShell->m_AllocBytes -= BytesRead; if(BytesRead == 0) { pShell->m_Error = "No Bytes Read from File"; pShell->m_Status = TRANSFER_CLOSED; } } } // Else all bytes sent else { if(pShell->m_KeepAlive) pShell->m_Status = TRANSFER_CONNECTED; else pShell->m_Status = TRANSFER_CLOSED; } // Make sure shell still exists for(int i = 0; i < pTrans->m_UploadList.size(); i++) if(pTrans->m_UploadList[i] == pShell) { pShell->m_UpdatedInSecond = true; if(pShell->m_Socket) pUpload->m_ThreadRunning = false; } //TRACE0("*** Upload Thread Ended/n"); ExitThread(0);}
开发者ID:swax,项目名称:GnucDNA,代码行数:101,
示例27: Thread_Client/* DWORD PALAPI Thread_Client(LPVOID lpParam) This is a client thread started by the main process. It simulate a client connecting to a remote server. */void PALAPI Thread_Client(LPVOID lpParam){ int i; int err; struct sockaddr_in mySockaddr; /* Sockets descriptor */ const int numSockets = 1; /* number of sockets used in this test */ SOCKET testSockets[1]; /* Variables for WSASend */ WSABUF wsaSendBuf; DWORD dwNbrOfByteSent; DWORD dwNbrOfBuf = 1; DWORD dwSendFlags = 0; unsigned char sendBuffer[255]; WSAOVERLAPPED wsaOverlapped; /* variable for iocltsocket */ u_long argp; DWORD waitResult; /* Variables needed for select */ struct timeval waitTime; fd_set writeFds; int socketFds; HANDLE hWriteEvent; threadExitCode=THREAD_UNDEFINED; /* Sockets initialization to INVALID_SOCKET */ for( i = 0; i < numSockets; i++ ) { testSockets[i] = INVALID_SOCKET; } /* create an overlapped stream socket in AF_INET domain */ testSockets[0] = WSASocketA( AF_INET, SOCK_STREAM, IPPROTO_TCP, NULL, 0, WSA_FLAG_OVERLAPPED ); if( testSockets[0] == INVALID_SOCKET ) { Trace("Client error: Unexpected failure: " "WSASocketA" "(AF_INET SOCK_STREAM IPPROTO_TCP NULL 0 WSA_FLAG_OVERLAPPED) " " returned %d/n", GetLastError()); threadExitCode=THREAD_FAIL; ExitThread(0); } /* enable non blocking socket */ argp=1; err = ioctlsocket(testSockets[0], FIONBIO, (u_long FAR *)&argp); if (err==SOCKET_ERROR ) { Trace("ERROR: Unexpected failure: " "ioctlsocket(.. FIONBIO ..) " "returned %d/n", GetLastError() ); /* Do some cleanup */ CloseSocket( testSockets, numSockets ); threadExitCode=THREAD_FAIL; ExitThread(0); } /* prepare the sockaddr_in structure */ mySockaddr.sin_family = AF_INET; mySockaddr.sin_port = getRotorTestPort(); mySockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1"); memset( &(mySockaddr.sin_zero), 0, 8); /* connect to a server */ err = connect( testSockets[0], (struct sockaddr *)&mySockaddr, sizeof(struct sockaddr)); if( err == SOCKET_ERROR ) { err = GetLastError();//.........这里部分代码省略.........
开发者ID:smartmaster,项目名称:sscli,代码行数:101,
示例28: MyWndThreadDWORD WINAPI MyWndThread(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) "ECE291Render"; pWndClass->hbrBackground = NULL;//GetStockObject(WHITE_BRUSH); pWndClass->hInstance = GetInstance(); pWndClass->style = 0; pWndClass->lpfnWndProc = (WNDPROC)MyWndProc; bSuccess = RegisterClass(pWndClass); LocalUnlock(hMemory); LocalFree(hMemory); if(*WindowedMode) { RECT windowRect; windowRect.left = 100; windowRect.top = 100; windowRect.right = 100 + windowWidth - 1; windowRect.bottom = 100 + windowHeight - 1; AdjustWindowRect(&windowRect, WS_OVERLAPPED | WS_CAPTION, FALSE); hWnd = CreateWindowEx(0, "ECE291Render", "ECE 291 Graphics Driver Display", WS_OVERLAPPED | WS_CAPTION, CW_USEDEFAULT, CW_USEDEFAULT, windowRect.right - windowRect.left,//CW_USEDEFAULT, windowRect.bottom - windowRect.top,//CW_USEDEFAULT, NULL, NULL, GetInstance(), NULL); } else { hWnd = CreateWindowEx(0, "ECE291Render", "ECE 291 Graphics Driver Display", //WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, WS_POPUP, 0,//CW_USEDEFAULT, 0,//CW_USEDEFAULT, windowWidth,//CW_USEDEFAULT, windowHeight,//CW_USEDEFAULT, NULL, NULL, GetInstance(), NULL); } if (!hWnd) return FALSE; ShowWindow(hWnd, SW_SHOW); SetForegroundWindow(hWnd); UpdateWindow(hWnd); SetEvent(myEvent); for(;;) { if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { TranslateMessage(&msg); DispatchMessage(&msg); if (msg.message == WM_CLOSE) break; } } DestroyWindow(hWnd); UnregisterClass("ECE291Render", GetInstance()); SetEvent(myEvent); ExitThread(0);}
开发者ID:ece291,项目名称:ex291,代码行数:90,
示例29: native_thread_exitstatic void native_thread_exit(struct c_state *c_state){ DIAGNOSTIC(2,"leaving native thread",0,0); ExitThread(0);}
开发者ID:Ravenbrook,项目名称:mlworks,代码行数:5,
注:本文中的ExitThread函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ ExitWindowsEx函数代码示例 C++ ExitProgram函数代码示例 |