Esempio n. 1
0
Process::~Process()
{
	try {
		if (processHandle() != INVALID_HANDLE_VALUE && active()) {
			TerminateProcess(processHandle(), 0);
		}
	}
	catch(WinApiException e) {}
	CloseHandle(pi.hProcess);
	CloseHandle(pi.hThread);
}
Esempio n. 2
0
DWORD Process::exitCode() const
{
	DWORD code;
	tryApi(_T("GetExitCodeProcess"),
		GetExitCodeProcess(processHandle(),&code) != 0);
	return code;
}
Esempio n. 3
0
bool Process::active()
{
	DWORD res = WaitForSingleObject(processHandle(),0);
	if (res == WAIT_OBJECT_0) return false;
	else if (res == WAIT_TIMEOUT) return true;
	else {
		tryApi(_T("WaitForSingleObject"),res != WAIT_FAILED);
		return false;
	}
}
Esempio n. 4
0
Lines DBWinReader::ProcessLines(const DBWinMessages& DBWinMessages)
{
	Lines resolvedLines = CheckHandleCache();
	for (auto i = DBWinMessages.begin(); i != DBWinMessages.end(); ++i)
	{
		std::string processName; 
		if (i->handle)
		{
			Handle processHandle(i->handle);
			processName = Str(ProcessInfo::GetProcessName(processHandle.get())).str();
			m_handleCache.Add(i->pid, std::move(processHandle));
		}

		auto lines = ProcessLine(Line(i->time, i->systemTime, i->pid, processName, i->message));
		for (auto line = lines.begin(); line != lines.end(); ++line)
			resolvedLines.push_back(*line);
	}

	return resolvedLines;
}
Esempio n. 5
0
int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) 
{
	//процесс
	HANDLE handle = processHandle(L"DllProject.exe"); //куда внедряем
	DWORD dwProcessId = GetProcessId(handle);
	CloseHandle(handle);

	//dll
	TCHAR szLibFile[MAX_PATH];
	//GetModuleFileName(NULL, szLibFile, sizeof(szLibFile));
	//_tcscpy(_tcsrchr(szLibFile, TEXT('\\')) + 1, TEXT("Dll.dll"));
	_tcscpy(szLibFile, TEXT("C:\\Projects\\InjectDll\\Dll\\Debug\\ImportDll.dll")); //что внедряем

	//инжектируем
	if (InjectLibW(dwProcessId, szLibFile)) 
	{
		MessageBox(NULL,L"DLL Injection/Ejection successful. Pause!",NULL,MB_OK); 
		EjectLibW(dwProcessId, szLibFile);
	} 
	else 
	{
		MessageBox(NULL,L"DLL Injection/Ejection failed.",NULL,MB_OK);
	}
}