58 static auto mod = GetModuleHandleA(
"ntdll.dll");
61 static auto pNtQuerySystemInformation =
reinterpret_cast<decltype(&NtQuerySystemInformation)
>(GetProcAddress(mod,
"NtQuerySystemInformation"));
62 if (!pNtQuerySystemInformation)
return false;
66 NTSTATUS status = STATUS_UNSUCCESSFUL;
67 while (status != STATUS_SUCCESS) {
69 status = pNtQuerySystemInformation(SystemProcessInformation, bBuf.
buf, bBuf.
buf_size, &ret_len);
70 if (status == STATUS_INFO_LENGTH_MISMATCH) {
71 if (!bBuf.
alloc(ret_len)) {
79 if (status != STATUS_SUCCESS) {
84 SYSTEM_PROCESS_INFORMATION* info = (SYSTEM_PROCESS_INFORMATION*)bBuf.
buf;
86 if (info->UniqueProcessId == pid) {
90 if (!info->NextEntryOffset) {
93 size_t record_size = info->NextEntryOffset;
94 if (record_size <
sizeof(SYSTEM_PROCESS_INFORMATION)) {
97 std::cout <<
"The new version of SYSTEM_PROCESS_INFORMATION is not supported!\n";
101 info = (SYSTEM_PROCESS_INFORMATION*)((ULONG_PTR)info + info->NextEntryOffset);
111 LARGE_INTEGER createTime = info->CreateTime;