ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

cmlib.h
Go to the documentation of this file.
00001 /*
00002  * PROJECT:   registry manipulation library
00003  * LICENSE:   GPL - See COPYING in the top level directory
00004  * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
00005  *            Copyright 2001 - 2005 Eric Kohl
00006  */
00007 
00008 //
00009 // Debug support switch
00010 //
00011 #define _CMLIB_DEBUG_ 1
00012 
00013 #ifdef CMLIB_HOST
00014     #include <typedefs.h>
00015     #include <stdio.h>
00016     #include <string.h>
00017 
00018     // Definitions copied from <ntstatus.h>
00019     // We only want to include host headers, so we define them manually
00020     #define STATUS_SUCCESS                   ((NTSTATUS)0x00000000)
00021     #define STATUS_NOT_IMPLEMENTED           ((NTSTATUS)0xC0000002)
00022     #define STATUS_NO_MEMORY                 ((NTSTATUS)0xC0000017)
00023     #define STATUS_INSUFFICIENT_RESOURCES    ((NTSTATUS)0xC000009A)
00024     #define STATUS_REGISTRY_CORRUPT          ((NTSTATUS)0xC000014C)
00025     #define STATUS_NOT_REGISTRY_FILE         ((NTSTATUS)0xC000015C)
00026     #define STATUS_REGISTRY_RECOVERED        ((NTSTATUS)0x40000009)
00027 
00028     #define REG_OPTION_VOLATILE              1
00029     #define OBJ_CASE_INSENSITIVE             0x00000040L
00030     #define USHORT_MAX                       USHRT_MAX
00031 
00032     VOID NTAPI
00033     KeQuerySystemTime(
00034         OUT PLARGE_INTEGER CurrentTime);
00035 
00036     VOID NTAPI
00037     RtlInitializeBitMap(
00038         IN PRTL_BITMAP BitMapHeader,
00039         IN PULONG BitMapBuffer,
00040         IN ULONG SizeOfBitMap);
00041 
00042     ULONG NTAPI
00043     RtlFindSetBits(
00044         IN PRTL_BITMAP BitMapHeader,
00045         IN ULONG NumberToFind,
00046         IN ULONG HintIndex);
00047 
00048     VOID NTAPI
00049     RtlSetBits(
00050         IN PRTL_BITMAP BitMapHeader,
00051         IN ULONG StartingIndex,
00052         IN ULONG NumberToSet);
00053 
00054     VOID NTAPI
00055     RtlClearAllBits(
00056         IN PRTL_BITMAP BitMapHeader);
00057 
00058     #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
00059     #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
00060 
00061     #define PKTHREAD PVOID
00062     #define PKGUARDED_MUTEX PVOID
00063     #define PERESOURCE PVOID
00064     #define PFILE_OBJECT PVOID
00065     #define PKEVENT PVOID
00066     #define PWORK_QUEUE_ITEM PVOID
00067     #define EX_PUSH_LOCK PULONG_PTR
00068 
00069     #define CMLTRACE(x, ...)
00070 #else
00071     //
00072     // Debug/Tracing support
00073     //
00074     #if _CMLIB_DEBUG_
00075     #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
00076     #define CMLTRACE DbgPrintEx
00077     #else
00078     #define CMLTRACE(x, ...)                                 \
00079     if (x & CmlibTraceLevel) DbgPrint(__VA_ARGS__)
00080     #endif
00081     #else
00082     #define CMLTRACE(x, ...) DPRINT(__VA_ARGS__)
00083     #endif
00084 
00085     #include <ntdef.h>
00086     #include <ntddk.h>
00087 
00088     /* Prevent inclusion of Windows headers through <wine/unicode.h> */
00089     #define _WINDEF_
00090     #define _WINBASE_
00091     #define _WINNLS_
00092 #endif
00093 
00094 
00095 //
00096 // These define the Debug Masks Supported
00097 //
00098 #define CMLIB_HCELL_DEBUG                                 0x01
00099 
00100 #ifndef ROUND_UP
00101 #define ROUND_UP(a,b)        ((((a)+(b)-1)/(b))*(b))
00102 #define ROUND_DOWN(a,b)      (((a)/(b))*(b))
00103 #endif
00104 
00105 //
00106 // PAGE_SIZE definition
00107 //
00108 #ifndef PAGE_SIZE
00109 #if defined(TARGET_i386) || defined(TARGET_amd64) || defined(TARGET_arm)
00110 #define PAGE_SIZE 0x1000
00111 #else
00112 #error Local PAGE_SIZE definition required when built as host
00113 #endif
00114 #endif
00115 
00116 #define TAG_CM 'CM25'
00117 
00118 #define CMAPI NTAPI
00119 
00120 #include <wine/unicode.h>
00121 #include <wchar.h>
00122 #include "hivedata.h"
00123 #include "cmdata.h"
00124 
00125 #if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H)
00126 
00127 #define PCM_KEY_SECURITY_CACHE_ENTRY PVOID
00128 #define PCM_KEY_CONTROL_BLOCK PVOID
00129 #define CMP_SECURITY_HASH_LISTS                         64
00130 #define PCM_CELL_REMAP_BLOCK PVOID
00131 
00132 //
00133 // Use Count Log and Entry
00134 //
00135 typedef struct _CM_USE_COUNT_LOG_ENTRY
00136 {
00137     HCELL_INDEX Cell;
00138     PVOID Stack[7];
00139 } CM_USE_COUNT_LOG_ENTRY, *PCM_USE_COUNT_LOG_ENTRY;
00140 
00141 typedef struct _CM_USE_COUNT_LOG
00142 {
00143     USHORT Next;
00144     USHORT Size;
00145     CM_USE_COUNT_LOG_ENTRY Log[32];
00146 } CM_USE_COUNT_LOG, *PCM_USE_COUNT_LOG;
00147 
00148 //
00149 // Configuration Manager Hive Structure
00150 //
00151 typedef struct _CMHIVE
00152 {
00153     HHIVE Hive;
00154     HANDLE FileHandles[3];
00155     LIST_ENTRY NotifyList;
00156     LIST_ENTRY HiveList;
00157     EX_PUSH_LOCK HiveLock;
00158     PKTHREAD HiveLockOwner;
00159     PKGUARDED_MUTEX ViewLock;
00160     PKTHREAD ViewLockOwner;
00161     EX_PUSH_LOCK WriterLock;
00162     PKTHREAD WriterLockOwner;
00163     PERESOURCE FlusherLock;
00164     EX_PUSH_LOCK SecurityLock;
00165     PKTHREAD HiveSecurityLockOwner;
00166     LIST_ENTRY LRUViewListHead;
00167     LIST_ENTRY PinViewListHead;
00168     PFILE_OBJECT FileObject;
00169     UNICODE_STRING FileFullPath;
00170     UNICODE_STRING FileUserName;
00171     USHORT MappedViews;
00172     USHORT PinnedViews;
00173     ULONG UseCount;
00174     ULONG SecurityCount;
00175     ULONG SecurityCacheSize;
00176     LONG SecurityHitHint;
00177     PCM_KEY_SECURITY_CACHE_ENTRY SecurityCache;
00178     LIST_ENTRY SecurityHash[CMP_SECURITY_HASH_LISTS];
00179     PKEVENT UnloadEvent;
00180     PCM_KEY_CONTROL_BLOCK RootKcb;
00181     BOOLEAN Frozen;
00182     PWORK_QUEUE_ITEM UnloadWorkItem;
00183     BOOLEAN GrowOnlyMode;
00184     ULONG GrowOffset;
00185     LIST_ENTRY KcbConvertListHead;
00186     LIST_ENTRY KnodeConvertListHead;
00187     PCM_CELL_REMAP_BLOCK CellRemapArray;
00188     CM_USE_COUNT_LOG UseCountLog;
00189     CM_USE_COUNT_LOG LockHiveLog;
00190     ULONG Flags;
00191     LIST_ENTRY TrustClassEntry;
00192     ULONG FlushCount;
00193     BOOLEAN HiveIsLoading;
00194     PKTHREAD CreatorOwner;
00195 } CMHIVE, *PCMHIVE;
00196 
00197 #endif
00198 
00199 typedef struct _HV_HIVE_CELL_PAIR
00200 {
00201     PHHIVE Hive;
00202     HCELL_INDEX Cell;
00203 } HV_HIVE_CELL_PAIR, *PHV_HIVE_CELL_PAIR;
00204 
00205 #define STATIC_CELL_PAIR_COUNT 4
00206 typedef struct _HV_TRACK_CELL_REF
00207 {
00208     USHORT Count;
00209     USHORT Max;
00210     PHV_HIVE_CELL_PAIR CellArray;
00211     HV_HIVE_CELL_PAIR StaticArray[STATIC_CELL_PAIR_COUNT];
00212     USHORT StaticCount;
00213 } HV_TRACK_CELL_REF, *PHV_TRACK_CELL_REF;
00214 
00215 extern ULONG CmlibTraceLevel;
00216 
00217 /*
00218  * Public functions.
00219  */
00220 NTSTATUS CMAPI
00221 HvInitialize(
00222              PHHIVE RegistryHive,
00223    ULONG Operation,
00224    ULONG HiveType,
00225    ULONG HiveFlags,
00226    PVOID HiveData OPTIONAL,
00227    PALLOCATE_ROUTINE Allocate,
00228    PFREE_ROUTINE Free,
00229    PFILE_SET_SIZE_ROUTINE FileSetSize,
00230    PFILE_WRITE_ROUTINE FileWrite,
00231    PFILE_READ_ROUTINE FileRead,
00232    PFILE_FLUSH_ROUTINE FileFlush,
00233    ULONG Cluster OPTIONAL,
00234    PUNICODE_STRING FileName);
00235 
00236 VOID CMAPI
00237 HvFree(
00238    PHHIVE RegistryHive);
00239 
00240 PVOID CMAPI
00241 HvGetCell(
00242    PHHIVE RegistryHive,
00243    HCELL_INDEX CellOffset);
00244 
00245 #define HvReleaseCell(h, c)     \
00246     if (h->ReleaseCellRoutine) h->ReleaseCellRoutine(h, c)
00247 
00248 LONG CMAPI
00249 HvGetCellSize(
00250    PHHIVE RegistryHive,
00251    PVOID Cell);
00252 
00253 HCELL_INDEX CMAPI
00254 HvAllocateCell(
00255    PHHIVE RegistryHive,
00256    ULONG Size,
00257    HSTORAGE_TYPE Storage,
00258    IN HCELL_INDEX Vicinity);
00259 
00260 BOOLEAN CMAPI
00261 HvIsCellAllocated(
00262     IN PHHIVE RegistryHive,
00263     IN HCELL_INDEX CellIndex
00264 );
00265 
00266 HCELL_INDEX CMAPI
00267 HvReallocateCell(
00268    PHHIVE RegistryHive,
00269    HCELL_INDEX CellOffset,
00270    ULONG Size);
00271 
00272 VOID CMAPI
00273 HvFreeCell(
00274    PHHIVE RegistryHive,
00275    HCELL_INDEX CellOffset);
00276 
00277 BOOLEAN CMAPI
00278 HvMarkCellDirty(
00279    PHHIVE RegistryHive,
00280    HCELL_INDEX CellOffset,
00281    BOOLEAN HoldingLock);
00282 
00283 BOOLEAN CMAPI
00284 HvIsCellDirty(
00285     IN PHHIVE Hive,
00286     IN HCELL_INDEX Cell
00287 );
00288 
00289 BOOLEAN
00290 CMAPI
00291 HvHiveWillShrink(
00292     IN PHHIVE RegistryHive
00293 );
00294 
00295 BOOLEAN CMAPI
00296 HvSyncHive(
00297    PHHIVE RegistryHive);
00298 
00299 BOOLEAN CMAPI
00300 HvWriteHive(
00301    PHHIVE RegistryHive);
00302 
00303 BOOLEAN CMAPI
00304 CmCreateRootNode(
00305    PHHIVE Hive,
00306    PCWSTR Name);
00307 
00308 VOID CMAPI
00309 CmPrepareHive(
00310    PHHIVE RegistryHive);
00311 
00312 
00313 BOOLEAN
00314 CMAPI
00315 HvTrackCellRef(
00316     PHV_TRACK_CELL_REF CellRef,
00317     PHHIVE Hive,
00318     HCELL_INDEX Cell
00319 );
00320 
00321 VOID
00322 CMAPI
00323 HvReleaseFreeCellRefArray(
00324     PHV_TRACK_CELL_REF CellRef
00325 );
00326 
00327 /*
00328  * Private functions.
00329  */
00330 
00331 PHBIN CMAPI
00332 HvpAddBin(
00333    PHHIVE RegistryHive,
00334    ULONG Size,
00335    HSTORAGE_TYPE Storage);
00336 
00337 NTSTATUS CMAPI
00338 HvpCreateHiveFreeCellList(
00339    PHHIVE Hive);
00340 
00341 ULONG CMAPI
00342 HvpHiveHeaderChecksum(
00343    PHBASE_BLOCK HiveHeader);

Generated on Sat May 26 2012 04:34:52 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.