[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
This commit is contained in:
Alex Ionescu 2011-07-25 14:40:59 +00:00
parent 436714e461
commit b2fc587c78

View file

@ -264,7 +264,6 @@ BasepFakeStaticServerData(VOID)
UNICODE_STRING SystemRootString; UNICODE_STRING SystemRootString;
UNICODE_STRING UnexpandedSystemRootString = RTL_CONSTANT_STRING(L"%SystemRoot%"); UNICODE_STRING UnexpandedSystemRootString = RTL_CONSTANT_STRING(L"%SystemRoot%");
UNICODE_STRING BaseSrvCSDString; UNICODE_STRING BaseSrvCSDString;
ULONG BaseSrvCSDNumber;
RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] = RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] =
{ {
{ {
@ -275,16 +274,6 @@ BasepFakeStaticServerData(VOID)
}, },
{0} {0}
}; };
RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable1[] =
{
{
NULL,
RTL_QUERY_REGISTRY_DIRECT,
L"CSDVersion",
&BaseSrvCSDNumber
},
{0}
};
/* Allocate the fake data */ /* Allocate the fake data */
BaseStaticServerData = RtlAllocateHeap(RtlGetProcessHeap(), BaseStaticServerData = RtlAllocateHeap(RtlGetProcessHeap(),
@ -298,6 +287,7 @@ BasepFakeStaticServerData(VOID)
&UnexpandedSystemRootString, &UnexpandedSystemRootString,
&SystemRootString, &SystemRootString,
NULL); NULL);
DPRINT1("Status: %lx. Root: %wZ\n", Status, &SystemRootString);
ASSERT(NT_SUCCESS(Status)); ASSERT(NT_SUCCESS(Status));
Buffer[SystemRootString.Length / sizeof(WCHAR)] = UNICODE_NULL; Buffer[SystemRootString.Length / sizeof(WCHAR)] = UNICODE_NULL;
@ -322,23 +312,16 @@ BasepFakeStaticServerData(VOID)
ASSERT(FALSE); ASSERT(FALSE);
} }
RtlInitEmptyUnicodeString(&BaseSrvCSDString, Buffer, sizeof(BaseStaticServerData->CSDVersion)); /*
* Confirmed that in Windows, CSDNumber and RCNumber are actually Length
Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, * and MaximumLength of the CSD String, since the same UNICODE_STRING is
L"", * being queried twice, the first time as a ULONG!
BaseServerRegistryConfigurationTable1, *
NULL, * Somehow, in Windows this doesn't cause a buffer overflow, but it might
NULL); * in ReactOS, so this code is disabled until someone figures out WTF.
if (NT_SUCCESS(Status)) */
{ BaseStaticServerData->CSDNumber = 0;
BaseStaticServerData->CSDNumber = (USHORT)(BaseSrvCSDNumber & 0xFFFF); BaseStaticServerData->RCNumber = 0;
BaseStaticServerData->RCNumber = (USHORT)(BaseSrvCSDNumber >> 16);
}
else
{
BaseStaticServerData->CSDNumber = 0;
BaseStaticServerData->RCNumber = 0;
}
Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT,
L"", L"",
@ -347,6 +330,7 @@ BasepFakeStaticServerData(VOID)
NULL); NULL);
if (NT_SUCCESS(Status)) if (NT_SUCCESS(Status))
{ {
DPRINT1("CSD String: %wZ\n", BaseSrvCSDString);
wcsncpy(BaseStaticServerData->CSDVersion, wcsncpy(BaseStaticServerData->CSDVersion,
BaseSrvCSDString.Buffer, BaseSrvCSDString.Buffer,
BaseSrvCSDString.Length / sizeof(WCHAR)); BaseSrvCSDString.Length / sizeof(WCHAR));
@ -446,6 +430,7 @@ DllMain(HANDLE hDll,
} }
/* Get the server data */ /* Get the server data */
DPRINT1("Server data: %p\n", Peb->ReadOnlyStaticServerData);
if (!Peb->ReadOnlyStaticServerData) if (!Peb->ReadOnlyStaticServerData)
{ {
/* Build fake one for ReactOS */ /* Build fake one for ReactOS */
@ -462,6 +447,7 @@ DllMain(HANDLE hDll,
/* Get the server data */ /* Get the server data */
BaseStaticServerData = Peb->ReadOnlyStaticServerData[CSR_CONSOLE]; BaseStaticServerData = Peb->ReadOnlyStaticServerData[CSR_CONSOLE];
DPRINT1("Static data: %p\n", BaseStaticServerData);
ASSERT(BaseStaticServerData); ASSERT(BaseStaticServerData);
/* Check if we are running a CSR Server */ /* Check if we are running a CSR Server */