21#ifdef USE_RTL_BITMAP64
23#define MAXINDEX 0xFFFFFFFFFFFFFFFF
26#define RTL_BITMAP RTL_BITMAP64
27#define PRTL_BITMAP PRTL_BITMAP64
28#define RTL_BITMAP_RUN RTL_BITMAP_RUN64
29#define PRTL_BITMAP_RUN PRTL_BITMAP_RUN64
31#define BitScanForward(Index, Mask) \
32 do { unsigned long tmp; BitScanForward64(&tmp, Mask); *Index = tmp; } while (0)
34#define BitScanReverse(Index, Mask) \
35 do { unsigned long tmp; BitScanReverse64(&tmp, Mask); *Index = tmp; } while (0)
36#define RtlFillMemoryUlong RtlFillMemoryUlonglong
38#define RtlInitializeBitMap RtlInitializeBitMap64
39#define RtlClearAllBits RtlClearAllBits64
40#define RtlSetAllBits RtlSetAllBits64
41#define RtlClearBit RtlClearBit64
42#define RtlSetBit RtlSetBit64
43#define RtlClearBits RtlClearBits64
44#define RtlSetBits RtlSetBits64
45#define RtlTestBit RtlTestBit64
46#define RtlAreBitsClear RtlAreBitsClear64
47#define RtlAreBitsSet RtlAreBitsSet64
48#define RtlNumberOfSetBits RtlNumberOfSetBits64
49#define RtlNumberOfClearBits RtlNumberOfClearBits64
50#define RtlFindClearBits RtlFindClearBits64
51#define RtlFindSetBits RtlFindSetBits64
52#define RtlFindClearBitsAndSet RtlFindClearBitsAndSet64
53#define RtlFindSetBitsAndClear RtlFindSetBitsAndClear64
54#define RtlFindNextForwardRunClear RtlFindNextForwardRunClear64
55#define RtlFindNextForwardRunSet RtlFindNextForwardRunSet64
56#define RtlFindFirstRunClear RtlFindFirstRunClear64
57#define RtlFindLastBackwardRunClear RtlFindLastBackwardRunClear64
58#define RtlFindClearRuns RtlFindClearRuns64
59#define RtlFindLongestRunClear RtlFindLongestRunClear64
60#define RtlFindLongestRunSet RtlFindLongestRunSet64
63#define MAXINDEX 0xFFFFFFFF
76 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
77 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
78 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
79 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
80 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
81 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
82 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
83 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
84 1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
85 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
86 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
87 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
88 2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
89 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
90 3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
91 4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8
108 ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap);
162 ASSERT(StartingIndex <= BitMapHeader->SizeOfBitMap);
175 InvValue = ~(*
Buffer++) >> BitPos << BitPos;
178 while (InvValue == 0 &&
Buffer < MaxBuffer)
208#ifndef USE_RTL_BITMAP64
266 BitMapHeader->SizeOfBitMap = SizeOfBitMap;
267 BitMapHeader->Buffer = BitMapBuffer;
298 ASSERT(BitNumber <= BitMapHeader->SizeOfBitMap);
308 ASSERT(BitNumber <= BitMapHeader->SizeOfBitMap);
338 if (NumberToClear < Bits)
341 Bits -= NumberToClear;
344 Mask = Mask << Bits >> Bits;
356 NumberToClear -= Bits;
365 if (NumberToClear != 0)
398 if (NumberToSet < Bits)
404 Mask = Mask << Bits >> Bits;
425 if (NumberToSet != 0)
438 ASSERT(BitNumber < BitMapHeader->SizeOfBitMap);
439 return (BitMapHeader->Buffer[BitNumber /
_BITCOUNT] >> (BitNumber & (
_BITCOUNT - 1))) & 1;
482 MaxByte =
Byte + BitMapHeader->SizeOfBitMap / 8;
489 if (BitMapHeader->SizeOfBitMap & 7)
491 Shift = 8 - (BitMapHeader->SizeOfBitMap & 7);
517 if (!BitMapHeader ||
NumberToFind > BitMapHeader->SizeOfBitMap)
533 Margin = BitMapHeader->SizeOfBitMap;
559 CurrentBit += CurrentLength;
585 if (!BitMapHeader ||
NumberToFind > BitMapHeader->SizeOfBitMap)
601 Margin = BitMapHeader->SizeOfBitMap;
627 CurrentBit += CurrentLength;
699 if (FromIndex >= BitMapHeader->SizeOfBitMap)
701 *StartingRunIndex = FromIndex;
707 *StartingRunIndex = FromIndex +
Length;
723 if (FromIndex >= BitMapHeader->SizeOfBitMap)
725 *StartingRunIndex = FromIndex;
731 *StartingRunIndex = FromIndex +
Length;
757 FromIndex =
min(FromIndex, BitMapHeader->SizeOfBitMap - 1);
764 InvValue = ~(*
Buffer--) << BitPos >> BitPos;
767 while (InvValue == 0)
770 if (Buffer < BitMapHeader->
Buffer)
788 while (
Value == 0 &&
Buffer >= BitMapHeader->Buffer)
804 *StartingRunIndex = 0;
808 return (FromIndex - *StartingRunIndex);
824 for (
Run = 0;
Run < SizeOfRunArray;
Run++)
832 if (NumberOfBits == 0)
break;
836 RunArray[
Run].NumberOfBits = NumberOfBits;
839 if (NumberOfBits < RunArray[SmallestRun].NumberOfBits)
849 if (
Run < SizeOfRunArray || !LocateLongestRuns)
863 if (NumberOfBits == 0)
break;
866 if (NumberOfBits > RunArray[SmallestRun].NumberOfBits)
870 RunArray[SmallestRun].NumberOfBits = NumberOfBits;
873 for (
Run = 0;
Run < SizeOfRunArray;
Run++)
876 if (NumberOfBits < RunArray[SmallestRun].NumberOfBits)
885 FromIndex += NumberOfBits;
907 if (NumberOfBits == 0)
break;
910 if (NumberOfBits > MaxNumberOfBits)
913 MaxNumberOfBits = NumberOfBits;
918 FromIndex += NumberOfBits;
921 return MaxNumberOfBits;
940 if (NumberOfBits == 0)
break;
943 if (NumberOfBits > MaxNumberOfBits)
946 MaxNumberOfBits = NumberOfBits;
951 FromIndex += NumberOfBits;
954 return MaxNumberOfBits;
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define RtlInitializeBitMap
#define RtlFindNextForwardRunClear
#define RtlFindLastBackwardRunClear
#define RtlFindClearBitsAndSet
#define RtlNumberOfSetBits
#define RtlFindNextForwardRunSet
#define RtlFindLongestRunClear
#define RtlFindFirstRunClear
#define RtlFindSetBitsAndClear
#define RtlNumberOfClearBits
#define RtlFillMemoryUlong(dst, len, val)
_In_ ULONG _In_ ULONG _In_ ULONG Length
BITMAP_INDEX NTAPI RtlFindLongestRunSet(IN PRTL_BITMAP BitMapHeader, IN PBITMAP_INDEX StartingIndex)
static const UCHAR BitCountTable[256]
static __inline BITMAP_INDEX RtlpGetLengthOfRunSet(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX StartingIndex, _In_ BITMAP_INDEX MaxLength)
static __inline BITMAP_INDEX RtlpGetLengthOfRunClear(_In_ PRTL_BITMAP BitMapHeader, _In_ BITMAP_INDEX StartingIndex, _In_ BITMAP_INDEX MaxLength)
CCHAR NTAPI RtlFindLeastSignificantBit(ULONGLONG Value)
CCHAR NTAPI RtlFindMostSignificantBit(ULONGLONG Value)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
_In_ ULONG _In_ ULONG HintIndex