Author: ion Date: Mon Jul 25 14:40:59 2011 New Revision: 52861
URL: http://svn.reactos.org/svn/reactos?rev=52861&view=rev Log: [KERNEL32]: Fix querying the CSDNumber and RCNumber, as this seems to be a bug (no valid data was found on Windows).
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/d... ============================================================================== --- trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/dllmain.c [iso-8859-1] Mon Jul 25 14:40:59 2011 @@ -264,7 +264,6 @@ UNICODE_STRING SystemRootString; UNICODE_STRING UnexpandedSystemRootString = RTL_CONSTANT_STRING(L"%SystemRoot%"); UNICODE_STRING BaseSrvCSDString; - ULONG BaseSrvCSDNumber; RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] = { { @@ -272,16 +271,6 @@ RTL_QUERY_REGISTRY_DIRECT, L"CSDVersion", &BaseSrvCSDString - }, - {0} - }; - RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable1[] = - { - { - NULL, - RTL_QUERY_REGISTRY_DIRECT, - L"CSDVersion", - &BaseSrvCSDNumber }, {0} }; @@ -298,6 +287,7 @@ &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 @@ 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 @@ NULL); if (NT_SUCCESS(Status)) { + DPRINT1("CSD String: %wZ\n", BaseSrvCSDString); wcsncpy(BaseStaticServerData->CSDVersion, BaseSrvCSDString.Buffer, BaseSrvCSDString.Length / sizeof(WCHAR)); @@ -446,6 +430,7 @@ }
/* Get the server data */ + DPRINT1("Server data: %p\n", Peb->ReadOnlyStaticServerData); if (!Peb->ReadOnlyStaticServerData) { /* Build fake one for ReactOS */ @@ -462,6 +447,7 @@
/* 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 */