这篇教程C++ GetExitCodeThread函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetExitCodeThread函数的典型用法代码示例。如果您正苦于以下问题:C++ GetExitCodeThread函数的具体用法?C++ GetExitCodeThread怎么用?C++ GetExitCodeThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetExitCodeThread函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: TSC_LOCK_INITunsigned int TscThreadExecutor::multi_thread(ThreadProc threadProc){ TSC_THREAD *threadHandles = new TSC_THREAD[_settings._jobs]; TSC_LOCK_INIT(&_fileSync); TSC_LOCK_INIT(&_errorSync); TSC_LOCK_INIT(&_reportSync);#ifdef TSC_THREADING_MODEL_WIN for (unsigned int i = 0; i < _settings._jobs; ++i) { threadHandles[i] = (HANDLE)_beginthreadex(NULL, 0, threadProc, this, 0, NULL); if (!threadHandles[i]) { std::cerr << "#### ./nTscThreadExecutor::check error, errno :" << errno << std::endl; exit(EXIT_FAILURE); } } DWORD waitResult = WaitForMultipleObjects(_settings._jobs, threadHandles, TRUE, INFINITE); if (waitResult != WAIT_OBJECT_0) { if (waitResult == WAIT_FAILED) { std::cerr << "#### ./nTscThreadExecutor::check wait failed, result: " << waitResult << " error: " << GetLastError() << std::endl; exit(EXIT_FAILURE); } else { std::cerr << "#### ./nTscThreadExecutor::check wait failed, result: " << waitResult << std::endl; exit(EXIT_FAILURE); } } unsigned int result = 0; for (unsigned int i = 0; i < _settings._jobs; ++i) { DWORD exitCode; if (!GetExitCodeThread(threadHandles[i], &exitCode)) { std::cerr << "#### ./nTscThreadExecutor::check get exit code failed, error:" << GetLastError() << std::endl; exit(EXIT_FAILURE); } result += exitCode; if (!CloseHandle(threadHandles[i])) { std::cerr << "#### ./nTscThreadExecutor::check close handle failed, error:" << GetLastError() << std::endl; exit(EXIT_FAILURE); } }#else for (unsigned int i = 0; i < _settings._jobs; ++i) { int ret = pthread_create(&threadHandles[i], nullptr, threadProc, this); if (ret) { std::cerr << "#### ./nTscThreadExecutor::check error, errno :" << ret << std::endl; exit(EXIT_FAILURE); } } unsigned int result = 0; void* tret = nullptr; for (int i = 0; i < _settings._jobs; ++i) { int ret = pthread_join(threadHandles[i], &tret); if (ret) { std::cerr << "#### ./nTscThreadExecutor::check get exit code failed, error:" << ret << std::endl; exit(EXIT_FAILURE); } result += (unsigned int)(intptr_t)(tret); }#endif TSC_LOCK_DELETE(&_fileSync); TSC_LOCK_DELETE(&_errorSync); TSC_LOCK_DELETE(&_reportSync); delete[] threadHandles; return result;}
开发者ID:hxofgithub,项目名称:TscanCode,代码行数:79,
示例2: WndProc//.........这里部分代码省略......... ofn.lpstrFileTitle = NULL ; // Set in Open and Close functions ofn.nMaxFileTitle = MAX_PATH ; ofn.lpstrInitialDir = NULL ; ofn.lpstrTitle = NULL ; ofn.Flags = 0 ; // Set in Open and Close functions ofn.nFileOffset = 0 ; ofn.nFileExtension = 0 ; ofn.lpstrDefExt = TEXT ("txt") ; ofn.lCustData = 0L ; ofn.lpfnHook = NULL ; ofn.lpTemplateName = NULL ; ofn.hwndOwner = hwnd ; ofn.lpstrFile = szFileName ; ofn.lpstrFileTitle = szTitleName ; ofn.Flags = OFN_HIDEREADONLY | OFN_CREATEPROMPT ; if (GetOpenFileName(&ofn)) { std::wstring wfilename(szFileName); std::string filename; for(int i = 0; i < wfilename.size(); i++) { filename += wfilename[i]; } ifs = OpenFile(filename); readFile(ifs); DWORD threadID; DWORD exitStatus; if (sendThread == 0 || (GetExitCodeThread(sendThread, &exitStatus) && exitStatus != STILL_ACTIVE)) { sendThread = CreateThread(NULL, 0, sendBufferThread, &global, NULL, &threadID); } } } break; case WM_CHAR: // Process keystroke break; case WM_LBUTTONDOWN: break; case WM_SIZE: cxClient = LOWORD(lParam); cyClient = HIWORD(lParam); si.cbSize = sizeof(si); si.fMask = SIF_ALL; si.nMin = 0; si.nMax = cyClient; si.nPos = 0; si.nPage = 50; SetScrollInfo(hwnd, SB_VERT, &si, TRUE); break; case WM_VSCROLL: si.cbSize = sizeof(si); si.fMask = SIF_ALL; GetScrollInfo(hwnd, SB_VERT, &si); iVertPos = si.nPos; switch(LOWORD(wParam)){ case SB_LINEUP:
开发者ID:kptnkrnch,项目名称:WirelessProtocol,代码行数:67,
示例3: lockVOIDIN_PROCESS_APPLICATION::ShutDownInternal(){ DWORD dwThreadStatus = 0; DWORD dwTimeout = m_pConfig->QueryShutdownTimeLimitInMS(); HANDLE handle = NULL; WIN32_FIND_DATA fileData; if (IsDebuggerPresent()) { dwTimeout = INFINITE; } if (m_fShutdownCalledFromNative || m_status == APPLICATION_STATUS::STARTING || m_status == APPLICATION_STATUS::FAIL) { return; } { SRWLockWrapper lock(m_srwLock); if (m_fShutdownCalledFromNative || m_status == APPLICATION_STATUS::STARTING || m_status == APPLICATION_STATUS::FAIL) { return; } // We need to keep track of when both managed and native initiate shutdown // to avoid AVs. If shutdown has already been initiated in managed, we don't want to call into // managed. We still need to wait on main exiting no matter what. m_fShutdownCalledFromNative // is used for detecting redundant calls and blocking more requests to OnExecuteRequestHandler. m_fShutdownCalledFromNative = TRUE; m_status = APPLICATION_STATUS::SHUTDOWN; if (!m_fShutdownCalledFromManaged) { // We cannot call into managed if the dll is detaching from the process. // Calling into managed code when the dll is detaching is strictly a bad idea, // and usually results in an AV saying "The string binding is invalid" if (!g_fProcessDetach) { m_ShutdownHandler(m_ShutdownHandlerContext); m_ShutdownHandler = NULL; } } // Release the lock before we wait on the thread to exit. } if (!m_fShutdownCalledFromManaged) { if (m_hThread != NULL && GetExitCodeThread(m_hThread, &dwThreadStatus) != 0 && dwThreadStatus == STILL_ACTIVE) { // wait for graceful shutdown, i.e., the exit of the background thread or timeout if (WaitForSingleObject(m_hThread, dwTimeout) != WAIT_OBJECT_0) { // if the thread is still running, we need kill it first before exit to avoid AV if (GetExitCodeThread(m_hThread, &dwThreadStatus) != 0 && dwThreadStatus == STILL_ACTIVE) { // Calling back into managed at this point is prone to have AVs // Calling terminate thread here may be our best solution. TerminateThread(m_hThread, STATUS_CONTROL_C_EXIT); } } } } CloseHandle(m_hThread); m_hThread = NULL; s_Application = NULL; CloseStdErrHandles(); if (m_pStdFile != NULL) { fflush(stdout); fflush(stderr); fclose(m_pStdFile); } if (m_hLogFileHandle != INVALID_HANDLE_VALUE) { m_Timer.CancelTimer(); CloseHandle(m_hLogFileHandle); m_hLogFileHandle = INVALID_HANDLE_VALUE; } // delete empty log file handle = FindFirstFile(m_struLogFilePath.QueryStr(), &fileData); if (handle != INVALID_HANDLE_VALUE && fileData.nFileSizeHigh == 0 && fileData.nFileSizeLow == 0) // skip check of nFileSizeHigh { FindClose(handle); // no need to check whether the deletion succeeds//.........这里部分代码省略.........
开发者ID:akrisiun,项目名称:IISIntegration,代码行数:101,
示例4: hook_enableint hook_enable() { // Lock the thread control mutex. This will be unlocked when the // thread has finished starting, or when it has fully stopped. #ifdef _WIN32 WaitForSingleObject(hook_control_mutex, INFINITE); #else pthread_mutex_lock(&hook_control_mutex); #endif // Set the initial status. int status = UIOHOOK_FAILURE; #ifndef _WIN32 // Create the thread attribute. pthread_attr_t hook_thread_attr; pthread_attr_init(&hook_thread_attr); // Get the policy and priority for the thread attr. int policy; pthread_attr_getschedpolicy(&hook_thread_attr, &policy); int priority = sched_get_priority_max(policy); #endif #if defined(_WIN32) DWORD hook_thread_id; DWORD *hook_thread_status = malloc(sizeof(DWORD)); hook_thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) hook_thread_proc, hook_thread_status, 0, &hook_thread_id); if (hook_thread != INVALID_HANDLE_VALUE) { #else int *hook_thread_status = malloc(sizeof(int)); if (pthread_create(&hook_thread, &hook_thread_attr, hook_thread_proc, hook_thread_status) == 0) { #endif #if defined(_WIN32) // Attempt to set the thread priority to time critical. if (SetThreadPriority(hook_thread, THREAD_PRIORITY_TIME_CRITICAL) == 0) { logger_proc(LOG_LEVEL_WARN, "%s [%u]: Could not set thread priority %li for thread %#p! (%#lX)/n", __FUNCTION__, __LINE__, (long) THREAD_PRIORITY_TIME_CRITICAL, hook_thread , (unsigned long) GetLastError()); } #elif (defined(__APPLE__) && defined(__MACH__)) || _POSIX_C_SOURCE >= 200112L // Some POSIX revisions do not support pthread_setschedprio so we will // use pthread_setschedparam instead. struct sched_param param = { .sched_priority = priority }; if (pthread_setschedparam(hook_thread, SCHED_OTHER, ¶m) != 0) { logger_proc(LOG_LEVEL_WARN, "%s [%u]: Could not set thread priority %i for thread 0x%lX!/n", __FUNCTION__, __LINE__, priority, (unsigned long) hook_thread); } #else // Raise the thread priority using glibc pthread_setschedprio. if (pthread_setschedprio(hook_thread, priority) != 0) { logger_proc(LOG_LEVEL_WARN, "%s [%u]: Could not set thread priority %i for thread 0x%lX!/n", __FUNCTION__, __LINE__, priority, (unsigned long) hook_thread); } #endif // Wait for the thread to indicate that it has passed the // initialization portion by blocking until either a EVENT_HOOK_ENABLED // event is received or the thread terminates. // NOTE This unlocks the hook_control_mutex while we wait. #ifdef _WIN32 WaitForSingleObject(hook_control_cond, INFINITE); #else pthread_cond_wait(&hook_control_cond, &hook_control_mutex); #endif #ifdef _WIN32 if (WaitForSingleObject(hook_running_mutex, 0) != WAIT_TIMEOUT) { #else if (pthread_mutex_trylock(&hook_running_mutex) == 0) { #endif // Lock Successful; The hook is not running but the hook_control_cond // was signaled! This indicates that there was a startup problem! // Get the status back from the thread. #ifdef _WIN32 WaitForSingleObject(hook_thread, INFINITE); GetExitCodeThread(hook_thread, hook_thread_status); #else pthread_join(hook_thread, (void **) &hook_thread_status); status = *hook_thread_status; #endif } else { // Lock Failure; The hook is currently running and wait was signaled // indicating that we have passed all possible start checks. We can // always assume a successful startup at this point. status = UIOHOOK_SUCCESS; } free(hook_thread_status); logger_proc(LOG_LEVEL_DEBUG, "%s [%u]: Thread Result: (%#X)./n", __FUNCTION__, __LINE__, status); } else { status = UIOHOOK_ERROR_THREAD_CREATE; } // Make sure the control mutex is unlocked.//.........这里部分代码省略.........
开发者ID:InspectorWidget,项目名称:libuiohook,代码行数:101,
示例5: CheckThreadsBOOL CheckThreads(__in DWORD ProcId)/*++Routine Description: Enumerates all threads (or optionally only threads for one process) in the system. It the calls the WCT API on each of them.Arguments: ProcId--Specifies the process ID to analyze. If '0' all processes in the system will be checked.Return Value: TRUE if processes could be checked; FALSE if a general failure occurred.--*/{ DWORD processes[1024]; DWORD numProcesses; DWORD i; // Try to enable the SE_DEBUG_NAME privilege for this process. // Continue even if this fails--we just won't be able to retrieve // wait chains for processes not owned by the current user. if (!GrantDebugPrivilege()) { printf("Could not enable the debug privilege"); } // Get a list of all processes currently running. if (EnumProcesses(processes, sizeof(processes), &numProcesses) == FALSE) { printf("Could not enumerate processes"); return FALSE; } for (i = 0; i < numProcesses / sizeof(DWORD); i++) { HANDLE process; HANDLE snapshot; if (processes[i] == GetCurrentProcessId()) { continue; } // If the caller specified a Process ID, check if we have a match. if (ProcId != 0) { if (processes[i] != ProcId) { continue; } } // Get a handle to this process. process = OpenProcess(PROCESS_ALL_ACCESS, FALSE, processes[i]); if (process) { WCHAR file[MAX_PATH]; printf("Process 0x%x - ", processes[i]); // Retrieve the executable name and print it. if (GetProcessImageFileName(process, file, ARRAYSIZE(file)) > 0) { PCWSTR filePart = wcsrchr(file, L'//'); if (filePart) { filePart++; } else { filePart = file; } printf("%S", filePart); } printf("/n----------------------------------/n"); // Get a snapshot of this process. This enables us to // enumerate its threads. snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, processes[i]); if (snapshot) { THREADENTRY32 thread; thread.dwSize = sizeof(thread); // Walk the thread list and print each wait chain if (Thread32First(snapshot, &thread)) { do { if (thread.th32OwnerProcessID == processes[i]) { // Open a handle to this specific thread HANDLE threadHandle = OpenThread(THREAD_ALL_ACCESS, FALSE, thread.th32ThreadID); if (threadHandle) { // Check whether the thread is still running DWORD exitCode; GetExitCodeThread(threadHandle, &exitCode); if (exitCode == STILL_ACTIVE) { // Print the wait chain. PrintWaitChain(thread.th32ThreadID); } CloseHandle(threadHandle); } } } while (Thread32Next(snapshot, &thread));//.........这里部分代码省略.........
开发者ID:ambakshi,项目名称:safeio-win32,代码行数:101,
示例6: if//.........这里部分代码省略......... //m_threadRun=true; /* } else {*/ //if (m_hSpeechRecogThread) //{ // CSimpleDict* pSimpleDict; // m_pKinectWindow->GetSimpleDict(&pSimpleDict); // pSimpleDict->~CSimpleDict(); // WaitForSingleObject(m_hSpeechRecogThread, 200); // CloseHandle(m_hSpeechRecogThread); // m_threadRun=false; //} //} break; ////In-bed detection case ID_FALLDETECTION: if (!(pFallDetect->getIsRunFallDetect())) { pFallDetect->setIsRunFallDetect(TRUE); if (!m_FallDetectThreadRun) { m_hFallDetectTxt2SpeechThread = CreateThread(NULL, 0, pFallDetect->Txt2SpeechStaticThread, (PVOID)pFallDetect, 0, 0); m_FallDetectThreadRun = TRUE; } } else { pFallDetect->setIsRunFallDetect(FALSE); if (m_FallDetectThreadRun) { DWORD lpExitCode; GetExitCodeThread(m_hFallDetectTxt2SpeechThread, &lpExitCode); TerminateThread(m_hFallDetectTxt2SpeechThread, lpExitCode); WaitForSingleObject(m_hFallDetectTxt2SpeechThread, 200); CloseHandle(m_hFallDetectTxt2SpeechThread); m_FallDetectThreadRun = FALSE; } } break; case ID_MOVEMENTDETECTION: if (!(pFallDetect->getIsRunMovementDetect())) { pFallDetect->setIsRunMovementDetect(TRUE); } else { pFallDetect->setIsRunMovementDetect(FALSE); } break; case ID_OUTOFBEDDETECTION: break; case ID_LYANGLEDETECTION: if (!(pDepthInbedApps->getIsRunLyAngleDetect())) { pDepthInbedApps->setIsRunLyAngleDetect(TRUE); } else { pDepthInbedApps->setIsRunLyAngleDetect(FALSE); } break;
开发者ID:tangguang,项目名称:KinectV1Explorer_GuangTang,代码行数:67,
示例7: InjectCodeint InjectCode (){ HANDLE hProcess = 0; // Process handle HMODULE hUser32 = 0; // Handle of user32.dll BYTE *pCodeRemote; // Address of InjectFunc() in the remote process. BYTE *pGetSASWndRemote; // Address of GetSASWnd() in the remote process. HANDLE hThread = 0; // The handle and ID of the thread executing DWORD dwThreadId = 0; // the remote InjectFunc(). INJDATA DataLocal; // INJDATA structure BOOL fUnicode; // TRUE if remote process is Unicode int nSuccess = 0; // Subclassing succeded? DWORD dwNumBytesCopied = 0; // Number of bytes written to the remote process. DWORD size; // Calculated function size (= AfterFunc() - Func()) int SearchSize; // SASWindowProc() dummy addr. search size int nDummyOffset; // Offset in SASWindowProc() of dummy addr. BOOL FoundDummyAddr; // Dummy INJDATA reference found in SASWindowProc() ? HWND hSASWnd; // Window handle of Winlogon process BYTE *p; // Enable Debug privilege (needed for some processes) if (!EnablePrivilege(SE_DEBUG_NAME, TRUE)) return 0; // Get handle of "USER32.DLL" hUser32 = GetModuleHandle("user32"); if (!hUser32) return 0; // Get remote process ID PID = GetPIDFromName(szProcessName); if (PID == -1) return 0; // Open remote process hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID); if (!hProcess) return 0; __try { // Initialize INJDATA for GetSASWnd() call strcpy(DataLocal.szClassName, "SAS Window class"); strcpy(DataLocal.szWindowName, "SAS window"); DataLocal.fnFindWindow = (FINDWINDOW) GetProcAddress(hUser32, "FindWindowA"); if (DataLocal.fnFindWindow == NULL) __leave; // Allocate memory in the remote process and write a copy of initialized INJDATA into it size = sizeof(INJDATA); pDataRemote = (PBYTE) VirtualAllocEx(hProcess, 0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!pDataRemote) __leave; if (!WriteProcessMemory(hProcess, pDataRemote, &DataLocal, size, &dwNumBytesCopied) || dwNumBytesCopied != size) __leave; // Allocate memory in remote process and write a copy of GetSASWnd() into it size = (PBYTE)AfterGetSASWnd - (PBYTE)GetSASWnd; pGetSASWndRemote = (PBYTE) VirtualAllocEx(hProcess, 0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!pGetSASWndRemote) __leave; if (!WriteProcessMemory(hProcess, pGetSASWndRemote, &GetSASWnd, size, &dwNumBytesCopied) || dwNumBytesCopied != size) __leave; // Start execution of remote GetSASWnd() hThread = CreateRemoteThread(hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) pGetSASWndRemote, pDataRemote, 0 , &dwThreadId); // Failed if (!hThread) __leave; // Wait for GetSASWnd() to terminate and get return code (SAS Wnd handle) WaitForSingleObject(hThread, INFINITE); GetExitCodeThread(hThread, (PDWORD) &hSASWnd); // Didn't found "SAS window" if (!hSASWnd) __leave; // Cleanup VirtualFreeEx(hProcess, pGetSASWndRemote, 0, MEM_RELEASE); VirtualFreeEx(hProcess, pDataRemote, 0, MEM_RELEASE); pGetSASWndRemote = NULL; pDataRemote = NULL; // Allocate memory in remote process and write a copy of SASWindowProc() into it size = (PBYTE)AfterSASWindowProc - (PBYTE)SASWindowProc; pSASWinProcRemote = (PBYTE) VirtualAllocEx(hProcess, 0, size, MEM_COMMIT, PAGE_EXECUTE_READWRITE); if (!pSASWinProcRemote) __leave; if (!WriteProcessMemory(hProcess, pSASWinProcRemote, &SASWindowProc, size, &dwNumBytesCopied) || dwNumBytesCopied != size) __leave; // Is remote process unicode ? fUnicode = IsWindowUnicode(hSASWnd);//.........这里部分代码省略.........
开发者ID:justdan96,项目名称:VNCappWrapper,代码行数:101,
示例8: strcpy/* * Class: sun_tools_attach_WindowsVirtualMachine * Method: enqueue * Signature: (JZLjava/lang/String;[Ljava/lang/Object;)V */JNIEXPORT void JNICALL Java_sun_tools_attach_WindowsVirtualMachine_enqueue (JNIEnv *env, jclass cls, jlong handle, jbyteArray stub, jstring cmd, jstring pipename, jobjectArray args){ DataBlock data; DataBlock* pData; DWORD* pCode; DWORD numBytes; DWORD stubLen; HANDLE hProcess, hThread; jint argsLen, i; jbyte* stubCode; jboolean isCopy; /* * Setup data to copy to target process */ data._LoadLibrary = _LoadLibrary; data._GetProcAddress = _GetProcAddress; strcpy(data.jvmLib, "jvm"); strcpy(data.func1, "JVM_EnqueueOperation"); strcpy(data.func2, "[email C++ GetExplTargetUnit函数代码示例 C++ GetExePath函数代码示例
|