-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGdiRes.cpp
62 lines (52 loc) · 1.23 KB
/
GdiRes.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#pragma comment(lib, "user32.lib")
#pragma comment(lib, "shlwapi.lib")
#ifndef _UNICODE
#define _UNICODE
#endif
#ifndef UNICODE
#define UNICODE
#endif
#include <windows.h>
#include <wchar.h>
#include <shlwapi.h>
INT wmain(INT argc, WCHAR *argv[])
{
if (argc != 2)
{
wprintf(L"Usage: %s <PID>\n", argv[0]);
return 0;
}
DWORD pid;
pid = StrToInt(argv[1]);
wprintf(L"PID: %d\n", pid);
HANDLE processHandle;
processHandle = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
if (processHandle == NULL)
{
wprintf(L"Failed OpenProcess with LastError=%d\n", GetLastError());
return 0;
}
DWORD handleCount;
// GDI object
handleCount = GetGuiResources(processHandle, GR_GDIOBJECTS);
if (handleCount == 0)
{
wprintf(L"GDI Objects: LastError=%d\n", GetLastError());
}
else
{
wprintf(L"GDI Objects: %d\n", handleCount);
}
// USER object
handleCount = GetGuiResources(processHandle, GR_USEROBJECTS);
if (handleCount == 0)
{
wprintf(L"USER Objects: LastError=%d\n", GetLastError());
}
else
{
wprintf(L"USER Objects: %d\n", handleCount);
}
CloseHandle(processHandle);
return 0;
}