test: cm.h File Reference

Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

# cm.h File Reference

Go to the source code of this file.

## Classes

struct | _BOOT_DRIVER_LIST_ENTRY
struct | _CM_SYSTEM_CONTROL_VECTOR

## Typedefs

typedef _BOOT_DRIVER_LIST_ENTRY | BOOT_DRIVER_LIST_ENTRY
typedef _BOOT_DRIVER_LIST_ENTRY * | PBOOT_DRIVER_LIST_ENTRY
typedef _CM_SYSTEM_CONTROL_VECTOR | CM_SYSTEM_CONTROL_VECTOR
typedef _CM_SYSTEM_CONTROL_VECTOR * | PCM_SYSTEM_CONTROL_VECTOR
typedef VOID(* | PCM_TRACE_NOTIFY_ROUTINE )(IN NTSTATUS Status, IN HANDLE KeyHandle, IN LONGLONG ElapsedTime, IN PUNICODE_STRING KeyName, IN UCHAR Type)

## Functions

PHANDLE | CmGetSystemDriverList (VOID)
BOOLEAN | CmInitSystem1 (IN PLOADER_PARAMETER_BLOCK LoaderBlock)
BOOLEAN | CmInitSystem2 ()
VOID | CmNotifyRunDown (PETHREAD Thread)
VOID | CmShutdownSystem (VOID)
VOID | CmBootLastKnownGood (ULONG ErrorLevel)
VOID | CmGetSystemControlValues (PVOID SystemHiveBuffer, PCM_SYSTEM_CONTROL_VECTOR ControlVector)
VOID | CmQueryRegistryQuotaInformation (IN PSYSTEM_REGISTRY_QUOTA_INFORMATION RegistryQuotaInformation)
VOID | CmSetRegistryQuotaInformation (IN PSYSTEM_REGISTRY_QUOTA_INFORMATION RegistryQuotaInformation)
NTSTATUS | CmSetTraceNotifyRoutine (IN PCM_TRACE_NOTIFY_ROUTINE NotifyRoutine, IN BOOLEAN Remove)

## Variables

UNICODE_STRING | CmRegistryRootName
UNICODE_STRING | CmRegistryMachineName
UNICODE_STRING | CmRegistryMachineHardwareName
UNICODE_STRING | CmRegistryMachineHardwareDescriptionName
UNICODE_STRING | CmRegistryMachineHardwareDescriptionSystemName
UNICODE_STRING | CmRegistryMachineHardwareDeviceMapName
UNICODE_STRING | CmRegistryMachineHardwareResourceMapName
UNICODE_STRING | CmRegistryMachineHardwareOwnerMapName
UNICODE_STRING | CmRegistryMachineSystemName
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSet
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetEnumName
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetEnumRootName
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetServices
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetHardwareProfilesCurrent
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetControlClass
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetControlSafeBoot
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetControlSessionManagerMemoryManagement
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetControlBootLog
UNICODE_STRING | CmRegistryMachineSystemCurrentControlSetServicesEventLog
UNICODE_STRING | CmRegistryUserName
UNICODE_STRING | CmTypeName []
PWSTR | CmTypeString []
UNICODE_STRING | CmClassName []
PWSTR | CmClassString []

## Typedef Documentation

typedef struct _BOOT_DRIVER_LIST_ENTRY BOOT_DRIVER_LIST_ENTRY

typedef struct _CM_SYSTEM_CONTROL_VECTOR CM_SYSTEM_CONTROL_VECTOR

typedef struct _BOOT_DRIVER_LIST_ENTRY * PBOOT_DRIVER_LIST_ENTRY

typedef struct _CM_SYSTEM_CONTROL_VECTOR * PCM_SYSTEM_CONTROL_VECTOR

typedef VOID(* PCM_TRACE_NOTIFY_ROUTINE)(IN NTSTATUS Status, IN HANDLE KeyHandle, IN LONGLONG ElapsedTime, IN PUNICODE_STRING KeyName, IN UCHAR Type)

| Definition at line 197 of file cm.h.

## Function Documentation

VOID CmBootLastKnownGood | ( | ULONG | ErrorLevel | ) |

Definition at line 3778 of file cmsysini.c.

References ARC_STATUS, CmFirstTime, CmpIsLastKnownGoodBoot(), ESUCCESS, HalRebootRoutine, HalReturnToFirmware(), HalSetEnvironmentVariable(), KeBugCheckEx(), PAGED_CODE, Status, and TRUE.

Referenced by IopLoadDriver().

    03784                    :
    03785
    03786     This function is called to indicate a failure during the boot process.
    03787     The actual result is based on the value of ErrorLevel:
    03788
    03789         IGNORE - Will return, boot should proceed
    03790         NORMAL - Will return, boot should proceed
    03791
    03792         SEVERE - If not booting LastKnownGood, will switch to LastKnownGood
    03793                  and reboot the system.
    03794
    03795                  If already booting LastKnownGood, will return.  Boot should
    03796                  proceed.
    03797
    03798         CRITICAL - If not booting LastKnownGood, will switch to LastKnownGood
    03799                  and reboot the system.
    03800
    03801                  If already booting LastKnownGood, will bugcheck.
    03802
    03803 Arguments:
    03804
    03805     ErrorLevel - Supplies the severity level of the failure
    03806
    03807 Return Value:
    03808
    03809     None.  If it returns, boot should proceed.  May cause the system to
    03810     reboot.
    03811
    03812 --*/
    03813
    03814 {
    03815     ARC_STATUS Status;
    03816
    03817     PAGED_CODE();
    03818
    03819     if (CmFirstTime != TRUE) {
    03820
    03821         //
    03822         // NtInitializeRegistry has been called, so handling
    03823         // driver errors is not a task for ScReg.
    03824         // Treat all errors as Normal
    03825         //
    03826         return;
    03827     }
    03828
    03829     switch (ErrorLevel) {
    03830         case NormalError:
    03831         case IgnoreError:
    03832             break;
    03833
    03834         case SevereError:
    03835             if (CmpIsLastKnownGoodBoot()) {
    03836                 break;
    03837             } else {
    03838                 Status = HalSetEnvironmentVariable("LastKnownGood", "TRUE");
    03839                 if (Status == ESUCCESS) {
    03840                     HalReturnToFirmware(HalRebootRoutine);
    03841                 }
    03842             }
    03843             break;
    03844
    03845         case CriticalError:
    03846             if (CmpIsLastKnownGoodBoot()) {
    03847                 KeBugCheckEx(CRITICAL_SERVICE_FAILED,5,9,0,0);
    03848             } else {
    03849                 Status = HalSetEnvironmentVariable("LastKnownGood", "TRUE");
    03850                 if (Status == ESUCCESS) {
    03851                     HalReturnToFirmware(HalRebootRoutine);
    03852                 } else {
    03853                     KeBugCheckEx(SET_ENV_VAR_FAILED,5,10,0,0);
    03854                 }
    03855             }
    03856             break;
    03857     }
    03858     return;
    03859 }

VOID CmGetSystemControlValues | ( | PVOID | SystemHiveBuffer,
|  | PCM_SYSTEM_CONTROL_VECTOR | ControlVector
| ) |

Definition at line 50 of file cmcontrl.c.

References ASSERT, _CM_SYSTEM_CONTROL_VECTOR::Buffer, _CM_SYSTEM_CONTROL_VECTOR::BufferLength, CM_KEY_VALUE_SMALL, CmDefaultLanguageId, CmDefaultLanguageIdLength, CmDefaultLanguageIdType, CmInstallUILanguageId, CmInstallUILanguageIdLength, CmInstallUILanguageIdType, CmpConvertLangId(), CmpFindControlSet(), CmpFindSubKeyByName(), CmpFindValueByName, CmpIsHKeyValueSmall, CmpWalkPath(), _CM_KEY_VALUE::Data, _CM_KEY_VALUE::DataLength, HCELL_INDEX, HCELL_NIL, HFILE_TYPE_PRIMARY, HINIT_FLAT, HIVE_VOLATILE, HvGetCell, HvInitializeHive(), Index, KeBugCheckEx(), _CM_SYSTEM_CONTROL_VECTOR::KeyPath, L, Name, NT_SUCCESS, NTSTATUS(), NULL, PHBASE_BLOCK, PHCELL_INDEX, PsDefaultSystemLocaleId, PsDefaultThreadLocaleId, PsDefaultUILanguageId, PsInstallUILanguageId, RtlInitUnicodeString(), TRUE, _CM_KEY_VALUE::Type, _CM_SYSTEM_CONTROL_VECTOR::Type, and _CM_SYSTEM_CONTROL_VECTOR::ValueName.

    00056                    :
    00057
    00058     Look for registry values in current control set, as specified
    00059     by entries in ControlVector.  Report data for value entries
    00060     (if any) to variables ControlVector points to.
    00061
    00062 Arguments:
    00063
    00064     SystemHiveBuffer - pointer to flat image of the system hive
    00065
    00066     ControlVector - pointer to structure that describes what values
    00067                     to suck out and store
    00068
    00069 Return Value:
    00070
    00071     NONE.
    00072
    00073 --*/
    00074 {
    00075     NTSTATUS        status;
    00076     PHHIVE          SystemHive;
    00077     CMHIVE          TempHive;
    00078     HCELL_INDEX     RootCell;
    00079     HCELL_INDEX     BaseCell;
    00080     UNICODE_STRING  Name;
    00081     PHCELL_INDEX    Index;
    00082     HCELL_INDEX     KeyCell;
    00083     HCELL_INDEX     ValueCell;
    00084     PCM_KEY_VALUE   ValueBody;
    00085     PVOID           ValueData;
    00086     ULONG           Length;
    00087     BOOLEAN         AutoSelect;
    00088     BOOLEAN         small;
    00089     ULONG           tmplength;
    00090
    00091
    00092     //
    00093     // set up to read flat system hive image loader passes us
    00094     //
    00095     RtlZeroMemory((PVOID)&TempHive, sizeof(TempHive));
    00096     SystemHive = &(TempHive.Hive);
    00097     status = HvInitializeHive(
    00098                 SystemHive,
    00099                 HINIT_FLAT,
    00100                 HIVE_VOLATILE,
    00101                 HFILE_TYPE_PRIMARY,
    00102                 SystemHiveBuffer,
    00103                 NULL,
    00104                 NULL,
    00105                 NULL,
    00106                 NULL,
    00107                 NULL,
    00108                 NULL,
    00109                 1,
    00110                 NULL
    00111                 );
    00112     if (!NT_SUCCESS(status)) {
    00113         KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1,1,0,0);
    00114     }
    00115
    00116     //
    00117     // get hive.cell of root of current control set
    00118     //
    00119     RootCell = ((PHBASE_BLOCK)SystemHiveBuffer)->RootCell;
    00120     RtlInitUnicodeString(&Name, L"current");
    00121     BaseCell = CmpFindControlSet(
    00122                     SystemHive,
    00123                     RootCell,
    00124                     &Name,
    00125                     &AutoSelect
    00126                     );
    00127     if (BaseCell == HCELL_NIL) {
    00128         KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1,2,0,0);
    00129     }
    00130
    00131     RtlInitUnicodeString(&Name, L"control");
    00132     BaseCell = CmpFindSubKeyByName(SystemHive,
    00133                                    (PCM_KEY_NODE)HvGetCell(SystemHive,BaseCell),
    00134                                    &Name);
    00135     if (BaseCell == HCELL_NIL) {
    00136         KeBugCheckEx(BAD_SYSTEM_CONFIG_INFO,1,3,0,0);
    00137     }
    00138
    00139     //
    00140     // SystemHive.BaseCell = \registry\machine\system\currentcontrolset\control
    00141     //
    00142
    00143     //
    00144     // step through vector, trying to fetch each value
    00145     //
    00146     while (ControlVector->KeyPath != NULL) {
    00147
    00148         //
    00149         //  Assume we will fail to find the key or value.
    00150         //
    00151
    00152         Length = (ULONG)-1;
    00153
    00154         KeyCell = CmpWalkPath(SystemHive, BaseCell, ControlVector->KeyPath);
    00155
    00156         if (KeyCell != HCELL_NIL) {
    00157
    00158             //
    00159             // found the key, look for the value entry
    00160             //
    00161             RtlInitUnicodeString(&Name, ControlVector->ValueName);
    00162             ValueCell = CmpFindValueByName(SystemHive,
    00163                                            (PCM_KEY_NODE)HvGetCell(SystemHive,KeyCell),
    00164                                            &Name);
    00165             if (ValueCell != HCELL_NIL) {
    00166
    00167                 //
    00168                 // SystemHive.ValueCell is value entry body
    00169                 //
    00170
    00171                 if (ControlVector->BufferLength == NULL) {
    00172                     tmplength = sizeof(ULONG);
    00173                 } else {
    00174                     tmplength = *(ControlVector->BufferLength);
    00175                 }
    00176
    00177                 ValueBody = (PCM_KEY_VALUE)HvGetCell(SystemHive, ValueCell);
    00178
    00179                 small = CmpIsHKeyValueSmall(Length, ValueBody->DataLength);
    00180
    00181                 if (tmplength < Length) {
    00182                     Length = tmplength;
    00183                 }
    00184
    00185                 if (Length > 0) {
    00186
    00187                     if (small == TRUE) {
    00188                         ValueData = (PVOID)(&(ValueBody->Data));
    00189                     } else {
    00190                         ValueData = (PVOID)HvGetCell(SystemHive, ValueBody->Data);
    00191                     }
    00192
    00193                     ASSERT((small ? (Length <= CM_KEY_VALUE_SMALL) : TRUE));
    00194
    00195                     RtlMoveMemory(
    00196                         ControlVector->Buffer,
    00197                         ValueData,
    00198                         Length
    00199                         );
    00200                 }
    00201
    00202                 if (ControlVector->Type != NULL) {
    00203                     *(ControlVector->Type) = ValueBody->Type;
    00204                 }
    00205             }
    00206         }
    00207
    00208         //
    00209         // Stash the length of result (-1 if nothing was found)
    00210         //
    00211
    00212         if (ControlVector->BufferLength != NULL) {
    00213             *(ControlVector->BufferLength) = Length;
    00214         }
    00215
    00216         ControlVector++;
    00217     }
    00218
    00219     //
    00220     // Get the default locale ID for the system from the registry.
    00221     //
    00222
    00223     if (CmDefaultLanguageIdType == REG_SZ) {
    00224         PsDefaultSystemLocaleId = (LCID) CmpConvertLangId(
    00225                                                 CmDefaultLanguageId,
    00226                                                 CmDefaultLanguageIdLength);
    00227     } else {
    00228         PsDefaultSystemLocaleId = 0x00000409;
    00229     }
    00230
    00231     //
    00232     // Get the install (native UI) language ID for the system from the registry.
    00233     //
    00234
    00235     if (CmInstallUILanguageIdType == REG_SZ) {
    00236         PsInstallUILanguageId =  CmpConvertLangId(
    00237                                                 CmInstallUILanguageId,
    00238                                                 CmInstallUILanguageIdLength);
    00239     } else {
    00240         PsInstallUILanguageId = LANGIDFROMLCID(PsDefaultSystemLocaleId);
    00241     }
    00242
    00243     //
    00244     // Set the default thread locale to the default system locale
    00245     // for now.  This will get changed as soon as somebody logs in.
    00246     // Use the install (native) language id as our default UI language id.
    00247     // This also will get changed as soon as somebody logs in.
    00248     //
    00249
    00250     PsDefaultThreadLocaleId = PsDefaultSystemLocaleId;
    00251     PsDefaultUILanguageId = PsInstallUILanguageId;
    00252 }

PHANDLE CmGetSystemDriverList | ( | VOID |  | ) |

Definition at line 2169 of file cmsysini.c.

References CML_BUGCHECK, CMLOG, CmpFindControlSet(), CmpFindDrivers(), CmpFreeDriverList(), CmpKeyObjectType, CmpLockRegistryExclusive(), CmpResolveDriverDependencies(), CmpSortDriverList(), CmpUnlockRegistry(), CMS_INIT_ERROR, DriverEntry(), ExAllocatePool, Handle, HCELL_INDEX, HCELL_NIL, Hive, KeBugCheckEx(), KernelMode, L, Name, NonPagedPool, NT_SUCCESS, NtClose(), NtOpenKey(), NTSTATUS(), NULL, ObDereferenceObject, ObjectAttributes, ObReferenceObjectByHandle(), PAGED_CODE, RtlInitUnicodeString(), and Status.

Referenced by IopInitializeSystemDrivers().

    02175                    :
    02176
    02177     Traverses the current SERVICES subtree and creates the list of drivers
    02178     to be loaded during Phase 1 initialization.
    02179
    02180 Arguments:
    02181
    02182     None
    02183
    02184 Return Value:
    02185
    02186     A pointer to an array of handles, each of which refers to a key in
    02187     the \Services section of the control set.  The caller will traverse
    02188     this array and load and initialize the drivers described by the keys.
    02189
    02190     The last key will be NULL.  The array is allocated in Pool and should
    02191     be freed by the caller.
    02192
    02193 --*/
    02194
    02195 {
    02196     OBJECT_ATTRIBUTES ObjectAttributes;
    02197     HANDLE SystemHandle;
    02198     UNICODE_STRING Name;
    02199     NTSTATUS Status;
    02200     PCM_KEY_BODY KeyBody;
    02201     LIST_ENTRY DriverList;
    02202     PHHIVE Hive;
    02203     HCELL_INDEX RootCell;
    02204     HCELL_INDEX ControlCell;
    02205     ULONG DriverCount;
    02206     PLIST_ENTRY Current;
    02207     PHANDLE Handle;
    02208     PBOOT_DRIVER_LIST_ENTRY DriverEntry;
    02209     BOOLEAN Success;
    02210     BOOLEAN AutoSelect;
    02211
    02212     PAGED_CODE();
    02213     InitializeListHead(&DriverList);
    02214     RtlInitUnicodeString(&Name,
    02215                          L"\\Registry\\Machine\\System");
    02216
    02217     InitializeObjectAttributes(&ObjectAttributes,
    02218                                &Name,
    02219                                OBJ_CASE_INSENSITIVE,
    02220                                (HANDLE)NULL,
    02221                                NULL);
    02222     Status = NtOpenKey(&SystemHandle,
    02223                        KEY_READ,
    02224                        &ObjectAttributes);
    02225
    02226     if (!NT_SUCCESS(Status)) {
    02227         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02228             KdPrint(("CM: CmGetSystemDriverList couldn't open registry key %wZ\n",&Name));
    02229             KdPrint(("CM:     status %08lx\n", Status));
    02230         }
    02231         return(NULL);
    02232     }
    02233
    02234
    02235     Status = ObReferenceObjectByHandle( SystemHandle,
    02236                                         KEY_QUERY_VALUE,
    02237                                         CmpKeyObjectType,
    02238                                         KernelMode,
    02239                                         (PVOID *)(&KeyBody),
    02240                                         NULL );
    02241     if (!NT_SUCCESS(Status)) {
    02242         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02243             KdPrint(("CM: CmGetSystemDriverList couldn't dereference Systemhandle\n"));
    02244             KdPrint(("CM:     status %08lx\n", Status));
    02245         }
    02246         NtClose(SystemHandle);
    02247         return(NULL);
    02248     }
    02249
    02250     CmpLockRegistryExclusive();
    02251
    02252     Hive = KeyBody->KeyControlBlock->KeyHive;
    02253     RootCell = KeyBody->KeyControlBlock->KeyCell;
    02254
    02255     //
    02256     // Now we have found out the PHHIVE and HCELL_INDEX of the root of the
    02257     // SYSTEM hive, we can use all the same code that the OS Loader does.
    02258     //
    02259
    02260     RtlInitUnicodeString(&Name, L"Current");
    02261     ControlCell = CmpFindControlSet(Hive,
    02262                                     RootCell,
    02263                                     &Name,
    02264                                     &AutoSelect);
    02265     if (ControlCell == HCELL_NIL) {
    02266         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02267             KdPrint(("CM: CmGetSystemDriverList couldn't find control set\n"));
    02268         }
    02269         CmpUnlockRegistry();
    02270         ObDereferenceObject((PVOID)KeyBody);
    02271         NtClose(SystemHandle);
    02272         return(NULL);
    02273     }
    02274
    02275     Success = CmpFindDrivers(Hive,
    02276                              ControlCell,
    02277                              SystemLoad,
    02278                              NULL,
    02279                              &DriverList);
    02280
    02281
    02282     if (!Success) {
    02283         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02284             KdPrint(("CM: CmGetSystemDriverList couldn't find any valid drivers\n"));
    02285         }
    02286         CmpFreeDriverList(Hive, &DriverList);
    02287         CmpUnlockRegistry();
    02288         ObDereferenceObject((PVOID)KeyBody);
    02289         NtClose(SystemHandle);
    02290         return(NULL);
    02291     }
    02292
    02293     if (!CmpSortDriverList(Hive,
    02294                            ControlCell,
    02295                            &DriverList)) {
    02296         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02297             KdPrint(("CM: CmGetSystemDriverList couldn't sort driver list\n"));
    02298         }
    02299         CmpFreeDriverList(Hive, &DriverList);
    02300         CmpUnlockRegistry();
    02301         ObDereferenceObject((PVOID)KeyBody);
    02302         NtClose(SystemHandle);
    02303         return(NULL);
    02304     }
    02305
    02306     if (!CmpResolveDriverDependencies(&DriverList)) {
    02307         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02308             KdPrint(("CM: CmGetSystemDriverList couldn't resolve driver dependencies\n"));
    02309         }
    02310         CmpFreeDriverList(Hive, &DriverList);
    02311         CmpUnlockRegistry();
    02312         ObDereferenceObject((PVOID)KeyBody);
    02313         NtClose(SystemHandle);
    02314         return(NULL);
    02315     }
    02316     CmpUnlockRegistry();
    02317     ObDereferenceObject((PVOID)KeyBody);
    02318     NtClose(SystemHandle);
    02319
    02320     //
    02321     // We now have a fully sorted and ordered list of drivers to be loaded
    02322     // by IoInit.
    02323     //
    02324
    02325     //
    02326     // Count the nodes in the list.
    02327     //
    02328     Current = DriverList.Flink;
    02329     DriverCount = 0;
    02330     while (Current != &DriverList) {
    02331         ++DriverCount;
    02332         Current = Current->Flink;
    02333     }
    02334
    02335     Handle = (PHANDLE)ExAllocatePool(NonPagedPool,
    02336                                      (DriverCount+1) * sizeof(HANDLE));
    02337
    02338     if (Handle == NULL) {
    02339         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,5,8,0,0); // odds against this are huge
    02340     }
    02341
    02342     //
    02343     // Walk the list, opening each registry key and adding it to the
    02344     // table of handles.
    02345     //
    02346     Current = DriverList.Flink;
    02347     DriverCount = 0;
    02348     while (Current != &DriverList) {
    02349         DriverEntry = CONTAINING_RECORD(Current,
    02350                                         BOOT_DRIVER_LIST_ENTRY,
    02351                                         Link);
    02352
    02353         InitializeObjectAttributes(&ObjectAttributes,
    02354                                    &DriverEntry->RegistryPath,
    02355                                    OBJ_CASE_INSENSITIVE,
    02356                                    (HANDLE)NULL,
    02357                                    NULL);
    02358
    02359         Status = NtOpenKey(Handle+DriverCount,
    02360                            KEY_READ | KEY_WRITE,
    02361                            &ObjectAttributes);
    02362         if (!NT_SUCCESS(Status)) {
    02363             CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    02364                 KdPrint(("CM: CmGetSystemDriverList couldn't open driver "));
    02365                 KdPrint(("key %wZ\n", &DriverEntry->RegistryPath));
    02366                 KdPrint(("    status %08lx\n",Status));
    02367             }
    02368         } else {
    02369             ++DriverCount;
    02370         }
    02371         Current = Current->Flink;
    02372     }
    02373     Handle[DriverCount] = NULL;
    02374
    02375     return(Handle);
    02376 }

BOOLEAN CmInitSystem1 | ( | IN PLOADER_PARAMETER_BLOCK | LoaderBlock | ) |

Definition at line 293 of file cmsysini.c.

References ASSERT, CLONE_HIVE_INDEX, _HIVE_LIST_ENTRY::CmHive, CML_BUGCHECK, CML_MAJOR, CMLOG, CmpAddToHiveFileList(), CmpCloneControlSet(), CmpComputeGlobalQuotaAllowed(), CmpCreateControlSet(), CmpCreateObjectTypes(), CmpCreateRegistryRoot(), CmpHiveListHead, CmpHiveRootSecurityDescriptor(), CmpInitializeCache(), CmpInitializeHardwareConfiguration(), CmpInitializeHive(), CmpInitializeMachineDependentConfiguration(), CmpInitializeRegistryNames(), CmpInitializeSystemHive(), CmpKcbLock, CmpLinkHiveToMaster(), CmpLinkKeyToHive(), CmpLoadOptions, CmpLockRegistryExclusive(), CmpMachineHiveList, CmpMasterHive, CmpNoMasterCreates, CmpPostLock, CmpRegistryLock, CmpStashBuffer, CmpStashBufferSize, CmpSystemProcess, CmpUnlockRegistry(), CmRegistryMachineHardwareName, CmRegistryMachineName, CmRegistrySystemCloneName, CmRegistryUserName, CMS_INIT, CMS_INIT_ERROR, ExAllocatePoolWithTag, ExFreePool(), ExInitializeFastMutex, ExInitializeResource, FALSE, HBLOCK_SIZE, HFILE_TYPE_PRIMARY, HINIT_CREATE, HIVE_VOLATILE, KeBugCheckEx(), L, NT_SUCCESS, NtClose(), NtCreateKey(), NtOpenKey(), NtSetValueKey(), NTSTATUS(), NULL, nullclass, ObjectAttributes, PAGED_CODE, PagedPool, PsGetCurrentProcess, RtlInitUnicodeString(), and TRUE.

    00298                    :
    00299
    00300     This function is called as part of phase1 init, after the object
    00301     manager has been inited, but before IoInit.  It's purpose is to
    00302     set up basic registry object operations, and transform data
    00303     captured during boot into registry format (whether it was read
    00304     from the SYSTEM hive file by the osloader or computed by recognizers.)
    00305     After this call, Nt*Key calls work, but only part of the name
    00306     space is available and any changes written must be held in
    00307     memory.
    00308
    00309     CmpMachineHiveList entries marked CM_PHASE_1 are available
    00310     after return from this call, but writes must be held in memory.
    00311
    00312     This function will:
    00313
    00314         1.  Create the regisrty worker/lazy-write thread
    00315         2.  Create the registry key object type
    00316         4.  Create the master hive
    00317         5.  Create the \REGISTRY node
    00318         6.  Create a KEY object that refers to \REGISTRY
    00319         7.  Create \REGISTRY\MACHINE node
    00320         8.  Create the SYSTEM hive, fill in with data from loader
    00321         9.  Create the HARDWARE hive, fill in with data from loader
    00322        10.  Create:
    00323                 \REGISTRY\MACHINE\SYSTEM
    00324                 \REGISTRY\MACHINE\HARDWARE
    00325                 Both of which will be link nodes in the master hive.
    00326
    00327     NOTE:   We do NOT free allocated pool in failure case.  This is because
    00328             our caller is going to bugcheck anyway, and having the memory
    00329             object to look at is useful.
    00330
    00331 Arguments:
    00332
    00333     LoaderBlock - supplies the LoaderBlock passed in from the OSLoader.
    00334         By looking through the memory descriptor list we can find the
    00335         SYSTEM hive which the OSLoader has placed in memory for us.
    00336
    00337 Return Value:
    00338
    00339     TRUE if all operations were successful, false if any failed.
    00340
    00341     Bugchecks when something went wrong (CONFIG_INITIALIZATION_FAILED,4,.....)
    00342
    00343 --*/
    00344 {
    00345     HANDLE  key1;
    00346     OBJECT_ATTRIBUTES ObjectAttributes;
    00347     NTSTATUS    status;
    00348     NTSTATUS    status2;
    00349     PSECURITY_DESCRIPTOR SecurityDescriptor;
    00350     PCMHIVE HardwareHive;
    00351     PCMHIVE CloneHive;
    00352     UNICODE_STRING NameString;
    00353
    00354     PAGED_CODE();
    00355     CMLOG(CML_MAJOR, CMS_INIT) KdPrint(("CmInitSystem1\n"));
    00356
    00357     //
    00358     // Initialize Names of all registry paths.
    00359     // This simply initializes unicode strings so we don't have to bother
    00360     // with it later. This can not fail.
    00361     //
    00362     CmpInitializeRegistryNames();
    00363
    00364     //
    00365     // Compute registry global quota
    00366     //
    00367     CmpComputeGlobalQuotaAllowed();
    00368
    00369     //
    00370     // Initialize the hive list head
    00371     //
    00372     InitializeListHead(&CmpHiveListHead);
    00373
    00374     //
    00375     // Initialize the global registry resource
    00376     //
    00377     ExInitializeResource(&CmpRegistryLock);
    00378
    00379     //
    00380     // Initialize the KCB tree mutex
    00381     //
    00382     ExInitializeFastMutex(&CmpKcbLock);
    00383
    00384     //
    00385     // Initialize the PostList mutex
    00386     //
    00387     ExInitializeFastMutex(&CmpPostLock);
    00388
    00389     //
    00390     // Initialize the cache
    00391     //
    00392     CmpInitializeCache ();
    00393
    00394     //
    00395     // Save the current process to allow us to attach to it later.
    00396     //
    00397     CmpSystemProcess = &PsGetCurrentProcess()->Pcb;
    00398
    00399     CmpLockRegistryExclusive();
    00400
    00401     //
    00402     // Create the Key object type.
    00403     //
    00404     if (!CmpCreateObjectTypes()) {
    00405         CMLOG(CML_MAJOR, CMS_INIT_ERROR) {
    00406             KdPrint(("CmInitSystem1: CmpCreateObjectTypes failed\n"));
    00407         }
    00408         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,1,0,0); // could not registrate with object manager
    00409         return FALSE;
    00410     }
    00411
    00412
    00413     //
    00414     // Create the master hive and initialize it.
    00415     //
    00416     status = CmpInitializeHive(&CmpMasterHive,
    00417                 HINIT_CREATE,
    00418                 HIVE_VOLATILE,
    00419                 HFILE_TYPE_PRIMARY,     // i.e. no logging, no alterate
    00420                 NULL,
    00421                 NULL,
    00422                 NULL,
    00423                 NULL,
    00424                 NULL,
    00425                 NULL);
    00426     if (!NT_SUCCESS(status)) {
    00427         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    00428             KdPrint(("CmInitSystem1: CmpInitializeHive(master) failed\n"));
    00429         }
    00430         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,2,0,0); // could not initialize master hive
    00431         return (FALSE);
    00432     }
    00433
    00434     //
    00435     // try to allocate a stash buffer.  if we can't get 1 page this
    00436     // early on, we're in deep trouble, so punt.
    00437     //
    00438     CmpStashBuffer = ExAllocatePoolWithTag(PagedPool, HBLOCK_SIZE,'bSmC');
    00439     if (CmpStashBuffer == NULL) {
    00440         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,3,0,0); // odds against this are huge
    00441         return FALSE;
    00442     }
    00443     CmpStashBufferSize = HBLOCK_SIZE;
    00444
    00445     //
    00446     // Create the \REGISTRY node
    00447     //
    00448     if (!CmpCreateRegistryRoot()) {
    00449         CMLOG(CML_MAJOR, CMS_INIT_ERROR) {
    00450             KdPrint(("CmInitSystem1: CmpCreateRegistryRoot failed\n"));
    00451         }
    00452         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,4,0,0); // could not create root of the registry
    00453         return FALSE;
    00454     }
    00455
    00456     //
    00457     // --- 6. Create \REGISTRY\MACHINE and \REGISTRY\USER nodes ---
    00458     //
    00459
    00460     //
    00461     // Get default security descriptor for the nodes we will create.
    00462     //
    00463     SecurityDescriptor = CmpHiveRootSecurityDescriptor();
    00464
    00465     InitializeObjectAttributes(
    00466         &ObjectAttributes,
    00467         &CmRegistryMachineName,
    00468         OBJ_CASE_INSENSITIVE,
    00469         (HANDLE)NULL,
    00470         SecurityDescriptor
    00471         );
    00472
    00473     if (!NT_SUCCESS(NtCreateKey(
    00474                         &key1,
    00475                         KEY_READ | KEY_WRITE,
    00476                         &ObjectAttributes,
    00477                         0,
    00478                         &nullclass,
    00479                         0,
    00480                         NULL
    00481         )))
    00482     {
    00483         ExFreePool(SecurityDescriptor);
    00484         CMLOG(CML_MAJOR, CMS_INIT_ERROR) {
    00485             KdPrint(("CmInitSystem1: NtCreateKey(MACHINE) failed\n"));
    00486         }
    00487         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,5,0,0); // could not create HKLM
    00488         return FALSE;
    00489     }
    00490
    00491     NtClose(key1);
    00492
    00493     InitializeObjectAttributes(
    00494         &ObjectAttributes,
    00495         &CmRegistryUserName,
    00496         OBJ_CASE_INSENSITIVE,
    00497         (HANDLE)NULL,
    00498         SecurityDescriptor
    00499         );
    00500
    00501     if (!NT_SUCCESS(NtCreateKey(
    00502                         &key1,
    00503                         KEY_READ | KEY_WRITE,
    00504                         &ObjectAttributes,
    00505                         0,
    00506                         &nullclass,
    00507                         0,
    00508                         NULL
    00509         )))
    00510     {
    00511         ExFreePool(SecurityDescriptor);
    00512         CMLOG(CML_MAJOR, CMS_INIT_ERROR) {
    00513             KdPrint(("CmInitSystem1: NtCreateKey(USER) failed\n"));
    00514         }
    00515         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,6,0,0); // could not create HKUSER
    00516         return FALSE;
    00517     }
    00518
    00519     NtClose(key1);
    00520
    00521
    00522     //
    00523     // --- 7. Create the SYSTEM hive, fill in with data from loader ---
    00524     //
    00525     if (!CmpInitializeSystemHive(LoaderBlock)) {
    00526         ExFreePool(SecurityDescriptor);
    00527         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    00528             KdPrint(("CmpInitSystem1: "));
    00529             KdPrint(("Hive allocation failure for SYSTEM\n"));
    00530         }
    00531         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,7,0,0); // could not create SystemHive
    00532         return(FALSE);
    00533     }
    00534
    00535     //
    00536     // Create the symbolic link \Registry\Machine\System\CurrentControlSet
    00537     //
    00538     status = CmpCreateControlSet(LoaderBlock);
    00539     if (!NT_SUCCESS(status)) {
    00540         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,8,0,0); // could not create CurrentControlSet
    00541         return(FALSE);
    00542     }
    00543
    00544     //
    00545     // Handle the copying of the CurrentControlSet to a Clone volatile
    00546     // hive (but only if we really want to have a clone)
    00547     //
    00548
    00549 #if CLONE_CONTROL_SET
    00550
    00551     //
    00552     // Create the Clone temporary hive, link it into the master hive,
    00553     // and make a symbolic link to it.
    00554     //
    00555     status = CmpInitializeHive(&CloneHive,
    00556                 HINIT_CREATE,
    00557                 HIVE_VOLATILE,
    00558                 HFILE_TYPE_PRIMARY,
    00559                 NULL,
    00560                 NULL,
    00561                 NULL,
    00562                 NULL,
    00563                 NULL,
    00564                 NULL);
    00565     if (!NT_SUCCESS(status)) {
    00566         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    00567             KdPrint(("CmpInitSystem1: "));
    00568             KdPrint(("Could not initialize CLONE hive\n"));
    00569         }
    00570         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,9,0,0); // could not initialize clone hive
    00571         return(FALSE);
    00572     }
    00573
    00574     if (CmpLinkHiveToMaster(
    00575             &CmRegistrySystemCloneName,
    00576             NULL,
    00577             CloneHive,
    00578             TRUE,
    00579             SecurityDescriptor
    00580             ) != STATUS_SUCCESS)
    00581     {
    00582         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    00583             KdPrint(("CmInitSystem1: CmpLinkHiveToMaster(Clone) failed\n"));
    00584         }
    00585         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,10,0,0); // could not link clone hive to master hive
    00586         return FALSE;
    00587     }
    00588     CmpAddToHiveFileList(CloneHive);
    00589     CmpMachineHiveList[CLONE_HIVE_INDEX].CmHive = CloneHive;
    00590
    00591     CmpLinkKeyToHive(
    00592         L"\\Registry\\Machine\\System\\Clone",
    00593         L"\\Registry\\Machine\\CLONE\\CLONE"
    00594         );
    00595
    00596
    00597     //
    00598     // Clone the current control set for the service controller
    00599     //
    00600     status = CmpCloneControlSet();
    00601
    00602     //
    00603     // If this didn't work, it's bad, but not bad enough to fail the boot
    00604     //
    00605     ASSERT(NT_SUCCESS(status));
    00606
    00607 #endif
    00608
    00609     //
    00610     // --- 8. Create the HARDWARE hive, fill in with data from loader ---
    00611     //
    00612     status = CmpInitializeHive(&HardwareHive,
    00613                 HINIT_CREATE,
    00614                 HIVE_VOLATILE,
    00615                 HFILE_TYPE_PRIMARY,     // i.e. no log, no alternate
    00616                 NULL,
    00617                 NULL,
    00618                 NULL,
    00619                 NULL,
    00620                 NULL,
    00621                 NULL);
    00622     if (!NT_SUCCESS(status)) {
    00623         ExFreePool(SecurityDescriptor);
    00624         CMLOG(CML_BUGCHECK, CMS_INIT_ERROR) {
    00625             KdPrint(("CmpInitSystem1: "));
    00626             KdPrint(("Could not initialize HARDWARE hive\n"));
    00627         }
    00628         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,11,0,0); // could not initialize hardware hive
    00629         return(FALSE);
    00630     }
    00631
    00632     //
    00633     // Allocate the root node
    00634     //
    00635     if (CmpLinkHiveToMaster(
    00636             &CmRegistryMachineHardwareName,
    00637             NULL,
    00638             HardwareHive,
    00639             TRUE,
    00640             SecurityDescriptor
    00641             ) != STATUS_SUCCESS)
    00642     {
    00643         CMLOG(CML_MAJOR, CMS_INIT_ERROR) {
    00644             KdPrint(("CmInitSystem1: CmpLinkHiveToMaster(Hardware) failed\n"));
    00645         }
    00646         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,12,0,0); // could not link hardware hive to master hive
    00647         return FALSE;
    00648     }
    00649     CmpAddToHiveFileList(HardwareHive);
    00650
    00651     ExFreePool(SecurityDescriptor);
    00652
    00653     CmpMachineHiveList[0].CmHive = HardwareHive;
    00654
    00655     //
    00656     // put loader configuration tree data to our hardware registry.
    00657     //
    00658     status = CmpInitializeHardwareConfiguration(LoaderBlock);
    00659
    00660     if (!NT_SUCCESS(status)) {
    00661         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,13,0,0); // could not initialize hardware configuration
    00662         return(FALSE);
    00663     }
    00664
    00665     CmpNoMasterCreates = TRUE;
    00666     CmpUnlockRegistry();
    00667
    00668     //
    00669     // put machine dependant configuration data to our hardware registry.
    00670     //
    00671     status = CmpInitializeMachineDependentConfiguration(LoaderBlock);
    00672
    00673
    00674     //
    00675     // store boot loader command tail in registry
    00676     //
    00677     RtlInitUnicodeString(
    00678         &NameString,
    00679         L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Control"
    00680         );
    00681
    00682     InitializeObjectAttributes(
    00683         &ObjectAttributes,
    00684         &NameString,
    00685         OBJ_CASE_INSENSITIVE,
    00686         (HANDLE)NULL,
    00687         NULL
    00688         );
    00689
    00690     status2 = NtOpenKey(
    00691                 &key1,
    00692                 KEY_WRITE,
    00693                 &ObjectAttributes
    00694                 );
    00695
    00696     if (NT_SUCCESS(status2)) {
    00697         RtlInitUnicodeString(
    00698             &NameString,
    00699             L"SystemStartOptions"
    00700             );
    00701
    00702         NtSetValueKey(
    00703             key1,
    00704             &NameString,
    00705             0,              // TitleIndex
    00706             REG_SZ,
    00707             CmpLoadOptions.Buffer,
    00708             CmpLoadOptions.Length
    00709             );
    00710
    00711         NtClose(key1);
    00712     }
    00713     ExFreePool(CmpLoadOptions.Buffer);
    00714
    00715
    00716     if (!NT_SUCCESS(status)) {
    00717         KeBugCheckEx(CONFIG_INITIALIZATION_FAILED,4,14,0,0); // could not open CurrentControlSet\\Control
    00718         return(FALSE);
    00719     }
    00720
    00721     return TRUE;
    00722 }

BOOLEAN CmInitSystem2 | ( |  | ) |

VOID CmNotifyRunDown | ( | PETHREAD | Thread | ) |

Definition at line 1028 of file cmnotify.c.

References _CM_ASYNC_USER_POST_BLOCK::Apc, APC_LEVEL, _CM_POST_BLOCK_UNION::AsyncUser, _CM_POST_BLOCK::CancelPostList, CML_API, CMLOG, CmpCancelSlavePost(), CmpClearListEntry, CmpFreePostBlock(), CmpFreeSlavePost(), CmpLockRegistryExclusive(), CmpRemoveEntryList, CmpSetIoStatus, CmpUnlockRegistry(), CMS_EXCEPTION, CMS_NTAPI, EXCEPTION_EXECUTE_HANDLER, FALSE, _CM_ASYNC_USER_POST_BLOCK::IoStatusBlock, IsMasterPostBlock, KeLowerIrql(), KeRaiseIrql(), KeRemoveQueueApc(), KeSetEvent(), L, _CM_POST_BLOCK::NotifyList, NULL, ObDereferenceObject, PAGED_CODE, PostAsyncUser, _ETHREAD::PostBlockList, PostBlockType, PsGetCurrentProcess, _CM_POST_BLOCK::ThreadList, TRUE, _CM_POST_BLOCK::u, and _CM_ASYNC_USER_POST_BLOCK::UserEvent.

Referenced by PspExitThread().

    01033                    :
    01034
    01035     This routine is called from PspExitThread to clean up any pending
    01036     notify requests.
    01037
    01038     It will traverse the thread's PostBlockList, for each PostBlock it
    01039     finds, it will:
    01040
    01041         1.  Remove it from the relevent NotifyBlock.  This requires
    01042             that we hold the Registry mutex.
    01043
    01044         2.  Remove it from the thread's PostBlockList.  This requires
    01045             that we run at APC level.
    01046
    01047         3.  By the time this procedure runs, user apcs are not interesting
    01048             and neither are SystemEvents, so do not bother processing
    01049             them.
    01050
    01051             UserEvents and IoStatusBlocks could be refered to by other
    01052             threads in the same process, or even a different process,
    01053             so process them so those threads know what happened, use
    01054             status code of STATUS_NOTIFY_CLEANUP.
    01055
    01056             If the notify is a master one, cancel all slave notifications.
    01057             Else only remove this notification from the master CancelPortList
    01058
    01059         4.  Free the post block.
    01060
    01061 Arguments:
    01062
    01063     Thread - pointer to the executive thread object for the thread
    01064              we wish to do rundown on.
    01065
    01066 Return Value:
    01067
    01068     NONE.
    01069
    01070 --*/
    01071 {
    01072     PCM_POST_BLOCK      PostBlock;
    01073     PCM_NOTIFY_BLOCK    NotifyBlock;
    01074     KIRQL               OldIrql;
    01075
    01076     PAGED_CODE();
    01077
    01078     if ( IsListEmpty(&(Thread->PostBlockList)) == TRUE ) {
    01079         return;
    01080     }
    01081
    01082     CMLOG(CML_API, CMS_NTAPI) {
    01083         KdPrint(("CmNotifyRunDown: ethread:%08lx\n", Thread));
    01084     }
    01085
    01086     CmpLockRegistryExclusive();
    01087
    01088         //
    01089     // Aquire exclusive access over the postlist(s)
    01090     //
    01091     // This is not needed (see the rule above)
    01092     //LOCK_POST_LIST();
    01093
    01094     KeRaiseIrql(APC_LEVEL, &OldIrql);
    01095     while (IsListEmpty(&(Thread->PostBlockList)) == FALSE) {
    01096
    01097         //
    01098         // remove from thread list
    01099         //
    01100         PostBlock = (PCM_POST_BLOCK)RemoveHeadList(&(Thread->PostBlockList));
    01101         PostBlock = CONTAINING_RECORD(
    01102                         PostBlock,
    01103                         CM_POST_BLOCK,
    01104                         ThreadList
    01105                         );
    01106
    01107         // Protect for multiple deletion of the same object
    01108         CmpClearListEntry(&(PostBlock->ThreadList));
    01109
    01110         CMLOG(CML_API, CMS_NTAPI) {
    01111 #if DBG
    01112             if(PostBlock->TraceIntoDebugger) {
    01113                 KdPrint(("[CM]CmpNotifyRunDown: ethread:%08lx, PostBlock:%08lx\n", Thread,PostBlock));
    01114             }
    01115 #endif
    01116         }
    01117
    01118         //
    01119         // Canceling a master notification implies canceling all the slave notifications
    01120         // from the CancelPostList
    01121         //
    01122         if(IsMasterPostBlock(PostBlock)) {
    01123             CMLOG(CML_API, CMS_NTAPI) {
    01124 #if DBG
    01125                 if(PostBlock->TraceIntoDebugger) {
    01126                         KdPrint(("[CM]\tCmpNotifyRunDown: PostBlock:%08lx is a master block\n", PostBlock));
    01127                 }
    01128 #endif
    01129             }
    01130             //
    01131             // at this point, CmpReportNotify and friends will no longer
    01132             // attempt to post this post block.
    01133             //
    01134             if (PostBlockType(PostBlock) == PostAsyncUser) {
    01135                 //
    01136                 // report status and wake up any threads that might otherwise
    01137                 // be stuck.  also drop any event references we hold
    01138                 //
    01139                 //  Sundown only: Use a 32bit IO_STATUS_BLOCK if the caller is 32bit.
    01140
    01141                 try {
    01142                     CmpSetIoStatus(PostBlock->u->AsyncUser.IoStatusBlock,
    01143                                    STATUS_NOTIFY_CLEANUP,
    01144                                    0L,
    01145                                    PsGetCurrentProcess()->Wow64Process != NULL);
    01146                 } except (EXCEPTION_EXECUTE_HANDLER) {
    01147                     CMLOG(CML_API, CMS_EXCEPTION) {
    01148                         KdPrint(("!!CmNotifyRundown: code:%08lx\n", GetExceptionCode()));
    01149                     }
    01150                     NOTHING;
    01151                 }
    01152
    01153                 if (PostBlock->u->AsyncUser.UserEvent != NULL) {
    01154                     KeSetEvent(
    01155                         PostBlock->u->AsyncUser.UserEvent,
    01156                         0,
    01157                         FALSE
    01158                         );
    01159                     ObDereferenceObject(PostBlock->u->AsyncUser.UserEvent);
    01160                 }
    01161
    01162                 //
    01163                 // Cancel the APC. Otherwise the rundown routine will also
    01164                 // free the post block if the APC happens to be queued at
    01165                 // this point. If the APC is queued, then the post block has
    01166                 // already been removed from the notify list, so don't remove
    01167                 // it again.
    01168                 //
    01169                 if (!KeRemoveQueueApc(PostBlock->u->AsyncUser.Apc)) {
    01170
    01171                     //
    01172                     // remove from notify block's list
    01173                     //
    01174                     // Use Cmp variant to protect for multiple deletion of the same object
    01175                     CmpRemoveEntryList(&(PostBlock->NotifyList));
    01176                 }
    01177             } else {
    01178                 //
    01179                 // remove from notify block's list
    01180                 //
    01181                 // Use Cmp variant to protect for multiple deletion of the same object
    01182                 CmpRemoveEntryList(&(PostBlock->NotifyList));
    01183             }
    01184
    01185             //
    01186             // Cancel all slave Post requests that may be linked to self
    01187             //
    01188             CmpCancelSlavePost(PostBlock,NULL); // we do not want delayed deref
    01189                         //
    01190                         // Free the slave Post blocks too
    01191                         //
    01192                         CmpFreeSlavePost(PostBlock);
    01193         } else {
    01194
    01195             CMLOG(CML_API, CMS_NTAPI) {
    01196 #if DBG
    01197                 if(PostBlock->TraceIntoDebugger) {
    01198                     KdPrint(("[CM]\tCmpNotifyRunDown: PostBlock:%08lx is a slave block\n", PostBlock));
    01199                 }
    01200 #endif
    01201             }
    01202             //
    01203             // Is a slave PostBlock, just remove self from the Notify PostList
    01204             //
    01205             // Use Cmp variant to protect for multiple deletion of the same object
    01206             CmpRemoveEntryList(&(PostBlock->NotifyList));
    01207
    01208             //
    01209             // and unchain from the Master CancelPostList
    01210             //
    01211             // Use Cmp variant to protect for multiple deletion of the same object
    01212             CmpRemoveEntryList(&(PostBlock->CancelPostList));
    01213
    01214         }
    01215
    01216         //
    01217         // Free the post block.  Use Ex call because PostBlocks are NOT
    01218         // part of the global registry pool computation, but are instead
    01219         // part of NonPagedPool with Quota.
    01220         //
    01221         CmpFreePostBlock(PostBlock);
    01222     }
    01223
    01224     KeLowerIrql(OldIrql);
    01225
    01226     // This is not needed (see the rule above)
    01227     //UNLOCK_POST_LIST();
    01228
    01229     CmpUnlockRegistry();
    01230     return;
    01231 }

VOID CmQueryRegistryQuotaInformation | ( | IN PSYSTEM_REGISTRY_QUOTA_INFORMATION | RegistryQuotaInformation | ) |

Definition at line 92 of file cmgquota.c.

References CmpGlobalQuota, CmpGlobalQuotaUsed, and MmSizeOfPagedPoolInBytes.

Referenced by NtQuerySystemInformation().

    00098                    :
    00099
    00100     Returns the registry quota information
    00101
    00102 Arguments:
    00103
    00104     RegistryQuotaInformation - Supplies pointer to buffer that will return
    00105         the registry quota information.
    00106
    00107 Return Value:
    00108
    00109     None.
    00110
    00111 --*/
    00112
    00113 {
    00114     RegistryQuotaInformation->RegistryQuotaAllowed  = CmpGlobalQuota;
    00115     RegistryQuotaInformation->RegistryQuotaUsed     = CmpGlobalQuotaUsed;
    00116     RegistryQuotaInformation->PagedPoolSize         = MmSizeOfPagedPoolInBytes;
    00117 }

VOID CmSetRegistryQuotaInformation | ( | IN PSYSTEM_REGISTRY_QUOTA_INFORMATION | RegistryQuotaInformation | ) |

Definition at line 121 of file cmgquota.c.

References CM_MINIMUM_GLOBAL_QUOTA, CM_REGISTRY_WARNING_LEVEL, CM_WRAP_LIMIT, CmpGlobalQuota, CmpGlobalQuotaAllowed, and CmpGlobalQuotaWarning.

Referenced by NtSetSystemInformation().

    00127                    :
    00128
    00129     Sets the registry quota information.  The caller is assumed to have
    00130     completed the necessary security checks already.
    00131
    00132 Arguments:
    00133
    00134     RegistryQuotaInformation - Supplies pointer to buffer that provides
    00135         the new registry quota information.
    00136
    00137 Return Value:
    00138
    00139     None.
    00140
    00141 --*/
    00142
    00143 {
    00144     CmpGlobalQuota = RegistryQuotaInformation->RegistryQuotaAllowed;
    00145
    00146     //
    00147     // Sanity checks against insane values
    00148     //
    00149     if (CmpGlobalQuota > CM_WRAP_LIMIT) {
    00150         CmpGlobalQuota = CM_WRAP_LIMIT;
    00151     }
    00152     if (CmpGlobalQuota < CM_MINIMUM_GLOBAL_QUOTA) {
    00153         CmpGlobalQuota = CM_MINIMUM_GLOBAL_QUOTA;
    00154     }
    00155
    00156     //
    00157     // Recompute the warning level
    00158     //
    00159     CmpGlobalQuotaWarning = CM_REGISTRY_WARNING_LEVEL * (CmpGlobalQuota / 100);
    00160
    00161     CmpGlobalQuotaAllowed = CmpGlobalQuota;
    00162 }

NTSTATUS CmSetTraceNotifyRoutine | ( | IN PCM_TRACE_NOTIFY_ROUTINE | NotifyRoutine,
|  | IN BOOLEAN | Remove
| ) |

VOID CmShutdownSystem | ( | VOID |  | ) |

Definition at line 3944 of file cmsysini.c.

References CmpLockRegistryExclusive(), CmpUnlockRegistry(), CmpWorker(), _REGISTRY_COMMAND::Command, CommandArea, HvShutdownComplete, PAGED_CODE, REG_CMD_SHUTDOWN, and TRUE.

    03949                    :
    03950
    03951     Shuts down the registry.
    03952
    03953     Call to CmpWorkerThread, which will call back
    03954     to CmpDoFlushAll();
    03955
    03956 Arguments:
    03957
    03958     NONE
    03959
    03960 Return Value:
    03961
    03962     NONE
    03963
    03964 --*/
    03965 {
    03966     REGISTRY_COMMAND CommandArea;
    03967
    03968     PAGED_CODE();
    03969     CmpLockRegistryExclusive();
    03970
    03971     CommandArea.Command = REG_CMD_SHUTDOWN;
    03972     CmpWorker(&CommandArea);
    03973
    03974     HvShutdownComplete = TRUE;      // Tell HvSyncHive to ignore all
    03975                                     // further requests
    03976
    03977     CmpUnlockRegistry();
    03978     return;
    03979 }

## Variable Documentation

UNICODE_STRING CmClassName[]

| Definition at line 91 of file cm.h. Referenced by CmpInitializeMachineDependentConfiguration(), CmpInitializeRegistryNames(), and CmpInitializeRegistryNode().

PWSTR CmClassString[]

| Definition at line 92 of file cm.h. Referenced by CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineHardwareDescriptionName

| Definition at line 35 of file cm.h. Referenced by CmpInitializeHardwareConfiguration(), and CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineHardwareDescriptionSystemName

| Definition at line 37 of file cm.h. Referenced by CmpInitializeMachineDependentConfiguration(), CmpInitializeRegistryNames(), IopInitializeBuiltinDriver(), IopLoadDriver(), IoQueryDeviceDescription(), KeSetup80387OrEmulate(), and VdmpInitialize().

UNICODE_STRING CmRegistryMachineHardwareDeviceMapName

| Definition at line 39 of file cm.h. Referenced by CmpInitializeHardwareConfiguration(), and CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineHardwareName

| Definition at line 34 of file cm.h. Referenced by CmInitSystem1(), and CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineHardwareOwnerMapName

| Definition at line 43 of file cm.h. Referenced by CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineHardwareResourceMapName

| Definition at line 41 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopBuildCmResourceList(), IopInitializeResourceMap(), and IoReportHalResourceUsage().

UNICODE_STRING CmRegistryMachineName

| Definition at line 33 of file cm.h. Referenced by CmInitSystem1(), CmpInitializeRegistryNames(), and IopProcessCriticalDeviceRoutine().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSet

| Definition at line 47 of file cm.h. Referenced by CmpInitializeRegistryNames(), CmpInterlockedFunction(), CmpSaveBootControlSet(), IopInitializePlugPlayServices(), and IopSetupRemoteBootCard().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlBootLog

| Definition at line 63 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopBootLog(), and IopCopyBootLogRegistryToFile().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlClass

| Definition at line 57 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopCallDriverAddDevice(), and IopSetupRemoteBootCard().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlSafeBoot

| Definition at line 59 of file cm.h. Referenced by CmpInitializeRegistryNames(), and IopSafebootDriverLoad().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetControlSessionManagerMemoryManagement

| Definition at line 61 of file cm.h. Referenced by CmpInitializeMachineDependentConfiguration(), and CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetEnumName

| Definition at line 49 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopApplyFunctionToServiceInstances(), IopCallDriverAddDevice(), IopCleanupDeviceRegistryValues(), IopDeleteLegacyKey(), IopDeviceObjectFromDeviceInstance(), IopDeviceObjectToDeviceInstance(), IopDriverLoadingFailed(), IopInitializePlugPlayServices(), IopIsDeviceInstanceEnabled(), IopMakeGloballyUniqueId(), IopProcessCriticalDevice(), IopProcessNewDeviceNode(), IopServiceInstanceToDeviceInstance(), and IoReportDetectedDevice().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetEnumRootName

| Definition at line 51 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopCreateMadeupNode(), and IopGetRootDevices().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetHardwareProfilesCurrent

| Definition at line 55 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopGetDeviceInstanceCsConfigFlags(), IopIsDeviceInstanceEnabled(), and IopOpenCurrentHwProfileDeviceInstanceKey().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetServices

| Definition at line 53 of file cm.h. Referenced by CmpInitializeRegistryNames(), IopAddRemoteBootValuesToRegistry(), IopOpenServiceEnumKeys(), IopUnloadAttachedDriver(), MiResolveImageReferences(), and MmCallDllInitialize().

UNICODE_STRING CmRegistryMachineSystemCurrentControlSetServicesEventLog

| Definition at line 65 of file cm.h. Referenced by CmpInitializeRegistryNames(), and IoInitSystem().

UNICODE_STRING CmRegistryMachineSystemName

| Definition at line 45 of file cm.h. Referenced by CmpInitializeRegistryNames(), CmpInitializeSystemHive(), and IopStoreSystemPartitionInformation().

UNICODE_STRING CmRegistryRootName

| Definition at line 32 of file cm.h. Referenced by CmpCreateRegistryRoot(), and CmpInitializeRegistryNames().

UNICODE_STRING CmRegistryUserName

| Definition at line 67 of file cm.h. Referenced by CmInitSystem1(), and CmpInitializeRegistryNames().

UNICODE_STRING CmTypeName[]

| Definition at line 82 of file cm.h. Referenced by CmpInitializeRegistryNames(), CmpInitializeRegistryNode(), and KeSetup80387OrEmulate().

PWSTR CmTypeString[]

| Definition at line 83 of file cm.h. Referenced by CmpInitializeRegistryNames(), pIoQueryBusDescription(), and pIoQueryDeviceDescription().