[BASESRV]: Fix definition of NLS_USER_INFO so that it matches exactly that of Server 2003 (this now makes BASE_SERVER_STATIC_DATA correct too).

[BASESRV]: Implement BaseSrvNlsGetUserInfo.

svn path=/trunk/; revision=59882
This commit is contained in:
Alex Ionescu 2013-08-29 21:00:54 +00:00
parent 76ac8a4d9d
commit 103ab26886
4 changed files with 79 additions and 11 deletions

View file

@ -17,6 +17,7 @@ NTSTATUS WINAPI BaseSetProcessCreateNotify(BASE_PROCESS_CREATE_NOTIFY_ROUTINE);
typedef struct _NLS_USER_INFO
{
WCHAR sLanguage[80];
WCHAR iCountry[80];
WCHAR sCountry[80];
WCHAR sList[80];
@ -29,7 +30,7 @@ typedef struct _NLS_USER_INFO
WCHAR iLZero[80];
WCHAR iNegNumber[80];
WCHAR sNativeDigits[80];
WCHAR iDigitSubstitution[80];
WCHAR NumShape[80];
WCHAR sCurrency[80];
WCHAR sMonDecSep[80];
WCHAR sMonThouSep[80];
@ -37,25 +38,29 @@ typedef struct _NLS_USER_INFO
WCHAR iCurrDigits[80];
WCHAR iCurrency[80];
WCHAR iNegCurr[80];
WCHAR sPosSign[80];
WCHAR sNegSign[80];
WCHAR sPositiveSign[80];
WCHAR sNegativeSign[80];
WCHAR sTimeFormat[80];
WCHAR sTime[80];
WCHAR iTime[80];
WCHAR iTLZero[80];
WCHAR iTimePrefix[80];
WCHAR s1159[80];
WCHAR s2359[80];
WCHAR sShortDate[80];
WCHAR sDate[80];
WCHAR iDate[80];
WCHAR sYearMonth[80];
WCHAR sLongDate[80];
WCHAR iCalType[80];
WCHAR iFirstDay[80];
WCHAR iFirstWeek[80];
WCHAR sLocale[80];
WCHAR sLocaleName[85];
WCHAR iFirstDayOfWeek[80];
WCHAR iFirstWeekOfYear[80];
WCHAR Locale[80];
LCID UserLocaleId;
LUID InteractiveUserLuid;
CHAR InteractiveUserSid[68]; // SECURITY_MAX_SID_SIZE to make ROS happy
ULONG ulCacheUpdateCount;
} NLS_USER_INFO, *PNLS_USER_INFO;
C_ASSERT(sizeof(NLS_USER_INFO) == 0x1870);
typedef struct _BASE_STATIC_SERVER_DATA
{
@ -82,6 +87,9 @@ typedef struct _BASE_STATIC_SERVER_DATA
BOOLEAN LUIDDeviceMapsEnabled;
ULONG TermsrvClientTimeZoneChangeNum;
} BASE_STATIC_SERVER_DATA, *PBASE_STATIC_SERVER_DATA;
C_ASSERT(sizeof(BASE_STATIC_SERVER_DATA) == 0x1AC8);
VOID WINAPI BaseSrvNLSInit(IN PBASE_STATIC_SERVER_DATA StaticData);
#endif // _BASE_H

View file

@ -268,6 +268,12 @@ typedef struct
ULONG LocaleId;
} BASE_NLS_CREATE_SECTION, *PBASE_NLS_CREATE_SECTION;
typedef struct
{
PVOID /*PNLS_USER_INFO*/ NlsUserInfo;
ULONG Size;
} BASE_NLS_GET_USER_INFO, *PBASE_NLS_GET_USER_INFO;
typedef struct _BASE_API_MESSAGE
{
PORT_MESSAGE Header;
@ -297,6 +303,7 @@ typedef struct _BASE_API_MESSAGE
BASE_REFRESH_INIFILE_MAPPING RefreshIniFileMappingRequest;
BASE_DEFINE_DOS_DEVICE DefineDosDeviceRequest;
BASE_NLS_CREATE_SECTION NlsCreateSection;
BASE_NLS_GET_USER_INFO NlsGetUserInfo;
} Data;
} BASE_API_MESSAGE, *PBASE_API_MESSAGE;

View file

@ -525,6 +525,9 @@ BaseInitializeStaticServerData(IN PCSR_SERVER_DLL LoadedServerDll)
ASSERT(NT_SUCCESS(Status));
}
/* Initialize NLS */
BaseSrvNLSInit(BaseStaticServerData);
/* Finally, set the pointer */
LoadedServerDll->SharedSection = BaseStaticServerData;
}

View file

@ -15,6 +15,9 @@
/* GLOBALS ********************************************************************/
RTL_CRITICAL_SECTION NlsCacheCriticalSection;
PNLS_USER_INFO pNlsRegUserInfo;
BOOLEAN BaseSrvKernel32DelayLoadComplete;
HANDLE BaseSrvKernel32DllHandle;
UNICODE_STRING BaseSrvKernel32DllPath;
@ -102,6 +105,29 @@ BaseSrvDelayLoadKernel32(VOID)
return Status;
}
VOID
WINAPI
BaseSrvNLSInit(IN PBASE_STATIC_SERVER_DATA StaticData)
{
/* Initialize the lock */
RtlInitializeCriticalSection(&NlsCacheCriticalSection);
/* Initialize the data with all F's */
pNlsRegUserInfo = &StaticData->NlsUserInfo;
RtlFillMemory(&StaticData->NlsUserInfo, 0xFF, sizeof(StaticData->NlsUserInfo));
/* Set empty LCID */
pNlsRegUserInfo->UserLocaleId = 0;
/* Reset the cache update counter */
RtlEnterCriticalSection(&NlsCacheCriticalSection);
pNlsRegUserInfo->ulCacheUpdateCount = 0;
RtlLeaveCriticalSection(&NlsCacheCriticalSection);
/* Get the LCID */
NtQueryDefaultLocale(0, &pNlsRegUserInfo->UserLocaleId);
}
/* PUBLIC SERVER APIS *********************************************************/
CSR_API(BaseSrvNlsSetUserInfo)
@ -268,8 +294,32 @@ CSR_API(BaseSrvNlsUpdateCacheCount)
CSR_API(BaseSrvNlsGetUserInfo)
{
DPRINT1("%s not yet implemented\n", __FUNCTION__);
return STATUS_NOT_IMPLEMENTED;
NTSTATUS Status;
PBASE_NLS_GET_USER_INFO NlsMsg = &((PBASE_API_MESSAGE)ApiMessage)->Data.NlsGetUserInfo;
/* Make sure the buffer is valid and of the right size */
if ((CsrValidateMessageBuffer(ApiMessage, &NlsMsg->NlsUserInfo, NlsMsg->Size, TRUE)) &&
(NlsMsg->Size == sizeof(NLS_USER_INFO)))
{
/* Acquire the lock to prevent updates while we copy */
Status = RtlEnterCriticalSection(&NlsCacheCriticalSection);
if (NT_SUCCESS(Status))
{
/* Do the copy now, then drop the lock */
RtlCopyMemory(&NlsMsg->NlsUserInfo, pNlsRegUserInfo, NlsMsg->Size);
DPRINT1("NLS Data copy complete\n");
RtlLeaveCriticalSection(&NlsCacheCriticalSection);
}
}
else
{
/* The data was invalid, bail out */
DPRINT1("NLS: Size of info is invalid: %lx vs %lx\n", NlsMsg->Size, sizeof(NLS_USER_INFO));
Status = STATUS_INVALID_PARAMETER;
}
/* All done */
return Status;
}
/* EOF */