14#if !defined(CMLIB_HOST) && !defined(_BLDR_)
33 if (!RegistryHive->
Flat)
59 if (RegistryHive->Flat)
65 if (Block >= RegistryHive->Storage[
Type].Length)
69 if (RegistryHive->Storage[
Type].BlockList[Block].BlockAddress)
90 return ((
PHCELL)Cell - 1)->Size;
129 CellBlock, CellLastBlock - CellBlock);
143#if !defined(CMLIB_HOST) && !defined(_BLDR_)
178 static CCHAR FindFirstSet[128] = {
179 0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
180 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
181 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
182 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
183 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
184 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
185 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
186 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
246 if (*pFreeCellOffset == CellIndex)
248 *pFreeCellOffset = *FreeCellData;
251 pFreeCellOffset = FreeCellData;
258 for (FreeListIndex = 0; FreeListIndex < 24; FreeListIndex++)
266 pFreeCellOffset = FreeCellData;
294 FreeCellOffset = *pFreeCellOffset;
295 *pFreeCellOffset = *FreeCellData;
296 return FreeCellOffset;
298 pFreeCellOffset = FreeCellData;
331 FreeOffset =
sizeof(
HBIN);
332 while (FreeOffset < Bin->
Size)
385 FreeCellOffset =
Bin->FileOffset +
sizeof(
HBIN);
417 return FreeCellOffset;
439 OldCell =
HvGetCell(RegistryHive, CellIndex);
456 NewCell =
HvGetCell(RegistryHive, NewCellIndex);
496 Bin->FileOffset +
Bin->Size)
499 if (Neighbor->
Size > 0)
509 while (Neighbor <
Free)
511 if (Neighbor->
Size > 0)
524 HvpAddFree(RegistryHive, Neighbor, NeighborCellIndex);
550#define CELL_REF_INCREMENT 10
574 CellRef->StaticArray[CellRef->StaticCount].Hive = Hive;
575 CellRef->StaticArray[CellRef->StaticCount].Cell = Cell;
576 CellRef->StaticCount++;
580 DPRINT(
"HvTrackCellRef: Static array full, use dynamic array.\n");
583 if (CellRef->Max == 0)
587 ASSERT(CellRef->Count == 0);
592 ASSERT(CellRef->CellArray);
594 ASSERT(CellRef->Count <= CellRef->Max);
596 if (CellRef->Count == CellRef->Max)
604 DPRINT1(
"HvTrackCellRef: Cannot reallocate the reference table.\n");
611 if (CellRef->CellArray)
617 CmpFree(CellRef->CellArray, 0);
619 CellRef->CellArray = NewCellArray;
626 CellRef->CellArray[CellRef->Count].Hive = Hive;
627 CellRef->CellArray[CellRef->Count].Cell = Cell;
644 if (CellRef->StaticCount > 0)
650 for (
i = 0;
i < CellRef->StaticCount;
i++)
653 CellRef->StaticArray[
i].Cell);
657 CellRef->StaticCount = 0;
661 if (CellRef->Count > 0)
664 ASSERT(CellRef->Count <= CellRef->Max);
665 ASSERT(CellRef->CellArray);
668 for (
i = 0;
i < CellRef->Count;
i++)
671 CellRef->CellArray[
i].Cell);
675 CmpFree(CellRef->CellArray, 0);
676 CellRef->CellArray =
NULL;
677 CellRef->Count = CellRef->Max = 0;
PVOID NTAPI CmpAllocate(_In_ SIZE_T Size, _In_ BOOLEAN Paged, _In_ ULONG Tag)
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
#define BlockOffset(V, L)
#define HvReleaseCell(Hive, Cell)
#define STATIC_CELL_PAIR_COUNT
#define CMLIB_HCELL_DEBUG
#define HvGetCell(Hive, Cell)
PHBIN CMAPI HvpAddBin(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage)
#define NT_SUCCESS(StatCode)
#define ROUND_UP(n, align)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
BOOLEAN CMAPI HvTrackCellRef(IN OUT PHV_TRACK_CELL_REF CellRef, IN PHHIVE Hive, IN HCELL_INDEX Cell)
VOID NTAPI CmpLazyFlush(VOID)
static __inline PHCELL CMAPI HvpGetCellHeader(PHHIVE RegistryHive, HCELL_INDEX CellIndex)
static VOID CMAPI HvpRemoveFree(PHHIVE RegistryHive, PHCELL CellBlock, HCELL_INDEX CellIndex)
static NTSTATUS CMAPI HvpAddFree(PHHIVE RegistryHive, PHCELL FreeBlock, HCELL_INDEX FreeIndex)
HCELL_INDEX CMAPI HvAllocateCell(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage, HCELL_INDEX Vicinity)
#define CELL_REF_INCREMENT
BOOLEAN CMAPI HvIsCellDirty(IN PHHIVE Hive, IN HCELL_INDEX Cell)
VOID CMAPI HvReleaseFreeCellRefArray(IN OUT PHV_TRACK_CELL_REF CellRef)
LONG CMAPI HvGetCellSize(IN PHHIVE Hive, IN PVOID Address)
PCELL_DATA CMAPI HvpGetCellData(_In_ PHHIVE Hive, _In_ HCELL_INDEX CellIndex)
BOOLEAN CMAPI HvMarkCellDirty(PHHIVE RegistryHive, HCELL_INDEX CellIndex, BOOLEAN HoldingLock)
static __inline ULONG CMAPI HvpComputeFreeListIndex(ULONG Size)
BOOLEAN CMAPI HvIsCellAllocated(IN PHHIVE RegistryHive, IN HCELL_INDEX CellIndex)
static HCELL_INDEX CMAPI HvpFindFree(PHHIVE RegistryHive, ULONG Size, HSTORAGE_TYPE Storage)
HCELL_INDEX CMAPI HvReallocateCell(PHHIVE RegistryHive, HCELL_INDEX CellIndex, ULONG Size)
NTSTATUS CMAPI HvpCreateHiveFreeCellList(PHHIVE Hive)
static __inline LONG CMAPI HvpGetCellFullSize(PHHIVE RegistryHive, PVOID Cell)
VOID CMAPI HvFreeCell(PHHIVE RegistryHive, HCELL_INDEX CellIndex)
#define HvGetCellBlock(Cell)
#define HCELL_OFFSET_MASK
#define HCELL_OFFSET_SHIFT
#define HvGetCellType(Cell)
#define UNREFERENCED_PARAMETER(P)
_In_ ULONG _In_ ULONG _In_ ULONG Length
HCELL_INDEX FreeDisplay[24]
DUAL Storage[HTYPE_COUNT]
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free