diff --git a/reactos/dll/win32/kernel32/client/dllmain.c b/reactos/dll/win32/kernel32/client/dllmain.c index 55d0c680222..8b0e7bc092a 100644 --- a/reactos/dll/win32/kernel32/client/dllmain.c +++ b/reactos/dll/win32/kernel32/client/dllmain.c @@ -22,6 +22,9 @@ extern UNICODE_STRING SystemDirectory; extern UNICODE_STRING WindowsDirectory; + +PBASE_STATIC_SERVER_DATA BaseStaticServerData; + BOOLEAN BaseRunningInServerProcess; WCHAR BaseDefaultPathBuffer[6140]; @@ -252,6 +255,135 @@ BasepInitConsole(VOID) return TRUE; } +VOID +WINAPI +BasepFakeStaticServerData(VOID) +{ + NTSTATUS Status; + WCHAR Buffer[MAX_PATH]; + UNICODE_STRING SystemRootString; + UNICODE_STRING UnexpandedSystemRootString = RTL_CONSTANT_STRING(L"%SystemRoot%"); + UNICODE_STRING BaseSrvCSDString; + ULONG BaseSrvCSDNumber; + RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable[] = + { + { + NULL, + RTL_QUERY_REGISTRY_DIRECT, + L"CSDVersion", + &BaseSrvCSDString + }, + {0} + }; + RTL_QUERY_REGISTRY_TABLE BaseServerRegistryConfigurationTable1[] = + { + { + NULL, + RTL_QUERY_REGISTRY_DIRECT, + L"CSDVersion", + &BaseSrvCSDNumber + }, + {0} + }; + + /* Allocate the fake data */ + BaseStaticServerData = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + sizeof(BASE_STATIC_SERVER_DATA)); + ASSERT(BaseStaticServerData != NULL); + + /* Get the Windows directory */ + RtlInitEmptyUnicodeString(&SystemRootString, Buffer, sizeof(Buffer)); + Status = RtlExpandEnvironmentStrings_U(NULL, + &UnexpandedSystemRootString, + &SystemRootString, + NULL); + ASSERT(NT_SUCCESS(Status)); + + Buffer[SystemRootString.Length / sizeof(WCHAR)] = UNICODE_NULL; + Status = RtlCreateUnicodeString(&BaseStaticServerData->WindowsDirectory, + SystemRootString.Buffer); + ASSERT(NT_SUCCESS(Status)); + + wcscat(SystemRootString.Buffer, L"\\system32"); + Status = RtlCreateUnicodeString(&BaseStaticServerData->WindowsSystemDirectory, + SystemRootString.Buffer); + ASSERT(NT_SUCCESS(Status)); + + if (!SessionId) + { + Status = RtlCreateUnicodeString(&BaseStaticServerData->NamedObjectDirectory, + L"\\BaseNamedObjects"); + ASSERT(NT_SUCCESS(Status)); + } + else + { + /* Hopefully we'll fix CSRSS Before we add multiple sessions... */ + ASSERT(FALSE); + } + + RtlInitEmptyUnicodeString(&BaseSrvCSDString, Buffer, sizeof(Buffer)); + + 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; + } + + Status = RtlQueryRegistryValues(RTL_REGISTRY_WINDOWS_NT, + L"", + BaseServerRegistryConfigurationTable, + NULL, + NULL); + if (NT_SUCCESS(Status)) + { + wcsncpy(BaseStaticServerData->CSDVersion, + BaseSrvCSDString.Buffer, + BaseSrvCSDString.Length / sizeof(WCHAR)); + } + else + { + BaseStaticServerData->CSDVersion[0] = UNICODE_NULL; + } + + Status = NtQuerySystemInformation(SystemBasicInformation, + &BaseStaticServerData->SysInfo, + sizeof(BaseStaticServerData->SysInfo), + NULL); + ASSERT(NT_SUCCESS(Status)); + + BaseStaticServerData->DefaultSeparateVDM = FALSE; + BaseStaticServerData->IsWowTaskReady = FALSE; + BaseStaticServerData->LUIDDeviceMapsEnabled = FALSE; + BaseStaticServerData->TermsrvClientTimeZoneId = TIME_ZONE_ID_INVALID; + BaseStaticServerData->TermsrvClientTimeZoneChangeNum = 0; + + Status = NtQuerySystemInformation(SystemTimeOfDayInformation, + &BaseStaticServerData->TimeOfDay, + sizeof(BaseStaticServerData->TimeOfDay), + NULL); + ASSERT(NT_SUCCESS(Status)); + + DPRINT1("ReactOS Base API Connected: %wZ %wZ %wZ %S (%lx.%lx) %d KB\n", + BaseStaticServerData->WindowsDirectory, + BaseStaticServerData->WindowsSystemDirectory, + BaseStaticServerData->NamedObjectDirectory, + BaseStaticServerData->CSDVersion, + BaseStaticServerData->CSDNumber, + BaseStaticServerData->RCNumber, + BaseStaticServerData->SysInfo.PageSize * + BaseStaticServerData->SysInfo.NumberOfPhysicalPages / 1024); +} BOOL WINAPI @@ -312,6 +444,25 @@ DllMain(HANDLE hDll, ZwTerminateProcess(NtCurrentProcess(), Status); return FALSE; } + + /* Get the server data */ + if (!Peb->ReadOnlyStaticServerData) + { + /* Build fake one for ReactOS */ + BasepFakeStaticServerData(); + + /* Allocate the array */ + Peb->ReadOnlyStaticServerData = RtlAllocateHeap(RtlGetProcessHeap(), + HEAP_ZERO_MEMORY, + 4 * sizeof(PVOID)); + + /* Set the data for the BASESRV DLL Index */ + Peb->ReadOnlyStaticServerData[CSR_CONSOLE] = BaseStaticServerData; + } + + /* Get the server data */ + BaseStaticServerData = Peb->ReadOnlyStaticServerData[CSR_CONSOLE]; + ASSERT(BaseStaticServerData); /* Check if we are running a CSR Server */ if (!BaseRunningInServerProcess) diff --git a/reactos/dll/win32/kernel32/include/kernel32.h b/reactos/dll/win32/kernel32/include/kernel32.h index c71c608c9ac..4ce327318ef 100644 --- a/reactos/dll/win32/kernel32/include/kernel32.h +++ b/reactos/dll/win32/kernel32/include/kernel32.h @@ -80,6 +80,75 @@ typedef struct _CODEPAGE_ENTRY CPTABLEINFO CodePageTable; } CODEPAGE_ENTRY, *PCODEPAGE_ENTRY; +typedef struct _NLS_USER_INFO +{ + WCHAR iCountry[80]; + WCHAR sCountry[80]; + WCHAR sList[80]; + WCHAR iMeasure[80]; + WCHAR iPaperSize[80]; + WCHAR sDecimal[80]; + WCHAR sThousand[80]; + WCHAR sGrouping[80]; + WCHAR iDigits[80]; + WCHAR iLZero[80]; + WCHAR iNegNumber[80]; + WCHAR sNativeDigits[80]; + WCHAR iDigitSubstitution[80]; + WCHAR sCurrency[80]; + WCHAR sMonDecSep[80]; + WCHAR sMonThouSep[80]; + WCHAR sMonGrouping[80]; + WCHAR iCurrDigits[80]; + WCHAR iCurrency[80]; + WCHAR iNegCurr[80]; + WCHAR sPosSign[80]; + WCHAR sNegSign[80]; + WCHAR sTimeFormat[80]; + WCHAR s1159[80]; + WCHAR s2359[80]; + WCHAR sShortDate[80]; + WCHAR sYearMonth[80]; + WCHAR sLongDate[80]; + WCHAR iCalType[80]; + WCHAR iFirstDay[80]; + WCHAR iFirstWeek[80]; + WCHAR sLocale[80]; + WCHAR sLocaleName[85]; + LCID UserLocaleId; + LUID InteractiveUserLuid; + CHAR InteractiveUserSid[SECURITY_MAX_SID_SIZE]; + ULONG ulCacheUpdateCount; +} NLS_USER_INFO, *PNLS_USER_INFO; + +typedef struct _BASE_STATIC_SERVER_DATA +{ + UNICODE_STRING WindowsDirectory; + UNICODE_STRING WindowsSystemDirectory; + UNICODE_STRING NamedObjectDirectory; + USHORT WindowsMajorVersion; + USHORT WindowsMinorVersion; + USHORT BuildNumber; + USHORT CSDNumber; + USHORT RCNumber; + WCHAR CSDVersion[128]; + SYSTEM_BASIC_INFORMATION SysInfo; + SYSTEM_TIMEOFDAY_INFORMATION TimeOfDay; + PVOID IniFileMapping; + NLS_USER_INFO NlsUserInfo; + BOOLEAN DefaultSeparateVDM; + BOOLEAN IsWowTaskReady; + UNICODE_STRING WindowsSys32x86Directory; + BOOLEAN fTermsrvAppInstallMode; + TIME_ZONE_INFORMATION tziTermsrvClientTimeZone; + KSYSTEM_TIME ktTermsrvClientBias; + ULONG TermsrvClientTimeZoneId; + BOOLEAN LUIDDeviceMapsEnabled; + ULONG TermsrvClientTimeZoneChangeNum; +} BASE_STATIC_SERVER_DATA, *PBASE_STATIC_SERVER_DATA; + +extern PBASE_STATIC_SERVER_DATA BaseStaticServerData; + typedef DWORD (*WaitForInputIdleType)(