ReactOS  0.4.14-dev-583-g2a1ba2c
cm.h File Reference
#include "cmlib.h"
#include "cm_x.h"
Include dependency graph for cm.h:

Go to the source code of this file.

Classes

struct  _CM_KEY_HASH
 
struct  _CM_KEY_HASH_TABLE_ENTRY
 
struct  _CM_NAME_HASH
 
struct  _CM_NAME_HASH_TABLE_ENTRY
 
struct  _CM_KEY_SECURITY_CACHE
 
struct  _CM_KEY_SECURITY_CACHE_ENTRY
 
struct  _CACHED_CHILD_LIST
 
struct  _CM_INDEX_HINT_BLOCK
 
struct  _CM_KEY_BODY
 
struct  _CM_NAME_CONTROL_BLOCK
 
struct  _CM_KEY_CONTROL_BLOCK
 
struct  _CM_NOTIFY_BLOCK
 
struct  _CM_CELL_REMAP_BLOCK
 
struct  _CM_ALLOC_PAGE
 
struct  _CM_DELAY_ALLOC
 
struct  _CM_DELAYED_CLOSE_ENTRY
 
struct  _CM_DELAY_DEREF_KCB_ITEM
 
struct  _CM_USE_COUNT_LOG_ENTRY
 
struct  _CM_USE_COUNT_LOG
 
struct  _CMHIVE
 
struct  _CM_CACHED_VALUE_INDEX
 
struct  _CM_CACHED_VALUE
 
struct  _HIVE_LIST_ENTRY
 
struct  _CM_PARSE_CONTEXT
 
struct  _CMP_MF_TYPE
 
struct  _CM_SYSTEM_CONTROL_VECTOR
 
struct  _KEY_VALUE_INFORMATION
 
struct  _KEY_INFORMATION
 

Macros

#define _CM_
 
#define _CM_DEBUG_   0x00
 
#define CM_HANDLE_DEBUG   0x01
 
#define CM_NAMESPACE_DEBUG   0x02
 
#define CM_SECURITY_DEBUG   0x04
 
#define CM_REFERENCE_DEBUG   0x08
 
#define CM_CALLBACK_DEBUG   0x10
 
#define CMTRACE(x, fmt, ...)   DPRINT(fmt, ##__VA_ARGS__)
 
#define ASSERT_VALUE_BIG(h, s)   ASSERTMSG("Big keys not supported!\n", !CmpIsKeyValueBig(h, s));
 
#define CM_KCB_SIGNATURE   'bKmC'
 
#define CM_KCB_INVALID_SIGNATURE   '4FmC'
 
#define CM_KCB_NO_SUBKEY   0x01
 
#define CM_KCB_SUBKEY_ONE   0x02
 
#define CM_KCB_SUBKEY_HINT   0x04
 
#define CM_KCB_SYM_LINK_FOUND   0x08
 
#define CM_KCB_KEY_NON_EXIST   0x10
 
#define CM_KCB_NO_DELAY_CLOSE   0x20
 
#define CM_KCB_INVALID_CACHED_INFO   0x40
 
#define CM_KCB_READ_ONLY_KEY   0x80
 
#define CM_KEY_BODY_TYPE   0x6B793032
 
#define CM_KEY_VALUE_SMALL   0x4
 
#define CM_KEY_VALUE_BIG   0x3FD8
 
#define CM_KEY_VALUE_SPECIAL_SIZE   0x80000000
 
#define CMP_SECURITY_HASH_LISTS   64
 
#define CMP_MAX_CALLBACKS   100
 
#define CMP_HASH_IRRATIONAL   314159269
 
#define CMP_HASH_PRIME   1000000007
 
#define CMP_CREATE_FAKE_KCB   0x1
 
#define CMP_LOCK_HASHES_FOR_KCB   0x2
 
#define CMP_CREATE_KCB_KCB_LOCKED   0x2
 
#define CMP_OPEN_KCB_NO_CREATE   0x4
 
#define CMP_ENLIST_KCB_LOCKED_SHARED   0x1
 
#define CMP_ENLIST_KCB_LOCKED_EXCLUSIVE   0x2
 
#define CMP_UNLOCK_KCB_LOCKED   0x1
 
#define CMP_UNLOCK_REGISTRY_LOCKED   0x2
 
#define MAXIMUM_CACHED_DATA   2 * PAGE_SIZE
 
#define CM_NUMBER_OF_MACHINE_HIVES   6
 
#define CM_KCBS_PER_PAGE   ((PAGE_SIZE - FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage)) / sizeof(CM_KEY_CONTROL_BLOCK))
 
#define CM_DELAYS_PER_PAGE   ((PAGE_SIZE - FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage)) / sizeof(CM_DELAY_ALLOC))
 

Typedefs

typedef enum _VALUE_SEARCH_RETURN_TYPE VALUE_SEARCH_RETURN_TYPE
 
typedef struct _CM_KEY_HASH CM_KEY_HASH
 
typedef struct _CM_KEY_HASHPCM_KEY_HASH
 
typedef struct _CM_KEY_HASH_TABLE_ENTRY CM_KEY_HASH_TABLE_ENTRY
 
typedef struct _CM_KEY_HASH_TABLE_ENTRYPCM_KEY_HASH_TABLE_ENTRY
 
typedef struct _CM_NAME_HASH CM_NAME_HASH
 
typedef struct _CM_NAME_HASHPCM_NAME_HASH
 
typedef struct _CM_NAME_HASH_TABLE_ENTRY CM_NAME_HASH_TABLE_ENTRY
 
typedef struct _CM_NAME_HASH_TABLE_ENTRYPCM_NAME_HASH_TABLE_ENTRY
 
typedef struct _CM_KEY_SECURITY_CACHE CM_KEY_SECURITY_CACHE
 
typedef struct _CM_KEY_SECURITY_CACHEPCM_KEY_SECURITY_CACHE
 
typedef struct _CM_KEY_SECURITY_CACHE_ENTRY CM_KEY_SECURITY_CACHE_ENTRY
 
typedef struct _CM_KEY_SECURITY_CACHE_ENTRYPCM_KEY_SECURITY_CACHE_ENTRY
 
typedef struct _CACHED_CHILD_LIST CACHED_CHILD_LIST
 
typedef struct _CACHED_CHILD_LISTPCACHED_CHILD_LIST
 
typedef struct _CM_INDEX_HINT_BLOCK CM_INDEX_HINT_BLOCK
 
typedef struct _CM_INDEX_HINT_BLOCKPCM_INDEX_HINT_BLOCK
 
typedef struct _CM_KEY_BODY CM_KEY_BODY
 
typedef struct _CM_KEY_BODYPCM_KEY_BODY
 
typedef struct _CM_NAME_CONTROL_BLOCK CM_NAME_CONTROL_BLOCK
 
typedef struct _CM_NAME_CONTROL_BLOCKPCM_NAME_CONTROL_BLOCK
 
typedef struct _CM_KEY_CONTROL_BLOCK CM_KEY_CONTROL_BLOCK
 
typedef struct _CM_KEY_CONTROL_BLOCKPCM_KEY_CONTROL_BLOCK
 
typedef struct _CM_NOTIFY_BLOCK CM_NOTIFY_BLOCK
 
typedef struct _CM_NOTIFY_BLOCKPCM_NOTIFY_BLOCK
 
typedef struct _CM_CELL_REMAP_BLOCK CM_CELL_REMAP_BLOCK
 
typedef struct _CM_CELL_REMAP_BLOCKPCM_CELL_REMAP_BLOCK
 
typedef struct _CM_ALLOC_PAGE CM_ALLOC_PAGE
 
typedef struct _CM_ALLOC_PAGEPCM_ALLOC_PAGE
 
typedef struct _CM_DELAY_ALLOC CM_DELAY_ALLOC
 
typedef struct _CM_DELAY_ALLOCPCM_DELAY_ALLOC
 
typedef struct _CM_DELAYED_CLOSE_ENTRY CM_DELAYED_CLOSE_ENTRY
 
typedef struct _CM_DELAYED_CLOSE_ENTRYPCM_DELAYED_CLOSE_ENTRY
 
typedef struct _CM_DELAY_DEREF_KCB_ITEM CM_DELAY_DEREF_KCB_ITEM
 
typedef struct _CM_DELAY_DEREF_KCB_ITEMPCM_DELAY_DEREF_KCB_ITEM
 
typedef struct _CM_USE_COUNT_LOG_ENTRY CM_USE_COUNT_LOG_ENTRY
 
typedef struct _CM_USE_COUNT_LOG_ENTRYPCM_USE_COUNT_LOG_ENTRY
 
typedef struct _CM_USE_COUNT_LOG CM_USE_COUNT_LOG
 
typedef struct _CM_USE_COUNT_LOGPCM_USE_COUNT_LOG
 
typedef struct _CMHIVE CMHIVE
 
typedef struct _CMHIVEPCMHIVE
 
typedef struct _CM_CACHED_VALUE_INDEX CM_CACHED_VALUE_INDEX
 
typedef struct _CM_CACHED_VALUE_INDEXPCM_CACHED_VALUE_INDEX
 
typedef struct _CM_CACHED_VALUE CM_CACHED_VALUE
 
typedef struct _CM_CACHED_VALUEPCM_CACHED_VALUE
 
typedef struct _HIVE_LIST_ENTRY HIVE_LIST_ENTRY
 
typedef struct _HIVE_LIST_ENTRYPHIVE_LIST_ENTRY
 
typedef struct _CM_PARSE_CONTEXT CM_PARSE_CONTEXT
 
typedef struct _CM_PARSE_CONTEXTPCM_PARSE_CONTEXT
 
typedef struct _CMP_MF_TYPE CMP_MF_TYPE
 
typedef struct _CMP_MF_TYPEPCMP_MF_TYPE
 
typedef struct _CM_SYSTEM_CONTROL_VECTOR CM_SYSTEM_CONTROL_VECTOR
 
typedef struct _CM_SYSTEM_CONTROL_VECTORPCM_SYSTEM_CONTROL_VECTOR
 
typedef struct _KEY_VALUE_INFORMATION KEY_VALUE_INFORMATION
 
typedef struct _KEY_VALUE_INFORMATIONPKEY_VALUE_INFORMATION
 
typedef struct _KEY_INFORMATION KEY_INFORMATION
 
typedef struct _KEY_INFORMATIONPKEY_INFORMATION
 

Enumerations

enum  _VALUE_SEARCH_RETURN_TYPE { SearchSuccess, SearchNeedExclusiveLock, SearchFail }
 

Functions

NTSTATUS CmiCallRegisteredCallbacks (IN REG_NOTIFY_CLASS Argument1, IN PVOID Argument2)
 
VOID NTAPI CmpInitHiveViewList (IN PCMHIVE Hive)
 
VOID NTAPI CmpDestroyHiveViewList (IN PCMHIVE Hive)
 
VOID NTAPI CmpInitSecurityCache (IN PCMHIVE Hive)
 
VOID NTAPI CmpDestroySecurityCache (IN PCMHIVE Hive)
 
VALUE_SEARCH_RETURN_TYPE NTAPI CmpFindValueByNameFromCache (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PCUNICODE_STRING Name, OUT PCM_CACHED_VALUE **CachedValue, OUT ULONG *Index, OUT PCM_KEY_VALUE *Value, OUT BOOLEAN *ValueIsCached, OUT PHCELL_INDEX CellToRelease)
 
VALUE_SEARCH_RETURN_TYPE NTAPI CmpQueryKeyValueData (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PCM_CACHED_VALUE *CachedValue, IN PCM_KEY_VALUE ValueKey, IN BOOLEAN ValueIsCached, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, OUT PULONG ResultLength, OUT PNTSTATUS Status)
 
VALUE_SEARCH_RETURN_TYPE NTAPI CmpGetValueListFromCache (IN PCM_KEY_CONTROL_BLOCK Kcb, OUT PCELL_DATA *CellData, OUT BOOLEAN *IndexIsCached, OUT PHCELL_INDEX ValueListToRelease)
 
VALUE_SEARCH_RETURN_TYPE NTAPI CmpGetValueKeyFromCache (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PCELL_DATA CellData, IN ULONG Index, OUT PCM_CACHED_VALUE **CachedValue, OUT PCM_KEY_VALUE *Value, IN BOOLEAN IndexIsCached, OUT BOOLEAN *ValueIsCached, OUT PHCELL_INDEX CellToRelease)
 
VALUE_SEARCH_RETURN_TYPE NTAPI CmpCompareNewValueDataAgainstKCBCache (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PUNICODE_STRING ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
 
ULONG NTAPI CmCheckRegistry (IN PCMHIVE Hive, IN ULONG Flags)
 
BOOLEAN NTAPI CmpGetHiveName (IN PCMHIVE Hive, OUT PUNICODE_STRING HiveName)
 
NTSTATUS NTAPI CmpAddToHiveFileList (IN PCMHIVE Hive)
 
VOID NTAPI CmpRemoveFromHiveFileList (IN PCMHIVE Hive)
 
VOID NTAPI CmpSetGlobalQuotaAllowed (VOID)
 
VOID NTAPI CmpReportNotify (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PHHIVE Hive, IN HCELL_INDEX Cell, IN ULONG Filter)
 
VOID NTAPI CmpFlushNotify (IN PCM_KEY_BODY KeyBody, IN BOOLEAN LockHeld)
 
INIT_FUNCTION VOID NTAPI CmpInitCallback (VOID)
 
INIT_FUNCTION VOID NTAPI CmpInitializeCache (VOID)
 
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateDelayAlloc (VOID)
 
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateAlloc (VOID)
 
INIT_FUNCTION VOID NTAPI CmpInitDelayDerefKCBEngine (VOID)
 
VOID NTAPI CmpCloseKeyObject (IN PEPROCESS Process OPTIONAL, IN PVOID Object, IN ACCESS_MASK GrantedAccess, IN ULONG ProcessHandleCount, IN ULONG SystemHandleCount)
 
VOID NTAPI CmpDeleteKeyObject (IN PVOID Object)
 
NTSTATUS NTAPI CmpParseKey (IN PVOID ParseObject, IN PVOID ObjectType, IN OUT PACCESS_STATE AccessState, IN KPROCESSOR_MODE AccessMode, IN ULONG Attributes, IN OUT PUNICODE_STRING CompleteName, IN OUT PUNICODE_STRING RemainingName, IN OUT PVOID Context OPTIONAL, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos OPTIONAL, OUT PVOID *Object)
 
NTSTATUS NTAPI CmpSecurityMethod (IN PVOID Object, IN SECURITY_OPERATION_CODE OperationType, IN PSECURITY_INFORMATION SecurityInformation, IN PSECURITY_DESCRIPTOR SecurityDescriptor, IN OUT PULONG CapturedLength, IN OUT PSECURITY_DESCRIPTOR *ObjectSecurityDescriptor, IN POOL_TYPE PoolType, IN PGENERIC_MAPPING GenericMapping)
 
NTSTATUS NTAPI CmpQueryKeyName (IN PVOID Object, IN BOOLEAN HasObjectName, OUT POBJECT_NAME_INFORMATION ObjectNameInfo, IN ULONG Length, OUT PULONG ReturnLength, IN KPROCESSOR_MODE AccessMode)
 
NTSTATUS NTAPI CmpInitializeHive (OUT PCMHIVE *CmHive, IN ULONG OperationType, IN ULONG HiveFlags, IN ULONG FileType, IN PVOID HiveData OPTIONAL, IN HANDLE Primary, IN HANDLE Log, IN HANDLE External, IN PCUNICODE_STRING FileName OPTIONAL, IN ULONG CheckFlags)
 
NTSTATUS NTAPI CmpDestroyHive (IN PCMHIVE CmHive)
 
PSECURITY_DESCRIPTOR NTAPI CmpHiveRootSecurityDescriptor (VOID)
 
NTSTATUS NTAPI CmpLinkHiveToMaster (IN PUNICODE_STRING LinkName, IN HANDLE RootDirectory, IN PCMHIVE CmHive, IN BOOLEAN Allocate, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
 
NTSTATUS NTAPI CmpOpenHiveFiles (IN PCUNICODE_STRING BaseName, IN PCWSTR Extension OPTIONAL, OUT PHANDLE Primary, OUT PHANDLE Log, OUT PULONG PrimaryDisposition, OUT PULONG LogDisposition, IN BOOLEAN CreateAllowed, IN BOOLEAN MarkAsSystemHive, IN BOOLEAN NoBuffering, OUT PULONG ClusterSize OPTIONAL)
 
VOID NTAPI CmpCloseHiveFiles (IN PCMHIVE Hive)
 
NTSTATUS NTAPI CmpInitHiveFromFile (IN PCUNICODE_STRING HiveName, IN ULONG HiveFlags, OUT PCMHIVE *Hive, IN OUT PBOOLEAN New, IN ULONG CheckFlags)
 
VOID NTAPI CmpInitializeHiveList (VOID)
 
BOOLEAN NTAPI CmpTestRegistryLockExclusive (VOID)
 
BOOLEAN NTAPI CmpTestRegistryLock (VOID)
 
VOID NTAPI CmpLockRegistryExclusive (VOID)
 
VOID NTAPI CmpLockRegistry (VOID)
 
VOID NTAPI CmpUnlockRegistry (VOID)
 
VOID NTAPI CmpLockHiveFlusherExclusive (IN PCMHIVE Hive)
 
VOID NTAPI CmpLockHiveFlusherShared (IN PCMHIVE Hive)
 
BOOLEAN NTAPI CmpTestHiveFlusherLockExclusive (IN PCMHIVE Hive)
 
BOOLEAN NTAPI CmpTestHiveFlusherLockShared (IN PCMHIVE Hive)
 
VOID NTAPI CmpUnlockHiveFlusher (IN PCMHIVE Hive)
 
PVOID NTAPI CmpAllocateDelayItem (VOID)
 
VOID NTAPI CmpFreeDelayItem (PVOID Entry)
 
VOID NTAPI CmpDelayDerefKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpAddToDelayedClose (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
 
VOID NTAPI CmpArmDelayedCloseTimer (VOID)
 
VOID NTAPI CmpRemoveFromDelayedClose (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
INIT_FUNCTION VOID NTAPI CmpInitializeDelayedCloseTable (VOID)
 
PCM_KEY_CONTROL_BLOCK NTAPI CmpCreateKeyControlBlock (IN PHHIVE Hive, IN HCELL_INDEX Index, IN PCM_KEY_NODE Node, IN PCM_KEY_CONTROL_BLOCK Parent, IN ULONG Flags, IN PUNICODE_STRING KeyName)
 
PCM_KEY_CONTROL_BLOCK NTAPI CmpAllocateKeyControlBlock (VOID)
 
VOID NTAPI CmpFreeKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpRemoveKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpCleanUpKcbValueCache (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpCleanUpKcbCacheWithLock (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
 
VOID NTAPI CmpCleanUpSubKeyInfo (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
PUNICODE_STRING NTAPI CmpConstructName (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
BOOLEAN NTAPI CmpReferenceKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI CmpDereferenceKeyControlBlockWithLock (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
 
VOID NTAPI CmpDereferenceKeyControlBlock (IN PCM_KEY_CONTROL_BLOCK Kcb)
 
VOID NTAPI EnlistKeyBodyWithKCB (IN PCM_KEY_BODY KeyObject, IN ULONG Flags)
 
VOID NTAPI DelistKeyBodyFromKCB (IN PCM_KEY_BODY KeyBody, IN BOOLEAN LockHeld)
 
VOID NTAPI CmpAcquireTwoKcbLocksExclusiveByKey (IN ULONG ConvKey1, IN ULONG ConvKey2)
 
VOID NTAPI CmpReleaseTwoKcbLockByKey (IN ULONG ConvKey1, IN ULONG ConvKey2)
 
VOID NTAPI CmpFlushNotifiesOnKeyBodyList (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeld)
 
BOOLEAN NTAPI CmpGetNextName (IN OUT PUNICODE_STRING RemainingName, OUT PUNICODE_STRING NextName, OUT PBOOLEAN LastName)
 
BOOLEAN NTAPI CmpDoFlushAll (IN BOOLEAN ForceFlush)
 
VOID NTAPI CmpShutdownWorkers (VOID)
 
VOID NTAPI CmpCmdInit (IN BOOLEAN SetupBoot)
 
NTSTATUS NTAPI CmpCmdHiveOpen (IN POBJECT_ATTRIBUTES FileAttributes, IN PSECURITY_CLIENT_CONTEXT ImpersonationContext, IN OUT PBOOLEAN Allocate, OUT PCMHIVE *NewHive, IN ULONG CheckFlags)
 
VOID NTAPI CmpLazyFlush (VOID)
 
NTSTATUS NTAPI CmpDoCreate (IN PHHIVE Hive, IN HCELL_INDEX Cell, IN PACCESS_STATE AccessState, IN PUNICODE_STRING Name, IN KPROCESSOR_MODE AccessMode, IN PCM_PARSE_CONTEXT Context, IN PCM_KEY_CONTROL_BLOCK ParentKcb, OUT PVOID *Object)
 
NTSTATUS NTAPI CmpCreateLinkNode (IN PHHIVE Hive, IN HCELL_INDEX Cell, IN PACCESS_STATE AccessState, IN UNICODE_STRING Name, IN KPROCESSOR_MODE AccessMode, IN ULONG CreateOptions, IN PCM_PARSE_CONTEXT Context, IN PCM_KEY_CONTROL_BLOCK ParentKcb, OUT PVOID *Object)
 
INIT_FUNCTION HCELL_INDEX NTAPI CmpFindControlSet (IN PHHIVE SystemHive, IN HCELL_INDEX RootCell, IN PUNICODE_STRING SelectKeyName, OUT PBOOLEAN AutoSelect)
 
INIT_FUNCTION VOID NTAPI CmGetSystemControlValues (IN PVOID SystemHiveData, IN PCM_SYSTEM_CONTROL_VECTOR ControlVector)
 
NTSTATUS NTAPI CmpSaveBootControlSet (IN USHORT ControlSet)
 
INIT_FUNCTION NTSTATUS NTAPI CmpInitializeRegistryNode (IN PCONFIGURATION_COMPONENT_DATA CurrentEntry, IN HANDLE NodeHandle, OUT PHANDLE NewHandle, IN INTERFACE_TYPE InterfaceType, IN ULONG BusNumber, IN PUSHORT DeviceIndexTable)
 
NTSTATUS NTAPI CmpInitializeMachineDependentConfiguration (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
INIT_FUNCTION NTSTATUS NTAPI CmpInitializeHardwareConfiguration (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
 
NTSTATUS NTAPI CmpCreateEvent (IN EVENT_TYPE EventType, OUT PHANDLE EventHandle, OUT PKEVENT *Event)
 
PVOID NTAPI CmpAllocate (IN SIZE_T Size, IN BOOLEAN Paged, IN ULONG Tag)
 
VOID NTAPI CmpFree (IN PVOID Ptr, IN ULONG Quota)
 
BOOLEAN NTAPI CmpFileRead (IN PHHIVE RegistryHive, IN ULONG FileType, IN OUT PULONG FileOffset, OUT PVOID Buffer, IN SIZE_T BufferLength)
 
BOOLEAN NTAPI CmpFileWrite (IN PHHIVE RegistryHive, IN ULONG FileType, IN OUT PULONG FileOffset, IN PVOID Buffer, IN SIZE_T BufferLength)
 
BOOLEAN NTAPI CmpFileSetSize (IN PHHIVE RegistryHive, IN ULONG FileType, IN ULONG FileSize, IN ULONG OldFileSize)
 
BOOLEAN NTAPI CmpFileFlush (IN PHHIVE RegistryHive, IN ULONG FileType, IN OUT PLARGE_INTEGER FileOffset, IN ULONG Length)
 
NTSTATUS NTAPI CmEnumerateValueKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN ULONG Index, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
 
NTSTATUS NTAPI CmSetValueKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN PUNICODE_STRING ValueName, IN ULONG Type, IN PVOID Data, IN ULONG DataSize)
 
NTSTATUS NTAPI CmQueryKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN KEY_INFORMATION_CLASS KeyInformationClass, IN PVOID KeyInformation, IN ULONG Length, IN PULONG ResultLength)
 
NTSTATUS NTAPI CmEnumerateKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN ULONG Index, IN KEY_INFORMATION_CLASS KeyInformationClass, IN PVOID KeyInformation, IN ULONG Length, IN PULONG ResultLength)
 
NTSTATUS NTAPI CmDeleteKey (IN PCM_KEY_BODY KeyBody)
 
NTSTATUS NTAPI CmFlushKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN EclusiveLock)
 
NTSTATUS NTAPI CmDeleteValueKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN UNICODE_STRING ValueName)
 
NTSTATUS NTAPI CmQueryValueKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN UNICODE_STRING ValueName, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, IN PULONG ResultLength)
 
NTSTATUS NTAPI CmLoadKey (IN POBJECT_ATTRIBUTES TargetKey, IN POBJECT_ATTRIBUTES SourceFile, IN ULONG Flags, IN PCM_KEY_BODY KeyBody)
 
NTSTATUS NTAPI CmUnloadKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN ULONG Flags)
 
ULONG NTAPI CmpEnumerateOpenSubKeys (IN PCM_KEY_CONTROL_BLOCK RootKcb, IN BOOLEAN RemoveEmptyCacheEntries, IN BOOLEAN DereferenceOpenedEntries)
 
HCELL_INDEX NTAPI CmpCopyCell (IN PHHIVE SourceHive, IN HCELL_INDEX SourceCell, IN PHHIVE DestinationHive, IN HSTORAGE_TYPE StorageType)
 
NTSTATUS NTAPI CmpDeepCopyKey (IN PHHIVE SourceHive, IN HCELL_INDEX SrcKeyCell, IN PHHIVE DestinationHive, IN HSTORAGE_TYPE StorageType, OUT PHCELL_INDEX DestKeyCell OPTIONAL)
 
NTSTATUS NTAPI CmSaveKey (IN PCM_KEY_CONTROL_BLOCK Kcb, IN HANDLE FileHandle, IN ULONG Flags)
 
NTSTATUS NTAPI CmSaveMergedKeys (IN PCM_KEY_CONTROL_BLOCK HighKcb, IN PCM_KEY_CONTROL_BLOCK LowKcb, IN HANDLE FileHandle)
 
INIT_FUNCTION BOOLEAN NTAPI CmInitSystem1 (VOID)
 
VOID NTAPI CmShutdownSystem (VOID)
 
VOID NTAPI CmSetLazyFlushState (IN BOOLEAN Enable)
 
VOID NTAPI CmpSetVersionData (VOID)
 
INIT_FUNCTION PUNICODE_STRING *NTAPI CmGetSystemDriverList (VOID)
 
INIT_FUNCTION BOOLEAN NTAPI CmpFindDrivers (IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN SERVICE_LOAD_TYPE LoadType, IN PWSTR BootFileSystem OPTIONAL, IN PLIST_ENTRY DriverListHead)
 
INIT_FUNCTION BOOLEAN NTAPI CmpSortDriverList (IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN PLIST_ENTRY DriverListHead)
 
INIT_FUNCTION BOOLEAN NTAPI CmpResolveDriverDependencies (IN PLIST_ENTRY DriverListHead)
 
INIT_FUNCTION BOOLEAN NTAPI CmpIsSafe (IN PHHIVE Hive, IN HCELL_INDEX SafeBootCell, IN HCELL_INDEX DriverCell)
 

Variables

ULONG CmpTraceLevel
 
BOOLEAN CmpSpecialBootCondition
 
BOOLEAN CmpFlushOnLockRelease
 
BOOLEAN CmpShareSystemHives
 
BOOLEAN CmpMiniNTBoot
 
BOOLEAN CmpNoVolatileCreates
 
EX_PUSH_LOCK CmpHiveListHeadLock
 
EX_PUSH_LOCK CmpLoadHiveLock
 
LIST_ENTRY CmpHiveListHead
 
POBJECT_TYPE CmpKeyObjectType
 
ERESOURCE CmpRegistryLock
 
PCM_KEY_HASH_TABLE_ENTRY CmpCacheTable
 
PCM_NAME_HASH_TABLE_ENTRY CmpNameCacheTable
 
KGUARDED_MUTEX CmpDelayedCloseTableLock
 
CMHIVE CmControlHive
 
WCHAR CmDefaultLanguageId []
 
ULONG CmDefaultLanguageIdLength
 
ULONG CmDefaultLanguageIdType
 
WCHAR CmInstallUILanguageId []
 
ULONG CmInstallUILanguageIdLength
 
ULONG CmInstallUILanguageIdType
 
ULONG CmNtGlobalFlag
 
LANGID PsInstallUILanguageId
 
LANGID PsDefaultUILanguageId
 
CM_SYSTEM_CONTROL_VECTOR CmControlVector []
 
ULONG CmpConfigurationAreaSize
 
PCM_FULL_RESOURCE_DESCRIPTOR CmpConfigurationData
 
UNICODE_STRING CmTypeName []
 
UNICODE_STRING CmClassName []
 
CMP_MF_TYPE CmpMultifunctionTypes []
 
USHORT CmpUnknownBusCount
 
ULONG CmpTypeCount [MaximumType+1]
 
HIVE_LIST_ENTRY CmpMachineHiveList []
 
UNICODE_STRING CmSymbolicLinkValueName
 
UNICODE_STRING CmpSystemStartOptions
 
UNICODE_STRING CmpLoadOptions
 
BOOLEAN CmSelfHeal
 
BOOLEAN CmpSelfHeal
 
ULONG CmpBootType
 
HANDLE CmpRegistryRootHandle
 
BOOLEAN ExpInTextModeSetup
 
BOOLEAN InitIsWinPEMode
 
ULONG CmpHashTableSize
 
ULONG CmpDelayedCloseSize
 
ULONG CmpDelayedCloseIndex
 
BOOLEAN CmpNoWrite
 
BOOLEAN CmpForceForceFlush
 
BOOLEAN CmpWasSetupBoot
 
BOOLEAN CmpProfileLoaded
 
PCMHIVE CmiVolatileHive
 
LIST_ENTRY CmiKeyObjectListHead
 
BOOLEAN CmpHoldLazyFlush
 

Macro Definition Documentation

◆ _CM_

#define _CM_

Definition at line 8 of file cm.h.

◆ _CM_DEBUG_

#define _CM_DEBUG_   0x00

Definition at line 14 of file cm.h.

◆ ASSERT_VALUE_BIG

#define ASSERT_VALUE_BIG (   h,
  s 
)    ASSERTMSG("Big keys not supported!\n", !CmpIsKeyValueBig(h, s));

Definition at line 42 of file cm.h.

◆ CM_CALLBACK_DEBUG

#define CM_CALLBACK_DEBUG   0x10

Definition at line 23 of file cm.h.

◆ CM_DELAYS_PER_PAGE

#define CM_DELAYS_PER_PAGE   ((PAGE_SIZE - FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage)) / sizeof(CM_DELAY_ALLOC))

Definition at line 126 of file cm.h.

◆ CM_HANDLE_DEBUG

#define CM_HANDLE_DEBUG   0x01

Definition at line 19 of file cm.h.

◆ CM_KCB_INVALID_CACHED_INFO

#define CM_KCB_INVALID_CACHED_INFO   0x40

Definition at line 60 of file cm.h.

◆ CM_KCB_INVALID_SIGNATURE

#define CM_KCB_INVALID_SIGNATURE   '4FmC'

Definition at line 49 of file cm.h.

◆ CM_KCB_KEY_NON_EXIST

#define CM_KCB_KEY_NON_EXIST   0x10

Definition at line 58 of file cm.h.

◆ CM_KCB_NO_DELAY_CLOSE

#define CM_KCB_NO_DELAY_CLOSE   0x20

Definition at line 59 of file cm.h.

◆ CM_KCB_NO_SUBKEY

#define CM_KCB_NO_SUBKEY   0x01

Definition at line 54 of file cm.h.

◆ CM_KCB_READ_ONLY_KEY

#define CM_KCB_READ_ONLY_KEY   0x80

Definition at line 61 of file cm.h.

◆ CM_KCB_SIGNATURE

#define CM_KCB_SIGNATURE   'bKmC'

Definition at line 48 of file cm.h.

◆ CM_KCB_SUBKEY_HINT

#define CM_KCB_SUBKEY_HINT   0x04

Definition at line 56 of file cm.h.

◆ CM_KCB_SUBKEY_ONE

#define CM_KCB_SUBKEY_ONE   0x02

Definition at line 55 of file cm.h.

◆ CM_KCB_SYM_LINK_FOUND

#define CM_KCB_SYM_LINK_FOUND   0x08

Definition at line 57 of file cm.h.

◆ CM_KCBS_PER_PAGE

#define CM_KCBS_PER_PAGE   ((PAGE_SIZE - FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage)) / sizeof(CM_KEY_CONTROL_BLOCK))

Definition at line 124 of file cm.h.

◆ CM_KEY_BODY_TYPE

#define CM_KEY_BODY_TYPE   0x6B793032

Definition at line 66 of file cm.h.

◆ CM_KEY_VALUE_BIG

#define CM_KEY_VALUE_BIG   0x3FD8

Definition at line 72 of file cm.h.

◆ CM_KEY_VALUE_SMALL

#define CM_KEY_VALUE_SMALL   0x4

Definition at line 71 of file cm.h.

◆ CM_KEY_VALUE_SPECIAL_SIZE

#define CM_KEY_VALUE_SPECIAL_SIZE   0x80000000

Definition at line 73 of file cm.h.

◆ CM_NAMESPACE_DEBUG

#define CM_NAMESPACE_DEBUG   0x02

Definition at line 20 of file cm.h.

◆ CM_NUMBER_OF_MACHINE_HIVES

#define CM_NUMBER_OF_MACHINE_HIVES   6

Definition at line 119 of file cm.h.

◆ CM_REFERENCE_DEBUG

#define CM_REFERENCE_DEBUG   0x08

Definition at line 22 of file cm.h.

◆ CM_SECURITY_DEBUG

#define CM_SECURITY_DEBUG   0x04

Definition at line 21 of file cm.h.

◆ CMP_CREATE_FAKE_KCB

#define CMP_CREATE_FAKE_KCB   0x1

Definition at line 90 of file cm.h.

◆ CMP_CREATE_KCB_KCB_LOCKED

#define CMP_CREATE_KCB_KCB_LOCKED   0x2

Definition at line 96 of file cm.h.

◆ CMP_ENLIST_KCB_LOCKED_EXCLUSIVE

#define CMP_ENLIST_KCB_LOCKED_EXCLUSIVE   0x2

Definition at line 103 of file cm.h.

◆ CMP_ENLIST_KCB_LOCKED_SHARED

#define CMP_ENLIST_KCB_LOCKED_SHARED   0x1

Definition at line 102 of file cm.h.

◆ CMP_HASH_IRRATIONAL

#define CMP_HASH_IRRATIONAL   314159269

Definition at line 84 of file cm.h.

◆ CMP_HASH_PRIME

#define CMP_HASH_PRIME   1000000007

Definition at line 85 of file cm.h.

◆ CMP_LOCK_HASHES_FOR_KCB

#define CMP_LOCK_HASHES_FOR_KCB   0x2

Definition at line 91 of file cm.h.

◆ CMP_MAX_CALLBACKS

#define CMP_MAX_CALLBACKS   100

Definition at line 79 of file cm.h.

◆ CMP_OPEN_KCB_NO_CREATE

#define CMP_OPEN_KCB_NO_CREATE   0x4

Definition at line 97 of file cm.h.

◆ CMP_SECURITY_HASH_LISTS

#define CMP_SECURITY_HASH_LISTS   64

Definition at line 78 of file cm.h.

◆ CMP_UNLOCK_KCB_LOCKED

#define CMP_UNLOCK_KCB_LOCKED   0x1

Definition at line 108 of file cm.h.

◆ CMP_UNLOCK_REGISTRY_LOCKED

#define CMP_UNLOCK_REGISTRY_LOCKED   0x2

Definition at line 109 of file cm.h.

◆ CMTRACE

#define CMTRACE (   x,
  fmt,
  ... 
)    DPRINT(fmt, ##__VA_ARGS__)

Definition at line 36 of file cm.h.

◆ MAXIMUM_CACHED_DATA

#define MAXIMUM_CACHED_DATA   2 * PAGE_SIZE

Definition at line 114 of file cm.h.

Typedef Documentation

◆ CACHED_CHILD_LIST

◆ CM_ALLOC_PAGE

◆ CM_CACHED_VALUE

◆ CM_CACHED_VALUE_INDEX

◆ CM_CELL_REMAP_BLOCK

◆ CM_DELAY_ALLOC

◆ CM_DELAY_DEREF_KCB_ITEM

◆ CM_DELAYED_CLOSE_ENTRY

◆ CM_INDEX_HINT_BLOCK

◆ CM_KEY_BODY

◆ CM_KEY_CONTROL_BLOCK

◆ CM_KEY_HASH

◆ CM_KEY_HASH_TABLE_ENTRY

◆ CM_KEY_SECURITY_CACHE

◆ CM_KEY_SECURITY_CACHE_ENTRY

◆ CM_NAME_CONTROL_BLOCK

◆ CM_NAME_HASH

◆ CM_NAME_HASH_TABLE_ENTRY

◆ CM_NOTIFY_BLOCK

◆ CM_PARSE_CONTEXT

◆ CM_SYSTEM_CONTROL_VECTOR

◆ CM_USE_COUNT_LOG

◆ CM_USE_COUNT_LOG_ENTRY

◆ CMHIVE

◆ CMP_MF_TYPE

◆ HIVE_LIST_ENTRY

◆ KEY_INFORMATION

◆ KEY_VALUE_INFORMATION

◆ PCACHED_CHILD_LIST

◆ PCM_ALLOC_PAGE

◆ PCM_CACHED_VALUE

◆ PCM_CACHED_VALUE_INDEX

◆ PCM_CELL_REMAP_BLOCK

◆ PCM_DELAY_ALLOC

◆ PCM_DELAY_DEREF_KCB_ITEM

◆ PCM_DELAYED_CLOSE_ENTRY

◆ PCM_INDEX_HINT_BLOCK

◆ PCM_KEY_BODY

◆ PCM_KEY_CONTROL_BLOCK

◆ PCM_KEY_HASH

◆ PCM_KEY_HASH_TABLE_ENTRY

◆ PCM_KEY_SECURITY_CACHE

◆ PCM_KEY_SECURITY_CACHE_ENTRY

◆ PCM_NAME_CONTROL_BLOCK

◆ PCM_NAME_HASH

◆ PCM_NAME_HASH_TABLE_ENTRY

◆ PCM_NOTIFY_BLOCK

◆ PCM_PARSE_CONTEXT

◆ PCM_SYSTEM_CONTROL_VECTOR

◆ PCM_USE_COUNT_LOG

◆ PCM_USE_COUNT_LOG_ENTRY

◆ PCMHIVE

typedef struct _CMHIVE * PCMHIVE

◆ PCMP_MF_TYPE

◆ PHIVE_LIST_ENTRY

◆ PKEY_INFORMATION

◆ PKEY_VALUE_INFORMATION

◆ VALUE_SEARCH_RETURN_TYPE

Enumeration Type Documentation

◆ _VALUE_SEARCH_RETURN_TYPE

Enumerator
SearchSuccess 
SearchNeedExclusiveLock 
SearchFail 

Definition at line 132 of file cm.h.

133 {
136  SearchFail
Definition: cm.h:136
enum _VALUE_SEARCH_RETURN_TYPE VALUE_SEARCH_RETURN_TYPE

Function Documentation

◆ CmCheckRegistry()

ULONG NTAPI CmCheckRegistry ( IN PCMHIVE  Hive,
IN ULONG  Flags 
)

Definition at line 21 of file cmcheck.c.

23 {
24  /* FIXME: HACK! */
25  DPRINT1("CmCheckRegistry(0x%p, %lu) is UNIMPLEMENTED!\n", RegistryHive, Flags);
26  return 0;
27 }
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define DPRINT1
Definition: precomp.h:8

Referenced by CmpInitializeHive().

◆ CmDeleteKey()

NTSTATUS NTAPI CmDeleteKey ( IN PCM_KEY_BODY  KeyBody)

Definition at line 1824 of file cmapi.c.

1825 {
1826  NTSTATUS Status;
1827  PHHIVE Hive;
1829  HCELL_INDEX Cell, ParentCell;
1831 
1832  /* Acquire hive lock */
1833  CmpLockRegistry();
1834 
1835  /* Get the kcb */
1836  Kcb = KeyBody->KeyControlBlock;
1837 
1838  /* Don't allow deleting the root */
1839  if (!Kcb->ParentKcb)
1840  {
1841  /* Fail */
1843  return STATUS_CANNOT_DELETE;
1844  }
1845 
1846  /* Lock parent and child */
1848 
1849  /* Check if we're already being deleted */
1850  if (Kcb->Delete)
1851  {
1852  /* Don't do it twice */
1854  goto Quickie;
1855  }
1856 
1857  /* Get the hive and node */
1858  Hive = Kcb->KeyHive;
1859  Cell = Kcb->KeyCell;
1860 
1861  /* Lock flushes */
1863 
1864  /* Get the key node */
1865  Node = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
1866  ASSERT(Node);
1867 
1868  /* Sanity check */
1869  ASSERT(Node->Flags == Kcb->Flags);
1870 
1871  /* Check if we don't have any children */
1872  if (!(Node->SubKeyCounts[Stable] + Node->SubKeyCounts[Volatile]) &&
1873  !(Node->Flags & KEY_NO_DELETE))
1874  {
1875  /* Send notification to registered callbacks */
1876  CmpReportNotify(Kcb, Hive, Cell, REG_NOTIFY_CHANGE_NAME);
1877 
1878  /* Get the parent and free the cell */
1879  ParentCell = Node->Parent;
1880  Status = CmpFreeKeyByCell(Hive, Cell, TRUE);
1881  if (NT_SUCCESS(Status))
1882  {
1883  /* Flush any notifications */
1885 
1886  /* Clean up information we have on the subkey */
1888 
1889  /* Get the parent node */
1890  Parent = (PCM_KEY_NODE)HvGetCell(Hive, ParentCell);
1891  if (Parent)
1892  {
1893  /* Update the maximum name length */
1894  Kcb->ParentKcb->KcbMaxNameLen = (USHORT)Parent->MaxNameLen;
1895 
1896  /* Make sure we're dirty */
1897  ASSERT(HvIsCellDirty(Hive, ParentCell));
1898 
1899  /* Update the write time */
1900  KeQuerySystemTime(&Parent->LastWriteTime);
1901  Kcb->ParentKcb->KcbLastWriteTime = Parent->LastWriteTime;
1902 
1903  /* Release the cell */
1904  HvReleaseCell(Hive, ParentCell);
1905  }
1906 
1907  /* Set the KCB in delete mode and remove it */
1908  Kcb->Delete = TRUE;
1910 
1911  /* Clear the cell */
1912  Kcb->KeyCell = HCELL_NIL;
1913  }
1914  }
1915  else
1916  {
1917  /* Fail */
1919  }
1920 
1921  /* Release the cell */
1922  HvReleaseCell(Hive, Cell);
1923 
1924  /* Release flush lock */
1926 
1927  /* Release the KCB locks */
1928 Quickie:
1929  CmpReleaseTwoKcbLockByKey(Kcb->ConvKey, Kcb->ParentKcb->ConvKey);
1930 
1931  /* Release hive lock */
1933  return Status;
1934 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
VOID NTAPI CmpUnlockHiveFlusher(IN PCMHIVE Hive)
Definition: cmsysini.c:1965
BOOLEAN CMAPI HvIsCellDirty(IN PHHIVE Hive, IN HCELL_INDEX Cell)
Definition: hivecell.c:126
#define TRUE
Definition: types.h:120
struct _CM_KEY_CONTROL_BLOCK * ParentKcb
Definition: cm.h:281
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
#define REG_NOTIFY_CHANGE_NAME
Definition: winreg.h:38
#define HCELL_NIL
Definition: hivedata.h:85
HCELL_INDEX KeyCell
Definition: cm.h:278
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
VOID NTAPI CmpReleaseTwoKcbLockByKey(IN ULONG ConvKey1, IN ULONG ConvKey2)
Definition: cmsysini.c:2050
VOID NTAPI CmpCleanUpSubKeyInfo(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:517
union node Node
Definition: types.h:1255
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
struct _CM_KEY_NODE * PCM_KEY_NODE
VOID NTAPI CmpRemoveKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:306
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define STATUS_CANNOT_DELETE
Definition: shellext.h:71
PHHIVE KeyHive
Definition: cm.h:277
#define KEY_NO_DELETE
Definition: cmdata.h:33
VOID NTAPI CmpLockHiveFlusherShared(IN PCMHIVE Hive)
Definition: cmsysini.c:1954
Status
Definition: gdiplustypes.h:24
VOID NTAPI CmpFlushNotifiesOnKeyBodyList(IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeld)
Definition: cmkcbncb.c:1140
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS NTAPI CmpFreeKeyByCell(IN PHHIVE Hive, IN HCELL_INDEX Cell, IN BOOLEAN Unlink)
Definition: cmkeydel.c:159
VOID NTAPI CmpReportNotify(IN PCM_KEY_CONTROL_BLOCK Kcb, IN PHHIVE Hive, IN HCELL_INDEX Cell, IN ULONG Filter)
Definition: cmnotify.c:19
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907
VOID NTAPI CmpAcquireTwoKcbLocksExclusiveByKey(IN ULONG ConvKey1, IN ULONG ConvKey2)
Definition: cmsysini.c:2021
Definition: cm.h:391
Definition: dlist.c:348

Referenced by NtDeleteKey().

◆ CmDeleteValueKey()

NTSTATUS NTAPI CmDeleteValueKey ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN UNICODE_STRING  ValueName 
)

Definition at line 916 of file cmapi.c.

918 {
920  PHHIVE Hive;
922  HCELL_INDEX ChildCell, Cell;
923  PCHILD_LIST ChildList;
925  ULONG ChildIndex;
926  BOOLEAN Result;
927 
928  /* Acquire hive lock */
929  CmpLockRegistry();
930 
931  /* Lock KCB exclusively */
933 
934  /* Don't touch deleted keys */
935  if (Kcb->Delete)
936  {
937  /* Undo everything */
938  CmpReleaseKcbLock(Kcb);
940  return STATUS_KEY_DELETED;
941  }
942 
943  /* Get the hive and the cell index */
944  Hive = Kcb->KeyHive;
945  Cell = Kcb->KeyCell;
946 
947  /* Lock flushes */
949 
950  /* Get the parent key node */
951  Parent = (PCM_KEY_NODE)HvGetCell(Hive, Cell);
952  ASSERT(Parent);
953 
954  /* Get the value list and check if it has any entries */
955  ChildList = &Parent->ValueList;
956  if (ChildList->Count)
957  {
958  /* Try to find this value */
959  Result = CmpFindNameInList(Hive,
960  ChildList,
961  &ValueName,
962  &ChildIndex,
963  &ChildCell);
964  if (!Result)
965  {
966  /* Fail */
968  goto Quickie;
969  }
970 
971  /* Value not found, return error */
972  if (ChildCell == HCELL_NIL) goto Quickie;
973 
974  /* We found the value, mark all relevant cells dirty */
975  if (!((HvMarkCellDirty(Hive, Cell, FALSE)) &&
976  (HvMarkCellDirty(Hive, Parent->ValueList.List, FALSE)) &&
977  (HvMarkCellDirty(Hive, ChildCell, FALSE))))
978  {
979  /* Not enough log space, fail */
981  goto Quickie;
982  }
983 
984  /* Get the key value */
985  Value = (PCM_KEY_VALUE)HvGetCell(Hive, ChildCell);
986  ASSERT(Value);
987 
988  /* Mark it and all related data as dirty */
989  if (!CmpMarkValueDataDirty(Hive, Value))
990  {
991  /* Not enough log space, fail */
993  goto Quickie;
994  }
995 
996  /* Sanity checks */
997  ASSERT(HvIsCellDirty(Hive, Parent->ValueList.List));
998  ASSERT(HvIsCellDirty(Hive, ChildCell));
999 
1000  /* Remove the value from the child list */
1001  Status = CmpRemoveValueFromList(Hive, ChildIndex, ChildList);
1002  if (!NT_SUCCESS(Status))
1003  {
1004  /* Set known error */
1006  goto Quickie;
1007  }
1008 
1009  /* Remove the value and its data itself */
1010  if (!CmpFreeValue(Hive, ChildCell))
1011  {
1012  /* Failed to free the value, fail */
1014  goto Quickie;
1015  }
1016 
1017  /* Set the last write time */
1018  KeQuerySystemTime(&Parent->LastWriteTime);
1019  Kcb->KcbLastWriteTime = Parent->LastWriteTime;
1020 
1021  /* Sanity check */
1022  ASSERT(Parent->MaxValueNameLen == Kcb->KcbMaxValueNameLen);
1023  ASSERT(Parent->MaxValueDataLen == Kcb->KcbMaxValueDataLen);
1024  ASSERT(HvIsCellDirty(Hive, Cell));
1025 
1026  /* Check if the value list is empty now */
1027  if (!Parent->ValueList.Count)
1028  {
1029  /* Then clear key node data */
1030  Parent->MaxValueNameLen = 0;
1031  Parent->MaxValueDataLen = 0;
1032  Kcb->KcbMaxValueNameLen = 0;
1033  Kcb->KcbMaxValueDataLen = 0;
1034  }
1035 
1036  /* Cleanup the value cache */
1038 
1039  /* Sanity checks */
1040  ASSERT(!(CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)));
1041  ASSERT(!(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND));
1042 
1043  /* Set the value cache */
1044  Kcb->ValueCache.Count = ChildList->Count;
1045  Kcb->ValueCache.ValueList = ChildList->List;
1046 
1047  /* Notify registered callbacks */
1048  CmpReportNotify(Kcb, Hive, Cell, REG_NOTIFY_CHANGE_LAST_SET);
1049 
1050  /* Change default Status to success */
1052  }
1053 
1054 Quickie:
1055  /* Release the parent cell, if any */
1056  if (Parent) HvReleaseCell(Hive, Cell);
1057 
1058  /* Check if we had a value */
1059  if (Value)
1060  {
1061  /* Release the child cell */
1062  ASSERT(ChildCell != HCELL_NIL);
1063  HvReleaseCell(Hive, ChildCell);
1064  }
1065 
1066  /* Release locks */
1068  CmpReleaseKcbLock(Kcb);
1070  return Status;
1071 }
#define KeQuerySystemTime(t)
Definition: env_spec_w32.h:570
VOID NTAPI CmpUnlockHiveFlusher(IN PCMHIVE Hive)
Definition: cmsysini.c:1965
_In_opt_ ULONG _Out_ PULONG Value
Definition: rtlfuncs.h:2343
BOOLEAN CMAPI HvIsCellDirty(IN PHHIVE Hive, IN HCELL_INDEX Cell)
Definition: hivecell.c:126
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
HCELL_INDEX List
Definition: cmdata.h:75
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
#define HCELL_NIL
Definition: hivedata.h:85
#define CMP_IS_CELL_CACHED(c)
Definition: cm_x.h:28
BOOLEAN NTAPI CmpFindNameInList(IN PHHIVE Hive, IN PCHILD_LIST ChildList, IN PUNICODE_STRING Name, OUT PULONG ChildIndex OPTIONAL, OUT PHCELL_INDEX CellIndex)
Definition: cmname.c:149
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
NTSTATUS NTAPI CmpRemoveValueFromList(IN PHHIVE Hive, IN ULONG Index, IN OUT PCHILD_LIST ChildList)
Definition: cmvalue.c:320
_In_ PUNICODE_STRING ValueName
Definition: cmfuncs.h:264
BOOLEAN NTAPI CmpFreeValue(IN PHHIVE Hive, IN HCELL_INDEX Cell)
Definition: cmvalue.c:73
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _CM_KEY_NODE * PCM_KEY_NODE
#define REG_NOTIFY_CHANGE_LAST_SET
Definition: winreg.h:40
_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
#define STATUS_KEY_DELETED
Definition: ntstatus.h:599
FORCEINLINE VOID CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cm_x.h:169
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
BOOLEAN CMAPI HvMarkCellDirty(PHHIVE RegistryHive, HCELL_INDEX CellOffset, BOOLEAN HoldingLock)
Definition: hivecell.c:100
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Count
Definition: cmdata.h:74
VOID NTAPI CmpLockHiveFlusherShared(IN PCMHIVE Hive)
Definition: cmsysini.c:1954
Status
Definition: gdiplustypes.h:24
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
struct _CM_KEY_VALUE * PCM_KEY_VALUE
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI CmpReportNotify(IN PCM_KEY_CONTROL_BLOCK Kcb, IN PHHIVE Hive, IN HCELL_INDEX Cell, IN ULONG Filter)
Definition: cmnotify.c:19
VOID NTAPI CmpCleanUpKcbValueCache(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:431
FORCEINLINE VOID CmpAcquireKcbLockExclusive(PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cm_x.h:102
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907
Definition: cm.h:391
#define STATUS_NO_LOG_SPACE
Definition: ntstatus.h:600
#define CM_KCB_SYM_LINK_FOUND
Definition: cm.h:57
BOOLEAN NTAPI CmpMarkValueDataDirty(IN PHHIVE Hive, IN PCM_KEY_VALUE Value)
Definition: cmvalue.c:19

Referenced by NtDeleteValueKey().

◆ CmEnumerateKey()

NTSTATUS NTAPI CmEnumerateKey ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN ULONG  Index,
IN KEY_INFORMATION_CLASS  KeyInformationClass,
IN PVOID  KeyInformation,
IN ULONG  Length,
IN PULONG  ResultLength 
)

Definition at line 1735 of file cmapi.c.

1741 {
1742  NTSTATUS Status;
1743  PHHIVE Hive;
1745  HCELL_INDEX ChildCell;
1746  HV_TRACK_CELL_REF CellReferences = {0};
1747 
1748  /* Acquire hive lock */
1749  CmpLockRegistry();
1750 
1751  /* Lock the KCB shared */
1753 
1754  /* Don't touch deleted keys */
1755  if (Kcb->Delete)
1756  {
1757  /* Undo everything */
1759  goto Quickie;
1760  }
1761 
1762  /* Get the hive and parent */
1763  Hive = Kcb->KeyHive;
1764  Parent = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
1765  ASSERT(Parent);
1766 
1767  /* Get the child cell */
1768  ChildCell = CmpFindSubKeyByNumber(Hive, Parent, Index);
1769 
1770  /* Release the parent cell */
1771  HvReleaseCell(Hive, Kcb->KeyCell);
1772 
1773  /* Check if we found the child */
1774  if (ChildCell == HCELL_NIL)
1775  {
1776  /* We didn't, fail */
1778  goto Quickie;
1779  }
1780 
1781  /* Now get the actual child node */
1782  Child = (PCM_KEY_NODE)HvGetCell(Hive, ChildCell);
1783  ASSERT(Child);
1784 
1785  /* Track references */
1786  if (!HvTrackCellRef(&CellReferences, Hive, ChildCell))
1787  {
1788  /* Can't allocate memory for tracking */
1790  goto Quickie;
1791  }
1792 
1793  /* Data can be user-mode, use SEH */
1794  _SEH2_TRY
1795  {
1796  /* Query the data requested */
1797  Status = CmpQueryKeyData(Hive,
1798  Child,
1800  KeyInformation,
1801  Length,
1802  ResultLength);
1803  }
1805  {
1806  /* Fail with exception code */
1808  _SEH2_YIELD(goto Quickie);
1809  }
1810  _SEH2_END;
1811 
1812 Quickie:
1813  /* Release references */
1814  HvReleaseFreeCellRefArray(&CellReferences);
1815 
1816  /* Release locks */
1817  CmpReleaseKcbLock(Kcb);
1819  return Status;
1820 }
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
_In_ ULONG _In_ KEY_INFORMATION_CLASS KeyInformationClass
Definition: zwfuncs.h:166
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
HCELL_INDEX NTAPI CmpFindSubKeyByNumber(IN PHHIVE Hive, IN PCM_KEY_NODE Node, IN ULONG Number)
Definition: cmindex.c:600
#define HCELL_NIL
Definition: hivedata.h:85
VOID CMAPI HvReleaseFreeCellRefArray(IN OUT PHV_TRACK_CELL_REF CellRef)
Definition: hivecell.c:607
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
#define CmpAcquireKcbLockShared(k)
Definition: cm_x.h:121
_SEH2_TRY
Definition: create.c:4250
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
struct _CM_KEY_NODE * PCM_KEY_NODE
#define STATUS_KEY_DELETED
Definition: ntstatus.h:599
FORCEINLINE VOID CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cm_x.h:169
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
ULONG HCELL_INDEX
Definition: hivedata.h:80
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN CMAPI HvTrackCellRef(IN OUT PHV_TRACK_CELL_REF CellRef, IN PHHIVE Hive, IN HCELL_INDEX Cell)
Definition: hivecell.c:527
Status
Definition: gdiplustypes.h:24
NTSTATUS NTAPI CmpQueryKeyData(IN PHHIVE Hive, IN PCM_KEY_NODE Node, IN KEY_INFORMATION_CLASS KeyInformationClass, IN OUT PVOID KeyInformation, IN ULONG Length, IN OUT PULONG ResultLength)
Definition: cmapi.c:376
_SEH2_END
Definition: create.c:4424
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907

Referenced by NtEnumerateKey().

◆ CmEnumerateValueKey()

NTSTATUS NTAPI CmEnumerateValueKey ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN ULONG  Index,
IN KEY_VALUE_INFORMATION_CLASS  KeyValueInformationClass,
IN PVOID  KeyValueInformation,
IN ULONG  Length,
IN PULONG  ResultLength 
)

Definition at line 1192 of file cmapi.c.

1198 {
1199  NTSTATUS Status;
1200  PHHIVE Hive;
1202  HCELL_INDEX CellToRelease = HCELL_NIL, CellToRelease2 = HCELL_NIL;
1204  BOOLEAN IndexIsCached, ValueIsCached = FALSE;
1205  PCELL_DATA CellData;
1206  PCM_CACHED_VALUE *CachedValue;
1208  PAGED_CODE();
1209 
1210  /* Acquire hive lock */
1211  CmpLockRegistry();
1212 
1213  /* Lock the KCB shared */
1215 
1216  /* Don't touch deleted keys */
1217 DoAgain:
1218  if (Kcb->Delete)
1219  {
1220  /* Undo everything */
1221  CmpReleaseKcbLock(Kcb);
1223  return STATUS_KEY_DELETED;
1224  }
1225 
1226  /* Get the hive and parent */
1227  Hive = Kcb->KeyHive;
1228  Parent = (PCM_KEY_NODE)HvGetCell(Hive, Kcb->KeyCell);
1229  ASSERT(Parent);
1230 
1231  /* FIXME: Lack of cache? */
1232  if (Kcb->ValueCache.Count != Parent->ValueList.Count)
1233  {
1234  DPRINT1("HACK: Overriding value cache count\n");
1235  Kcb->ValueCache.Count = Parent->ValueList.Count;
1236  }
1237 
1238  /* Make sure the index is valid */
1239  if (Index >= Kcb->ValueCache.Count)
1240  {
1241  /* Release the cell and fail */
1242  HvReleaseCell(Hive, Kcb->KeyCell);
1244  goto Quickie;
1245  }
1246 
1247  /* We don't deal with this yet */
1248  if (Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND)
1249  {
1250  /* Shouldn't happen */
1251  ASSERT(FALSE);
1252  }
1253 
1254  /* Find the value list */
1256  &CellData,
1257  &IndexIsCached,
1258  &CellToRelease);
1260  {
1261  /* Check if we need an exclusive lock */
1262  ASSERT(CellToRelease == HCELL_NIL);
1263  HvReleaseCell(Hive, Kcb->KeyCell);
1264 
1265  /* Try with exclusive KCB lock */
1267  goto DoAgain;
1268  }
1269  else if (Result != SearchSuccess)
1270  {
1271  /* Sanity check */
1272  ASSERT(CellData == NULL);
1273 
1274  /* Release the cell and fail */
1276  goto Quickie;
1277  }
1278 
1279  /* Now get the key value */
1281  CellData,
1282  Index,
1283  &CachedValue,
1284  &ValueData,
1285  IndexIsCached,
1286  &ValueIsCached,
1287  &CellToRelease2);
1289  {
1290  /* Cleanup state */
1291  ASSERT(CellToRelease2 == HCELL_NIL);
1292  if (CellToRelease)
1293  {
1294  HvReleaseCell(Hive, CellToRelease);
1295  CellToRelease = HCELL_NIL;
1296  }
1297  HvReleaseCell(Hive, Kcb->KeyCell);
1298 
1299  /* Try with exclusive KCB lock */
1301  goto DoAgain;
1302  }
1303  else if (Result != SearchSuccess)
1304  {
1305  /* Sanity check */
1306  ASSERT(ValueData == NULL);
1307 
1308  /* Release the cells and fail */
1310  goto Quickie;
1311  }
1312 
1313  /* User data, need SEH */
1314  _SEH2_TRY
1315  {
1316  /* Query the information requested */
1318  CachedValue,
1319  ValueData,
1320  ValueIsCached,
1322  KeyValueInformation,
1323  Length,
1324  ResultLength,
1325  &Status);
1327  {
1328  /* Cleanup state */
1329  if (CellToRelease2) HvReleaseCell(Hive, CellToRelease2);
1330  HvReleaseCell(Hive, Kcb->KeyCell);
1331  if (CellToRelease) HvReleaseCell(Hive, CellToRelease);
1332 
1333  /* Try with exclusive KCB lock */
1335  _SEH2_YIELD(goto DoAgain);
1336  }
1337  }
1339  {
1340  /* Get exception code */
1342  }
1343  _SEH2_END;
1344 
1345 Quickie:
1346  /* If we have a cell to release, do so */
1347  if (CellToRelease != HCELL_NIL) HvReleaseCell(Hive, CellToRelease);
1348 
1349  /* Release the parent cell */
1350  HvReleaseCell(Hive, Kcb->KeyCell);
1351 
1352  /* If we have a cell to release, do so */
1353  if (CellToRelease2 != HCELL_NIL) HvReleaseCell(Hive, CellToRelease2);
1354 
1355  /* Release locks */
1356  CmpReleaseKcbLock(Kcb);
1358  return Status;
1359 }
VALUE_SEARCH_RETURN_TYPE NTAPI CmpGetValueKeyFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, IN PCELL_DATA CellData, IN ULONG Index, OUT PCM_CACHED_VALUE **CachedValue, OUT PCM_KEY_VALUE *Value, IN BOOLEAN IndexIsCached, OUT BOOLEAN *ValueIsCached, OUT PHCELL_INDEX CellToRelease)
Definition: cmvalche.c:96
IN CINT OUT PVOID IN ULONG OUT PULONG ResultLength
Definition: conport.c:47
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_NO_MORE_ENTRIES
Definition: ntstatus.h:193
VALUE_SEARCH_RETURN_TYPE NTAPI CmpQueryKeyValueData(IN PCM_KEY_CONTROL_BLOCK Kcb, IN PCM_CACHED_VALUE *CachedValue, IN PCM_KEY_VALUE ValueKey, IN BOOLEAN ValueIsCached, IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass, IN PVOID KeyValueInformation, IN ULONG Length, OUT PULONG ResultLength, OUT PNTSTATUS Status)
Definition: cmvalche.c:327
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
LONG NTSTATUS
Definition: precomp.h:26
#define HCELL_NIL
Definition: hivedata.h:85
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
#define CmpAcquireKcbLockShared(k)
Definition: cm_x.h:121
#define PAGED_CODE()
Definition: video.h:57
_SEH2_TRY
Definition: create.c:4250
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
VALUE_SEARCH_RETURN_TYPE NTAPI CmpGetValueListFromCache(IN PCM_KEY_CONTROL_BLOCK Kcb, OUT PCELL_DATA *CellData, OUT BOOLEAN *IndexIsCached, OUT PHCELL_INDEX ValueListToRelease)
Definition: cmvalche.c:44
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _CM_KEY_NODE * PCM_KEY_NODE
_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
#define STATUS_KEY_DELETED
Definition: ntstatus.h:599
FORCEINLINE VOID CmpReleaseKcbLock(PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cm_x.h:169
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
ULONG HCELL_INDEX
Definition: hivedata.h:80
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
static const UCHAR Index[8]
Definition: usbohci.c:18
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
Status
Definition: gdiplustypes.h:24
_SEH2_END
Definition: create.c:4424
FORCEINLINE VOID CmpConvertKcbSharedToExclusive(IN PCM_KEY_CONTROL_BLOCK k)
Definition: cm_x.h:189
#define DPRINT1
Definition: precomp.h:8
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
enum _VALUE_SEARCH_RETURN_TYPE VALUE_SEARCH_RETURN_TYPE
_In_ ULONG _In_ KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass
Definition: cmfuncs.h:93
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907
#define CM_KCB_SYM_LINK_FOUND
Definition: cm.h:57

Referenced by NtEnumerateValueKey().

◆ CmFlushKey()

NTSTATUS NTAPI CmFlushKey ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN BOOLEAN  EclusiveLock 
)

Definition at line 1938 of file cmapi.c.

1940 {
1941  PCMHIVE CmHive;
1943  PHHIVE Hive;
1944 
1945  /* Ignore flushes until we're ready */
1946  if (CmpNoWrite) return STATUS_SUCCESS;
1947 
1948  /* Get the hives */
1949  Hive = Kcb->KeyHive;
1950  CmHive = (PCMHIVE)Hive;
1951 
1952  /* Check if this is the master hive */
1953  if (CmHive == CmiVolatileHive)
1954  {
1955  /* Flush all the hives instead */
1957  }
1958  else
1959  {
1960  /* Don't touch the hive */
1962 
1966 
1967  /* Will the hive shrink? */
1968  if (HvHiveWillShrink(Hive))
1969  {
1970  /* I don't believe the current Hv does shrinking */
1971  ASSERT(FALSE);
1972  // CMP_ASSERT_EXCLUSIVE_REGISTRY_LOCK_OR_LOADING(CmHive);
1973  }
1974  else
1975  {
1976  /* Now we can release views */
1978  // CMP_ASSERT_VIEW_LOCK_OWNED(CmHive);
1980  (CmHive->HiveIsLoading == TRUE) ||
1985  }
1986 
1987  /* Flush only this hive */
1988  if (!HvSyncHive(Hive))
1989  {
1990  /* Fail */
1992  }
1993 
1994  /* Release the flush lock */
1996  }
1997 
1998  /* Return the status */
1999  return Status;
2000 }
VOID NTAPI CmpUnlockHiveFlusher(IN PCMHIVE Hive)
Definition: cmsysini.c:1965
PKGUARDED_MUTEX ViewLock
Definition: cm.h:399
struct _CMHIVE * PCMHIVE
#define TRUE
Definition: types.h:120
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
#define STATUS_REGISTRY_IO_FAILED
Definition: ntstatus.h:555
LONG NTSTATUS
Definition: precomp.h:26
smooth NULL
Definition: ftsmooth.c:416
PCMHIVE CmiVolatileHive
Definition: cmsysini.c:17
BOOLEAN HiveIsLoading
Definition: cm.h:433
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
BOOLEAN CmpSpecialBootCondition
Definition: cmsysini.c:28
BOOLEAN CMAPI HvSyncHive(PHHIVE RegistryHive)
Definition: hivewrt.c:243
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PKTHREAD ViewLockOwner
Definition: cm.h:400
Status
Definition: gdiplustypes.h:24
static PCMHIVE CmHive
Definition: registry.c:28
VOID NTAPI CmpLockHiveFlusherExclusive(IN PCMHIVE Hive)
Definition: cmsysini.c:1943
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
BOOLEAN NTAPI CmpDoFlushAll(IN BOOLEAN ForceFlush)
Definition: cmapi.c:82
BOOLEAN NTAPI CmpTestRegistryLockExclusive(VOID)
Definition: cmsysini.c:1935
#define KeGetCurrentThread
Definition: hal.h:44
return STATUS_SUCCESS
Definition: btrfs.c:2938
Definition: cm.h:391
BOOLEAN CMAPI HvHiveWillShrink(IN PHHIVE RegistryHive)
Definition: hivewrt.c:277

Referenced by CmUnloadKey(), and NtFlushKey().

◆ CmGetSystemControlValues()

INIT_FUNCTION VOID NTAPI CmGetSystemControlValues ( IN PVOID  SystemHiveData,
IN PCM_SYSTEM_CONTROL_VECTOR  ControlVector 
)

Definition at line 104 of file cmcontrl.c.

106 {
109  HCELL_INDEX RootCell, BaseCell, KeyCell, ValueCell;
114  BOOLEAN Auto, IsSmallKey;
115  PVOID Buffer;
116 
117  /* LUDDDIIIICRROOOUUSSSS KI^H^H HACKKKK */
118  if (!SystemHiveData) return;
119 
120  /* Initialize the Hive View List and the security cache */
124 
125  /* Initialize the Hive */
127  HINIT_FLAT,
130  SystemHiveData,
131  NULL,
132  NULL,
133  NULL,
134  NULL,
135  NULL,
136  NULL,
137  1,
138  NULL);
139  if (!NT_SUCCESS(Status)) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 1, 0, 0);
140 
141  /* Sanity check, flat hives don't have release routines */
142  ASSERT(SystemHive->ReleaseCellRoutine == NULL);
143 
144  /* Set the Root Cell */
145  RootCell = ((PHBASE_BLOCK)SystemHiveData)->RootCell;
146 
147  /* Find the current control set */
148  RtlInitUnicodeString(&KeyName, L"current");
149  BaseCell = CmpFindControlSet(SystemHive, RootCell, &KeyName, &Auto);
150  if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO, 1, 2, 0, 0);
151 
152  /* Find the control subkey */
153  RtlInitUnicodeString(&KeyName, L"control");
154  Node = (PCM_KEY_NODE)HvGetCell(SystemHive, BaseCell);
156  if (BaseCell == HCELL_NIL) KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1 , 3, 0, 0);
157 
158  /* Loop each key */
159  while (ControlVector->KeyPath)
160  {
161  /* Assume failure */
162  Length = -1;
163 
164  /* Get the cell for this key */
165  KeyCell = CmpWalkPath(SystemHive, BaseCell, ControlVector->KeyPath);
166  if (KeyCell != HCELL_NIL)
167  {
168  /* Now get the cell for the value */
169  RtlInitUnicodeString(&KeyName, ControlVector->ValueName);
170  Node = (PCM_KEY_NODE)HvGetCell(SystemHive, KeyCell);
171  ValueCell = CmpFindValueByName(SystemHive, Node, &KeyName);
172  if (ValueCell != HCELL_NIL)
173  {
174  /* Check if there's any data */
175  if (!ControlVector->BufferLength)
176  {
177  /* No, the buffer will only be large enough for a ULONG */
178  DataSize = sizeof(ULONG);
179  }
180  else
181  {
182  /* Yes, save the data size */
183  DataSize = *ControlVector->BufferLength;
184  }
185 
186  /* Get the actual data */
188 
189  /* Check if this is a small key */
190  IsSmallKey = CmpIsKeyValueSmall(&Length, ValueData->DataLength);
191 
192  /* If the length is bigger then our buffer, normalize it */
193  if (DataSize < Length) Length = DataSize;
194 
195  /* Make sure we have some data */
196  if (Length > 0)
197  {
198  /* Check if this was a small key */
199  if (IsSmallKey)
200  {
201  /* The buffer is directly safe to read */
202  Buffer = (PVOID)(&(ValueData->Data));
203  }
204  else
205  {
206  /* Use the longer path */
208  }
209 
210  /* Sanity check if this is a small key */
211  ASSERT((IsSmallKey ?
212  (Length <= CM_KEY_VALUE_SMALL) : TRUE));
213 
214  /* Copy the data in the buffer */
215  RtlCopyMemory(ControlVector->Buffer, Buffer, Length);
216  }
217 
218  /* Check if we should return the data type */
219  if (ControlVector->Type)
220  {
221  /* Return the type that we read */
222  *ControlVector->Type = ValueData->Type;
223  }
224  }
225  }
226 
227  /* Return the size that we read */
228  if (ControlVector->BufferLength) *ControlVector->BufferLength = Length;
229 
230  /* Go to the next entry */
231  ControlVector++;
232  }
233 
234  /* Check if the ID is in the registry */
236  {
237  /* Read it */
241  }
242  else
243  {
244  /* Use EN_US by default */
245  PsDefaultSystemLocaleId = 0x409;
246  }
247 
248  /* Check if the ID Is in the registry */
250  {
251  /* Read it */
254  }
255  else
256  {
257  /* Otherwise, use the default */
259  }
260 
261  /* Set the defaults for the Thread UI */
264 }
LANGID PsDefaultUILanguageId
Definition: locale.c:24
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
ULONG CmDefaultLanguageIdType
Definition: cmdata.c:24
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
WCHAR CmInstallUILanguageId[12]
Definition: cmdata.c:26
#define HIVE_VOLATILE
Definition: hivedata.h:23
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
LONG NTSTATUS
Definition: precomp.h:26
#define HCELL_NIL
Definition: hivedata.h:85
LCID PsDefaultSystemLocaleId
Definition: locale.c:20
DWORD LCID
Definition: nls.h:13
LCID PsDefaultThreadLocaleId
Definition: locale.c:25
LANGID PsInstallUILanguageId
Definition: locale.c:21
INIT_FUNCTION HCELL_INDEX NTAPI CmpWalkPath(IN PHHIVE SystemHive, IN HCELL_INDEX ParentCell, IN LPWSTR Path)
Definition: cmcontrl.c:73
struct _HBASE_BLOCK * PHBASE_BLOCK
union node Node
Definition: types.h:1255
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
VOID NTAPI CmpInitHiveViewList(IN PCMHIVE Hive)
Definition: cmmapvw.c:21
static BOOLEAN CmpIsKeyValueSmall(OUT PULONG RealLength, IN ULONG Length)
Definition: cmlib.h:323
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
struct _CM_KEY_NODE * PCM_KEY_NODE
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
#define HINIT_FLAT
Definition: hivedata.h:17
HCELL_INDEX NTAPI CmpFindValueByName(IN PHHIVE Hive, IN PCM_KEY_NODE KeyNode, IN PUNICODE_STRING Name)
Definition: cmvalue.c:99
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
_In_ GUID _In_ PVOID ValueData
Definition: hubbusif.h:311
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
INIT_FUNCTION HCELL_INDEX NTAPI CmpFindControlSet(IN PHHIVE SystemHive, IN HCELL_INDEX RootCell, IN PUNICODE_STRING SelectKeyName, OUT PBOOLEAN AutoSelect)
Definition: cmboot.c:25
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CM_KEY_VALUE_SMALL
Definition: cm.h:71
static const WCHAR L[]
Definition: oid.c:1250
#define LANGIDFROMLCID(l)
Definition: nls.h:18
INIT_FUNCTION LANGID NTAPI CmpConvertLangId(IN LPWSTR Name, IN ULONG NameLength)
Definition: cmcontrl.c:22
Status
Definition: gdiplustypes.h:24
ULONG CmDefaultLanguageIdLength
Definition: cmdata.c:23
VOID NTAPI CmpInitSecurityCache(IN PCMHIVE Hive)
Definition: cmsecach.c:21
struct _HHIVE * PHHIVE
ULONG CmInstallUILanguageIdLength
Definition: cmdata.c:27
WCHAR CmDefaultLanguageId[12]
Definition: cmdata.c:22
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
struct _CM_KEY_VALUE * PCM_KEY_VALUE
static CMHIVE SystemHive
Definition: registry.c:57
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
HCELL_INDEX NTAPI CmpFindSubKeyByName(IN PHHIVE Hive, IN PCM_KEY_NODE Parent, IN PCUNICODE_STRING SearchName)
Definition: cmindex.c:683
_In_ NDIS_STATUS _In_ ULONG _In_ USHORT _In_opt_ PVOID _In_ ULONG DataSize
Definition: ndis.h:4751
CMHIVE CmControlHive
Definition: cmdata.c:34
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
Definition: cm.h:391
Definition: dlist.c:348
ULONG CmInstallUILanguageIdType
Definition: cmdata.c:28
#define REG_SZ
Definition: layer.c:22

Referenced by ExpInitializeExecutive().

◆ CmGetSystemDriverList()

INIT_FUNCTION PUNICODE_STRING* NTAPI CmGetSystemDriverList ( VOID  )

Definition at line 1776 of file cmsysini.c.

1777 {
1778  LIST_ENTRY DriverList;
1780  NTSTATUS Status;
1781  PCM_KEY_BODY KeyBody;
1782  PHHIVE Hive;
1783  HCELL_INDEX RootCell, ControlCell;
1784  HANDLE KeyHandle;
1786  PLIST_ENTRY NextEntry;
1787  ULONG i;
1788  PUNICODE_STRING* ServicePath = NULL;
1789  BOOLEAN Success, AutoSelect;
1791  PAGED_CODE();
1792 
1793  /* Initialize the driver list */
1794  InitializeListHead(&DriverList);
1795 
1796  /* Open the system hive key */
1797  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\System");
1799  &KeyName,
1801  NULL,
1802  NULL);
1804  if (!NT_SUCCESS(Status)) return NULL;
1805 
1806  /* Reference the key object to get the root hive/cell to access directly */
1810  KernelMode,
1811  (PVOID*)&KeyBody,
1812  NULL);
1813  if (!NT_SUCCESS(Status))
1814  {
1815  /* Fail */
1816  NtClose(KeyHandle);
1817  return NULL;
1818  }
1819 
1820  /* Do all this under the registry lock */
1822 
1823  /* Get the hive and key cell */
1824  Hive = KeyBody->KeyControlBlock->KeyHive;
1825  RootCell = KeyBody->KeyControlBlock->KeyCell;
1826 
1827  /* Open the current control set key */
1828  RtlInitUnicodeString(&KeyName, L"Current");
1829  ControlCell = CmpFindControlSet(Hive, RootCell, &KeyName, &AutoSelect);
1830  if (ControlCell == HCELL_NIL) goto EndPath;
1831 
1832  /* Find all system drivers */
1833  Success = CmpFindDrivers(Hive, ControlCell, SystemLoad, NULL, &DriverList);
1834  if (!Success) goto EndPath;
1835 
1836  /* Sort by group/tag */
1837  if (!CmpSortDriverList(Hive, ControlCell, &DriverList)) goto EndPath;
1838 
1839  /* Remove circular dependencies (cycles) and sort */
1840  if (!CmpResolveDriverDependencies(&DriverList)) goto EndPath;
1841 
1842  /* Loop the list to count drivers */
1843  for (i = 0, NextEntry = DriverList.Flink;
1844  NextEntry != &DriverList;
1845  i++, NextEntry = NextEntry->Flink);
1846 
1847  /* Allocate the array */
1848  ServicePath = ExAllocatePool(NonPagedPool, (i + 1) * sizeof(PUNICODE_STRING));
1849  if (!ServicePath) KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1850 
1851  /* Loop the driver list */
1852  for (i = 0, NextEntry = DriverList.Flink;
1853  NextEntry != &DriverList;
1854  i++, NextEntry = NextEntry->Flink)
1855  {
1856  /* Get the entry */
1858 
1859  /* Allocate the path for the caller */
1860  ServicePath[i] = ExAllocatePool(NonPagedPool, sizeof(UNICODE_STRING));
1861  if (!ServicePath[i])
1862  {
1863  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1864  }
1865 
1866  /* Duplicate the registry path */
1868  &DriverEntry->RegistryPath,
1869  ServicePath[i]);
1870  if (!NT_SUCCESS(Status))
1871  {
1872  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 2, 1, 0, 0);
1873  }
1874  }
1875 
1876  /* Terminate the list */
1877  ServicePath[i] = NULL;
1878 
1879 EndPath:
1880  /* Free the driver list if we had one */
1881  if (!IsListEmpty(&DriverList)) CmpFreeDriverList(Hive, &DriverList);
1882 
1883  /* Unlock the registry */
1885 
1886  /* Close the key handle and dereference the object, then return the path */
1887  ObDereferenceObject(KeyBody);
1888  NtClose(KeyHandle);
1889  return ServicePath;
1890 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
INIT_FUNCTION BOOLEAN NTAPI CmpSortDriverList(IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:562
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
BOOL WINAPI EndPath(_In_ HDC)
LONG NTSTATUS
Definition: precomp.h:26
#define HCELL_NIL
Definition: hivedata.h:85
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
INIT_FUNCTION BOOLEAN NTAPI CmpFindDrivers(IN PHHIVE Hive, IN HCELL_INDEX ControlSet, IN SERVICE_LOAD_TYPE LoadType, IN PWCHAR BootFileSystem OPTIONAL, IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:383
INIT_FUNCTION BOOLEAN NTAPI CmpResolveDriverDependencies(IN PLIST_ENTRY DriverListHead)
Definition: cmboot.c:674
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
static int Link(const char **args)
Definition: vfdcmd.c:2414
#define PAGED_CODE()
Definition: video.h:57
Definition: arc.h:198
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
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI CmpLockRegistryExclusive(VOID)
Definition: cmsysini.c:1894
POBJECT_TYPE CmpKeyObjectType
Definition: cmsysini.c:16
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
struct _CM_KEY_CONTROL_BLOCK * KeyControlBlock
Definition: cm.h:229
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG HCELL_INDEX
Definition: hivedata.h:80
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
#define RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE
Definition: green.h:15
INIT_FUNCTION HCELL_INDEX NTAPI CmpFindControlSet(IN PHHIVE SystemHive, IN HCELL_INDEX RootCell, IN PUNICODE_STRING SelectKeyName, OUT PBOOLEAN AutoSelect)
Definition: cmboot.c:25
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
NTSYSAPI NTSTATUS WINAPI RtlDuplicateUnicodeString(int, const UNICODE_STRING *, UNICODE_STRING *)
static const WCHAR L[]
Definition: oid.c:1250
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
DRIVER_INITIALIZE DriverEntry
Definition: condrv.c:21
#define KEY_QUERY_VALUE
Definition: nt_native.h:1016
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
NTSYSAPI NTSTATUS NTAPI NtOpenKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes)
Definition: ntapi.c:336
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
INIT_FUNCTION VOID NTAPI CmpFreeDriverList(IN PHHIVE Hive, IN PLIST_ENTRY DriverList)
Definition: cmsysini.c:1727
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107

Referenced by IopInitializeSystemDrivers().

◆ CmiCallRegisteredCallbacks()

NTSTATUS CmiCallRegisteredCallbacks ( IN REG_NOTIFY_CLASS  Argument1,
IN PVOID  Argument2 
)

Definition at line 59 of file cmhook.c.

61 {
62  PLIST_ENTRY CurrentEntry;
64  PREGISTRY_CALLBACK CurrentCallback;
65  PAGED_CODE();
66 
68 
69  for (CurrentEntry = CmiCallbackHead.Flink;
70  CurrentEntry != &CmiCallbackHead;
71  CurrentEntry = CurrentEntry->Flink)
72  {
73  CurrentCallback = CONTAINING_RECORD(CurrentEntry, REGISTRY_CALLBACK, ListEntry);
74  if (!CurrentCallback->PendingDelete &&
75  ExAcquireRundownProtection(&CurrentCallback->RundownRef))
76  {
77  /* don't hold locks during the callbacks! */
79 
80  Status = CurrentCallback->Function(CurrentCallback->Context,
82  Argument2);
83 
85 
86  /* don't release the rundown protection before holding the callback lock
87  so the pointer to the next callback isn't cleared in case this callback
88  get's deleted */
89  ExReleaseRundownProtection(&CurrentCallback->RundownRef);
90  if(!NT_SUCCESS(Status))
91  {
92  /* one callback returned failure, don't call any more callbacks */
93  break;
94  }
95  }
96  }
97 
99 
100  return Status;
101 }
_IRQL_requires_same_ _In_opt_ PVOID Argument1
Definition: cmtypes.h:694
NTKERNELAPI VOID FASTCALL ExReleaseRundownProtection(_Inout_ PEX_RUNDOWN_REF RunRef)
LONG NTSTATUS
Definition: precomp.h:26
#define ExAcquireRundownProtection
Definition: ex.h:130
BOOLEAN PendingDelete
Definition: cmhook.c:30
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
#define PAGED_CODE()
Definition: video.h:57
EX_RUNDOWN_REF RundownRef
Definition: cmhook.c:26
LIST_ENTRY CmiCallbackHead
Definition: cmhook.c:20
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
_In_ PVOID Argument2
Definition: classpnp.h:680
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FAST_MUTEX CmiCallbackLock
Definition: cmhook.c:21
Definition: typedefs.h:117
Status
Definition: gdiplustypes.h:24
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
return STATUS_SUCCESS
Definition: btrfs.c:2938
PEX_CALLBACK_FUNCTION Function
Definition: cmhook.c:27

Referenced by CmpDeleteKeyObject(), NtDeleteKey(), NtDeleteValueKey(), NtEnumerateKey(), NtEnumerateValueKey(), NtQueryKey(), NtQueryValueKey(), and NtSetValueKey().

◆ CmInitSystem1()

INIT_FUNCTION BOOLEAN NTAPI CmInitSystem1 ( VOID  )

Definition at line 1511 of file cmsysini.c.

1512 {
1515  HANDLE KeyHandle;
1516  NTSTATUS Status;
1517  PCMHIVE HardwareHive;
1519  PAGED_CODE();
1520 
1521  /* Check if this is PE-boot */
1522  if (InitIsWinPEMode)
1523  {
1524  /* Set registry to PE mode */
1525  CmpMiniNTBoot = TRUE;
1527  }
1528 
1529  /* Initialize the hive list and lock */
1533 
1534  /* Initialize registry lock */
1536 
1537  /* Initialize the cache */
1539 
1540  /* Initialize allocation and delayed dereferencing */
1544 
1545  /* Initialize callbacks */
1546  CmpInitCallback();
1547 
1548  /* Initialize self healing */
1551 
1552  /* Save the current process and lock the registry */
1554 
1555  /* Create the key object types */
1557  if (!NT_SUCCESS(Status))
1558  {
1559  /* Bugcheck */
1560  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 1, Status, 0);
1561  }
1562 
1563  /* Build the master hive */
1565  HINIT_CREATE,
1566  HIVE_VOLATILE,
1568  NULL,
1569  NULL,
1570  NULL,
1571  NULL,
1572  NULL,
1573  0);
1574  if (!NT_SUCCESS(Status))
1575  {
1576  /* Bugcheck */
1577  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 2, Status, 0);
1578  }
1579 
1580  /* Create the \REGISTRY key node */
1581  if (!CmpCreateRegistryRoot())
1582  {
1583  /* Bugcheck */
1584  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 3, 0, 0);
1585  }
1586 
1587  /* Create the default security descriptor */
1589 
1590  /* Create '\Registry\Machine' key */
1591  RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\MACHINE");
1593  &KeyName,
1595  NULL,
1598  KEY_READ | KEY_WRITE,
1600  0,
1601  NULL,
1602  0,
1603  NULL);
1604  if (!NT_SUCCESS(Status))
1605  {
1606  /* Bugcheck */
1607  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 5, Status, 0);
1608  }
1609 
1610  /* Close the handle */
1611  NtClose(KeyHandle);
1612 
1613  /* Create '\Registry\User' key */
1614  RtlInitUnicodeString(&KeyName, L"\\REGISTRY\\USER");
1616  &KeyName,
1618  NULL,
1621  KEY_READ | KEY_WRITE,
1623  0,
1624  NULL,
1625  0,
1626  NULL);
1627  if (!NT_SUCCESS(Status))
1628  {
1629  /* Bugcheck */
1630  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 6, Status, 0);
1631  }
1632 
1633  /* Close the handle */
1634  NtClose(KeyHandle);
1635 
1636  /* After this point, do not allow creating keys in the master hive */
1638 
1639  /* Initialize the system hive */
1641  {
1642  /* Bugcheck */
1643  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 7, 0, 0);
1644  }
1645 
1646  /* Create the 'CurrentControlSet' link */
1648  if (!NT_SUCCESS(Status))
1649  {
1650  /* Bugcheck */
1651  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 8, Status, 0);
1652  }
1653 
1654  /* Create the hardware hive */
1655  Status = CmpInitializeHive(&HardwareHive,
1656  HINIT_CREATE,
1657  HIVE_VOLATILE,
1659  NULL,
1660  NULL,
1661  NULL,
1662  NULL,
1663  NULL,
1664  0);
1665  if (!NT_SUCCESS(Status))
1666  {
1667  /* Bugcheck */
1668  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 11, Status, 0);
1669  }
1670 
1671  /* Add the hive to the hive list */
1672  CmpMachineHiveList[0].CmHive = HardwareHive;
1673 
1674  /* Attach it to the machine key */
1675  RtlInitUnicodeString(&KeyName, L"\\Registry\\Machine\\HARDWARE");
1677  NULL,
1678  HardwareHive,
1679  TRUE,
1681  if (!NT_SUCCESS(Status))
1682  {
1683  /* Bugcheck */
1684  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 12, Status, 0);
1685  }
1686 
1687  /* Add to HiveList key */
1688  CmpAddToHiveFileList(HardwareHive);
1689 
1690  /* Free the security descriptor */
1692 
1693  /* Fill out the Hardware key with the ARC Data from the Loader */
1695  if (!NT_SUCCESS(Status))
1696  {
1697  /* Bugcheck */
1698  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 13, Status, 0);
1699  }
1700 
1701  /* Initialize machine-dependent information into the registry */
1703  if (!NT_SUCCESS(Status))
1704  {
1705  /* Bugcheck */
1706  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 14, Status, 0);
1707  }
1708 
1709  /* Initialize volatile registry settings */
1711  if (!NT_SUCCESS(Status))
1712  {
1713  /* Bugcheck */
1714  KeBugCheckEx(CONFIG_INITIALIZATION_FAILED, 1, 15, Status, 0);
1715  }
1716 
1717  /* Free the load options */
1719 
1720  /* If we got here, all went well */
1721  return TRUE;
1722 }
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateAlloc(VOID)
Definition: cmalloc.c:29
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING KeyName
Definition: ndis.h:4711
#define TRUE
Definition: types.h:120
NTSTATUS NTAPI NtCreateKey(OUT PHANDLE KeyHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN ULONG TitleIndex, IN PUNICODE_STRING Class OPTIONAL, IN ULONG CreateOptions, OUT PULONG Disposition OPTIONAL)
Definition: ntapi.c:240
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:182
LIST_ENTRY CmpHiveListHead
Definition: cmsysini.c:18
#define HIVE_VOLATILE
Definition: hivedata.h:23
INIT_FUNCTION BOOLEAN NTAPI CmpInitializeSystemHive(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:865
LONG NTSTATUS
Definition: precomp.h:26
PEPROCESS CmpSystemProcess
Definition: cmsysini.c:24
NTSTATUS NTAPI CmpLinkHiveToMaster(IN PUNICODE_STRING LinkName, IN HANDLE RootDirectory, IN PCMHIVE RegistryHive, IN BOOLEAN Allocate, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: cmsysini.c:798
NTSTATUS ExInitializeResourceLite(PULONG res)
Definition: env_spec_w32.h:641
HIVE_LIST_ENTRY CmpMachineHiveList[]
Definition: cmdata.c:41
PCMHIVE CmHive
Definition: cm.h:468
#define PAGED_CODE()
Definition: video.h:57
PSECURITY_DESCRIPTOR NTAPI CmpHiveRootSecurityDescriptor(VOID)
Definition: cmse.c:22
ERESOURCE CmpRegistryLock
Definition: cmsysini.c:19
LIST_ENTRY CmpSelfHealQueueListHead
Definition: cmsysini.c:21
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
#define ExInitializePushLock
Definition: ex.h:999
PCMHIVE CmiVolatileHive
Definition: cmsysini.c:17
PLOADER_PARAMETER_BLOCK KeLoaderBlock
Definition: krnlinit.c:29
#define KEY_WRITE
Definition: nt_native.h:1031
NTSTATUS NTAPI CmpInitializeMachineDependentConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmhardwr.c:21
#define HINIT_CREATE
Definition: hivedata.h:13
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
INIT_FUNCTION VOID NTAPI CmpInitDelayDerefKCBEngine(VOID)
Definition: cmdelay.c:268
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
BOOLEAN CmpMiniNTBoot
Definition: cmdata.c:60
#define TAG_CM
Definition: cmlib.h:203
static const WCHAR L[]
Definition: oid.c:1250
INIT_FUNCTION VOID NTAPI CmpInitializeCache(VOID)
Definition: cmkcbncb.c:26
EX_PUSH_LOCK CmpLoadHiveLock
Definition: cmdata.c:39
INIT_FUNCTION NTSTATUS NTAPI CmpCreateObjectTypes(VOID)
Definition: cmsysini.c:982
NTSTATUS NTAPI CmpInitializeHive(OUT PCMHIVE *CmHive, IN ULONG OperationType, IN ULONG HiveFlags, IN ULONG FileType, IN PVOID HiveData OPTIONAL, IN HANDLE Primary, IN HANDLE Log, IN HANDLE External, IN PCUNICODE_STRING FileName OPTIONAL, IN ULONG CheckFlags)
Definition: cminit.c:19
INIT_FUNCTION NTSTATUS NTAPI CmpCreateControlSet(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:524
Status
Definition: gdiplustypes.h:24
VOID FASTCALL KeInitializeGuardedMutex(OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:31
EX_PUSH_LOCK CmpHiveListHeadLock
Definition: cmdata.c:39
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
BOOLEAN CmpNoVolatileCreates
Definition: cmsysini.c:32
INIT_FUNCTION VOID NTAPI CmpInitCallback(VOID)
Definition: cmhook.c:38
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define TAG_CMSD
Definition: cmlib.h:206
INIT_FUNCTION BOOLEAN NTAPI CmpCreateRegistryRoot(VOID)
Definition: cmsysini.c:1072
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
KGUARDED_MUTEX CmpSelfHealQueueLock
Definition: cmsysini.c:20
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
INIT_FUNCTION VOID NTAPI CmpInitCmPrivateDelayAlloc(VOID)
Definition: cmalloc.c:44
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
INIT_FUNCTION NTSTATUS NTAPI CmpSetSystemValues(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmsysini.c:397
INIT_FUNCTION NTSTATUS NTAPI CmpInitializeHardwareConfiguration(IN PLOADER_PARAMETER_BLOCK LoaderBlock)
Definition: cmconfig.c:328
UNICODE_STRING CmpLoadOptions
Definition: cmdata.c:55
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107
NTSTATUS NTAPI CmpAddToHiveFileList(IN PCMHIVE Hive)
Definition: cmhvlist.c:130
BOOLEAN InitIsWinPEMode
Definition: init.c:69
Definition: cm.h:391
BOOLEAN CmpShareSystemHives
Definition: cmdata.c:57

Referenced by Phase1InitializationDiscard().

◆ CmLoadKey()

NTSTATUS NTAPI CmLoadKey ( IN POBJECT_ATTRIBUTES  TargetKey,
IN POBJECT_ATTRIBUTES  SourceFile,
IN ULONG  Flags,
IN PCM_KEY_BODY  KeyBody 
)

Definition at line 2004 of file cmapi.c.

2008 {
2009  SECURITY_QUALITY_OF_SERVICE ServiceQos;
2010  SECURITY_CLIENT_CONTEXT ClientSecurityContext;
2011  HANDLE KeyHandle;
2012  BOOLEAN Allocate = TRUE;
2013  PCMHIVE CmHive, LoadedHive;
2014  NTSTATUS Status;
2015  CM_PARSE_CONTEXT ParseContext;
2016 
2017  /* Check if we have a trust key */
2018  if (KeyBody)
2019  {
2020  /* Fail */
2021  DPRINT("Trusted classes not yet supported\n");
2022  }
2023 
2024  /* Build a service QoS for a security context */
2025  ServiceQos.Length = sizeof(SECURITY_QUALITY_OF_SERVICE);
2028  ServiceQos.EffectiveOnly = TRUE;
2030  &ServiceQos,
2031  FALSE,
2032  &ClientSecurityContext);
2033  if (!NT_SUCCESS(Status))
2034  {
2035  /* Fail */
2036  DPRINT1("Security context failed\n");
2037  return Status;
2038  }
2039 
2040  /* Open the target key */
2041  RtlZeroMemory(&ParseContext, sizeof(ParseContext));
2042  ParseContext.CreateOperation = FALSE;
2043  Status = ObOpenObjectByName(TargetKey,
2045  KernelMode,
2046  NULL,
2047  KEY_READ,
2048  &ParseContext,
2049  &KeyHandle);
2050  if (!NT_SUCCESS(Status)) KeyHandle = NULL;
2051 
2052  /* Open the hive */
2053  Status = CmpCmdHiveOpen(SourceFile,
2054  &ClientSecurityContext,
2055  &Allocate,
2056  &CmHive,
2057  0);
2058 
2059  /* Get rid of the security context */
2060  SeDeleteClientSecurity(&ClientSecurityContext);
2061 
2062  /* See if we failed */
2063  if (!NT_SUCCESS(Status))
2064  {
2065  /* See if the target already existed */
2066  if (KeyHandle)
2067  {
2068  /* Lock the registry */
2070 
2071  /* Check if we are already loaded */
2072  if (CmpIsHiveAlreadyLoaded(KeyHandle, SourceFile, &LoadedHive))
2073  {
2074  /* That's okay then */
2075  ASSERT(LoadedHive);
2077  }
2078 
2079  /* Release the registry */
2081  }
2082 
2083  /* Close the key handle if we had one */
2084  if (KeyHandle) ZwClose(KeyHandle);
2085  return Status;
2086  }
2087 
2088  /* Lock the registry shared */
2089  CmpLockRegistry();
2090 
2091  /* Lock loading */
2093 
2094  /* Lock the hive to this thread */
2097 
2098  /* Set flag */
2100 
2101  /* Link the hive */
2102  Status = CmpLinkHiveToMaster(TargetKey->ObjectName,
2103  TargetKey->RootDirectory,
2104  CmHive,
2105  Allocate,
2106  TargetKey->SecurityDescriptor);
2107  if (NT_SUCCESS(Status))
2108  {
2109  /* Add to HiveList key */
2111 
2112  /* Sync the hive if necessary */
2113  if (Allocate)
2114  {
2115  /* Sync it under the flusher lock */
2117  HvSyncHive(&CmHive->Hive);
2119  }
2120 
2121  /* Release the hive */
2124 
2125  /* Allow loads */
2127  }
2128  else
2129  {
2130  DPRINT1("CmpLinkHiveToMaster failed, Status %lx\n", Status);
2131  /* FIXME: TODO */
2132  ASSERT(FALSE);
2133  }
2134 
2135  /* Is this first profile load? */
2137  {
2138  /* User is now logged on, set quotas */
2141  }
2142 
2143  /* Unlock the registry */
2145 
2146  /* Close handle and return */
2147  if (KeyHandle) ZwClose(KeyHandle);
2148  return Status;
2149 }
NTSTATUS NTAPI ObOpenObjectByName(IN POBJECT_ATTRIBUTES ObjectAttributes, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, IN PACCESS_STATE PassedAccessState, IN ACCESS_MASK DesiredAccess, IN OUT PVOID ParseContext, OUT PHANDLE Handle)
Definition: obhandle.c:2529
VOID NTAPI CmpUnlockHiveFlusher(IN PCMHIVE Hive)
Definition: cmsysini.c:1965
FORCEINLINE VOID ExAcquirePushLockExclusive(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1022
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI CmpIsHiveAlreadyLoaded(IN HANDLE KeyHandle, IN POBJECT_ATTRIBUTES SourceFile, OUT PCMHIVE *CmHive)
Definition: cmapi.c:21
#define PsGetCurrentThread()
Definition: env_spec_w32.h:81
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI CmpLinkHiveToMaster(IN PUNICODE_STRING LinkName, IN HANDLE RootDirectory, IN PCMHIVE RegistryHive, IN BOOLEAN Allocate, IN PSECURITY_DESCRIPTOR SecurityDescriptor)
Definition: cmsysini.c:798
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
BOOLEAN CmpProfileLoaded
Definition: cmsysini.c:31
#define SeDeleteClientSecurity(C)
Definition: imports.h:320
NTSTATUS NTAPI CmpCmdHiveOpen(IN POBJECT_ATTRIBUTES FileAttributes, IN PSECURITY_CLIENT_CONTEXT ImpersonationContext, IN OUT PBOOLEAN Allocate, OUT PCMHIVE *NewHive, IN ULONG CheckFlags)
Definition: cmlazy.c:272
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
HHIVE Hive
Definition: cm.h:393
void DPRINT(...)
Definition: polytest.cpp:61
VOID NTAPI CmpLockRegistryExclusive(VOID)
Definition: cmsysini.c:1894
NTKERNELAPI NTSTATUS NTAPI SeCreateClientSecurity(IN PETHREAD Thread, IN PSECURITY_QUALITY_OF_SERVICE QualityOfService, IN BOOLEAN RemoteClient, OUT PSECURITY_CLIENT_CONTEXT ClientContext)
Definition: access.c:506
#define HIVE_IS_UNLOADING
Definition: hivedata.h:28
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI CmpUnlockRegistry(VOID)
Definition: cmsysini.c:1993
BOOLEAN CMAPI HvSyncHive(PHHIVE RegistryHive)
Definition: hivewrt.c:243
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103
#define REG_NO_LAZY_FLUSH
Definition: nt_native.h:1093
VOID NTAPI CmpSetGlobalQuotaAllowed(VOID)
Definition: cmquota.c:22
EX_PUSH_LOCK CmpLoadHiveLock
Definition: cmdata.c:39
Status
Definition: gdiplustypes.h:24
FORCEINLINE VOID ExReleasePushLock(PEX_PUSH_LOCK PushLock)
Definition: ex.h:1282
BOOLEAN CmpWasSetupBoot
Definition: cmsysini.c:30
PKTHREAD CreatorOwner
Definition: cm.h:434
ULONG HiveFlags
Definition: hivedata.h:321
static PCMHIVE CmHive
Definition: registry.c:28
struct _SECURITY_QUALITY_OF_SERVICE SECURITY_QUALITY_OF_SERVICE
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
#define HIVE_NOLAZYFLUSH
Definition: hivedata.h:24
VOID NTAPI CmpLockHiveFlusherExclusive(IN PCMHIVE Hive)
Definition: cmsysini.c:1943
#define DPRINT1
Definition: precomp.h:8
#define CmpKeyObjectType
Definition: ObTypes.c:132
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define KeGetCurrentThread
Definition: hal.h:44
return STATUS_SUCCESS
Definition: btrfs.c:2938
VOID NTAPI CmpLockRegistry(VOID)
Definition: cmsysini.c:1907
BOOLEAN CreateOperation
Definition: cm.h:489
NTSTATUS NTAPI CmpAddToHiveFileList(IN PCMHIVE Hive)
Definition: cmhvlist.c:130
Definition: cm.h:391

Referenced by NtLoadKeyEx().

◆ CmpAcquireTwoKcbLocksExclusiveByKey()

VOID NTAPI CmpAcquireTwoKcbLocksExclusiveByKey ( IN ULONG  ConvKey1,
IN ULONG  ConvKey2 
)

Definition at line 2021 of file cmsysini.c.

2023 {
2024  ULONG Index1, Index2;
2025 
2026  /* Sanity check */
2028 
2029  /* Get hash indexes */
2030  Index1 = GET_HASH_INDEX(ConvKey1);
2031  Index2 = GET_HASH_INDEX(ConvKey2);
2032 
2033  /* See which one is highest */
2034  if (Index1 < Index2)
2035  {
2036  /* Grab them in the proper order */
2039  }
2040  else
2041  {
2042  /* Grab the second one first, then the first */
2044  if (Index1 != Index2) CmpAcquireKcbLockExclusiveByKey(ConvKey1);
2045  }
2046 }
#define CMP_ASSERT_REGISTRY_LOCK()
Definition: cm_x.h:46
FORCEINLINE VOID CmpAcquireKcbLockExclusiveByKey(IN ULONG ConvKey)
Definition: cm_x.h:112
#define GET_HASH_INDEX(ConvKey)
Definition: cm_x.h:18
unsigned int ULONG
Definition: retypes.h:1

Referenced by CmDeleteKey(), CmpCreateKeyControlBlock(), and NtUnloadKey2().

◆ CmpAddToDelayedClose()

VOID NTAPI CmpAddToDelayedClose ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN BOOLEAN  LockHeldExclusively 
)

Definition at line 350 of file cmdelay.c.

352 {
353  ULONG i;
354  ULONG OldRefCount, NewRefCount;
356  PAGED_CODE();
357 
358  /* Sanity check */
359  CMP_ASSERT_KCB_LOCK(Kcb);
360 
361  /* Make sure it's valid */
362  if (Kcb->DelayedCloseIndex != CmpDelayedCloseSize) ASSERT(FALSE);
363 
364  /* Sanity checks */
365  ASSERT(Kcb->RefCount == 0);
366  ASSERT(IsListEmpty(&Kcb->KeyBodyListHead) == TRUE);
367  for (i = 0; i < 4; i++) ASSERT(Kcb->KeyBodyArray[i] == NULL);
368 
369  /* Allocate a delay item */
371  if (!Entry)
372  {
373  /* Cleanup immediately */
374  CmpCleanUpKcbCacheWithLock(Kcb, LockHeldExclusively);
375  return;
376  }
377 
378  /* Sanity check */
379  if (Kcb->InDelayClose) ASSERT(FALSE);
380 
381  /* Get the previous reference count */
382  OldRefCount = *(PLONG)&Kcb->InDelayClose;
383  ASSERT(OldRefCount == 0);
384 
385  /* Write the new one */
386  NewRefCount = 1;
387  if (InterlockedCompareExchange((PLONG)&Kcb->InDelayClose,
388  NewRefCount,
389  OldRefCount) != OldRefCount)
390  {
391  /* Sanity check */
392  ASSERT(FALSE);
393  }
394 
395  /* Reset the delayed close index */
396  Kcb->DelayedCloseIndex = 0;
397 
398  /* Set up the close entry */
399  Kcb->DelayCloseEntry = Entry;
400  Entry->KeyControlBlock = Kcb;
401 
402  /* Increase the number of elements */
404 
405  /* Acquire the delayed close table lock */
407 
408  /* Insert the entry into the list */
409  InsertHeadList(&CmpDelayedLRUListHead, &Entry->DelayedLRUList);
410 
411  /* Check if we need to enable anything */
414  {
415  /* Yes, we have too many elements to close, and no work item */
417  }
418 
419  /* Release the table lock */
421 }
KGUARDED_MUTEX CmpDelayedCloseTableLock
Definition: cmdelay.c:21
ULONG CmpDelayedCloseSize
Definition: cmdelay.c:19
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
ULONG CmpDelayedCloseElements
Definition: cmdelay.c:20
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
FORCEINLINE VOID InsertHeadList(_Inout_ PLIST_ENTRY ListHead, _Inout_ __drv_aliasesMem PLIST_ENTRY Entry)
Definition: rtlfuncs.h:201
#define InterlockedCompareExchange
Definition: interlocked.h:104
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
VOID NTAPI CmpCleanUpKcbCacheWithLock(IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
Definition: cmkcbncb.c:476
#define PAGED_CODE()
Definition: video.h:57
PVOID NTAPI CmpAllocateDelayItem(VOID)
Definition: cmalloc.c:196
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
smooth NULL
Definition: ftsmooth.c:416
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
Definition: cm.h:357
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
LIST_ENTRY CmpDelayedLRUListHead
Definition: cmdelay.c:24
#define InterlockedIncrement
Definition: armddk.h:53
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
unsigned int ULONG
Definition: retypes.h:1
VOID NTAPI CmpArmDelayedCloseTimer(VOID)
Definition: cmdelay.c:335
signed int * PLONG
Definition: retypes.h:5
base of all file and directory entries
Definition: entries.h:82

Referenced by CmpDereferenceKeyControlBlockWithLock().

◆ CmpAddToHiveFileList()

NTSTATUS NTAPI CmpAddToHiveFileList ( IN PCMHIVE  Hive)

Definition at line 130 of file cmhvlist.c.

131 {
135  UNICODE_STRING HivePath;
137  ULONG Length;
138  OBJECT_NAME_INFORMATION DummyNameInfo;
139  POBJECT_NAME_INFORMATION FileNameInfo;
140 
141  HivePath.Buffer = NULL;
142  FileNameInfo = NULL;
143 
144  /* Create or open the hive list key */
148  NULL,
149  NULL);
150  Status = ZwCreateKey(&KeyHandle,
153  0,
154  NULL,
156  NULL);
157  if (!NT_SUCCESS(Status))
158  {
159  /* Fail */
160  DPRINT1("CmpAddToHiveFileList: Creation or opening of the hive list failed, status = 0x%08lx\n", Status);
161  return Status;
162  }
163 
164  /* Retrieve the name of the hive */
165  if (!CmpGetHiveName(Hive, &HivePath))
166  {
167  /* Fail */
168  DPRINT1("CmpAddToHiveFileList: Unable to retrieve the hive name\n");
170  goto Quickie;
171  }
172 
173  /* Get the name of the corresponding file */
174  if (!(Hive->Hive.HiveFlags & HIVE_VOLATILE))
175  {
176  /* Determine the right buffer size and allocate */
177  Status = ZwQueryObject(Hive->FileHandles[HFILE_TYPE_PRIMARY],
179  &DummyNameInfo,
180  sizeof(DummyNameInfo),
181  &Length);
183  {
184  DPRINT1("CmpAddToHiveFileList: Hive file name size query failed, status = 0x%08lx\n", Status);
185  goto Quickie;
186  }
187 
188  FileNameInfo = ExAllocatePoolWithTag(PagedPool,
189  Length + sizeof(UNICODE_NULL),
190  TAG_CM);
191  if (FileNameInfo == NULL)
192  {
194  goto Quickie;
195  }
196 
197  /* Try to get the value */
198  Status = ZwQueryObject(Hive->FileHandles[HFILE_TYPE_PRIMARY],
200  FileNameInfo,
201  Length,
202  &Length);
203  if (NT_SUCCESS(Status))
204  {
205  /* Null-terminate and add the length of the terminator */
206  Length -= sizeof(OBJECT_NAME_INFORMATION);
207  FilePath = FileNameInfo->Name.Buffer;
208  FilePath[Length / sizeof(WCHAR)] = UNICODE_NULL;
209  Length += sizeof(UNICODE_NULL);
210  }
211  else
212  {
213  /* Fail */
214  DPRINT1("CmpAddToHiveFileList: Hive file name query failed, status = 0x%08lx\n", Status);
215  goto Quickie;
216  }
217  }
218  else
219  {
220  /* No name */
221  FilePath = L"";
222  Length = sizeof(UNICODE_NULL);
223  }
224 
225  /* Set the entry in the hive list */
226  Status = ZwSetValueKey(KeyHandle,
227  &HivePath,
228  0,
229  REG_SZ,
230  FilePath,
231  Length);
232  if (!NT_SUCCESS(Status))
233  {
234  /* Fail */
235  DPRINT1("CmpAddToHiveFileList: Setting of entry in the hive list failed, status = 0x%08lx\n", Status);
236  }
237 
238 Quickie:
239  /* Cleanup and return status */
240  if (HivePath.Buffer)
241  {
242  ExFreePoolWithTag(HivePath.Buffer, TAG_CM);
243  }
244  if (FileNameInfo)
245  {
246  ExFreePoolWithTag(FileNameInfo, TAG_CM);
247  }
249  return Status;
250 }
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:35
BOOLEAN NTAPI CmpGetHiveName(IN PCMHIVE Hive, OUT PUNICODE_STRING HiveName)
Definition: cmhvlist.c:24
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
Definition: ndis.h:4711
#define KEY_READ
Definition: nt_native.h:1023
#define HIVE_VOLATILE
Definition: hivedata.h:23
LONG NTSTATUS
Definition: precomp.h:26
UNICODE_STRING HiveListValueName
Definition: cmhvlist.c:17
uint16_t * PWCHAR
Definition: typedefs.h:54
UNICODE_STRING Name
Definition: nt_native.h:1270
PCWSTR FilePath
#define UNICODE_NULL
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_CM
Definition: cmlib.h:203
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Definition: obhandle.c:3376
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define REG_OPTION_VOLATILE
Definition: nt_native.h:1060
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define REG_SZ
Definition: layer.c:22

Referenced by CmInitSystem1(), CmLoadKey(), and CmpInitializeHiveList().

◆ CmpAllocate()

PVOID NTAPI CmpAllocate ( IN SIZE_T  Size,
IN BOOLEAN  Paged,
IN ULONG  Tag 
)

Definition at line 34 of file registry.c.

38 {
41 
42  return FrLdrTempAlloc(Size, Tag);
43 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:177
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
IN ULONG IN ULONG Tag
Definition: evtlib.h:159

◆ CmpAllocateDelayItem()

PVOID NTAPI CmpAllocateDelayItem ( VOID  )

Definition at line 196 of file cmalloc.c.

197 {
199  PCM_ALLOC_PAGE AllocPage;
200  ULONG i;
201  PLIST_ENTRY NextEntry;
202  PAGED_CODE();
203 
204  /* Lock the allocation buckets */
206 
207  /* Look for an item on the free list */
208 SearchList:
210  {
211  /* Get the current entry in the list */
213 
214  /* Grab the item */
215  Entry = CONTAINING_RECORD(NextEntry, CM_DELAY_ALLOC, ListEntry);
216 
217  /* Clear the list */
218  Entry->ListEntry.Flink = Entry->ListEntry.Blink = NULL;
219 
220  /* Grab the alloc page */
222 
223  /* Decrease free entries */
224  ASSERT(AllocPage->FreeCount != 0);
225  AllocPage->FreeCount--;
226 
227  /* Release the lock */
229  return Entry;
230  }
231 
232  /* Allocate an allocation page */
233  AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_CM);
234  if (AllocPage)
235  {
236  /* Set default entries */
237  AllocPage->FreeCount = CM_DELAYS_PER_PAGE;
238 
239  /* Loop each entry */
240  for (i = 0; i < CM_DELAYS_PER_PAGE; i++)
241  {
242  /* Get this entry and link it */
243  Entry = (PVOID)((ULONG_PTR)AllocPage +
244  FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage) +
245  i * sizeof(CM_DELAY_ALLOC));
247  &Entry->ListEntry);
248 
249  /* Clear the KCB pointer */
250  Entry->Kcb = NULL;
251  }
252  }
253  else
254  {
255  /* Release the lock */
257  return NULL;
258  }
259 
260  /* Do the search again */
261  goto SearchList;
262 }
#define TRUE
Definition: types.h:120
struct _Entry Entry
Definition: kefuncs.h:640
ULONG FreeCount
Definition: cm.h:340
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
PVOID NTAPI CmpAllocate(_In_ SIZE_T Size, _In_ BOOLEAN Paged, _In_ ULONG Tag)
Definition: bootreg.c:90
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
KGUARDED_MUTEX CmpDelayAllocBucketLock
Definition: cmalloc.c:18
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
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define TAG_CM
Definition: cmlib.h:203
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define CmpGetAllocPageFromDelayAlloc(a)
Definition: cm_x.h:260
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
struct _CM_DELAY_ALLOC CM_DELAY_ALLOC
unsigned int ULONG
Definition: retypes.h:1
#define CM_DELAYS_PER_PAGE
Definition: cm.h:126
base of all file and directory entries
Definition: entries.h:82
LIST_ENTRY CmpFreeDelayItemsListHead
Definition: cmalloc.c:22

Referenced by CmpAddToDelayedClose(), and CmpDelayDerefKeyControlBlock().

◆ CmpAllocateKeyControlBlock()

PCM_KEY_CONTROL_BLOCK NTAPI CmpAllocateKeyControlBlock ( VOID  )

Definition at line 111 of file cmalloc.c.

112 {
113  PLIST_ENTRY NextEntry;
114  PCM_KEY_CONTROL_BLOCK CurrentKcb;
115  PCM_ALLOC_PAGE AllocPage;
116  ULONG i;
117  PAGED_CODE();
118 
119  /* Check if private allocations are initialized */
120  if (CmpAllocInited)
121  {
122  /* They are, acquire the bucket lock */
124 
125  /* See if there's something on the free KCB list */
126 SearchKcbList:
128  {
129  /* Remove the entry */
130  NextEntry = RemoveHeadList(&CmpFreeKCBListHead);
131 
132  /* Get the KCB */
133  CurrentKcb = CONTAINING_RECORD(NextEntry,
135  FreeListEntry);
136 
137  /* Get the allocation page */
138  AllocPage = CmpGetAllocPageFromKcb(CurrentKcb);
139 
140  /* Decrease the free count */
141  ASSERT(AllocPage->FreeCount != 0);
142  AllocPage->FreeCount--;
143 
144  /* Make sure this KCB is privately allocated */
145  ASSERT(CurrentKcb->PrivateAlloc == 1);
146 
147  /* Release the allocation lock */
149 
150  /* Return the KCB */
151  return CurrentKcb;
152  }
153 
154  /* Allocate an allocation page */
155  AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_KCB);
156  if (AllocPage)
157  {
158  /* Set default entries */
159  AllocPage->FreeCount = CM_KCBS_PER_PAGE;
160 
161  /* Loop each entry */
162  for (i = 0; i < CM_KCBS_PER_PAGE; i++)
163  {
164  /* Get this entry */
165  CurrentKcb = (PVOID)((ULONG_PTR)AllocPage +
166  FIELD_OFFSET(CM_ALLOC_PAGE, AllocPage) +
167  i * sizeof(CM_KEY_CONTROL_BLOCK));
168 
169  /* Set it up */
170  CurrentKcb->PrivateAlloc = TRUE;
171  CurrentKcb->DelayCloseEntry = NULL;
173  &CurrentKcb->FreeListEntry);
174  }
175 
176  /* Now go back and search the list */
177  goto SearchKcbList;
178  }
179  }
180 
181  /* Allocate a KCB only */
182  CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_KCB);
183  if (CurrentKcb)
184  {
185  /* Set it up */
186  CurrentKcb->PrivateAlloc = 0;
187  CurrentKcb->DelayCloseEntry = NULL;
188  }
189 
190  /* Return it */
191  return CurrentKcb;
192 }
#define TRUE
Definition: types.h:120
ULONG FreeCount
Definition: cm.h:340
VOID FASTCALL KeAcquireGuardedMutex(IN PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:42
PVOID NTAPI CmpAllocate(_In_ SIZE_T Size, _In_ BOOLEAN Paged, _In_ ULONG Tag)
Definition: bootreg.c:90
#define InsertTailList(ListHead, Entry)
_Must_inspect_result_ FORCEINLINE BOOLEAN IsListEmpty(_In_ const LIST_ENTRY *ListHead)
Definition: rtlfuncs.h:57
#define PAGED_CODE()
Definition: video.h:57
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG PrivateAlloc
Definition: cm.h:265
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
smooth NULL
Definition: ftsmooth.c:416
FORCEINLINE PLIST_ENTRY RemoveHeadList(_Inout_ PLIST_ENTRY ListHead)
Definition: rtlfuncs.h:128
#define CM_KCBS_PER_PAGE
Definition: cm.h:124
struct _CM_KEY_CONTROL_BLOCK CM_KEY_CONTROL_BLOCK
void * PVOID
Definition: retypes.h:9
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
LIST_ENTRY CmpFreeKCBListHead
Definition: cmalloc.c:20
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define PAGE_SIZE
Definition: env_spec_w32.h:49
Definition: typedefs.h:117
#define TAG_KCB
Definition: cmlib.h:204
BOOLEAN CmpAllocInited
Definition: cmalloc.c:17
#define CmpGetAllocPageFromKcb(k)
Definition: cm_x.h:254
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
VOID FASTCALL KeReleaseGuardedMutex(IN OUT PKGUARDED_MUTEX GuardedMutex)
Definition: gmutex.c:53
KGUARDED_MUTEX CmpAllocBucketLock
Definition: cmalloc.c:18
unsigned int ULONG
Definition: retypes.h:1
PVOID DelayCloseEntry
Definition: cm.h:297
LIST_ENTRY FreeListEntry
Definition: cm.h:294

Referenced by CmpCreateKeyControlBlock().

◆ CmpArmDelayedCloseTimer()

VOID NTAPI CmpArmDelayedCloseTimer ( VOID  )

Definition at line 335 of file cmdelay.c.

336 {
338  PAGED_CODE();
339 
340  /* Set the worker active */
342 
343  /* Setup the interval */
344  Timeout.QuadPart = CmpDelayCloseIntervalInSeconds * -10000000;
346 }
#define TRUE
Definition: types.h:120
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
#define PAGED_CODE()
Definition: video.h:57
KTIMER CmpDelayCloseTimer
Definition: cmdelay.c:27
KDPC CmpDelayCloseDpc
Definition: cmdelay.c:26
BOOLEAN CmpDelayCloseWorkItemActive
Definition: cmdelay.c:22
static ULONG Timeout
Definition: ping.c:61
ULONG CmpDelayCloseIntervalInSeconds
Definition: cmdelay.c:25

Referenced by _Function_class_(), and CmpAddToDelayedClose().

◆ CmpCleanUpKcbCacheWithLock()

VOID NTAPI CmpCleanUpKcbCacheWithLock ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN BOOLEAN  LockHeldExclusively 
)

Definition at line 476 of file cmkcbncb.c.

478 {
480  PAGED_CODE();
481 
482  /* Sanity checks */
483  CMP_ASSERT_KCB_LOCK(Kcb);
484  ASSERT(Kcb->RefCount == 0);
485 
486  /* Cleanup the value cache */
488 
489  /* Dereference the NCB */
491 
492  /* Check if we have an index hint block and free it */
493  if (Kcb->ExtFlags & CM_KCB_SUBKEY_HINT) CmpFree(Kcb->IndexHint, 0);
494 
495  /* Check if we were already deleted */
496  Parent = Kcb->ParentKcb;
497  if (!Kcb->Delete) CmpRemoveKeyControlBlock(Kcb);
498 
499  /* Set invalid KCB signature */
500  Kcb->Signature = CM_KCB_INVALID_SIGNATURE;
501 
502  /* Free the KCB as well */
504 
505  /* Check if we have a parent */
506  if (Parent)
507  {
508  /* Dereference the parent */
509  LockHeldExclusively ?
510  CmpDereferenceKeyControlBlockWithLock(Parent,LockHeldExclusively) :
512  }
513 }
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
VOID NTAPI CmpDelayDerefKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmdelay.c:286
#define PAGED_CODE()
Definition: video.h:57
#define CM_KCB_INVALID_SIGNATURE
Definition: cm.h:49
VOID NTAPI CmpRemoveKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:306
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
Definition: bootreg.c:105
#define CM_KCB_SUBKEY_HINT
Definition: cm.h:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
VOID NTAPI CmpDereferenceNameControlBlockWithLock(IN PCM_NAME_CONTROL_BLOCK Ncb)
Definition: cmkcbncb.c:317
VOID NTAPI CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmalloc.c:53
VOID NTAPI CmpDereferenceKeyControlBlockWithLock(IN PCM_KEY_CONTROL_BLOCK Kcb, IN BOOLEAN LockHeldExclusively)
Definition: cmkcbncb.c:606
VOID NTAPI CmpCleanUpKcbValueCache(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmkcbncb.c:431

Referenced by _Function_class_(), CmpAddToDelayedClose(), CmpDereferenceKeyControlBlockWithLock(), and CmpEnumerateOpenSubKeys().

◆ CmpCleanUpKcbValueCache()

VOID NTAPI CmpCleanUpKcbValueCache ( IN PCM_KEY_CONTROL_BLOCK  Kcb)

Definition at line 431 of file cmkcbncb.c.

432 {
433  PULONG_PTR CachedList;
434  ULONG i;
435 
436  /* Make sure we have the exclusive lock */
437  CMP_ASSERT_KCB_LOCK(Kcb);
438 
439  /* Check if the value list is cached */
440  if (CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList))
441  {
442  /* Get the cache list */
443  CachedList = (PULONG_PTR)CMP_GET_CACHED_DATA(Kcb->ValueCache.ValueList);
444  for (i = 0; i < Kcb->ValueCache.Count; i++)
445  {
446  /* Check if this cell is cached */
447  if (CMP_IS_CELL_CACHED(CachedList[i]))
448  {
449  /* Free it */
450  CmpFree((PVOID)CMP_GET_CACHED_CELL(CachedList[i]), 0);
451  }
452  }
453 
454  /* Now free the list */
455  CmpFree((PVOID)CMP_GET_CACHED_CELL(Kcb->ValueCache.ValueList), 0);
456  Kcb->ValueCache.ValueList = HCELL_NIL;
457  }
458  else if (Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND)
459  {
460  /* This is a sym link, check if there's only one reference left */
461  if ((Kcb->ValueCache.RealKcb->RefCount == 1) &&
462  !(Kcb->ValueCache.RealKcb->Delete))
463  {
464  /* Disable delay close for the KCB */
465  Kcb->ValueCache.RealKcb->ExtFlags |= CM_KCB_NO_DELAY_CLOSE;
466  }
467 
468  /* Dereference the KCB */
469  CmpDelayDerefKeyControlBlock(Kcb->ValueCache.RealKcb);
470  Kcb->ExtFlags &= ~CM_KCB_SYM_LINK_FOUND;
471  }
472 }
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
#define HCELL_NIL
Definition: hivedata.h:85
#define CMP_IS_CELL_CACHED(c)
Definition: cm_x.h:28
#define CM_KCB_NO_DELAY_CLOSE
Definition: cm.h:59
VOID NTAPI CmpDelayDerefKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
Definition: cmdelay.c:286
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
#define CMP_GET_CACHED_DATA(c)
Definition: cm_x.h:36
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
Definition: bootreg.c:105
#define CMP_GET_CACHED_CELL(c)
Definition: cm_x.h:34
unsigned int ULONG
Definition: retypes.h:1
uint32_t * PULONG_PTR
Definition: typedefs.h:63
#define CM_KCB_SYM_LINK_FOUND
Definition: cm.h:57

Referenced by CmDeleteValueKey(), CmpCleanUpKcbCacheWithLock(), CmpCompareNewValueDataAgainstKCBCache(), and CmSetValueKey().

◆ CmpCleanUpSubKeyInfo()

VOID NTAPI CmpCleanUpSubKeyInfo ( IN PCM_KEY_CONTROL_BLOCK  Kcb)

Definition at line 517 of file cmkcbncb.c.

518 {
519  PCM_KEY_NODE KeyNode;
520 
521  /* Make sure we have the exclusive lock */
522  CMP_ASSERT_KCB_LOCK(Kcb);
523 
524  /* Check if there's any cached subkey */
525  if (Kcb->ExtFlags & (CM_KCB_NO_SUBKEY | CM_KCB_SUBKEY_ONE | CM_KCB_SUBKEY_HINT))
526  {
527  /* Check if there's a hint */
528  if (Kcb->ExtFlags & (CM_KCB_SUBKEY_HINT))
529  {
530  /* Kill it */
531  CmpFree(Kcb->IndexHint, 0);
532  }
533 
534  /* Remove subkey flags */
535  Kcb->ExtFlags &= ~(CM_KCB_NO_SUBKEY | CM_KCB_SUBKEY_ONE | CM_KCB_SUBKEY_HINT);
536  }
537 
538  /* Check if there's no linked cell */
539  if (Kcb->KeyCell == HCELL_NIL)
540  {
541  /* Make sure it's a delete */
542  ASSERT(Kcb->Delete);
543  KeyNode = NULL;
544  }
545  else
546  {
547  /* Get the key node */
548  KeyNode = (PCM_KEY_NODE)HvGetCell(Kcb->KeyHive, Kcb->KeyCell);
549  }
550 
551  /* Check if we got the node */
552  if (!KeyNode)
553  {
554  /* We didn't, mark the cached data invalid */
555  Kcb->ExtFlags |= CM_KCB_INVALID_CACHED_INFO;
556  }
557  else
558  {
559  /* We have a keynode, update subkey counts */
560  Kcb->ExtFlags &= ~CM_KCB_INVALID_CACHED_INFO;
561  Kcb->SubKeyCount = KeyNode->SubKeyCounts[Stable] +
562  KeyNode->SubKeyCounts[Volatile];
563 
564  /* Release the cell */
565  HvReleaseCell(Kcb->KeyHive, Kcb->KeyCell);
566  }
567 }
#define CMP_ASSERT_KCB_LOCK(k)
Definition: cm_x.h:245
#define CM_KCB_NO_SUBKEY
Definition: cm.h:54
#define HvReleaseCell(h, c)
Definition: cmlib.h:390
#define HCELL_NIL
Definition: hivedata.h:85
PVOID CMAPI HvGetCell(PHHIVE RegistryHive, HCELL_INDEX CellOffset)
Definition: hivecell.c:67
#define CM_KCB_SUBKEY_ONE
Definition: cm.h:55
smooth NULL
Definition: ftsmooth.c:416
struct _CM_KEY_NODE * PCM_KEY_NODE
#define CM_KCB_INVALID_CACHED_INFO
Definition: cm.h:60
VOID NTAPI CmpFree(_In_ PVOID Ptr, _In_ ULONG Quota)
Definition: bootreg.c:105
ULONG SubKeyCounts[HTYPE_COUNT]
Definition: cmdata.h:97
#define CM_KCB_SUBKEY_HINT
Definition: cm.h:56
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)

Referenced by CmDeleteKey(), CmpEnumerateOpenSubKeys(), and CmUnloadKey().

◆ CmpCloseHiveFiles()

VOID NTAPI CmpCloseHiveFiles ( IN PCMHIVE  Hive)

Definition at line 631 of file cminit.c.

632 {
633  ULONG i;
634 
635  for (i = 0; i < HFILE_TYPE_MAX; i++)
636  {
637  if (Hive->FileHandles[i] != NULL)
638  {
639  ZwClose(Hive->FileHandles[i]);
640  Hive->FileHandles[i] = NULL;
641  }
642  }
643 }
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
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
smooth NULL
Definition: ftsmooth.c:416
#define HFILE_TYPE_MAX
Definition: hivedata.h:36
unsigned int ULONG
Definition: retypes.h:1

Referenced by CmShutdownSystem(), and CmUnloadKey().

◆ CmpCloseKeyObject()

VOID NTAPI CmpCloseKeyObject ( IN PEPROCESS Process  OPTIONAL,
IN PVOID  Object,
IN ACCESS_MASK  GrantedAccess,
IN ULONG  ProcessHandleCount,
IN ULONG  SystemHandleCount 
)

Definition at line 159 of file cmsysini.c.

164 {
165  PCM_KEY_BODY KeyBody = (PCM_KEY_BODY)Object;
166  PAGED_CODE();
167 
168  /* Don't do anything if we're not the last handle */
169  if (SystemHandleCount > 1) return;
170 
171  /* Make sure we're a valid key body */
172  if (KeyBody->Type == CM_KEY_BODY_TYPE)
173  {
174  /* Don't do anything if we don't have a notify block */
175  if (!KeyBody->NotifyBlock) return;
176 
177  /* This shouldn't happen yet */
178  ASSERT(FALSE);
179  }
180 }
#define CM_KEY_BODY_TYPE
Definition: cm.h:66
struct _CM_NOTIFY_BLOCK * NotifyBlock
Definition: cm.h:230
#define PAGED_CODE()
Definition: video.h:57
static IUnknown Object
Definition: main.c:512
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG Type
Definition: cm.h:228
struct _CM_KEY_BODY * PCM_KEY_BODY

Referenced by CmpCreateObjectTypes().

◆ CmpCmdHiveOpen()

NTSTATUS NTAPI CmpCmdHiveOpen ( IN POBJECT_ATTRIBUTES  FileAttributes,
IN PSECURITY_CLIENT_CONTEXT  ImpersonationContext,
IN OUT PBOOLEAN  Allocate,
OUT PCMHIVE NewHive,
IN ULONG  CheckFlags 
)

Definition at line 272 of file cmlazy.c.

277 {
281  ULONG Length;
282  OBJECT_NAME_INFORMATION DummyNameInfo;
283  POBJECT_NAME_INFORMATION FileNameInfo;
284 
285  PAGED_CODE();
286 
287  if (FileAttributes->RootDirectory)
288  {
289  /*
290  * Validity check: The ObjectName is relative to RootDirectory,
291  * therefore it must not start with a path separator.
292  */
293  if (FileAttributes->ObjectName && FileAttributes->ObjectName->Buffer &&
294  FileAttributes->ObjectName->Length >= sizeof(WCHAR) &&
295  *FileAttributes->ObjectName->Buffer == OBJ_NAME_PATH_SEPARATOR)
296  {
298  }
299 
300  /* Determine the right buffer size and allocate */
301  Status = ZwQueryObject(FileAttributes->RootDirectory,
303  &DummyNameInfo,
304  sizeof(DummyNameInfo),
305  &Length);
307  {
308  DPRINT1("CmpCmdHiveOpen(): Root directory handle object name size query failed, Status = 0x%08lx\n", Status);
309  return Status;
310  }
311 
312  FileNameInfo = ExAllocatePoolWithTag(PagedPool,
313  Length + sizeof(UNICODE_NULL),
314  TAG_CM);
315  if (FileNameInfo == NULL)
316  {
317  DPRINT1("CmpCmdHiveOpen(): Unable to allocate memory\n");
319  }
320 
321  /* Try to get the value */
322  Status = ZwQueryObject(FileAttributes->RootDirectory,
324  FileNameInfo,
325  Length,
326  &Length);
327  if (!NT_SUCCESS(Status))
328  {
329  /* Fail */
330  DPRINT1("CmpCmdHiveOpen(): Root directory handle object name query failed, Status = 0x%08lx\n", Status);
331  ExFreePoolWithTag(FileNameInfo, TAG_CM);
332  return Status;
333  }
334 
335  /* Null-terminate and add the length of the terminator */
336  Length -= sizeof(OBJECT_NAME_INFORMATION);
337  FilePath = FileNameInfo->Name.Buffer;
338  FilePath[Length / sizeof(WCHAR)] = UNICODE_NULL;
339  Length += sizeof(UNICODE_NULL);
340 
341  /* Compute the size of the full path; Length already counts the terminating NULL */
342  Length = Length + sizeof(WCHAR) + FileAttributes->ObjectName->Length;
343  if (Length > MAXUSHORT)
344  {
345  /* Name size too long, bail out */
346  ExFreePoolWithTag(FileNameInfo, TAG_CM);
348  }
349 
350  /* Build the full path */
351  RtlInitEmptyUnicodeString(&FileName, NULL, 0);
353  if (!FileName.Buffer)
354  {
355  /* Fail */
356  DPRINT1("CmpCmdHiveOpen(): Unable to allocate memory\n");
357  ExFreePoolWithTag(FileNameInfo, TAG_CM);
359  }
360  FileName.MaximumLength = Length;
361  RtlCopyUnicodeString(&FileName, &FileNameInfo->Name);
362  ExFreePoolWithTag(FileNameInfo, TAG_CM);
363 
364  /*
365  * Append a path terminator if needed (we have already accounted
366  * for a possible extra one when allocating the buffer).
367  */
368  if (/* FileAttributes->ObjectName->Buffer[0] != OBJ_NAME_PATH_SEPARATOR && */ // We excluded ObjectName starting with a path separator above.
369  FileName.Length > 0 && FileName.Buffer[FileName.Length / sizeof(WCHAR) - 1] != OBJ_NAME_PATH_SEPARATOR)
370  {
371  /* ObjectName does not start with '\' and PathBuffer does not end with '\' */
372  FileName.Buffer[FileName.Length / sizeof(WCHAR)] = OBJ_NAME_PATH_SEPARATOR;
373  FileName.Length += sizeof(WCHAR);
374  FileName.Buffer[FileName.Length / sizeof(WCHAR)] = UNICODE_NULL;
375  }
376 
377  /* Append the object name */
379  if (!NT_SUCCESS(Status))
380  {
381  /* Fail */
382  DPRINT1("CmpCmdHiveOpen(): RtlAppendUnicodeStringToString() failed, Status = 0x%08lx\n", Status);
384  return Status;
385  }
386  }
387  else
388  {
389  FileName = *FileAttributes->ObjectName;
390  }
391 
392  /* Open the file in the current security context */
394  0,
395  NewHive,
396  Allocate,
397  CheckFlags);
398  if (((Status == STATUS_ACCESS_DENIED) ||
404  (ImpersonationContext))
405  {
406  /* We failed due to an account/security error, impersonate SYSTEM */
407  Status = SeImpersonateClientEx(ImpersonationContext, NULL);
408  if (NT_SUCCESS(Status))
409  {
410  /* Now try again */
412  0,
413  NewHive,
414  Allocate,
415  CheckFlags);
416 
417  /* Restore impersonation token */
418  PsRevertToSelf();
419  }
420  }
421 
422  if (FileAttributes->RootDirectory)
423  {
425  }
426 
427  /* Return status of open attempt */
428  return Status;
429 }
#define STATUS_WRONG_PASSWORD
Definition: ntstatus.h:328
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
NTKERNELAPI VOID NTAPI PsRevertToSelf(VOID)
Definition: security.c:556
LONG NTSTATUS
Definition: precomp.h:26
uint16_t * PWCHAR
Definition: typedefs.h:54
UNICODE_STRING Name
Definition: nt_native.h:1270
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:656
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_ACCOUNT_EXPIRED
Definition: ntstatus.h:622
NTSYSAPI VOID NTAPI RtlCopyUnicodeString(PUNICODE_STRING DestinationString, PUNICODE_STRING SourceString)
PCWSTR FilePath
#define STATUS_ACCOUNT_RESTRICTION
Definition: ntstatus.h:332
#define UNICODE_NULL
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
struct _OBJECT_NAME_INFORMATION OBJECT_NAME_INFORMATION
smooth NULL
Definition: ftsmooth.c:416
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE _In_ ACCESS_MASK _In_ POBJECT_ATTRIBUTES _Out_ PIO_STATUS_BLOCK _In_opt_ PLARGE_INTEGER _In_ ULONG FileAttributes
Definition: fltkernel.h:1230
#define STATUS_NO_SUCH_USER
Definition: ntstatus.h:322
#define STATUS_ACCOUNT_DISABLED
Definition: ntstatus.h:336
if(!(yy_init))
Definition: macro.lex.yy.c:714
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TAG_CM
Definition: cmlib.h:203
NTSTATUS NTAPI CmpInitHiveFromFile(IN PCUNICODE_STRING HiveName, IN ULONG HiveFlags, OUT PCMHIVE *Hive, IN OUT PBOOLEAN New, IN ULONG CheckFlags)
Definition: cmsysini.c:286
NTSTATUS NTAPI SeImpersonateClientEx(IN PSECURITY_CLIENT_CONTEXT ClientContext, IN PETHREAD ServerThread OPTIONAL)
Definition: access.c:589
Status
Definition: gdiplustypes.h:24
struct _FileName FileName
Definition: fatprocs.h:884
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define STATUS_OBJECT_PATH_INVALID
Definition: ntstatus.h:279
#define MAXUSHORT
Definition: typedefs.h:81
#define DPRINT1
Definition: precomp.h:8
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:281

Referenced by CmLoadKey().

◆ CmpCmdInit()

VOID NTAPI CmpCmdInit ( IN BOOLEAN  SetupBoot)

Definition at line 234 of file cmlazy.c.

235 {
237  PAGED_CODE();
238 
239  /* Setup the lazy DPC */
240  KeInitializeDpc(&CmpLazyFlushDpc, CmpLazyFlushDpcRoutine, NULL);
241 
242  /* Setup the lazy timer */
244 
245  /* Setup the lazy worker */
246  ExInitializeWorkItem(&CmpLazyWorkItem, CmpLazyFlushWorker, NULL);
247 
248  /* Setup the forced-lazy DPC and timer */
250  CmpEnableLazyFlushDpcRoutine,
251  NULL);
253 
254  /* Enable lazy flushing after 10 minutes */
255  DueTime.QuadPart = Int32x32To64(600, -10 * 1000 * 1000);
257 
258  /* Setup flush variables */
260  CmpWasSetupBoot = SetupBoot;
261 
262  /* Testing: Force Lazy Flushing */
264 
265  /* Setup the hive list if this is not a Setup boot */
266  if (!SetupBoot)
268 }
VOID NTAPI CmpInitializeHiveList(VOID)
Definition: cmsysini.c:1358
BOOLEAN NTAPI KeSetTimer(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:281
KTIMER CmpLazyFlushTimer
Definition: cmlazy.c:17
_In_ LARGE_INTEGER DueTime
Definition: kefuncs.h:524
KTIMER CmpEnableLazyFlushTimer
Definition: cmlazy.c:20
BOOLEAN CmpHoldLazyFlush
Definition: cmlazy.c:24
#define PAGED_CODE()
Definition: video.h:57
WORK_QUEUE_ITEM CmpLazyWorkItem
Definition: cmlazy.c:19
KDPC CmpLazyFlushDpc
Definition: cmlazy.c:18
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
#define ExInitializeWorkItem(Item, Routine, Context)
Definition: exfuncs.h:265
BOOLEAN CmpNoWrite
Definition: cmsysini.c:29
BOOLEAN CmpMiniNTBoot
Definition: cmdata.c:60
BOOLEAN CmpWasSetupBoot
Definition: cmsysini.c:30
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
#define Int32x32To64(a, b)
LONGLONG QuadPart
Definition: typedefs.h:112
KDPC CmpEnableLazyFlushDpc
Definition: cmlazy.c:21

Referenced by NtInitializeRegistry().

◆ CmpCompareNewValueDataAgainstKCBCache()

VALUE_SEARCH_RETURN_TYPE NTAPI CmpCompareNewValueDataAgainstKCBCache ( IN PCM_KEY_CONTROL_BLOCK  Kcb,
IN PUNICODE_STRING  ValueName,
IN ULONG  Type,
IN PVOID  Data,
IN ULONG  DataSize 
)

Definition at line 676 of file cmvalche.c.

681 {
682  VALUE_SEARCH_RETURN_TYPE SearchResult;
683  PCM_KEY_NODE KeyNode;
684  PCM_CACHED_VALUE *CachedValue;
685  ULONG Index;
687  BOOLEAN ValueCached, BufferAllocated = FALSE;
688  PVOID Buffer;
689  HCELL_INDEX ValueCellToRelease = HCELL_NIL, CellToRelease = HCELL_NIL;
690  BOOLEAN IsSmall;
691  ULONG_PTR CompareResult;
692  PAGED_CODE();
693 
694  /* Check if this is a symlink */
695  if (Kcb->Flags & KEY_SYM_LINK)
696  {
697  /* We need the exclusive lock */
698  if (!(CmpIsKcbLockedExclusive(Kcb)) &&
700  {
701  /* We need the exclusive lock */
703  }
704 
705  /* Otherwise, get the key node */
706  KeyNode = (PCM_KEY_NODE)HvGetCell(Kcb->KeyHive, Kcb->KeyCell);
707  if (!KeyNode) return SearchFail;
708 
709  /* Cleanup the KCB cache */
711 
712  /* Sanity checks */
713  ASSERT(!(CMP_IS_CELL_CACHED(Kcb->ValueCache.ValueList)));
714  ASSERT(!(Kcb->ExtFlags & CM_KCB_SYM_LINK_FOUND));
715 
716  /* Set the value cache */
717  Kcb->ValueCache.Count = KeyNode->ValueList.Count;
718  Kcb->ValueCache.ValueList = KeyNode->ValueList.List;
719 
720  /* Release the cell */
721  HvReleaseCell(Kcb->KeyHive, Kcb->KeyCell);
722  }
723 
724  /* Do the search */
725  SearchResult = CmpFindValueByNameFromCache(Kcb,
726  ValueName,
727  &CachedValue,
728  &Index,
729  &Value,
730  &ValueCached,
731  &ValueCellToRelease);
732  if (SearchResult == SearchNeedExclusiveLock)
733  {
734  /* We need the exclusive lock */
736  ASSERT(ValueCellToRelease == HCELL_NIL);
737  ASSERT(Value == NULL);
738  goto Quickie;
739  }
740  else if (SearchResult == SearchSuccess)
741  {
742  /* Sanity check */
743  ASSERT(Value);
744 
745  /* First of all, check if the key size and type matches */
746  if ((Type == Value->Type) &&
747  (DataSize == (Value->DataLength & ~CM_KEY_VALUE_SPECIAL_SIZE)))
748  {
749  /* Check if this is a small key */
750  IsSmall = (DataSize <= CM_KEY_VALUE_SMALL) ? TRUE: FALSE;
751  if (IsSmall)
<