1#include "gtest/gtest.h"
5static FILETIME At(
double seconds) {
6 ULONGLONG value = 134070000000000000ULL + (ULONGLONG)(seconds * 10000000.0);
8 time.dwLowDateTime = (DWORD)(value & 0xFFFFFFFF);
9 time.dwHighDateTime = (DWORD)(value >> 32);
15TEST(ProcessImages, ImageIsKnownAfterTheProcessExits) {
19 EXPECT_EQ(
LookupProcessImage(900001, At(0.5)), R
"(C:\Tests\Test_NtWriteVirtualMemoryx64.exe)");
22TEST(ProcessImages, SystemRootPathsBecomeWin32Paths) {
25 UINT length = GetWindowsDirectoryA(windows,
MAX_PATH);
26 EXPECT_EQ(
LookupProcessImage(900002, At(1)), std::string(windows, length) + R
"(\System32\Conhost.exe)");
29TEST(ProcessImages, ReusedPidResolvesByEventTime) {
37TEST(ProcessImages, SmallClockDifferenceStillMatches) {
44TEST(ProcessImages, UnknownProcessIsEmpty) {
48TEST(ProcessImages, ResolveNamesProcessesWithoutAnImageFile) {
53TEST(ProcessImages, ResolveFallsBackToWindowsForRunningProcesses) {
56 EXPECT_NE(image.find(
"Test_Service.exe"), std::string::npos) << image;
TEST(ProcessImages, ImageIsKnownAfterTheProcessExits)
void RecordProcessExit(DWORD processId)
Records a process exit (ProcessTerminated). Its entry is forgotten a minute later.
void RecordProcessStart(DWORD processId, const std::string &image, const FILETIME &time)
Records a process start (ProcessCreated).
std::string LookupProcessImage(DWORD processId, const FILETIME &time)
The image of the process that had processId at the given time, from the recorded starts....
std::string ResolveProcessImage(DWORD processId, const FILETIME &time)
LookupProcessImage, falling back to asking Windows (QueryFullProcessImageName) for processes the serv...