#include <ntoskrnl.h>
#include <debug.h>
Go to the source code of this file.
◆ BOGUS_LOCALE_ID
| #define BOGUS_LOCALE_ID 0xFFFF0000 |
◆ NDEBUG
◆ ExpGetCurrentUserUILanguage()
Definition at line 252 of file locale.c.
254{
255 UCHAR ValueBuffer[256];
268
269
271
272
275
276
280 UserKey,
284 {
285
290 ValueBuffer,
291 sizeof(ValueBuffer),
294 {
295
297 {
298
302 {
303
305 }
306 }
307 else
308 {
309
311 }
312 }
313
314
316 }
317
318
321}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define RTL_CONSTANT_STRING(s)
#define InitializeObjectAttributes(p, n, a, r, s)
_Must_inspect_result_ _Out_ PNDIS_STATUS _In_ NDIS_HANDLE _In_ ULONG _Out_ PNDIS_STRING _Out_ PNDIS_HANDLE KeyHandle
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI NTSTATUS NTAPI RtlOpenCurrentUser(_In_ ACCESS_MASK DesiredAccess, _Out_ PHANDLE KeyHandle)
@ KeyValuePartialInformation
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI NTSTATUS NTAPI RtlUnicodeStringToInteger(PUNICODE_STRING String, ULONG Base, PULONG Value)
struct _KEY_VALUE_PARTIAL_INFORMATION * PKEY_VALUE_PARTIAL_INFORMATION
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#define STATUS_UNSUCCESSFUL
_Must_inspect_result_ _In_ WDFDEVICE _In_ PCUNICODE_STRING KeyName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING ValueName
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _In_ ULONG ValueLength
_Must_inspect_result_ _In_ WDFKEY _In_ PCUNICODE_STRING _Out_opt_ PUSHORT _Inout_opt_ PUNICODE_STRING Value
Referenced by NtQueryDefaultUILanguage(), and NtSetDefaultUILanguage().
◆ ExpSetCurrentUserUILanguage()
Definition at line 325 of file locale.c.
327{
331 WCHAR ValueBuffer[8];
337
338
340 {
342 }
343
344
346
347
350
351
355 UserHandle,
357
358
361 {
362
365 {
366
368
369
373 0,
375 ValueBuffer,
377
378
380 }
381 }
382
383
386}
#define _swprintf(buf, format,...)
#define MAKELCID(lgid, srtid)
static NTSTATUS ExpValidateNlsLocaleId(_In_ LCID LocaleId)
Validates a NLS locale. Whether a locale is valid or not depends on the following conditions:
#define STATUS_INVALID_PARAMETER
Referenced by NtSetDefaultUILanguage().
◆ ExpValidateNlsLocaleData()
Validates the registry data of a NLS locale.
- Parameters
-
| [in] | LocaleData | A pointer to partial information that contains the NLS locale data. |
- Returns
- Returns TRUE if the following conditions are met, otherwise FALSE is returned.
Definition at line 48 of file locale.c.
50{
52
53
54 if (LocaleData->Type !=
REG_SZ)
55 {
57 }
58
59
60 if (LocaleData->DataLength <
sizeof(
WCHAR))
61 {
63 }
64
65
68 {
70 }
71
72
74}
Data(int index, int value)
Referenced by ExpValidateNlsLocaleId().
◆ ExpValidateNlsLocaleId()
Validates a NLS locale. Whether a locale is valid or not depends on the following conditions:
- The locale must exist in the Locale key, otherwise in the Alternate Sorts key;
- The locale must exist in the Language Groups key, and the queried value must be readable;
- The locale registry data must be of REG_SIZE type, has a consistent length and the locale belongs to a supported language group that is set.
- Parameters
-
| [in] | LocaleId | A locale identifier that corresponds to a specific locale to be validated. |
- Returns
- Returns STATUS_SUCCESS if the function has successfully validated the locale and it is valid. STATUS_OBJECT_NAME_NOT_FOUND is returned if the following locale does not exist on the system. A failure NTSTATUS code is returned otherwise.
Definition at line 103 of file locale.c.
105{
110 WCHAR ValueBuffer[20], LocaleIdBuffer[20];
116
117
119 &NlsLocaleKeyPath,
123
125 &AltSortKeyPath,
129
131 &LangGroupPath,
135
136
138
139
141
142
143 Status = ZwOpenKey(&NlsLocaleKey,
145 &NlsLocalKeyAttrs);
147 {
148 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", NlsLocaleKeyPath,
Status);
150 }
151
152
153 Status = ZwOpenKey(&AltSortKey,
155 &AltSortKeyAttrs);
157 {
158 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", AltSortKeyPath,
Status);
159 goto Quit;
160 }
161
162
163 Status = ZwOpenKey(&LangGroupKey,
165 &LangGroupKeyAttrs);
167 {
168 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", LangGroupPath,
Status);
169 goto Quit;
170 }
171
172
174 Status = ZwQueryValueKey(NlsLocaleKey,
175 &LocaleIdString,
177 BufferKey,
178 sizeof(ValueBuffer),
181 {
182
183 Status = ZwQueryValueKey(AltSortKey,
184 &LocaleIdString,
186 BufferKey,
187 sizeof(ValueBuffer),
190 {
191 DPRINT1(
"Failed to query value from Alternate Sorts key (Status 0x%lx)\n",
Status);
192 goto Quit;
193 }
194 }
195
196
199 {
200 DPRINT1(
"The queried locale is of bad value type or length (Type %lu, DataLength %lu)\n",
203 goto Quit;
204 }
205
206
208 Status = ZwQueryValueKey(LangGroupKey,
209 &LocaleIdString,
211 BufferKey,
212 sizeof(ValueBuffer),
215 {
216 DPRINT1(
"Failed to query value from Language Groups key (Status 0x%lx)\n",
Status);
217 goto Quit;
218 }
219
220
221
222
223
224
226 {
227 DPRINT1(
"The locale data is not valid!\n");
229 }
230
231Quit:
232 if (LangGroupKey !=
NULL)
233 {
235 }
236
237 if (AltSortKey !=
NULL)
238 {
240 }
241
242 if (NlsLocaleKey !=
NULL)
243 {
245 }
246
248}
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
static __inline BOOLEAN ExpValidateNlsLocaleData(_In_ PKEY_VALUE_PARTIAL_INFORMATION LocaleData)
Validates the registry data of a NLS locale.
#define STATUS_OBJECT_NAME_NOT_FOUND
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
Referenced by ExpSetCurrentUserUILanguage(), and NtSetDefaultLocale().
◆ NtQueryDefaultLocale()
◆ NtQueryDefaultUILanguage()
Definition at line 641 of file locale.c.
642{
646
647
649
650
652 {
653
655 {
656
658 }
659
661 {
662
663 *LanguageId = SafeLanguageId;
664 }
665 else
666 {
667
668
670 }
671 }
673 {
674
676 }
678
679
681}
LANGID PsInstallUILanguageId
NTSTATUS NTAPI ExpGetCurrentUserUILanguage(IN PCWSTR MuiName, OUT LANGID *LanguageId)
#define _SEH2_YIELD(__stmt)
Referenced by GetThreadUILanguage(), and GetUserDefaultUILanguage().
◆ NtQueryInstallUILanguage()
◆ NtSetDefaultLocale()
Definition at line 433 of file locale.c.
435{
442 WCHAR ValueBuffer[20];
445 UCHAR KeyValueBuffer[256];
448
449
451 {
453 }
454
455
456 if (UserProfile)
457 {
458
461
462
465 }
466 else
467 {
468
470 L"\\Registry\\Machine\\System\\CurrentControlSet"
471 L"\\Control\\Nls\\Language");
473 }
474
475
479 UserKey,
481
482
483 if (!DefaultLocaleId)
484 {
485
488 {
490 }
491
492
497 KeyValueInformation,
498 sizeof(KeyValueBuffer),
501 {
503 }
504
505
508 {
509
510 DefaultLocaleId = *((
ULONG*)KeyValueInformation->
Data);
511 }
512
514 {
515
519
520
522 }
523 else
524 {
526 }
527 }
528 else
529 {
530
533 {
534
537 {
538
539 if (UserProfile)
540 {
541
544 (
ULONG)DefaultLocaleId);
545 }
546 else
547 {
548
551 (
ULONG)DefaultLocaleId & 0xFFFF);
552 }
553
554
556
557
560 0,
562 ValueBuffer,
564 }
565 }
566 }
567
569
570
572 {
574 }
575
576
577 if (UserKey)
578 {
580 }
581
582
584 {
585
586 if (UserProfile)
587 {
588
589 MmSetSessionLocaleId(DefaultLocaleId);
590 }
591 else
592 {
593
595 }
596 }
597
598
600}
static const WCHAR Cleanup[]
NTSTATUS NTAPI ObCloseHandle(IN HANDLE Handle, IN KPROCESSOR_MODE AccessMode)
Referenced by LOCALE_Init(), LocaleDlgProc(), SaveCurrentLocale(), SetDefaultLanguage(), and START_TEST().
◆ NtSetDefaultUILanguage()
Definition at line 688 of file locale.c.
689{
692
693
694 if (LanguageId)
695 {
696
698 }
699 else
700 {
701
704 {
706 }
707
708
710 }
711
713}
NTSTATUS NTAPI ExpSetCurrentUserUILanguage(IN PCWSTR MuiName, IN LANGID LanguageId)
Referenced by LOCALE_Init().
◆ PsDefaultSystemLocaleId
| LCID PsDefaultSystemLocaleId = 0x00000409 |
◆ PsDefaultThreadLocaleId
| LCID PsDefaultThreadLocaleId = 0x00000409 |
◆ PsDefaultUILanguageId
◆ PsInstallUILanguageId