From b2fc587c78717ec03caf64d7c9dc85ee47105a85 Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Mon, 25 Jul 2011 14:40:59 +0000 Subject: [PATCH] [KERNEL32]: Fix querying the CSDNumber and RCNumber, as this seems to be a bug (no valid data was found on Windows). svn path=/trunk/; revision=52861 --- reactos/dll/win32/kernel32/client/dllmain.c | 42 +++++++-------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/dllmain.c b/reactos/dll/win32/kernel32/client/dllmain.c index 3c018774f89..b090969bc61 100644 --- a/reactos/dll/win32/kernel32/client/dllmain.c +++ b/reactos/dll/win32/kernel32/client/dllmain.c @@ -264,7 +264,6 @@ BasepFakeStaticServerData(VOID) UNICODE_STRING SystemRootString; UNICODE_STRING UnexpandedSystemRootString = RTL_CONSTANT_STRING(L"%SystemRoot%"); UNICODE_STRING BaseSrvCSDString; - ULONG BaseSrvCSDNumber; RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] = { { @@ -275,16 +274,6 @@ BasepFakeStaticServerData(VOID) }, {0} }; - RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable1[] = - { - { - NULL, - RTL_QUERY_REGISTRY_DIRECT, - L"CSDVersion", - &BaseSrvCSDNumber - }, - {0} - }; /* Allocate the fake data */ BaseStaticServerData = RtlAllocateHeap(RtlGetProcessHeap(), @@ -298,6 +287,7 @@ BasepFakeStaticServerData(VOID) &UnexpandedSystemRootString, &SystemRootString, NULL); + DPRINT1("Status: %lx. Root: %wZ\n", Status, &SystemRootString); ASSERT(NT_SUCCESS(Status)); Buffer[SystemRootString.Length / sizeof(WCHAR)] = UNICODE_NULL; @@ -322,23 +312,16 @@ BasepFakeStaticServerData(VOID) ASSERT(FALSE); } - RtlInitEmptyUnicodeString(&BaseSrvCSDString, Buffer, sizeof(BaseStaticServerData->CSDVersion)); - - Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, - L"", - BaseServerRegistryConfigurationTable1, - NULL, - NULL); - if (NT_SUCCESS(Status)) - { - BaseStaticServerData->CSDNumber = (USHORT)(BaseSrvCSDNumber & 0xFFFF); - BaseStaticServerData->RCNumber = (USHORT)(BaseSrvCSDNumber >> 16); - } - else - { - BaseStaticServerData->CSDNumber = 0; - BaseStaticServerData->RCNumber = 0; - } + /* + * Confirmed that in Windows, CSDNumber and RCNumber are actually Length + * and MaximumLength of the CSD String, since the same UNICODE_STRING is + * being queried twice, the first time as a ULONG! + * + * Somehow, in Windows this doesn't cause a buffer overflow, but it might + * in ReactOS, so this code is disabled until someone figures out WTF. + */ + BaseStaticServerData->CSDNumber = 0; + BaseStaticServerData->RCNumber = 0; Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, L"", @@ -347,6 +330,7 @@ BasepFakeStaticServerData(VOID) NULL); if (NT_SUCCESS(Status)) { + DPRINT1("CSD String: %wZ\n", BaseSrvCSDString); wcsncpy(BaseStaticServerData->CSDVersion, BaseSrvCSDString.Buffer, BaseSrvCSDString.Length / sizeof(WCHAR)); @@ -446,6 +430,7 @@ DllMain(HANDLE hDll, } /* Get the server data */ + DPRINT1("Server data: %p\n", Peb->ReadOnlyStaticServerData); if (!Peb->ReadOnlyStaticServerData) { /* Build fake one for ReactOS */ @@ -462,6 +447,7 @@ DllMain(HANDLE hDll, /* Get the server data */ BaseStaticServerData = Peb->ReadOnlyStaticServerData[CSR_CONSOLE]; + DPRINT1("Static data: %p\n", BaseStaticServerData); ASSERT(BaseStaticServerData); /* Check if we are running a CSR Server */