Last active
March 23, 2024 21:51
-
-
Save kevingosse/5dc76124ca986a41f1e8719c77b7987a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <windows.h> | |
#include <processsnapshot.h> | |
int main() | |
{ | |
auto processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, 40092); | |
if (processHandle == nullptr) | |
{ | |
std::cout << "Failed to open process\n"; | |
return 1; | |
} | |
HPSS snapshotHandle; | |
auto result = PssCaptureSnapshot(processHandle, PSS_CAPTURE_HANDLES, 0, &snapshotHandle); | |
if (result != ERROR_SUCCESS) | |
{ | |
std::cout << "Failed to capture snapshot\n"; | |
return 1; | |
} | |
PSS_HANDLE_INFORMATION handleInfo; | |
result = PssQuerySnapshot(snapshotHandle, PSS_QUERY_HANDLE_INFORMATION, &handleInfo, sizeof(handleInfo)); | |
if (result != ERROR_SUCCESS) | |
{ | |
std::cout << "Failed to query snapshot\n"; | |
return 1; | |
} | |
std::cout << "Handle count: " << handleInfo.HandlesCaptured << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment