156{
164
166
167
169
170
171 MakeBuffer(
Buffer, HalfSize, 0x55, HalfSize, 0xAA, 0);
172 for (
i = 0;
i < HalfSize; ++
i)
174 for (
i = HalfSize;
i <
Size; ++
i)
177
179 for (
i = 0;
i < 60;
i += 3)
180 {
184 }
185 for (
i = 60;
i < 64; ++
i)
187 for (
i = 64;
i < HalfSize; ++
i)
189 for (
i = HalfSize;
i <
Size; ++
i)
191 ok_bool_true(
CheckPattern(
Buffer, 3, 20, 0x11, 0x22, 0x33, 1, 4, 0x44, 0),
"CheckPattern");
192
193
196 ok_bool_true(
CheckPattern(
Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0),
"CheckPattern");
197
198 MakePattern(
Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
200 ok_bool_true(
CheckPattern(
Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0),
"CheckPattern");
201
211
212#undef RtlMoveMemory
213
216 ok_bool_true(
CheckPattern(
Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0),
"CheckPattern");
217
218 MakePattern(
Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
220 ok_bool_true(
CheckPattern(
Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0),
"CheckPattern");
221
231
232
235 ok_bool_true(
CheckPattern(
Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0),
"CheckPattern");
236
237 MakePattern(
Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
239 ok_bool_true(
CheckPattern(
Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0),
"CheckPattern");
240
250
251
254 ok_bool_true(
CheckPattern(
Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0),
"CheckPattern");
255
256 MakePattern(
Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
258 ok_bool_true(
CheckPattern(
Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0),
"CheckPattern");
259
269
270
273 ok_bool_true(
CheckPattern(
Buffer, 2, 6, 0x12, 0x34, 1, 1, 0x12, 2, 33, 0x12, 0x34, 2, 14, 0x56, 0x78, 1, 1, 0x56, 2, 10, 0x12, 0x34, 2, 192, 0x56, 0x78, 1, 1, 0, 0),
"CheckPattern");
274
275 MakePattern(
Buffer, 2, 32, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 192, 0x9A, 0xAB, 0);
277 ok_bool_true(
CheckPattern(
Buffer, 2, 32, 0x12, 0x34, 2, 7, 0x56, 0x78, 1, 1, 0x34, 2, 10, 0x12, 0x34, 2, 32, 0x56, 0x78, 2, 11, 0x9A, 0xAB, 1, 1, 0xAB, 2, 163, 0x9A, 0xAB, 1, 1, 0, 0),
"CheckPattern");
278
288
289
290 MakePattern(
Buffer, 8, HalfSize / 8 - 1, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
291 1, 1, 0x12,
292 8, HalfSize / 8, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
293 1, 7, 0x12, 0);
294
296 "RtlEqualMemory returned");
298 "RtlEqualMemory returned");
300 "RtlEqualMemory returned");
302 "RtlEqualMemory returned");
303
304
305 MakePattern(
Buffer, 8, HalfSize / 8 - 1, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
306 1, 1, 0x12,
307 8, HalfSize / 8, 0x12, 0x34, 0x56, 0x78, 0x9A, 0xBC, 0xDE, 0xF0,
308 1, 7, 0x12, 0);
309
316
329
330
352
363
364
371
381
382
389
399
400
407
417
418
424 ok_bool_true(
CheckBuffer(
Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0),
"CheckBuffer");
425
429#if defined(__GNUC__) && __GNUC__ >= 5
430#pragma GCC diagnostic push
431#pragma GCC diagnostic ignored "-Wmemset-transposed-args"
432#endif
434#if defined(__GNUC__) && __GNUC__ >= 5
435#pragma GCC diagnostic pop
436#endif
442
443#undef RtlFillMemory
444
450 ok_bool_true(
CheckBuffer(
Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0),
"CheckBuffer");
451
461
462
463#if !defined _M_AMD64 || defined KMT_KERNEL_MODE
464
468 ok_bool_true(
CheckPattern(
Buffer, 4, HalfSize / 4, 0x67, 0x45, 0x23, 0x01, 4, HalfSize / 4, 0xEF, 0xCD, 0xAB, 0x89, 1, 1, 0, 0),
"CheckPattern");
469
475 ok_bool_true(
CheckBuffer(
Buffer, 1, 0,
sizeof(
ULONG), 0xAA,
Size -
sizeof(
ULONG) - 1, 0, 1, 0, 0),
"CheckBuffer");
476
483#endif
484
485
486
487
488
494 ok_bool_true(
CheckBuffer(
Buffer, 3, 0x55, 7, 0x88, HalfSize - 10, 0x55, HalfSize, 0xAA, 1, 0, 0),
"CheckBuffer");
495
505
506
508
518
520}
static VOID MakePattern(OUT PVOID Buffer,...)
static BOOLEAN CheckPattern(IN const VOID *Buffer,...)
static BOOLEAN CheckBuffer(IN const VOID *Buffer,...)
#define ok_eq_hex(value, expected)
#define ok_bool_false(value, desc)
#define ok_eq_uint(value, expected)
#define ok_bool_true(value, desc)
#define ok_eq_size(value, expected)
#define KeRaiseIrql(irql, oldIrql)
#define RtlCompareMemory(s1, s2, l)
#define KeLowerIrql(oldIrql)
#define RtlFillMemory(Dest, Length, Fill)
#define EXCEPTION_EXECUTE_HANDLER
#define RtlEqualMemory(dst, src, len)
#define RtlFillMemoryUlong(dst, len, val)
VOID FASTCALL RtlPrefetchMemoryNonTemporal(IN PVOID Source, IN SIZE_T Length)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define RtlMoveMemory(Destination, Source, Length)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
FORCEINLINE PVOID RtlSecureZeroMemory(_Out_writes_bytes_all_(Size) PVOID Pointer, _In_ SIZE_T Size)
#define RtlCopyMemoryNonTemporal
_Must_inspect_result_ NTSYSAPI SIZE_T NTAPI RtlCompareMemoryUlong(_In_reads_bytes_(Length) PVOID Source, _In_ SIZE_T Length, _In_ ULONG Pattern)