From 7550f93c9e6d819327be0bbfe7a9bbaeccfd5bb5 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Wed, 30 Jan 2008 10:32:22 +0000 Subject: [PATCH] - Allocate memory for groups list dynamically, and make it enough (4096 bytes) for a really long list of groups. This makes Windows 2003 booting up to explorer without crashing. svn path=/trunk/; revision=32051 --- reactos/boot/freeldr/freeldr/windows/wlregistry.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/reactos/boot/freeldr/freeldr/windows/wlregistry.c b/reactos/boot/freeldr/freeldr/windows/wlregistry.c index 278a1afd870..026b61050cb 100644 --- a/reactos/boot/freeldr/freeldr/windows/wlregistry.c +++ b/reactos/boot/freeldr/freeldr/windows/wlregistry.c @@ -429,7 +429,7 @@ WinLdrScanRegistry(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, { LONG rc = 0; FRLDRHKEY hGroupKey, hOrderKey, hServiceKey, hDriverKey; - WCHAR GroupNameBuffer[512]; + LPWSTR GroupNameBuffer; WCHAR ServiceName[256]; ULONG OrderList[128]; ULONG BufferSize; @@ -480,7 +480,8 @@ WinLdrScanRegistry(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, } /* Get the Name Group */ - BufferSize = sizeof(GroupNameBuffer); + BufferSize = 4096; + GroupNameBuffer = MmHeapAlloc(BufferSize); rc = RegQueryValue(hGroupKey, L"List", NULL, (PUCHAR)GroupNameBuffer, &BufferSize); DbgPrint((DPRINT_REACTOS, "RegQueryValue(): rc %d\n", (int)rc)); if (rc != ERROR_SUCCESS) @@ -515,7 +516,10 @@ WinLdrScanRegistry(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, if (rc == ERROR_NO_MORE_ITEMS) break; if (rc != ERROR_SUCCESS) + { + MmHeapFree(GroupNameBuffer); return; + } //DbgPrint((DPRINT_REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName)); /* open driver Key */ @@ -591,7 +595,10 @@ WinLdrScanRegistry(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, if (rc == ERROR_NO_MORE_ITEMS) break; if (rc != ERROR_SUCCESS) + { + MmHeapFree(GroupNameBuffer); return; + } //DbgPrint((DPRINT_REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName)); /* open driver Key */ @@ -657,6 +664,9 @@ WinLdrScanRegistry(IN OUT PLOADER_PARAMETER_BLOCK LoaderBlock, /* Move to the next group name */ GroupName = GroupName + wcslen(GroupName) + 1; } + + /* Free allocated memory */ + MmHeapFree(GroupNameBuffer); } BOOLEAN