ReactOS  0.4.14-dev-50-g13bb5e2
hiveinit.c
Go to the documentation of this file.
1 /*
2  * PROJECT: Registry manipulation library
3  * LICENSE: GPL - See COPYING in the top level directory
4  * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
5  * Copyright 2001 - 2005 Eric Kohl
6  */
7 
8 #include "cmlib.h"
9 #define NDEBUG
10 #include <debug.h>
11 
19  IN PHBASE_BLOCK BaseBlock)
20 {
21  if (BaseBlock->Signature != HV_HBLOCK_SIGNATURE ||
22  BaseBlock->Major != HSYS_MAJOR ||
23  BaseBlock->Minor < HSYS_MINOR ||
24  BaseBlock->Type != HFILE_TYPE_PRIMARY ||
25  BaseBlock->Format != HBASE_FORMAT_MEMORY ||
26  BaseBlock->Cluster != 1 ||
27  BaseBlock->Sequence1 != BaseBlock->Sequence2 ||
28  HvpHiveHeaderChecksum(BaseBlock) != BaseBlock->CheckSum)
29  {
30  DPRINT1("Verify Hive Header failed:\n");
31  DPRINT1(" Signature: 0x%x, expected 0x%x; Major: 0x%x, expected 0x%x\n",
32  BaseBlock->Signature, HV_HBLOCK_SIGNATURE, BaseBlock->Major, HSYS_MAJOR);
33  DPRINT1(" Minor: 0x%x expected to be >= 0x%x; Type: 0x%x, expected 0x%x\n",
34  BaseBlock->Minor, HSYS_MINOR, BaseBlock->Type, HFILE_TYPE_PRIMARY);
35  DPRINT1(" Format: 0x%x, expected 0x%x; Cluster: 0x%x, expected 1\n",
36  BaseBlock->Format, HBASE_FORMAT_MEMORY, BaseBlock->Cluster);
37  DPRINT1(" Sequence: 0x%x, expected 0x%x; Checksum: 0x%x, expected 0x%x\n",
38  BaseBlock->Sequence1, BaseBlock->Sequence2,
39  HvpHiveHeaderChecksum(BaseBlock), BaseBlock->CheckSum);
40 
41  return FALSE;
42  }
43 
44  return TRUE;
45 }
46 
52 VOID CMAPI
54  PHHIVE Hive)
55 {
56  ULONG i;
57  PHBIN Bin;
58  ULONG Storage;
59 
60  for (Storage = 0; Storage < Hive->StorageTypeCount; Storage++)
61  {
62  Bin = NULL;
63  for (i = 0; i < Hive->Storage[Storage].Length; i++)
64  {
66  continue;
68  {
70  Hive->Free((PHBIN)Hive->Storage[Storage].BlockList[i].BinAddress, 0);
71  }
74  }
75 
76  if (Hive->Storage[Storage].Length)
77  Hive->Free(Hive->Storage[Storage].BlockList, 0);
78  }
79 }
80 
86 static __inline PHBASE_BLOCK
88  IN PHHIVE Hive,
89  IN BOOLEAN Paged,
90  IN ULONG Tag)
91 {
92  PHBASE_BLOCK BaseBlock;
94 
95  ASSERT(sizeof(HBASE_BLOCK) >= (HSECTOR_SIZE * Hive->Cluster));
96 
97  /* Allocate the buffer */
98  BaseBlock = Hive->Allocate(Hive->BaseBlockAlloc, Paged, Tag);
99  if (!BaseBlock) return NULL;
100 
101  /* Check for, and enforce, alignment */
102  Alignment = Hive->Cluster * HSECTOR_SIZE -1;
103  if ((ULONG_PTR)BaseBlock & Alignment)
104  {
105  /* Free the old header and reallocate a new one, always paged */
106  Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
107  BaseBlock = Hive->Allocate(PAGE_SIZE, TRUE, Tag);
108  if (!BaseBlock) return NULL;
109 
110  Hive->BaseBlockAlloc = PAGE_SIZE;
111  }
112 
113  return BaseBlock;
114 }
115 
123 static VOID
125  IN OUT PHBASE_BLOCK BaseBlock,
127 {
129  SIZE_T Length;
130 
131  /* Always NULL-initialize */
132  RtlZeroMemory(BaseBlock->FileName, (HIVE_FILENAME_MAXLEN + 1) * sizeof(WCHAR));
133 
134  /* Copy the 31 last characters of the hive file name if any */
135  if (!FileName) return;
136 
137  if (FileName->Length / sizeof(WCHAR) <= HIVE_FILENAME_MAXLEN)
138  {
139  Offset = 0;
140  Length = FileName->Length;
141  }
142  else
143  {
144  Offset = FileName->Length / sizeof(WCHAR) - HIVE_FILENAME_MAXLEN;
145  Length = HIVE_FILENAME_MAXLEN * sizeof(WCHAR);
146  }
147 
148  RtlCopyMemory(BaseBlock->FileName, FileName->Buffer + Offset, Length);
149 }
150 
161  IN OUT PHHIVE RegistryHive,
163 {
164  PHBASE_BLOCK BaseBlock;
165  ULONG Index;
166 
167  /* Allocate the base block */
168  BaseBlock = HvpAllocBaseBlockAligned(RegistryHive, FALSE, TAG_CM);
169  if (BaseBlock == NULL)
170  return STATUS_NO_MEMORY;
171 
172  /* Clear it */
173  RtlZeroMemory(BaseBlock, RegistryHive->BaseBlockAlloc);
174 
175  BaseBlock->Signature = HV_HBLOCK_SIGNATURE;
176  BaseBlock->Major = HSYS_MAJOR;
177  BaseBlock->Minor = HSYS_MINOR;
178  BaseBlock->Type = HFILE_TYPE_PRIMARY;
179  BaseBlock->Format = HBASE_FORMAT_MEMORY;
180  BaseBlock->Cluster = 1;
181  BaseBlock->RootCell = HCELL_NIL;
182  BaseBlock->Length = 0;
183  BaseBlock->Sequence1 = 1;
184  BaseBlock->Sequence2 = 1;
185  BaseBlock->TimeStamp.QuadPart = 0ULL;
186 
187  /*
188  * No need to compute the checksum since
189  * the hive resides only in memory so far.
190  */
191  BaseBlock->CheckSum = 0;
192 
193  /* Set default boot type */
194  BaseBlock->BootType = 0;
195 
196  /* Setup hive data */
197  RegistryHive->BaseBlock = BaseBlock;
198  RegistryHive->Version = BaseBlock->Minor; // == HSYS_MINOR
199 
200  for (Index = 0; Index < 24; Index++)
201  {
202  RegistryHive->Storage[Stable].FreeDisplay[Index] = HCELL_NIL;
203  RegistryHive->Storage[Volatile].FreeDisplay[Index] = HCELL_NIL;
204  }
205 
206  HvpInitFileName(BaseBlock, FileName);
207 
208  return STATUS_SUCCESS;
209 }
210 
222  PHHIVE Hive,
223  PHBASE_BLOCK ChunkBase,
225 {
226  SIZE_T BlockIndex;
227  PHBIN Bin, NewBin;
228  ULONG i;
229  ULONG BitmapSize;
232 
233  ChunkSize = ChunkBase->Length;
234  DPRINT("ChunkSize: %zx\n", ChunkSize);
235 
236  if (ChunkSize < sizeof(HBASE_BLOCK) ||
237  !HvpVerifyHiveHeader(ChunkBase))
238  {
239  DPRINT1("Registry is corrupt: ChunkSize 0x%zx < sizeof(HBASE_BLOCK) 0x%zx, "
240  "or HvpVerifyHiveHeader() failed\n", ChunkSize, sizeof(HBASE_BLOCK));
242  }
243 
244  /* Allocate the base block */
246  if (Hive->BaseBlock == NULL)
247  return STATUS_NO_MEMORY;
248 
249  RtlCopyMemory(Hive->BaseBlock, ChunkBase, sizeof(HBASE_BLOCK));
250 
251  /* Setup hive data */
252  Hive->Version = ChunkBase->Minor;
253 
254  /*
255  * Build a block list from the in-memory chunk and copy the data as
256  * we go.
257  */
258 
260  Hive->Storage[Stable].BlockList =
261  Hive->Allocate(Hive->Storage[Stable].Length *
262  sizeof(HMAP_ENTRY), FALSE, TAG_CM);
263  if (Hive->Storage[Stable].BlockList == NULL)
264  {
265  DPRINT1("Allocating block list failed\n");
266  Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
267  return STATUS_NO_MEMORY;
268  }
269 
270  for (BlockIndex = 0; BlockIndex < Hive->Storage[Stable].Length; )
271  {
272  Bin = (PHBIN)((ULONG_PTR)ChunkBase + (BlockIndex + 1) * HBLOCK_SIZE);
273  if (Bin->Signature != HV_HBIN_SIGNATURE ||
274  (Bin->Size % HBLOCK_SIZE) != 0)
275  {
276  DPRINT1("Invalid bin at BlockIndex %lu, Signature 0x%x, Size 0x%x\n",
277  (unsigned long)BlockIndex, (unsigned)Bin->Signature, (unsigned)Bin->Size);
278  Hive->Free(Hive->Storage[Stable].BlockList, 0);
279  Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
281  }
282 
283  NewBin = Hive->Allocate(Bin->Size, TRUE, TAG_CM);
284  if (NewBin == NULL)
285  {
286  Hive->Free(Hive->Storage[Stable].BlockList, 0);
287  Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
288  return STATUS_NO_MEMORY;
289  }
290 
291  Hive->Storage[Stable].BlockList[BlockIndex].BinAddress = (ULONG_PTR)NewBin;
292  Hive->Storage[Stable].BlockList[BlockIndex].BlockAddress = (ULONG_PTR)NewBin;
293 
294  RtlCopyMemory(NewBin, Bin, Bin->Size);
295 
296  if (Bin->Size > HBLOCK_SIZE)
297  {
298  for (i = 1; i < Bin->Size / HBLOCK_SIZE; i++)
299  {
300  Hive->Storage[Stable].BlockList[BlockIndex + i].BinAddress = (ULONG_PTR)NewBin;
301  Hive->Storage[Stable].BlockList[BlockIndex + i].BlockAddress =
302  ((ULONG_PTR)NewBin + (i * HBLOCK_SIZE));
303  }
304  }
305 
306  BlockIndex += Bin->Size / HBLOCK_SIZE;
307  }
308 
309  if (HvpCreateHiveFreeCellList(Hive))
310  {
311  HvpFreeHiveBins(Hive);
312  Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
313  return STATUS_NO_MEMORY;
314  }
315 
316  BitmapSize = ROUND_UP(Hive->Storage[Stable].Length,
317  sizeof(ULONG) * 8) / 8;
318  BitmapBuffer = (PULONG)Hive->Allocate(BitmapSize, TRUE, TAG_CM);
319  if (BitmapBuffer == NULL)
320  {
321  HvpFreeHiveBins(Hive);
322  Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
323  return STATUS_NO_MEMORY;
324  }
325 
326  RtlInitializeBitMap(&Hive->DirtyVector, BitmapBuffer, BitmapSize * 8);
328 
330 
331  return STATUS_SUCCESS;
332 }
333 
345  PHHIVE Hive,
346  PHBASE_BLOCK ChunkBase)
347 {
348  if (!HvpVerifyHiveHeader(ChunkBase))
350 
351  /* Setup hive data */
352  Hive->BaseBlock = ChunkBase;
353  Hive->Version = ChunkBase->Minor;
354  Hive->Flat = TRUE;
355  Hive->ReadOnly = TRUE;
356 
357  Hive->StorageTypeCount = 1;
358 
359  /* Set default boot type */
360  ChunkBase->BootType = 0;
361 
362  return STATUS_SUCCESS;
363 }
364 
365 typedef enum _RESULT
366 {
374 } RESULT;
375 
378  IN PHBASE_BLOCK *HiveBaseBlock,
380 {
381  PHBASE_BLOCK BaseBlock;
382  ULONG Result;
383  ULONG Offset = 0;
384 
385  ASSERT(sizeof(HBASE_BLOCK) >= (HSECTOR_SIZE * Hive->Cluster));
386 
387  /* Assume failure and allocate the base block */
388  *HiveBaseBlock = NULL;
389  BaseBlock = HvpAllocBaseBlockAligned(Hive, TRUE, TAG_CM);
390  if (!BaseBlock) return NoMemory;
391 
392  /* Clear it */
393  RtlZeroMemory(BaseBlock, sizeof(HBASE_BLOCK));
394 
395  /* Now read it from disk */
396  Result = Hive->FileRead(Hive,
398  &Offset,
399  BaseBlock,
400  Hive->Cluster * HSECTOR_SIZE);
401 
402  /* Couldn't read: assume it's not a hive */
403  if (!Result) return NotHive;
404 
405  /* Do validation */
406  if (!HvpVerifyHiveHeader(BaseBlock)) return NotHive;
407 
408  /* Return information */
409  *HiveBaseBlock = BaseBlock;
410  *TimeStamp = BaseBlock->TimeStamp;
411  return HiveSuccess;
412 }
413 
417 {
419  PHBASE_BLOCK BaseBlock = NULL;
420  ULONG Result;
422  ULONG Offset = 0;
423  PVOID HiveData;
424  ULONG FileSize;
425 
426  /* Get the hive header */
427  Result = HvpGetHiveHeader(Hive, &BaseBlock, &TimeStamp);
428  switch (Result)
429  {
430  /* Out of memory */
431  case NoMemory:
432 
433  /* Fail */
435 
436  /* Not a hive */
437  case NotHive:
438 
439  /* Fail */
441 
442  /* Has recovery data */
443  case RecoverData:
444  case RecoverHeader:
445 
446  /* Fail */
448  }
449 
450  /* Set default boot type */
451  BaseBlock->BootType = 0;
452 
453  /* Setup hive data */
454  Hive->BaseBlock = BaseBlock;
455  Hive->Version = BaseBlock->Minor;
456 
457  /* Allocate a buffer large enough to hold the hive */
458  FileSize = HBLOCK_SIZE + BaseBlock->Length; // == sizeof(HBASE_BLOCK) + BaseBlock->Length;
459  HiveData = Hive->Allocate(FileSize, TRUE, TAG_CM);
460  if (!HiveData)
461  {
462  Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
464  }
465 
466  /* Now read the whole hive */
467  Result = Hive->FileRead(Hive,
469  &Offset,
470  HiveData,
471  FileSize);
472  if (!Result)
473  {
474  Hive->Free(HiveData, FileSize);
475  Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
477  }
478 
479  // This is a HACK!
480  /* Free our base block... it's usless in this implementation */
481  Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
482 
483  /* Initialize the hive directly from memory */
484  Status = HvpInitializeMemoryHive(Hive, HiveData, FileName);
485  if (!NT_SUCCESS(Status))
486  Hive->Free(HiveData, FileSize);
487 
488  return Status;
489 }
490 
523  PHHIVE RegistryHive,
524  ULONG OperationType,
525  ULONG HiveFlags,
526  ULONG FileType,
527  PVOID HiveData OPTIONAL,
530  PFILE_SET_SIZE_ROUTINE FileSetSize,
531  PFILE_WRITE_ROUTINE FileWrite,
532  PFILE_READ_ROUTINE FileRead,
533  PFILE_FLUSH_ROUTINE FileFlush,
534  ULONG Cluster OPTIONAL,
536 {
538  PHHIVE Hive = RegistryHive;
539 
540  /*
541  * Create a new hive structure that will hold all the maintenance data.
542  */
543 
544  RtlZeroMemory(Hive, sizeof(HHIVE));
546 
547  Hive->Allocate = Allocate;
548  Hive->Free = Free;
549  Hive->FileSetSize = FileSetSize;
550  Hive->FileWrite = FileWrite;
551  Hive->FileRead = FileRead;
552  Hive->FileFlush = FileFlush;
553 
554  Hive->RefreshCount = 0;
556  Hive->Cluster = Cluster;
557  Hive->BaseBlockAlloc = sizeof(HBASE_BLOCK); // == HBLOCK_SIZE
558 
559  Hive->Version = HSYS_MINOR;
560 #if (NTDDI_VERSION < NTDDI_VISTA)
561  Hive->Log = (FileType == HFILE_TYPE_LOG);
562 #endif
563  Hive->HiveFlags = HiveFlags & ~HIVE_NOLAZYFLUSH;
564 
565  switch (OperationType)
566  {
567  case HINIT_CREATE:
568  Status = HvpCreateHive(Hive, FileName);
569  break;
570 
571  case HINIT_MEMORY:
572  Status = HvpInitializeMemoryHive(Hive, HiveData, FileName);
573  break;
574 
575  case HINIT_FLAT:
576  Status = HvpInitializeFlatHive(Hive, HiveData);
577  break;
578 
579  case HINIT_FILE:
580  {
581  Status = HvLoadHive(Hive, FileName);
582  if ((Status != STATUS_SUCCESS) &&
584  {
585  /* Unrecoverable failure */
586  return Status;
587  }
588 
589  /* Check for previous damage */
591  break;
592  }
593 
595  // Status = HvpInitializeMemoryInplaceHive(Hive, HiveData);
596  // break;
597 
598  case HINIT_MAPFILE:
599 
600  default:
601  /* FIXME: A better return status value is needed */
603  ASSERT(FALSE);
604  }
605 
606  if (!NT_SUCCESS(Status)) return Status;
607 
608  /* HACK: ROS: Init root key cell and prepare the hive */
609  // r31253
610  // if (OperationType == HINIT_CREATE) CmCreateRootNode(Hive, L"");
611  if (OperationType != HINIT_CREATE) CmPrepareHive(Hive);
612 
613  return Status;
614 }
615 
622 VOID CMAPI
624  PHHIVE RegistryHive)
625 {
626  if (!RegistryHive->ReadOnly)
627  {
628  /* Release hive bitmap */
629  if (RegistryHive->DirtyVector.Buffer)
630  {
631  RegistryHive->Free(RegistryHive->DirtyVector.Buffer, 0);
632  }
633 
634  HvpFreeHiveBins(RegistryHive);
635 
636  /* Free the BaseBlock */
637  if (RegistryHive->BaseBlock)
638  {
639  RegistryHive->Free(RegistryHive->BaseBlock, RegistryHive->BaseBlockAlloc);
640  RegistryHive->BaseBlock = NULL;
641  }
642  }
643 }
644 
645 /* EOF */
PULONG Buffer
Definition: typedefs.h:89
#define IN
Definition: typedefs.h:38
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG Sequence2
Definition: hivedata.h:123
ULONG Cluster
Definition: hivedata.h:149
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
#define HBLOCK_SIZE
Definition: hivedata.h:41
#define ROUND_UP(n, align)
Definition: eventvwr.h:31
BOOLEAN(CMAPI * PFILE_SET_SIZE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, ULONG FileSize, ULONG OldfileSize)
Definition: hivedata.h:241
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
RTL_BITMAP DirtyVector
Definition: hivedata.h:304
ULONG BootType
Definition: hivedata.h:161
Definition: hivedata.h:256
ULONG CMAPI HvpHiveHeaderChecksum(PHBASE_BLOCK HiveHeader)
Definition: hivesum.c:17
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
#define HSYS_MINOR
Definition: hivedata.h:58
ULONG Signature
Definition: hivedata.h:119
LONG NTSTATUS
Definition: precomp.h:26
#define HCELL_NIL
Definition: hivedata.h:85
BOOLEAN ReadOnly
Definition: hivedata.h:310
#define STATUS_REGISTRY_RECOVERED
Definition: ntstatus.h:123
ULONG_PTR BlockAddress
Definition: hivedata.h:258
NTSTATUS CMAPI HvpInitializeMemoryHive(PHHIVE Hive, PHBASE_BLOCK ChunkBase, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:221
#define HTYPE_COUNT
Definition: hivedata.h:71
#define HV_HHIVE_SIGNATURE
Definition: hivedata.h:50
PFREE_ROUTINE Free
Definition: hivedata.h:294
struct _HBIN * PHBIN
#define HINIT_MAPFILE
Definition: hivedata.h:18
#define HINIT_MEMORY_INPLACE
Definition: hivedata.h:16
PALLOCATE_ROUTINE Allocate
Definition: hivedata.h:293
NTSTATUS CMAPI HvpCreateHiveFreeCellList(PHHIVE Hive)
Definition: hivecell.c:279
#define HSECTOR_SIZE
Definition: hivedata.h:42
ULONG Length
Definition: hivedata.h:146
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
LARGE_INTEGER TimeStamp
Definition: hivedata.h:126
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:656
uint32_t ULONG_PTR
Definition: typedefs.h:63
VOID CMAPI HvFree(PHHIVE RegistryHive)
Definition: hiveinit.c:623
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
Definition: glfuncs.h:248
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
BOOLEAN(CMAPI * PFILE_READ_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:223
#define CMAPI
Definition: cfgmgr32.h:41
ULONG StorageTypeCount
Definition: hivedata.h:329
ULONG Sequence1
Definition: hivedata.h:122
_Inout_ PUCHAR _In_ PUCHAR _Out_ PUCHAR _Out_ PULONG ChunkSize
Definition: rtlfuncs.h:2276
BOOLEAN(CMAPI * PFILE_FLUSH_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: hivedata.h:249
static __inline PHBASE_BLOCK HvpAllocBaseBlockAligned(IN PHHIVE Hive, IN BOOLEAN Paged, IN ULONG Tag)
Definition: hiveinit.c:87
ULONG Major
Definition: hivedata.h:129
ULONG RefreshCount
Definition: hivedata.h:328
ULONG CheckSum
Definition: hivedata.h:158
#define HINIT_FILE
Definition: hivedata.h:15
union Alignment_ Alignment
#define HSYS_MAJOR
Definition: hivedata.h:57
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
Definition: bin.h:43
void DPRINT(...)
Definition: polytest.cpp:61
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:331
#define STATUS_REGISTRY_CORRUPT
Definition: ntstatus.h:554
#define HINIT_FLAT
Definition: hivedata.h:17
#define ULL(a, b)
Definition: format_msg.c:27
NTSTATUS CMAPI HvpCreateHive(IN OUT PHHIVE RegistryHive, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:160
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
PFILE_SET_SIZE_ROUTINE FileSetSize
Definition: hivedata.h:295
ULONG Signature
Definition: hivedata.h:288
BOOLEAN CMAPI HvpVerifyHiveHeader(IN PHBASE_BLOCK BaseBlock)
Definition: hiveinit.c:18
ULONG Version
Definition: hivedata.h:330
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define HINIT_CREATE
Definition: hivedata.h:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HFILE_TYPE_LOG
Definition: hivedata.h:34
BOOLEAN(CMAPI * PFILE_WRITE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:232
#define HV_HBIN_SIGNATURE
Definition: hivedata.h:52
static const UCHAR Index[8]
Definition: usbohci.c:18
VOID(CMAPI * PFREE_ROUTINE)(PVOID Ptr, ULONG Quota)
Definition: hivedata.h:217
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG Cluster
Definition: hivedata.h:308
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static ULONG BitmapBuffer[(XMS_BLOCKS+31)/32]
Definition: himem.c:86
#define TAG_CM
Definition: cmlib.h:203
NTSTATUS CMAPI HvpInitializeFlatHive(PHHIVE Hive, PHBASE_BLOCK ChunkBase)
Definition: hiveinit.c:344
#define HIVE_FILENAME_MAXLEN
Definition: hivedata.h:114
PFILE_WRITE_ROUTINE FileWrite
Definition: hivedata.h:296
static VOID HvpInitFileName(IN OUT PHBASE_BLOCK BaseBlock, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:124
VOID CMAPI CmPrepareHive(PHHIVE RegistryHive)
Definition: cminit.c:135
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define HINIT_MEMORY
Definition: hivedata.h:14
HCELL_INDEX RootCell
Definition: hivedata.h:143
SECURITY_INTEGER TimeStamp
Definition: sspi.h:78
NTSTATUS CMAPI HvInitialize(PHHIVE RegistryHive, ULONG OperationType, ULONG HiveFlags, ULONG FileType, PVOID HiveData OPTIONAL, PALLOCATE_ROUTINE Allocate, PFREE_ROUTINE Free, PFILE_SET_SIZE_ROUTINE FileSetSize, PFILE_WRITE_ROUTINE FileWrite, PFILE_READ_ROUTINE FileRead, PFILE_FLUSH_ROUTINE FileFlush, ULONG Cluster OPTIONAL, PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:522
Status
Definition: gdiplustypes.h:24
Definition: hiveinit.c:368
_RESULT
Definition: hiveinit.c:365
ULONG_PTR SIZE_T
Definition: typedefs.h:78
#define HBASE_FORMAT_MEMORY
Definition: hivedata.h:66
PHMAP_ENTRY BlockList
Definition: hivedata.h:278
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
ULONG HiveFlags
Definition: hivedata.h:321
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
ULONG_PTR BinAddress
Definition: hivedata.h:259
PFILE_FLUSH_ROUTINE FileFlush
Definition: hivedata.h:298
ULONG BaseBlockAlloc
Definition: hivedata.h:307
VOID CMAPI HvpFreeHiveBins(PHHIVE Hive)
Definition: hiveinit.c:53
unsigned int * PULONG
Definition: retypes.h:1
enum _RESULT RESULT
#define HIVE_NOLAZYFLUSH
Definition: hivedata.h:24
ULONG Length
Definition: hivedata.h:276
#define DPRINT1
Definition: precomp.h:8
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
PVOID(CMAPI * PALLOCATE_ROUTINE)(SIZE_T Size, BOOLEAN Paged, ULONG Tag)
Definition: hivedata.h:210
NTSTATUS CMAPI HvLoadHive(IN PHHIVE Hive, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:415
#define OUT
Definition: typedefs.h:39
#define HV_HBLOCK_SIGNATURE
Definition: hivedata.h:51
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
struct _HBASE_BLOCK HBASE_BLOCK
RESULT CMAPI HvpGetHiveHeader(IN PHHIVE Hive, IN PHBASE_BLOCK *HiveBaseBlock, IN PLARGE_INTEGER TimeStamp)
Definition: hiveinit.c:377
ULONG Minor
Definition: hivedata.h:133
return STATUS_SUCCESS
Definition: btrfs.c:2966
BOOLEAN Flat
Definition: hivedata.h:309
#define STATUS_NOT_REGISTRY_FILE
Definition: ntstatus.h:570
static IStorage Storage
Definition: ole2.c:3548
ULONG Type
Definition: hivedata.h:136
LONGLONG QuadPart
Definition: typedefs.h:112
PFILE_READ_ROUTINE FileRead
Definition: hivedata.h:297
ULONG Format
Definition: hivedata.h:139
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68