Author: ion
Date: Mon Jul 25 03:28:33 2011
New Revision: 52858
URL:
http://svn.reactos.org/svn/reactos?rev=52858&view=rev
Log:
[KERNEL32]: Define the BASE_STATIC_SERVER_DATA structure that BASESRV shares with KERNEL32
on Windows. In Windows, each CSR client/server pair can share such data through the
PEB's ReadOnlyStaticServerData array. In ReactOS, this is not (yet) implemented, so if
we don't have this data, kernel32 builds a "fake" copy instead. This
"fake" copy will still be useful though as it'll let kernel32 cache some
data (per-process). With proper CSRSS support, we could cache it per-system, but at least
this is a start.
Modified:
trunk/reactos/dll/win32/kernel32/client/dllmain.c
trunk/reactos/dll/win32/kernel32/include/kernel32.h
Modified: trunk/reactos/dll/win32/kernel32/client/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- 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 03:28:33
2011
@@ -21,6 +21,9 @@
extern UNICODE_STRING SystemDirectory;
extern UNICODE_STRING WindowsDirectory;
+
+
+PBASE_STATIC_SERVER_DATA BaseStaticServerData;
BOOLEAN BaseRunningInServerProcess;
@@ -252,6 +255,135 @@
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 @@
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)
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Mon Jul 25 03:28:33
2011
@@ -80,6 +80,75 @@
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)(