// 更新. void CSampleRunner::UpdateInternal(izanagi::graph::CGraphicsDevice* device) { if (m_RunProcess) { CloseProcess(); memset(&m_ProcInfo, 0, sizeof(m_ProcInfo)); STARTUPINFO startUpInfo; memset(&startUpInfo, 0, sizeof(startUpInfo)); startUpInfo.cb = sizeof(startUpInfo); const ExeInfo& info = m_InfoList[m_ColumnIdx][m_RowIdx]; LPSTR cmd = const_cast<LPSTR>(info.path.c_str()); if (CreateProcess( NULL, cmd, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &startUpInfo, &m_ProcInfo)) { CloseHandle(m_ProcInfo.hThread); } m_RunProcess = IZ_FALSE; } }
/* The shared state is not locked when prewait methods are called */ static void namedmutex_prewait (gpointer handle) { /* If the mutex is not currently owned, do nothing and let the * usual wait carry on. If it is owned, check that the owner * is still alive; if it isn't we override the previous owner * and assume that process exited abnormally and failed to * clean up. */ struct _WapiHandle_namedmutex *namedmutex_handle; gboolean ok; ok = _wapi_lookup_handle (handle, WAPI_HANDLE_NAMEDMUTEX, (gpointer *)&namedmutex_handle); if (ok == FALSE) { g_warning ("%s: error looking up named mutex handle %p", __func__, handle); return; } DEBUG ("%s: Checking ownership of named mutex handle %p", __func__, handle); if (namedmutex_handle->recursion == 0) { DEBUG ("%s: Named mutex handle %p not owned", __func__, handle); } else if (namedmutex_handle->pid == _wapi_getpid ()) { DEBUG ("%s: Named mutex handle %p owned by this process", __func__, handle); } else { int thr_ret; gpointer proc_handle; DEBUG ("%s: Named mutex handle %p owned by another process", __func__, handle); proc_handle = OpenProcess (0, 0, namedmutex_handle->pid); if (proc_handle == NULL) { /* Didn't find the process that this handle * was owned by, overriding it */ DEBUG ("%s: overriding old owner of named mutex handle %p", __func__, handle); thr_ret = _wapi_handle_lock_shared_handles (); g_assert (thr_ret == 0); namedmutex_handle->pid = 0; namedmutex_handle->tid = 0; namedmutex_handle->recursion = 0; _wapi_shared_handle_set_signal_state (handle, TRUE); _wapi_handle_unlock_shared_handles (); } else { DEBUG ("%s: Found active pid %d for named mutex handle %p", __func__, namedmutex_handle->pid, handle); } if (proc_handle != NULL) CloseProcess (proc_handle); } }
extern "C" int __declspec(dllexport) kill_process(int id) { int n=0; for(i=0;i<tb_cnt;i++) if(ID[i]==id) { CloseProcess(); ID[i] = -1; n++; break; } return n; };
BOOL __stdcall CreateProcessAndInjectDllW(const wchar_t *szTargetName,//ターゲットの名前 const wchar_t *szDllName) //いれるdll名 { PROCESS_INFORMATION *pi = CreateSuspendedProcessW(szTargetName); //NULLなら失敗 if(pi == NULL){ return FALSE; } HANDLE bRet= DllInjectionW(pi,szDllName); ResumeProcess(pi); CloseProcess(pi); if(!bRet){return FALSE;} return TRUE; }
void CommandDispatcher (PA_long32 pProcNum, sLONG_PTR *pResult, PackagePtr pParams) { switch(pProcNum) { case kInitPlugin : InitPlugin(); break; case kDeinitPlugin : DeinitPlugin(); break; case kCloseProcess : CloseProcess(); break; // --- Sleep case 1 : sleepSetCallback(pResult, pParams); break; case 2 : sleepRegisterCallback(pResult, pParams); break; case 3 : sleepUnregisterCallback(pResult, pParams); break; case 4 : sleepPrevent(pResult, pParams); break; case 5 : sleepUnprevent(pResult, pParams); break; // --- Wake case 6 : wakeSetCallback(pResult, pParams); break; case 7 : wakeRegisterCallback(pResult, pParams); break; case 8 : wakeUnregisterCallback(pResult, pParams); break; #if VERSIONWIN // --- Shutdown case 9 : shutdownSetCallback(pResult, pParams); break; case 10 : shutdownRegisterCallback(pResult, pParams); break; case 11 : shutdownUnregisterCallback(pResult, pParams); break; case 12 : shutdownPrevent(pResult, pParams); break; case 13 : shutdownUnprevent(pResult, pParams); break; #endif } }
CDlgView::~CDlgView() { CloseProcess(); }
// 解放. void CSampleRunner::ReleaseInternal() { CloseProcess(); }