00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
#ifndef _HIVE_
00031
#define _HIVE_
00032
00033
00034
00035
#include "hivedata.h"
00036
00037
#if DBG
00038
00039
extern ULONG HvHiveChecking;
00040
00041
#define DHvCheckHive(a) if(HvHiveChecking) ASSERT(HvCheckHive(a,NULL) == 0)
00042
#define DHvCheckBin(h,a) if(HvHiveChecking) ASSERT(HvCheckBin(h,a,NULL) == 0)
00043
00044
#else
00045 #define DHvCheckHive(a)
00046 #define DHvCheckBin(h,a)
00047
#endif
00048
00049 #define ROUND_UP(a, b) \
00050
( ((ULONG)(a) + (ULONG)(b) - 1) & ~((ULONG)(b) - 1) )
00051
00052
00053
00054
00055
00056
00057
00058 #define ASSERT_LISTENTRY(ListEntry) \
00059
ASSERT((ListEntry)->Flink->Blink==ListEntry); \
00060
ASSERT((ListEntry)->Blink->Flink==ListEntry);
00061
00062
00063
00064
00065
PHBIN
00066
HvpAddBin(
00067
PHHIVE Hive,
00068 ULONG NewSize,
00069 HSTORAGE_TYPE Type
00070 );
00071
00072
PHMAP_ENTRY
00073
HvpGetCellMap(
00074
PHHIVE Hive,
00075 HCELL_INDEX Cell
00076 );
00077
00078
VOID
00079
HvpFreeMap(
00080
PHHIVE Hive,
00081
PHMAP_DIRECTORY Dir,
00082 ULONG Start,
00083 ULONG End
00084 );
00085
00086 BOOLEAN
00087
HvpAllocateMap(
00088
PHHIVE Hive,
00089
PHMAP_DIRECTORY Dir,
00090 ULONG Start,
00091 ULONG End
00092 );
00093
00094 BOOLEAN
00095
HvpGrowLog1(
00096
PHHIVE Hive,
00097 ULONG Count
00098 );
00099
00100 BOOLEAN
00101
HvpGrowLog2(
00102
PHHIVE Hive,
00103 ULONG Size
00104 );
00105
00106 ULONG
00107
HvpHeaderCheckSum(
00108
PHBASE_BLOCK BaseBlock
00109 );
00110
00111
NTSTATUS
00112
HvpBuildMap(
00113
PHHIVE Hive,
00114 PVOID Image,
00115 PHCELL_INDEX TailDisplay OPTIONAL
00116 );
00117
00118
NTSTATUS
00119
HvpBuildMapAndCopy(
00120
PHHIVE Hive,
00121 PVOID Image,
00122 PHCELL_INDEX TailDisplay OPTIONAL
00123 );
00124
00125
NTSTATUS
00126
HvpInitMap(
00127
PHHIVE Hive
00128 );
00129
00130
VOID
00131
HvpCleanMap(
00132
PHHIVE Hive
00133 );
00134
00135
NTSTATUS
00136
HvpEnlistBinInMap(
00137
PHHIVE Hive,
00138 ULONG Length,
00139
PHBIN Bin,
00140 ULONG Offset,
00141 PHCELL_INDEX TailDisplay OPTIONAL
00142 );
00143
00144
VOID
00145
HvpFreeAllocatedBins(
00146
PHHIVE Hive
00147 );
00148
00149 BOOLEAN
00150
HvpDoWriteHive(
00151
PHHIVE Hive,
00152 ULONG FileType
00153 );
00154
00155
struct _CELL_DATA *
00156
HvpGetCellFlat(
00157
PHHIVE Hive,
00158 HCELL_INDEX Cell
00159 );
00160
00161
struct _CELL_DATA *
00162
HvpGetCellPaged(
00163
PHHIVE Hive,
00164 HCELL_INDEX Cell
00165 );
00166
00167
VOID
00168
HvpEnlistFreeCell(
00169
PHHIVE Hive,
00170 HCELL_INDEX Cell,
00171 ULONG Size,
00172 HSTORAGE_TYPE Type,
00173 BOOLEAN CoalesceForward,
00174 PHCELL_INDEX TailDisplay OPTIONAL
00175 );
00176
00177 BOOLEAN
00178
HvpEnlistFreeCells(
00179
PHHIVE Hive,
00180
PHBIN Bin,
00181 ULONG BinOffset,
00182 PHCELL_INDEX TailDisplay OPTIONAL
00183 );
00184
00185
00186
VOID
00187
HvpDelistFreeCell(
00188
PHHIVE Hive,
00189
PHCELL Pcell,
00190 HSTORAGE_TYPE Type,
00191 PHCELL_INDEX TailDisplay OPTIONAL
00192 );
00193
00194
00195
00196
00197 #define HINIT_CREATE 0
00198 #define HINIT_MEMORY 1
00199 #define HINIT_FILE 2
00200 #define HINIT_MEMORY_INPLACE 3
00201 #define HINIT_FLAT 4
00202
00203 #define HIVE_VOLATILE 1
00204 #define HIVE_NOLAZYFLUSH 2
00205 #define HIVE_HAS_BEEN_REPLACED 4
00206
00207
NTSTATUS
00208
HvInitializeHive(
00209
PHHIVE Hive,
00210 ULONG OperationType,
00211 ULONG HiveFlags,
00212 ULONG FileTypes,
00213 PVOID HiveData OPTIONAL,
00214 PALLOCATE_ROUTINE AllocateRoutine,
00215 PFREE_ROUTINE FreeRoutine,
00216
PFILE_SET_SIZE_ROUTINE FileSetSizeRoutine,
00217
PFILE_WRITE_ROUTINE FileWriteRoutine,
00218
PFILE_READ_ROUTINE FileReadRoutine,
00219
PFILE_FLUSH_ROUTINE FileFlushRoutine,
00220 ULONG Cluster,
00221 PUNICODE_STRING FileName
00222 );
00223
00224 BOOLEAN
00225
HvSyncHive(
00226
PHHIVE Hive
00227 );
00228
00229
NTSTATUS
00230
HvWriteHive(
00231
PHHIVE Hive
00232 );
00233
00234
NTSTATUS
00235
HvLoadHive(
00236
PHHIVE Hive,
00237 PHCELL_INDEX TailDisplay OPTIONAL
00238 );
00239
00240
VOID
00241
HvRefreshHive(
00242
PHHIVE Hive
00243 );
00244
00245
NTSTATUS
00246
HvReadInMemoryHive(
00247
PHHIVE Hive,
00248 PVOID *HiveImage
00249 );
00250
00251 ULONG
00252
HvCheckHive(
00253
PHHIVE Hive,
00254 PULONG Storage OPTIONAL
00255 );
00256
00257 ULONG
00258
HvCheckBin(
00259
PHHIVE Hive,
00260
PHBIN Bin,
00261 PULONG Storage
00262 );
00263
00264 BOOLEAN
00265
HvMarkCellDirty(
00266
PHHIVE Hive,
00267 HCELL_INDEX Cell
00268 );
00269
00270 BOOLEAN
00271
HvIsBinDirty(
00272 IN
PHHIVE Hive,
00273 IN HCELL_INDEX Cell
00274 );
00275
00276 BOOLEAN
00277
HvMarkDirty(
00278
PHHIVE Hive,
00279 HCELL_INDEX Start,
00280 ULONG Length
00281 );
00282
00283 BOOLEAN
00284
HvMarkClean(
00285
PHHIVE Hive,
00286 HCELL_INDEX Start,
00287 ULONG Length
00288 );
00289
00290 #define HvGetCell(Hive, Cell) (((Hive)->GetCellRoutine)(Hive, Cell))
00291
00292 #define HvpGetHCell(Hive, Cell) ( USE_OLD_CELL(Hive) ? \
00293
CONTAINING_RECORD(HvGetCell(Hive,Cell), \
00294
HCELL, \
00295
u.OldCell.u.UserData) : \
00296
CONTAINING_RECORD(HvGetCell(Hive,Cell), \
00297
HCELL, \
00298
u.NewCell.u.UserData))
00299
00300
00301 LONG
00302
HvGetCellSize(
00303
PHHIVE Hive,
00304 PVOID Address
00305 );
00306
00307
HCELL_INDEX
00308
HvAllocateCell(
00309
PHHIVE Hive,
00310 ULONG NewSize,
00311 HSTORAGE_TYPE Type
00312 );
00313
00314
VOID
00315
HvFreeCell(
00316
PHHIVE Hive,
00317 HCELL_INDEX Cell
00318 );
00319
00320
HCELL_INDEX
00321
HvReallocateCell(
00322
PHHIVE Hive,
00323 HCELL_INDEX Cell,
00324 ULONG NewSize
00325 );
00326
00327 BOOLEAN
00328
HvIsCellAllocated(
00329
PHHIVE Hive,
00330 HCELL_INDEX Cell
00331 );
00332
00333
VOID
00334
HvFreeHive(
00335
PHHIVE Hive
00336 );
00337
00338
VOID
00339
HvFreeHivePartial(
00340
PHHIVE Hive,
00341 HCELL_INDEX Start,
00342 HSTORAGE_TYPE Type
00343 );
00344
00345
#endif // _HIVE_