예제 #1
0
        void worker::update_final(CHandle& _mutex)
        {
            progress_ = 5;
            emit progress(progress_);

            run_async_function(copy_files_from_updates, [this, &_mutex](const installer::error& _err)
            {
                if (!_err.is_ok())
                {
                    emit error(_err);
                    return;
                }

                run_async_function(write_to_uninstall_key, [this, &_mutex](const installer::error& _err)
                {
                    if (!_err.is_ok())
                    {
                        emit error(_err);
                        return;
                    }

                    _mutex.Close();

                    run_async_function(start_process, [this](const installer::error& _err)
                    {
                        if (!_err.is_ok())
                        {
                            emit error(_err);
                            return;
                        }

                        run_async_function(copy_self_from_updates, [this](const installer::error& _err)
                        {
                            if (!_err.is_ok())
                            {
                                emit error(_err);
                                return;
                            }

                            run_async_function(delete_updates, [this](const installer::error& _err)
                            {
                                if (!_err.is_ok())
                                {
                                    emit error(_err);
                                    return;
                                }

                                emit finish();

                            }, 100);
                        }, 90);
                    }, 80);
                }, 75);
            }, 70);
        }
예제 #2
0
 void CloseProgressWindow(bool cancel = false)
 {
     if (!m_progressWindowThread)
         return;
     Sleep(100); // It could be that m_pProgressDlg->DoModal not yet created a window
     if (m_progressWindow)
         m_progressWindow->PostMessage(WM_CLOSE);
     WaitForSingleObject(m_progressWindowThread, INFINITE);
     m_progressWindowThread.Close();
     if (!cancel)
         g_cancel = false;
 }
예제 #3
0
//----------------------------------------------------------------------------
// writeHandleAndInject
//  Writes the internal mIEMainWindow to the mem file and invokes the page
//  action broker to inject the page actions DLL into the IE process.
HRESULT Proxy::writeHandleAndInject(DWORD aProcessId)
{
  // detect bitness of target process
  CHandle process(::OpenProcess(  PROCESS_QUERY_LIMITED_INFORMATION, FALSE, aProcessId ));
  if( !process ) {
    return HRESULT_FROM_WIN32(::GetLastError());
  }
  BOOL is64 = Is64bitProcess(process);
  process.Close();

  // write window handle
  CHandle fileMapping;
  HRESULT hr = writeHandle(mIEMainWindow, fileMapping.m_h);
  if (FAILED(hr)) {
    return hr;
  }

  // prepare broker process
  STARTUPINFO startInfo;
  ::ZeroMemory( &startInfo, sizeof( startInfo ) );
  startInfo.cb = sizeof( startInfo );
  startInfo.dwFlags |= STARTF_USESHOWWINDOW;
  startInfo.wShowWindow = FALSE;

  PROCESS_INFORMATION processInfo;
  ::ZeroMemory( &processInfo, sizeof( processInfo ) );

  // pass process-ID
  CString params;
  params.Format(_T("%lu"), aProcessId);

  // path for broker exe to use
  CString path;
  path.Format(_T("%s%s"), (is64) ? mInstallPath64 : mInstallPath32, sBrokerExec);

  if( ::CreateProcess(
      path.GetBuffer(MAX_PATH), params.GetBuffer(MAX_PATH),
      NULL, NULL, FALSE, CREATE_NO_WINDOW, NULL, NULL,
      &startInfo, &processInfo ) ){
    ::WaitForSingleObject( processInfo.hProcess, INFINITE );
    ::CloseHandle( processInfo.hThread );
    ::CloseHandle( processInfo.hProcess );
    return S_OK;
  }
  // something went wrong. Call GetLastError BEFORE closing file handle!
  DWORD dw = ::GetLastError();
  fileMapping.Close();
  return HRESULT_FROM_WIN32(dw);
}
예제 #4
0
파일: hfserver.cpp 프로젝트: AlexS2172/IVRM
void CHFServer::CloseHFProcess(LPCSTR szProcessName)
{
	std::string sProcessName =  utils::upcase(std::string(szProcessName));
	DWORD dwID = 0;
	CHandle hProcess = GetProcessId(sProcessName, dwID);
	long iCount = 0;
	if(hProcess == NULL)
		EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("No %s module found"), sProcessName.c_str());	

	while( hProcess != NULL)
	{
		EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Terminating %s module"), sProcessName.c_str());	
		

		if(!TerminateProcess(hProcess, 0)  )
		{
			DWORD dwError = GetLastError();

			if(dwID)
			{
				if(!Kill(dwID))
					EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Kill Process %s Failed with error %d and terminate with error %d"), sProcessName.c_str(), GetLastError() , dwError);	
			}  
			else
				EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Unable to terminate %s module %d"), sProcessName.c_str(), dwError);	
		}

		if(++iCount > 10)
		{
			EgLib::CEgLibTraceManager::Trace(LogFaults, __FUNCTION__ , _T("Too many %s process to terminate %d"), sProcessName.c_str(), GetLastError());	
			break;
		}
		hProcess.Close();
		hProcess.Attach(GetProcessId(sProcessName, dwID));
	}
}