ReactOS 0.4.16-dev-292-gbbdcc14
RtlBitmap.c File Reference
#include "precomp.h"
#include <versionhelpers.h>
#include <pseh/pseh2.h>
Include dependency graph for RtlBitmap.c:

Go to the source code of this file.

Functions

void Test_RtlFindMostSignificantBit (void)
 
void Test_RtlFindLeastSignificantBit (void)
 
void Test_RtlInitializeBitMap (void)
 
void Test_RtlClearAllBits (void)
 
void Test_RtlSetAllBits (void)
 
void Test_RtlClearBits (void)
 
void Test_RtlSetBits (void)
 
void Test_RtlAreBitsClear (void)
 
void Test_RtlAreBitsSet (void)
 
void Test_RtlNumberOfSetBits (void)
 
void Test_RtlNumberOfClearBits (void)
 
void Test_RtlFindClearBits (void)
 
void Test_RtlFindSetBits (void)
 
void Test_RtlFindClearBitsAndSet (void)
 
void Test_RtlFindSetBitsAndClear (void)
 
void Test_RtlFindNextForwardRunClear (void)
 
void Test_RtlFindFirstRunClear (void)
 
void Test_RtlFindLastBackwardRunClear (void)
 
void Test_RtlFindClearRuns (void)
 
void Test_RtlFindLongestRunClear (void)
 
 START_TEST (RtlBitmap)
 

Variables

static BOOL IsBroken = FALSE
 

Function Documentation

◆ START_TEST()

START_TEST ( RtlBitmap  )

Definition at line 603 of file RtlBitmap.c.

604{
605 /* Windows 2003 has broken bitmap code that modifies the buffer */
606 if (!IsWindows7OrGreater() && !IsReactOS())
607 {
608 IsBroken = TRUE;
609 }
610
631}
void Test_RtlFindLeastSignificantBit(void)
Definition: RtlBitmap.c:24
void Test_RtlSetBits(void)
Definition: RtlBitmap.c:177
void Test_RtlInitializeBitMap(void)
Definition: RtlBitmap.c:38
void Test_RtlFindNextForwardRunClear(void)
Definition: RtlBitmap.c:551
void Test_RtlClearAllBits(void)
Definition: RtlBitmap.c:71
void Test_RtlClearBits(void)
Definition: RtlBitmap.c:127
void Test_RtlFindClearBits(void)
Definition: RtlBitmap.c:357
void Test_RtlFindLastBackwardRunClear(void)
Definition: RtlBitmap.c:588
void Test_RtlFindLongestRunClear(void)
Definition: RtlBitmap.c:598
void Test_RtlFindClearRuns(void)
Definition: RtlBitmap.c:593
void Test_RtlFindSetBits(void)
Definition: RtlBitmap.c:408
static BOOL IsBroken
Definition: RtlBitmap.c:7
void Test_RtlAreBitsSet(void)
Definition: RtlBitmap.c:254
void Test_RtlFindMostSignificantBit(void)
Definition: RtlBitmap.c:10
void Test_RtlFindSetBitsAndClear(void)
Definition: RtlBitmap.c:504
void Test_RtlSetAllBits(void)
Definition: RtlBitmap.c:99
void Test_RtlFindClearBitsAndSet(void)
Definition: RtlBitmap.c:457
void Test_RtlFindFirstRunClear(void)
Definition: RtlBitmap.c:583
void Test_RtlNumberOfClearBits(void)
Definition: RtlBitmap.c:319
void Test_RtlAreBitsClear(void)
Definition: RtlBitmap.c:227
void Test_RtlNumberOfSetBits(void)
Definition: RtlBitmap.c:281
#define TRUE
Definition: types.h:120
VERSIONHELPERAPI IsWindows7OrGreater()

◆ Test_RtlAreBitsClear()

void Test_RtlAreBitsClear ( void  )

Definition at line 227 of file RtlBitmap.c.

228{
229 RTL_BITMAP BitMapHeader;
230 ULONG *Buffer;
231
232 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
233 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
234 Buffer[0] = 0x00ff00ff;
235 Buffer[1] = 0xc0cfc0cf;
236
237 ok_hex(RtlAreBitsClear(&BitMapHeader, 0, 8), FALSE);
238 ok_hex(RtlAreBitsClear(&BitMapHeader, 8, 8), TRUE);
239 ok_hex(RtlAreBitsClear(&BitMapHeader, 7, 8), FALSE);
240 ok_hex(RtlAreBitsClear(&BitMapHeader, 8, 9), FALSE);
241 ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 1), FALSE);
242
243 RtlInitializeBitMap(&BitMapHeader, Buffer, 31);
244 ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 1), TRUE);
245 ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 7), TRUE);
246 ok_hex(RtlAreBitsClear(&BitMapHeader, 24, 8), FALSE);
247
248 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
249 ok_hex(RtlAreBitsClear(&BitMapHeader, 60, 4), FALSE);
251}
static VOID FreeGuarded(_In_ PVOID Pointer)
Definition: apitest_guard.h:45
static PVOID AllocateGuarded(_In_ SIZE_T SizeRequested)
Definition: apitest_guard.h:10
#define ok_hex(expression, result)
Definition: atltest.h:94
Definition: bufpool.h:45
#define RtlAreBitsClear
Definition: dbgbitmap.h:327
#define RtlInitializeBitMap
Definition: dbgbitmap.h:326
#define FALSE
Definition: types.h:117
uint32_t ULONG
Definition: typedefs.h:59

Referenced by START_TEST().

◆ Test_RtlAreBitsSet()

void Test_RtlAreBitsSet ( void  )

Definition at line 254 of file RtlBitmap.c.

255{
256 RTL_BITMAP BitMapHeader;
257 ULONG *Buffer;
258
259 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
260 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
261 Buffer[0] = 0xff00ff00;
262 Buffer[1] = 0x3F303F30;
263
264 ok_hex(RtlAreBitsSet(&BitMapHeader, 0, 8), FALSE);
265 ok_hex(RtlAreBitsSet(&BitMapHeader, 8, 8), TRUE);
266 ok_hex(RtlAreBitsSet(&BitMapHeader, 7, 8), FALSE);
267 ok_hex(RtlAreBitsSet(&BitMapHeader, 8, 9), FALSE);
268 ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 1), FALSE);
269
270 RtlInitializeBitMap(&BitMapHeader, Buffer, 31);
271 ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 1), TRUE);
272 ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 7), TRUE);
273 ok_hex(RtlAreBitsSet(&BitMapHeader, 24, 8), FALSE);
274
275 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
276 ok_hex(RtlAreBitsSet(&BitMapHeader, 60, 4), FALSE);
278}
#define RtlAreBitsSet
Definition: dbgbitmap.h:328

Referenced by START_TEST().

◆ Test_RtlClearAllBits()

void Test_RtlClearAllBits ( void  )

Definition at line 71 of file RtlBitmap.c.

72{
73 RTL_BITMAP BitMapHeader;
75 ULONG BufferSize = 2 * sizeof(*Buffer);
76
78 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
79 memset(Buffer, 0xcc, BufferSize);
80 RtlClearAllBits(&BitMapHeader);
81 ok_hex(Buffer[0], 0x00000000);
82 ok_hex(Buffer[1], 0xcccccccc);
83
84 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
85 memset(Buffer, 0xcc, BufferSize);
86 RtlClearAllBits(&BitMapHeader);
87 ok_hex(Buffer[0], 0xcccccccc);
88 ok_hex(Buffer[1], 0xcccccccc);
89
90 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
91 memset(Buffer, 0xcc, BufferSize);
92 RtlClearAllBits(&BitMapHeader);
93 ok_hex(Buffer[0], 0x00000000);
94 ok_hex(Buffer[1], 0x00000000);
96}
#define RtlClearAllBits
Definition: dbgbitmap.h:329
#define memset(x, y, z)
Definition: compat.h:39
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:254

Referenced by START_TEST().

◆ Test_RtlClearBits()

void Test_RtlClearBits ( void  )

Definition at line 127 of file RtlBitmap.c.

128{
129 RTL_BITMAP BitMapHeader;
130 ULONG *Buffer;
131 ULONG BufferSize = 2 * sizeof(*Buffer);
132
134 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
135
136 memset(Buffer, 0xff, BufferSize);
137 RtlClearBits(&BitMapHeader, 0, 0);
138 ok_hex(Buffer[0], 0xffffffff);
139 ok_hex(Buffer[1], 0xffffffff);
140
141 memset(Buffer, 0xff, BufferSize);
142 RtlClearBits(&BitMapHeader, 0, 1);
143 ok_hex(Buffer[0], 0xfffffffe);
144 ok_hex(Buffer[1], 0xffffffff);
145
146 memset(Buffer, 0xff, BufferSize);
147 RtlClearBits(&BitMapHeader, 21, 1);
148 ok_hex(Buffer[0], 0xffdfffff);
149 ok_hex(Buffer[1], 0xffffffff);
150
151 memset(Buffer, 0xff, BufferSize);
152 RtlClearBits(&BitMapHeader, 7, 9);
153 ok_hex(Buffer[0], 0xffff007f);
154 ok_hex(Buffer[1], 0xffffffff);
155
156 memset(Buffer, 0xff, BufferSize);
157 RtlClearBits(&BitMapHeader, 13, 22);
158 ok_hex(Buffer[0], 0x00001fff);
159 ok_hex(Buffer[1], 0xfffffff8);
160
161 memset(Buffer, 0xff, BufferSize);
162 RtlClearBits(&BitMapHeader, 63, 1);
163 ok_hex(Buffer[0], 0xffffffff);
164 ok_hex(Buffer[1], 0x7fffffff);
165
166 memset(Buffer, 0xcc, BufferSize);
167 RtlClearBits(&BitMapHeader, 3, 6);
168 RtlClearBits(&BitMapHeader, 11, 5);
169 RtlClearBits(&BitMapHeader, 21, 7);
170 RtlClearBits(&BitMapHeader, 37, 4);
171 ok_hex(Buffer[0], 0xc00c0404);
172 ok_hex(Buffer[1], 0xcccccc0c);
174}
#define RtlClearBits
Definition: dbgbitmap.h:331

Referenced by START_TEST().

◆ Test_RtlFindClearBits()

void Test_RtlFindClearBits ( void  )

Definition at line 357 of file RtlBitmap.c.

358{
359 RTL_BITMAP BitMapHeader;
360 ULONG *Buffer;
361
362 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
363 Buffer[0] = 0x060F874D;
364 Buffer[1] = 0x3F303F30;
365
366 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
367 ok_int(RtlFindClearBits(&BitMapHeader, 0, 0), 0);
368 ok_int(RtlFindClearBits(&BitMapHeader, 0, 3), 0);
369 ok_int(RtlFindClearBits(&BitMapHeader, 1, 0), -1);
370 ok_int(RtlFindClearBits(&BitMapHeader, 1, 1), -1);
371
372 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
373 ok_int(RtlFindClearBits(&BitMapHeader, 0, 3), 0);
374 ok_int(RtlFindClearBits(&BitMapHeader, 1, 0), 1);
375 ok_int(RtlFindClearBits(&BitMapHeader, 1, 1), 1);
376 ok_int(RtlFindClearBits(&BitMapHeader, 1, 2), 4);
377
378 ok_int(RtlFindClearBits(&BitMapHeader, 2, 0), 4);
379 ok_int(RtlFindClearBits(&BitMapHeader, 3, 0), -1);
380
381 RtlInitializeBitMap(&BitMapHeader, Buffer, 32);
382 ok_int(RtlFindClearBits(&BitMapHeader, 0, 3), 0);
383 ok_int(RtlFindClearBits(&BitMapHeader, 0, 21), 16);
384 ok_int(RtlFindClearBits(&BitMapHeader, 0, 12), 8);
385 ok_int(RtlFindClearBits(&BitMapHeader, 0, 31), 24);
386 ok_int(RtlFindClearBits(&BitMapHeader, 0, 32), 0);
387 ok_int(RtlFindClearBits(&BitMapHeader, 0, 39), 0);
388 ok_int(RtlFindClearBits(&BitMapHeader, 4, 0), 11);
389 ok_int(RtlFindClearBits(&BitMapHeader, 5, 0), 20);
390 ok_int(RtlFindClearBits(&BitMapHeader, 4, 11), 11);
391 ok_int(RtlFindClearBits(&BitMapHeader, 4, 12), 20);
392 ok_int(RtlFindClearBits(&BitMapHeader, 2, 11), 11);
393 ok_int(RtlFindClearBits(&BitMapHeader, 2, 12), 12);
394 ok_int(RtlFindClearBits(&BitMapHeader, 1, 32), 1);
395 ok_int(RtlFindClearBits(&BitMapHeader, 4, 32), 11);
396 ok_int(RtlFindClearBits(&BitMapHeader, 5, 32), 20);
397
398 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
399 ok_int(RtlFindClearBits(&BitMapHeader, 5, 64), 20);
400 ok_int(RtlFindClearBits(&BitMapHeader, 9, 28), 27);
401 ok_int(RtlFindClearBits(&BitMapHeader, 10, 0), -1);
402 Buffer[1] = 0xFF303F30;
403 ok_int(RtlFindClearBits(&BitMapHeader, 1, 56), 1);
405}
#define ok_int(expression, result)
Definition: atltest.h:134
#define RtlFindClearBits
Definition: dbgbitmap.h:332

Referenced by START_TEST().

◆ Test_RtlFindClearBitsAndSet()

void Test_RtlFindClearBitsAndSet ( void  )

Definition at line 457 of file RtlBitmap.c.

458{
459 RTL_BITMAP BitMapHeader;
460 ULONG *Buffer;
461
462 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
463 Buffer[0] = 0x060F874D;
464 Buffer[1] = 0x3F303F30;
465
466 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
467 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 0, 0), 0);
468 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 0, 3), 0);
469 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 1, 0), -1);
470 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 1, 1), -1);
471 ok_hex(Buffer[0], 0x060F874D);
472
473 Buffer[0] = 0x060F874D;
474 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
475 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 1, 0), 1);
476 ok_hex(Buffer[0], 0x60f874f);
477 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 1, 1), 4);
478 ok_hex(Buffer[0], 0x60f875f);
479 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 1, 2), 5);
480 ok_hex(Buffer[0], 0x60f877f);
481 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 2, 0), -1);
482 ok_hex(Buffer[0], 0x60f877f);
483
484 Buffer[0] = 0x060F874D;
485 RtlInitializeBitMap(&BitMapHeader, Buffer, 32);
486 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 4, 0), 11);
487 ok_hex(Buffer[0], 0x60fff4d);
488 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 5, 0), 20);
489 ok_hex(Buffer[0], 0x7ffff4d);
490 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 4, 11), 27);
491 ok_hex(Buffer[0], 0x7fffff4d);
492
493 Buffer[0] = 0x060F874D;
494 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 4, 12), 20);
495 ok_hex(Buffer[0], 0x6ff874d);
496 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 2, 11), 11);
497 ok_hex(Buffer[0], 0x6ff9f4d);
498 ok_int(RtlFindClearBitsAndSet(&BitMapHeader, 2, 12), 13);
499 ok_hex(Buffer[0], 0x6ffff4d);
501}
#define RtlFindClearBitsAndSet
Definition: dbgbitmap.h:333

Referenced by START_TEST().

◆ Test_RtlFindClearRuns()

void Test_RtlFindClearRuns ( void  )

Definition at line 593 of file RtlBitmap.c.

594{
595}

Referenced by START_TEST().

◆ Test_RtlFindFirstRunClear()

void Test_RtlFindFirstRunClear ( void  )

Definition at line 583 of file RtlBitmap.c.

584{
585}

Referenced by START_TEST().

◆ Test_RtlFindLastBackwardRunClear()

void Test_RtlFindLastBackwardRunClear ( void  )

Definition at line 588 of file RtlBitmap.c.

589{
590}

Referenced by START_TEST().

◆ Test_RtlFindLeastSignificantBit()

void Test_RtlFindLeastSignificantBit ( void  )

Definition at line 24 of file RtlBitmap.c.

25{
27
28 ok_int(RtlFindLeastSignificantBit(0x0000000000000001ULL), 0);
29 ok_int(RtlFindLeastSignificantBit(0x0000000000000002ULL), 1);
30 ok_int(RtlFindLeastSignificantBit(0x1000000000000000ULL), 60);
31 ok_int(RtlFindLeastSignificantBit(0x8000000000000000ULL), 63);
32 ok_int(RtlFindLeastSignificantBit(0x8000000000000000ULL), 63);
33 ok_int(RtlFindLeastSignificantBit(0xFFFFFFFFFFFFFFFFULL), 0);
34 ok_int(RtlFindLeastSignificantBit(0x0000000070000000ULL), 28);
35}
NTSYSAPI CCHAR WINAPI RtlFindLeastSignificantBit(ULONGLONG)
Definition: bitmap.c:235

Referenced by START_TEST().

◆ Test_RtlFindLongestRunClear()

void Test_RtlFindLongestRunClear ( void  )

Definition at line 598 of file RtlBitmap.c.

599{
600}

Referenced by START_TEST().

◆ Test_RtlFindMostSignificantBit()

void Test_RtlFindMostSignificantBit ( void  )

Definition at line 10 of file RtlBitmap.c.

11{
13
14 ok_int(RtlFindMostSignificantBit(0x0000000000000001ULL), 0);
15 ok_int(RtlFindMostSignificantBit(0x0000000000000002ULL), 1);
16 ok_int(RtlFindMostSignificantBit(0x1000000000000000ULL), 60);
17 ok_int(RtlFindMostSignificantBit(0x8000000000000000ULL), 63);
18 ok_int(RtlFindMostSignificantBit(0x8000000000000001ULL), 63);
19 ok_int(RtlFindMostSignificantBit(0xFFFFFFFFFFFFFFFFULL), 63);
20 ok_int(RtlFindMostSignificantBit(0x0000000070000000ULL), 30);
21}
NTSYSAPI CCHAR WINAPI RtlFindMostSignificantBit(ULONGLONG)
Definition: bitmap.c:211

Referenced by START_TEST().

◆ Test_RtlFindNextForwardRunClear()

void Test_RtlFindNextForwardRunClear ( void  )

Definition at line 551 of file RtlBitmap.c.

552{
553 RTL_BITMAP BitMapHeader;
554 ULONG *Buffer;
555 ULONG Index;
556
557 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
558 Buffer[0] = 0xF9F078B2;
559 Buffer[1] = 0x3F303F30;
560
561 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
562 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 0, &Index), 0);
563 ok_int(Index, 0);
564 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 1, &Index), 0);
565 ok_int(Index, 1);
566
567 Index = -1;
568 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
569 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 0, &Index), 1);
570 ok_int(Index, 0);
571 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 1, &Index), 2);
572 ok_int(Index, 2);
573 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 7, &Index), 0);
574 ok_int(Index, 8);
575 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 17, &Index), 0);
576 ok_int(Index, 17);
577 ok_int(RtlFindNextForwardRunClear(&BitMapHeader, 39, &Index), 0);
578 ok_int(Index, 39);
580}
#define RtlFindNextForwardRunClear
Definition: dbgbitmap.h:338
_In_ WDFCOLLECTION _In_ ULONG Index

Referenced by START_TEST().

◆ Test_RtlFindSetBits()

void Test_RtlFindSetBits ( void  )

Definition at line 408 of file RtlBitmap.c.

409{
410 RTL_BITMAP BitMapHeader;
411 ULONG *Buffer;
412
413 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
414 Buffer[0] = 0xF9F078B2;
415 Buffer[1] = 0x3F303F30;
416
417 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
418 ok_int(RtlFindSetBits(&BitMapHeader, 0, 0), 0);
419 ok_int(RtlFindSetBits(&BitMapHeader, 0, 3), 0);
420 ok_int(RtlFindSetBits(&BitMapHeader, 1, 0), -1);
421 ok_int(RtlFindSetBits(&BitMapHeader, 1, 1), -1);
422
423 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
424 ok_int(RtlFindSetBits(&BitMapHeader, 0, 3), 0);
425 ok_int(RtlFindSetBits(&BitMapHeader, 1, 0), 1);
426 ok_int(RtlFindSetBits(&BitMapHeader, 1, 1), 1);
427 ok_int(RtlFindSetBits(&BitMapHeader, 1, 2), 4);
428
429 ok_int(RtlFindSetBits(&BitMapHeader, 2, 0), 4);
430 ok_int(RtlFindSetBits(&BitMapHeader, 3, 0), -1);
431
432 RtlInitializeBitMap(&BitMapHeader, Buffer, 32);
433 ok_int(RtlFindSetBits(&BitMapHeader, 0, 3), 0);
434 ok_int(RtlFindSetBits(&BitMapHeader, 0, 21), 16);
435 ok_int(RtlFindSetBits(&BitMapHeader, 0, 12), 8);
436 ok_int(RtlFindSetBits(&BitMapHeader, 0, 31), 24);
437 ok_int(RtlFindSetBits(&BitMapHeader, 0, 32), 0);
438 ok_int(RtlFindSetBits(&BitMapHeader, 0, 39), 0);
439 ok_int(RtlFindSetBits(&BitMapHeader, 4, 0), 11);
440 ok_int(RtlFindSetBits(&BitMapHeader, 5, 0), 20);
441 ok_int(RtlFindSetBits(&BitMapHeader, 4, 11), 11);
442 ok_int(RtlFindSetBits(&BitMapHeader, 4, 12), 20);
443 ok_int(RtlFindSetBits(&BitMapHeader, 2, 11), 11);
444 ok_int(RtlFindSetBits(&BitMapHeader, 1, 32), 1);
445 ok_int(RtlFindSetBits(&BitMapHeader, 4, 32), 11);
446 ok_int(RtlFindSetBits(&BitMapHeader, 5, 32), 20);
447
448 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
449 ok_int(RtlFindSetBits(&BitMapHeader, 5, 64), 20);
450 ok_int(RtlFindSetBits(&BitMapHeader, 6, 57), 40);
451 ok_int(RtlFindSetBits(&BitMapHeader, 7, 0), -1);
452 ok_int(RtlFindSetBits(&BitMapHeader, 1, 62), 1);
454}
#define RtlFindSetBits
Definition: dbgbitmap.h:340

Referenced by START_TEST().

◆ Test_RtlFindSetBitsAndClear()

void Test_RtlFindSetBitsAndClear ( void  )

Definition at line 504 of file RtlBitmap.c.

505{
506 RTL_BITMAP BitMapHeader;
507 ULONG *Buffer;
508
509 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
510 Buffer[0] = 0xF9F078B2;
511 Buffer[1] = 0x3F303F30;
512
513 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
514 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 0, 0), 0);
515 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 0, 3), 0);
516 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 1, 0), -1);
517 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 1, 1), -1);
518 ok_hex(Buffer[0], 0xF9F078B2);
519
520 Buffer[0] = 0xF9F078B2;
521 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
522 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 1, 0), 1);
523 ok_hex(Buffer[0], 0xf9f078b0);
524 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 1, 1), 4);
525 ok_hex(Buffer[0], 0xf9f078a0);
526 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 1, 2), 5);
527 ok_hex(Buffer[0], 0xf9f07880);
528 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 2, 0), -1);
529 ok_hex(Buffer[0], 0xf9f07880);
530
531 Buffer[0] = 0xF9F078B2;
532 RtlInitializeBitMap(&BitMapHeader, Buffer, 32);
533 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 4, 0), 11);
534 ok_hex(Buffer[0], 0xf9f000b2);
535 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 5, 0), 20);
536 ok_hex(Buffer[0], 0xf80000b2);
537 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 4, 11), 27);
538 ok_hex(Buffer[0], 0x800000b2);
539
540 Buffer[0] = 0xF9F078B2;
541 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 4, 12), 20);
542 ok_hex(Buffer[0], 0xf90078b2);
543 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 2, 11), 11);
544 ok_hex(Buffer[0], 0xf90060b2);
545 ok_int(RtlFindSetBitsAndClear(&BitMapHeader, 2, 12), 13);
546 ok_hex(Buffer[0], 0xf90000b2);
548}
#define RtlFindSetBitsAndClear
Definition: dbgbitmap.h:341

Referenced by START_TEST().

◆ Test_RtlInitializeBitMap()

void Test_RtlInitializeBitMap ( void  )

Definition at line 38 of file RtlBitmap.c.

39{
40 RTL_BITMAP BitMapHeader;
41 ULONG Buffer[2];
42 BOOLEAN Exception = FALSE;
43
45 {
47 }
49 {
50 Exception = TRUE;
51 }
53 ok_int(Exception, 1);
54
55 RtlInitializeBitMap(&BitMapHeader, NULL, -1);
56 ok_int(BitMapHeader.SizeOfBitMap, -1);
57 ok_ptr(BitMapHeader.Buffer, NULL);
58
59 memset(Buffer, 0xcc, sizeof(Buffer));
60 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
61 ok_int(BitMapHeader.SizeOfBitMap, 0);
62 ok_ptr(BitMapHeader.Buffer, Buffer);
63 ok_hex(Buffer[0], 0xcccccccc);
64
65 RtlInitializeBitMap(&BitMapHeader, Buffer, 8);
66 ok_int(BitMapHeader.SizeOfBitMap, 8);
67 ok_hex(Buffer[0], 0xcccccccc);
68}
unsigned char BOOLEAN
#define ok_ptr(expression, result)
Definition: atltest.h:108
#define NULL
Definition: types.h:112
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
ULONG SizeOfBitMap
Definition: typedefs.h:90
PULONG Buffer
Definition: typedefs.h:91

Referenced by START_TEST().

◆ Test_RtlNumberOfClearBits()

void Test_RtlNumberOfClearBits ( void  )

Definition at line 319 of file RtlBitmap.c.

320{
321 RTL_BITMAP BitMapHeader;
322 ULONG *Buffer;
323
324 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
325 Buffer[0] = 0xff00fff0;
326 Buffer[1] = 0x3F303F30;
327
328 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
329 ok_int(RtlNumberOfClearBits(&BitMapHeader), 28);
330 ok_hex(Buffer[0], 0xff00fff0);
331 ok_hex(Buffer[1], 0x3F303F30);
332
333 RtlInitializeBitMap(&BitMapHeader, Buffer, 56);
334 ok_int(RtlNumberOfClearBits(&BitMapHeader), 26);
335 ok_hex(Buffer[0], 0xff00fff0);
336 ok_hex(Buffer[1], 0x3F303F30);
337
338 RtlInitializeBitMap(&BitMapHeader, Buffer, 31);
339 ok_int(RtlNumberOfClearBits(&BitMapHeader), 12);
340 ok_hex(Buffer[0], IsBroken ? 0x7f00fff0 : 0xff00fff0);
341 ok_hex(Buffer[1], 0x3F303F30);
342
343 RtlInitializeBitMap(&BitMapHeader, Buffer, 4);
344 ok_int(RtlNumberOfClearBits(&BitMapHeader), 4);
345 ok_hex(Buffer[0], IsBroken ? 0x7f00ff00 : 0xff00fff0);
346 ok_hex(Buffer[1], 0x3F303F30);
347
348 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
349 ok_int(RtlNumberOfClearBits(&BitMapHeader), 0);
350 ok_hex(Buffer[0], IsBroken ? 0x7f00ff00 : 0xff00fff0);
351 ok_hex(Buffer[1], 0x3F303F30);
352
354}
#define RtlNumberOfClearBits
Definition: dbgbitmap.h:342

Referenced by START_TEST().

◆ Test_RtlNumberOfSetBits()

void Test_RtlNumberOfSetBits ( void  )

Definition at line 281 of file RtlBitmap.c.

282{
283 RTL_BITMAP BitMapHeader;
284 ULONG *Buffer;
285
286 Buffer = AllocateGuarded(2 * sizeof(*Buffer));
287 Buffer[0] = 0xff00ff0f;
288 Buffer[1] = 0x3F303F30;
289
290 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
291 ok_int(RtlNumberOfSetBits(&BitMapHeader), 36);
292 ok_hex(Buffer[0], 0xff00ff0f);
293 ok_hex(Buffer[1], 0x3F303F30);
294
295 RtlInitializeBitMap(&BitMapHeader, Buffer, 56);
296 ok_int(RtlNumberOfSetBits(&BitMapHeader), 30);
297 ok_hex(Buffer[0], 0xff00ff0f);
298 ok_hex(Buffer[1], 0x3F303F30);
299
300 RtlInitializeBitMap(&BitMapHeader, Buffer, 31);
301 ok_int(RtlNumberOfSetBits(&BitMapHeader), 19);
302 ok_hex(Buffer[0], IsBroken ? 0x7f00ff0f : 0xff00ff0f);
303 ok_hex(Buffer[1], 0x3F303F30);
304
305 RtlInitializeBitMap(&BitMapHeader, Buffer, 4);
306 ok_int(RtlNumberOfSetBits(&BitMapHeader), 4);
307 ok_hex(Buffer[0], IsBroken ? 0x7f00ff0f : 0xff00ff0f);
308 ok_hex(Buffer[1], 0x3F303F30);
309
310 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
311 ok_int(RtlNumberOfSetBits(&BitMapHeader), 0);
312 ok_hex(Buffer[0], IsBroken ? 0x7f00ff0f : 0xff00ff0f);
313 ok_hex(Buffer[1], 0x3F303F30);
314
316}
#define RtlNumberOfSetBits
Definition: dbgbitmap.h:343

Referenced by START_TEST().

◆ Test_RtlSetAllBits()

void Test_RtlSetAllBits ( void  )

Definition at line 99 of file RtlBitmap.c.

100{
101 RTL_BITMAP BitMapHeader;
102 ULONG *Buffer;
103 ULONG BufferSize = 2 * sizeof(*Buffer);
104
106 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
107 memset(Buffer, 0xcc, BufferSize);
108 RtlSetAllBits(&BitMapHeader);
109 ok_hex(Buffer[0], 0xffffffff);
110 ok_hex(Buffer[1], 0xcccccccc);
111
112 RtlInitializeBitMap(&BitMapHeader, Buffer, 0);
113 memset(Buffer, 0xcc, BufferSize);
114 RtlSetAllBits(&BitMapHeader);
115 ok_hex(Buffer[0], 0xcccccccc);
116 ok_hex(Buffer[1], 0xcccccccc);
117
118 RtlInitializeBitMap(&BitMapHeader, Buffer, 64);
119 memset(Buffer, 0xcc, BufferSize);
120 RtlSetAllBits(&BitMapHeader);
121 ok_hex(Buffer[0], 0xffffffff);
122 ok_hex(Buffer[1], 0xffffffff);
124}
#define RtlSetAllBits
Definition: dbgbitmap.h:346

Referenced by START_TEST().

◆ Test_RtlSetBits()

void Test_RtlSetBits ( void  )

Definition at line 177 of file RtlBitmap.c.

178{
179 RTL_BITMAP BitMapHeader;
180 ULONG *Buffer;
181 ULONG BufferSize = 2 * sizeof(*Buffer);
182
184 RtlInitializeBitMap(&BitMapHeader, Buffer, 19);
185
186 memset(Buffer, 0x00, BufferSize);
187 RtlSetBits(&BitMapHeader, 0, 0);
188 ok_hex(Buffer[0], 0x00000000);
189 ok_hex(Buffer[1], 0x00000000);
190
191 memset(Buffer, 0x00, BufferSize);
192 RtlSetBits(&BitMapHeader, 0, 1);
193 ok_hex(Buffer[0], 0x00000001);
194 ok_hex(Buffer[1], 0x00000000);
195
196 memset(Buffer, 0x00, BufferSize);
197 RtlSetBits(&BitMapHeader, 21, 1);
198 ok_hex(Buffer[0], 0x00200000);
199 ok_hex(Buffer[1], 0x00000000);
200
201 memset(Buffer, 0x00, BufferSize);
202 RtlSetBits(&BitMapHeader, 7, 9);
203 ok_hex(Buffer[0], 0x0000ff80);
204 ok_hex(Buffer[1], 0x00000000);
205
206 memset(Buffer, 0x00, BufferSize);
207 RtlSetBits(&BitMapHeader, 13, 22);
208 ok_hex(Buffer[0], 0xffffe000);
209 ok_hex(Buffer[1], 0x00000007);
210
211 memset(Buffer, 0x00, BufferSize);
212 RtlSetBits(&BitMapHeader, 63, 1);
213 ok_hex(Buffer[0], 0x00000000);
214 ok_hex(Buffer[1], 0x80000000);
215
216 memset(Buffer, 0xcc, BufferSize);
217 RtlSetBits(&BitMapHeader, 3, 6);
218 RtlSetBits(&BitMapHeader, 11, 5);
219 RtlSetBits(&BitMapHeader, 21, 7);
220 RtlSetBits(&BitMapHeader, 37, 4);
221 ok_hex(Buffer[0], 0xcfecfdfc);
222 ok_hex(Buffer[1], 0xcccccdec);
224}
#define RtlSetBits
Definition: dbgbitmap.h:345

Referenced by START_TEST().

Variable Documentation

◆ IsBroken

BOOL IsBroken = FALSE
static

Definition at line 7 of file RtlBitmap.c.

Referenced by START_TEST(), Test_RtlNumberOfClearBits(), and Test_RtlNumberOfSetBits().