示例#1
0
/**
 * Thread Run Function, calls Run_CreateProcess and notifies all 
 * interested parties on completion.
 */
void ToolRunner::Run()
{
	time(&m_starttime);
	m_pWrapper->OnStart();
	m_RetCode = Run_Capture(m_pWrapper->Command.c_str(), m_pWrapper->Params.c_str(), m_pWrapper->Folder.c_str());
	PostRun();
	m_pWrapper->SetRunning(false);
	m_pWrapper->OnFinished();
	ToolOwner::GetInstance()->MarkToolForDeletion(this);
}
示例#2
0
int TApp::Run(void)
{
	MSG		msg;

	InitApp();
	InitWindow();

	while (::GetMessageW(&msg, NULL, 0, 0))
	{
		if (PreProcMsg(&msg)) {
			continue;
		}

		::TranslateMessage(&msg);
		::DispatchMessageW(&msg);
	}

	PostRun();

	return	(int)msg.wParam;
}
示例#3
0
int ToolRunner::Run_NoCapture(LPCTSTR command, LPCTSTR params, LPCTSTR dir)
{
	int result = 0;

	tstring tempstr(_T("\"\" "));
	tempstr.insert(1, command);
	tempstr += params;

	if (_tcslen(dir) == 0)
		dir = NULL;

	OSVERSIONINFO osv = {sizeof(OSVERSIONINFO), 0, 0, 0, 0, _T("")};

	::GetVersionEx(&osv);
	bool bWin9x = osv.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS;
	
	SECURITY_ATTRIBUTES sa = {sizeof(SECURITY_ATTRIBUTES), 0, 0};
	sa.bInheritHandle = TRUE;
	sa.lpSecurityDescriptor = NULL;

	SECURITY_DESCRIPTOR sd;
	if (!bWin9x)
	{
		// On NT we can have a proper security descriptor...
		::InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
		::SetSecurityDescriptorDacl(&sd, TRUE, NULL, FALSE);
		sa.lpSecurityDescriptor = &sd;
	}

	STARTUPINFO si;
	memset(&si, 0, sizeof(STARTUPINFO));
	si.cb = sizeof(STARTUPINFO);

	PROCESS_INFORMATION pi = {0, 0, 0, 0};

	std::vector<TCHAR> cmdbuf(tempstr.length()+1);
	memcpy(&cmdbuf[0], tempstr.c_str(), tempstr.size() * sizeof(TCHAR));

	DWORD dwCreationFlags = CREATE_NEW_CONSOLE; // CREATE_NEW_PROCESS_GROUP - causes Ctrl-C to be disabled.

	bool bCreated = ::CreateProcess(
		NULL, 
		&cmdbuf[0], 
		&sa, /*LPSECURITY_ATTRIBUTES lpProcessAttributes*/
		NULL, /*LPSECURITYATTRIBUTES lpThreadAttributes*/
		TRUE, /*BOOL bInheritHandles*/ 
		dwCreationFlags, /*DWORD dwCreationFlags*/
		NULL, /*LPVOID lpEnvironment*/
		dir, /*LPCTSTR lpWorkingDir*/
		&si, /*LPSTARTUPINFO lpStartupInfo*/
		&pi /*LPPROCESS_INFORMATION lpProcessInformation*/ 
	) != 0;

	if (!bCreated)
	{
		CLastErrorInfo lei;
		m_pWrapper->_AddToolOutput(_T("\n> Failed to create process: "));
		m_pWrapper->_AddToolOutput((LPCTSTR)lei);

		return lei.GetErrorCode();
	}

	// We're waiting for this one to finish because it's a filter process - 
	// i.e. it will change the current file.
	if (m_pWrapper->IsFilter())
	{
		::WaitForSingleObject(pi.hProcess, INFINITE);
		DWORD dwExitCode;
		::GetExitCodeProcess(pi.hProcess, &dwExitCode);
		result = dwExitCode;
	}
	else
	{
		result = pi.dwProcessId;
	}
	
	// Detach...
	::CloseHandle(pi.hProcess);
	::CloseHandle(pi.hThread);

	PostRun();

	return result;
}
示例#4
0
void CRhGLShaderProgram::Disable(void)
{
  PostRun();
  glUseProgram( 0 );
}