-
Notifications
You must be signed in to change notification settings - Fork 20
/
tests.c
274 lines (220 loc) · 8.12 KB
/
tests.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
///////////////////////////////////////////
// debug KeQueryLogicalProcessorRelationship
#define TEMP_BUFFER_SIZE 128
#define TRACE_LEVEL_CRITICAL DPFLTR_ERROR_LEVEL
#define TRACE_LEVEL_FATAL DPFLTR_ERROR_LEVEL
#define TRACE_LEVEL_ERROR DPFLTR_ERROR_LEVEL
#define TRACE_LEVEL_WARNING DPFLTR_WARNING_LEVEL
#define TRACE_LEVEL_INFORMATION DPFLTR_TRACE_LEVEL
#define TRACE_LEVEL_VERBOSE DPFLTR_INFO_LEVEL
#include <ntstrsafe.h>
void
TraceGUMessage(
IN PCCHAR func,
IN PCCHAR file,
IN ULONG line,
IN ULONG level,
IN PCCHAR format,
...
)
{
va_list list;
NTSTATUS status;
char psPrefix [TEMP_BUFFER_SIZE];
PCCHAR fileName;
va_start(list, format);
fileName = strrchr(file, '\\');
if (fileName != NULL)
{
fileName++;
}
if(level == TRACE_LEVEL_ERROR)
{
status = RtlStringCchPrintfA(psPrefix, TEMP_BUFFER_SIZE, "%s", " ");
}
else
{
status = RtlStringCchPrintfA(psPrefix, TEMP_BUFFER_SIZE, "%s", " ");
level = TRACE_LEVEL_ERROR;
}
ASSERT(NT_SUCCESS(status));
vDbgPrintExWithPrefix(psPrefix , DPFLTR_IHVNETWORK_ID, level, format, list);
va_end(list);
}
#define GU_PRINT(_level_,_flag_, _format_, ...) \
TraceGUMessage(__FUNCTION__, __FILE__, __LINE__, _level_, _format_, __VA_ARGS__); \
#if (NTDDI_VERSION < NTDDI_WIN7)
#define KeQueryLogicalProcessorRelationship \
KeQueryLogicalProcessorRelationship_k8
#endif
void PrintNumaCpuConfiguration()
{
USHORT NodeNumber;
NTSTATUS Status;
GROUP_AFFINITY GroupAffinity;
USHORT NodeCount, HighestNodeNumber;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX Info = NULL;
ULONG BufferSize = 0;
PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX pCurrInfo;
USHORT i;
//
// Get required buffer size.
//
PROCESSOR_NUMBER Filter;
Filter.Group = 0;
Filter.Number = 3;
Filter.Reserved = 0;
Status = KeQueryLogicalProcessorRelationship(NULL, RelationAll, NULL, &BufferSize);
ASSERT(Status == STATUS_INFO_LENGTH_MISMATCH && BufferSize > 0);
//
// Allocate buffer (assume IRQL <= APC_LEVEL).
//
Info = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) ExAllocatePoolWithTag(PagedPool, BufferSize, ' gaT');
if (Info == NULL)
{
return;
}
//
// Get processor relationship information.
//
Status = KeQueryLogicalProcessorRelationship(NULL, RelationAll, Info, &BufferSize);
if(Status != STATUS_SUCCESS)
{
return;
}
GU_PRINT(TRACE_LEVEL_ERROR, GU, "\n\nSystem processor information:\n");
for(pCurrInfo = Info;
(char *) pCurrInfo < (char *) Info + BufferSize;
pCurrInfo = (PSYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX) ((char *) pCurrInfo + pCurrInfo->Size))
{
switch(pCurrInfo->Relationship)
{
case RelationProcessorCore:
GU_PRINT(TRACE_LEVEL_ERROR, GU, "--Processor core-- Group=%d Mask=0x%p\n",
pCurrInfo->Processor.GroupMask[0].Group,
(void *) pCurrInfo->Processor.GroupMask[0].Mask );
break;
case RelationProcessorPackage:
GU_PRINT(TRACE_LEVEL_ERROR, GU, "--Processor package-- Group count %d\n", pCurrInfo->Processor.GroupCount);
for(i = 0; i < pCurrInfo->Processor.GroupCount; i++)
{
GU_PRINT(TRACE_LEVEL_ERROR, GU, "Group #%d: Group=%d Mask=0x%p\n", i,
pCurrInfo->Processor.GroupMask[i].Group,
(void *) pCurrInfo->Processor.GroupMask[i].Mask);
}
break;
case RelationNumaNode:
GU_PRINT(TRACE_LEVEL_ERROR, GU, "--Numa node-- Node #%d ProcessorGroup=%d ProcessorMask=0x%p\n",
pCurrInfo->NumaNode.NodeNumber, pCurrInfo->NumaNode.GroupMask.Group, (void *) pCurrInfo->NumaNode.GroupMask.Mask);
break;
case RelationGroup:
GU_PRINT(TRACE_LEVEL_ERROR, GU, "--Groups info-- MaxGroupCount=%d ActiveGroupCount=%d\n",
pCurrInfo->Group.MaximumGroupCount, pCurrInfo->Group.ActiveGroupCount);
for(i = 0; i < pCurrInfo->Group.ActiveGroupCount; i++)
{
GU_PRINT(TRACE_LEVEL_ERROR, GU, "Group #%d: MaxProcCount=%d ActiveProcCount=%d ActiveProcMask=0x%p\n", i,
pCurrInfo->Group.GroupInfo[i].MaximumProcessorCount,
pCurrInfo->Group.GroupInfo[i].ActiveProcessorCount,
(void *) pCurrInfo->Group.GroupInfo[i].ActiveProcessorMask);
}
break;
case RelationCache:
GU_PRINT(TRACE_LEVEL_ERROR, GU, "--Cache info-- Level=L%d, Associativity=%d, LineSize=%d bytes, \
CacheSize=%d bytes, Type=%d, ProcGroup=%d, ProcMask=0x%p\n",
pCurrInfo->Cache.Level,
pCurrInfo->Cache.Associativity,
pCurrInfo->Cache.LineSize,
pCurrInfo->Cache.CacheSize,
pCurrInfo->Cache.Type,
pCurrInfo->Cache.GroupMask.Group,
(void *) pCurrInfo->Cache.GroupMask.Mask);
break;
default:
ASSERT(FALSE);
break;
}
}
}
// debug
/////////////////////////////////
void Routine1 (
PEPROCESS Process,
HANDLE ProcessId,
PPS_CREATE_NOTIFY_INFO CreateInfo)
{
;
}
void Routine2 (
PEPROCESS Process,
HANDLE ProcessId,
PPS_CREATE_NOTIFY_INFO CreateInfo)
{
volatile int a=0x0L;
}
void Routine3 (
PEPROCESS Process,
HANDLE ProcessId,
PPS_CREATE_NOTIFY_INFO CreateInfo)
{
volatile int a=0x1L;
}
typedef struct _test1 {
/*char *arrayOfCatchableTypes1[1];
int* arrayOfCatchableTypes2[2];
const long *arrayOfCatchableTypes3[1];
__int64* const arrayOfCatchableTypes4[1];
const __int64* const arrayOfCatchableTypes5[1];*/
//const char *Ptr1; // const char* Ptr
// char* const Ptr2; // char* const Ptr
//const char* const Ptr3; // const char* const Ptr
//const char* const *Ptr4; // const char* const *Ptr4
//volatile const char *Ptr5;
//char* volatile const Ptr6;
//volatile const char* volatile const Ptr7;
//volatile const char* volatile const *Ptr8;
//const char &Ptr10;
//char& Ptr20;
//const char& Ptr30;
//volatile const char &Ptr50;
//volatile const char& Ptr70;
//const char &Ptr11;
//char* const &Ptr21;
//const char* const &Ptr31;
//char *&Ptr40;
//char* &Ptr41;
//char **&Ptr42;
//volatile const char &Ptr51;
//char* volatile const &Ptr61;
//volatile const char* volatile const &Ptr71;
_ULARGE_INTEGER ff;
} test1_t;
void
RunTests (void)
{
//test1_t* test1;
//test1->Ptr1 = NULL;
//*test1.Ptr1 = '1';
/*PsSetCreateProcessNotifyRoutineEx_k8 (Routine1, FALSE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine2, FALSE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine3, FALSE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine2, TRUE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine3, TRUE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine2, FALSE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine3, FALSE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine2, TRUE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine1, TRUE);
PsSetCreateProcessNotifyRoutineEx_k8 (Routine3, TRUE); */
/*HANDLE Handle = NULL;
void const * Ptr = NULL;
MEMORY_INFORMATION_CLASS Class = MemoryBasicVlmInformation;
PVOID Ptr2 = NULL;
SIZE_T Size = 1;
PSIZE_T Size2 = &Size;
ZwQueryVirtualMemory_k8(
Handle,
Ptr,
Class,
Ptr2,
Size,
Size2);*/
}