18 {
19
20
21
22
23 accum.add(GetTickCount(), 0);
24 accum.add(GetMessagePos(), 0);
25 accum.add(GetMessageTime(), 0);
26 accum.add(GetInputState(), 0);
27 accum.add(GetCurrentProcessId(), 0);
28 accum.add(GetCurrentThreadId(), 0);
29
30 SYSTEM_INFO sys_info;
31 GetSystemInfo(&sys_info);
32 accum.add(sys_info, 1);
33
34 MEMORYSTATUS mem_info;
35 GlobalMemoryStatus(&mem_info);
36 accum.add(mem_info, 1);
37
38 POINT point;
39 GetCursorPos(&point);
40 accum.add(point, 1);
41
42 GetCaretPos(&point);
43 accum.add(point, 1);
44
45 LARGE_INTEGER perf_counter;
46 QueryPerformanceCounter(&perf_counter);
47 accum.add(perf_counter, 0);
48
49
50
51
52
53
54 HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
55
56#define TOOLHELP32_ITER(DATA_TYPE, FUNC_FIRST, FUNC_NEXT) \
57 if(!accum.polling_goal_achieved()) \
58 { \
59 DATA_TYPE info; \
60 info.dwSize = sizeof(DATA_TYPE); \
61 if(FUNC_FIRST(snapshot, &info)) \
62 { \
63 do \
64 { \
65 accum.add(info, 1); \
66 } while(FUNC_NEXT(snapshot, &info)); \
67 } \
68 }
69
73
74#undef TOOLHELP32_ITER
75
76 if(!accum.polling_goal_achieved())
77 {
78 size_t heap_lists_found = 0;
79 HEAPLIST32 heap_list;
80 heap_list.dwSize = sizeof(HEAPLIST32);
81
82 const size_t HEAP_LISTS_MAX = 32;
83 const size_t HEAP_OBJS_PER_LIST = 128;
84
85 if(Heap32ListFirst(snapshot, &heap_list))
86 {
87 do
88 {
89 accum.add(heap_list, 1);
90
91 if(++heap_lists_found > HEAP_LISTS_MAX)
92 break;
93
94 size_t heap_objs_found = 0;
95 HEAPENTRY32 heap_entry;
96 heap_entry.dwSize = sizeof(HEAPENTRY32);
97 if(Heap32First(&heap_entry, heap_list.th32ProcessID,
98 heap_list.th32HeapID))
99 {
100 do
101 {
102 if(heap_objs_found++ > HEAP_OBJS_PER_LIST)
103 break;
104 accum.add(heap_entry, 1);
105 } while(Heap32Next(&heap_entry));
106 }
107
108 if(accum.polling_goal_achieved())
109 break;
110
111 } while(Heap32ListNext(snapshot, &heap_list));
112 }
113 }
114
115 CloseHandle(snapshot);
116 }
#define TOOLHELP32_ITER(DATA_TYPE, FUNC_FIRST, FUNC_NEXT)