Пример #1
0
ULONG64 get_process_starttime( pid_t p_id )
{
	ULONG64 startTime = (ULONG64)-1;

	/*
	 * Do not raise privileges if we are inspecting ourselves.
	 * This function is used not only by prl_perf_ctl,
	 * but by all PerfCount users.
	 */
	if (::getpid() != p_id) {
		if (!set_debug_privilege())
			WRITE_TRACE(DBG_FATAL, "Failed to set debug privilege");
	}

	/** Converts specified 100-nanosecond intervals to milliseconds */
#define TO_MSECS(n100Nanoseconds) (n100Nanoseconds/10000)
#define TO_ULONGLONG(large_var, high_part, low_part)\
	( (((unsigned long long) large_var.high_part) << 32 ) + large_var.low_part)

	HANDLE hProcess = hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, p_id);
	if (NULL != hProcess)
	{
		FILETIME CreationTime, ExitTime, KernelTime, UserTime;
		if (GetProcessTimes(hProcess, &CreationTime, &ExitTime, &KernelTime, &UserTime))
			startTime = TO_MSECS(TO_ULONGLONG(CreationTime, dwHighDateTime, dwLowDateTime));

		CloseHandle(hProcess);
	}

	return startTime;

#undef TO_ULONGLONG
#undef TO_MSECS
}
Пример #2
0
//------------------------------------------------------------------------------
// Name: DebuggerCore()
// Desc: constructor
//------------------------------------------------------------------------------
DebuggerCore::DebuggerCore() : page_size_(0), process_handle_(0), start_address(0), image_base(0) {
	DebugSetProcessKillOnExit(false);

	SYSTEM_INFO sys_info;
	GetSystemInfo(&sys_info);
	page_size_ = sys_info.dwPageSize;

	set_debug_privilege(GetCurrentProcess(), true); // gogo magic powers
}
Пример #3
0
//------------------------------------------------------------------------------
// Name: ~DebuggerCore()
// Desc:
//------------------------------------------------------------------------------
DebuggerCore::~DebuggerCore() {
	detach();
	set_debug_privilege(GetCurrentProcess(), false);
}