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

cmcontrl.c File Reference

#include "cmp.h"

Go to the source code of this file.

Functions

HCELL_INDEX CmpWalkPath (PHHIVE SystemHive, HCELL_INDEX ParentCell, PWSTR Path)
LANGID CmpConvertLangId (PWSTR LangIdString, ULONG LangIdStringLength)
VOID CmGetSystemControlValues (PVOID SystemHiveBuffer, PCM_SYSTEM_CONTROL_VECTOR ControlVector)

Variables

WCHAR CmDefaultLanguageId []
ULONG CmDefaultLanguageIdLength
ULONG CmDefaultLanguageIdType
WCHAR CmInstallUILanguageId []
ULONG CmInstallUILanguageIdLength
ULONG CmInstallUILanguageIdType


Function Documentation

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_SYSTEM_CONTROL_VECTOR::Type, _CM_KEY_VALUE::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 }

LANGID CmpConvertLangId PWSTR  LangIdString,
ULONG  LangIdStringLength
 

Definition at line 310 of file cmcontrl.c.

References c, L, and USHORT.

Referenced by CmGetSystemControlValues().

00314 { 00315 00316 00317 USHORT i, Digit; 00318 WCHAR c; 00319 LANGID LangId; 00320 00321 LangId = 0; 00322 LangIdStringLength = LangIdStringLength / sizeof( WCHAR ); 00323 for (i=0; i < LangIdStringLength; i++) { 00324 c = LangIdString[ i ]; 00325 00326 if (c >= L'0' && c <= L'9') { 00327 Digit = c - L'0'; 00328 00329 } else if (c >= L'A' && c <= L'F') { 00330 Digit = c - L'A' + 10; 00331 00332 } else if (c >= L'a' && c <= L'f') { 00333 Digit = c - L'a' + 10; 00334 00335 } else { 00336 break; 00337 } 00338 00339 if (Digit >= 16) { 00340 break; 00341 } 00342 00343 LangId = (LangId << 4) | Digit; 00344 } 00345 00346 return LangId; 00347 }

HCELL_INDEX CmpWalkPath PHHIVE  SystemHive,
HCELL_INDEX  ParentCell,
PWSTR  Path
 

Definition at line 256 of file cmcontrl.c.

References CmpFindSubKeyByName(), CmpGetNextName(), HCELL_INDEX, HCELL_NIL, HvGetCell, Index, NTSTATUS(), PHCELL_INDEX, RtlInitUnicodeString(), and TRUE.

Referenced by CmGetSystemControlValues().

00263 : 00264 00265 Walk the path. 00266 00267 Arguments: 00268 00269 SystemHive - hive 00270 00271 ParentCell - where to start 00272 00273 Path - string to walk 00274 00275 Return Value: 00276 00277 HCELL_INDEX of found key cell, or HCELL_NIL for error 00278 00279 --*/ 00280 { 00281 NTSTATUS status; 00282 UNICODE_STRING PathString; 00283 UNICODE_STRING NextName; 00284 BOOLEAN Last; 00285 PHCELL_INDEX Index; 00286 HCELL_INDEX KeyCell; 00287 00288 KeyCell = ParentCell; 00289 RtlInitUnicodeString(&PathString, Path); 00290 00291 while (TRUE) { 00292 00293 CmpGetNextName(&PathString, &NextName, &Last); 00294 00295 if (NextName.Length == 0) { 00296 return KeyCell; 00297 } 00298 00299 KeyCell = CmpFindSubKeyByName(SystemHive, 00300 (PCM_KEY_NODE)HvGetCell(SystemHive,KeyCell), 00301 &NextName); 00302 00303 if (KeyCell == HCELL_NIL) { 00304 return HCELL_NIL; 00305 } 00306 } 00307 }


Variable Documentation

WCHAR CmDefaultLanguageId[]
 

Definition at line 23 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().

ULONG CmDefaultLanguageIdLength
 

Definition at line 24 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().

ULONG CmDefaultLanguageIdType
 

Definition at line 25 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().

WCHAR CmInstallUILanguageId[]
 

Definition at line 27 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().

ULONG CmInstallUILanguageIdLength
 

Definition at line 28 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().

ULONG CmInstallUILanguageIdType
 

Definition at line 29 of file cmcontrl.c.

Referenced by CmGetSystemControlValues().


Generated on Sat May 15 19:43:07 2004 for test by doxygen 1.3.7