mirror of
https://github.com/reactos/reactos.git
synced 2026-05-31 16:31:07 +08:00
[NTOS:CM] Simplify CmpGetRegistryPath to avoid unnecessary stack buffers. CORE-15882
This commit is contained in:
@@ -1166,32 +1166,24 @@ CmpCreateRegistryRoot(VOID)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static NTSTATUS
|
||||
CmpGetRegistryPath(OUT PWCHAR ConfigPath)
|
||||
static PCWSTR
|
||||
CmpGetRegistryPath(VOID)
|
||||
{
|
||||
/* Just use default path */
|
||||
wcscpy(ConfigPath, L"\\SystemRoot");
|
||||
PCWSTR ConfigPath;
|
||||
|
||||
/* Check if we are booted in setup */
|
||||
if (!ExpInTextModeSetup)
|
||||
{
|
||||
/* Add registry path */
|
||||
#if 0
|
||||
ResultSize = wcslen(ConfigPath);
|
||||
if (ResultSize && ConfigPath[ResultSize - 1] == L'\\')
|
||||
ConfigPath[ResultSize - 1] = UNICODE_NULL;
|
||||
#endif
|
||||
wcscat(ConfigPath, L"\\System32\\Config\\");
|
||||
ConfigPath = L"\\SystemRoot\\System32\\Config\\";
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscat(ConfigPath, L"\\");
|
||||
ConfigPath = L"\\SystemRoot\\";
|
||||
}
|
||||
|
||||
DPRINT1("CmpGetRegistryPath: ConfigPath = '%S'\n", ConfigPath);
|
||||
|
||||
/* Done */
|
||||
return STATUS_SUCCESS;
|
||||
return ConfigPath;
|
||||
}
|
||||
|
||||
_Function_class_(KSTART_ROUTINE)
|
||||
@@ -1199,7 +1191,8 @@ VOID
|
||||
NTAPI
|
||||
CmpLoadHiveThread(IN PVOID StartContext)
|
||||
{
|
||||
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
|
||||
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH];
|
||||
PCWSTR ConfigPath;
|
||||
UNICODE_STRING TempName, FileName, RegName;
|
||||
ULONG i, ErrorResponse, WorkerCount, Length;
|
||||
USHORT FileStart;
|
||||
@@ -1222,7 +1215,7 @@ CmpLoadHiveThread(IN PVOID StartContext)
|
||||
RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
|
||||
|
||||
/* Now build the system root path */
|
||||
CmpGetRegistryPath(ConfigPath);
|
||||
ConfigPath = CmpGetRegistryPath();
|
||||
RtlInitUnicodeString(&TempName, ConfigPath);
|
||||
RtlAppendUnicodeStringToString(&FileName, &TempName);
|
||||
FileStart = FileName.Length;
|
||||
@@ -1364,7 +1357,8 @@ VOID
|
||||
NTAPI
|
||||
CmpInitializeHiveList(VOID)
|
||||
{
|
||||
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH], ConfigPath[MAX_PATH];
|
||||
WCHAR FileBuffer[MAX_PATH], RegBuffer[MAX_PATH];
|
||||
PCWSTR ConfigPath;
|
||||
UNICODE_STRING TempName, FileName, RegName;
|
||||
HANDLE Thread;
|
||||
NTSTATUS Status;
|
||||
@@ -1381,7 +1375,7 @@ CmpInitializeHiveList(VOID)
|
||||
RtlInitEmptyUnicodeString(&RegName, RegBuffer, sizeof(RegBuffer));
|
||||
|
||||
/* Now build the system root path */
|
||||
CmpGetRegistryPath(ConfigPath);
|
||||
ConfigPath = CmpGetRegistryPath();
|
||||
RtlInitUnicodeString(&TempName, ConfigPath);
|
||||
RtlAppendUnicodeStringToString(&FileName, &TempName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user