#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 254 of file locale.c.
256{
257 UCHAR ValueBuffer[256];
270
271
273
274
277
278
282 UserKey,
286 {
287
292 ValueBuffer,
293 sizeof(ValueBuffer),
296 {
297
299 {
300
304 {
305
307 }
308 }
309 else
310 {
311
313 }
314 }
315
316
318 }
319
320
323}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
#define NT_SUCCESS(StatCode)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
#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 RTL_CONSTANT_STRING(s)
#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 327 of file locale.c.
329{
333 WCHAR ValueBuffer[8];
339
340
342 {
344 }
345
346
348
349
352
353
357 UserHandle,
359
360
363 {
364
367 {
368
372
373
377 0,
379 ValueBuffer,
381
382
384 }
385 }
386
387
390}
#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
140
141
143
144
145 Status = ZwOpenKey(&NlsLocaleKey,
147 &NlsLocalKeyAttrs);
149 {
150 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", NlsLocaleKeyPath,
Status);
152 }
153
154
155 Status = ZwOpenKey(&AltSortKey,
157 &AltSortKeyAttrs);
159 {
160 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", AltSortKeyPath,
Status);
161 goto Quit;
162 }
163
164
165 Status = ZwOpenKey(&LangGroupKey,
167 &LangGroupKeyAttrs);
169 {
170 DPRINT1(
"Failed to open %wZ (Status 0x%lx)\n", LangGroupPath,
Status);
171 goto Quit;
172 }
173
174
176 Status = ZwQueryValueKey(NlsLocaleKey,
177 &LocaleIdString,
179 BufferKey,
180 sizeof(ValueBuffer),
183 {
184
185 Status = ZwQueryValueKey(AltSortKey,
186 &LocaleIdString,
188 BufferKey,
189 sizeof(ValueBuffer),
192 {
193 DPRINT1(
"Failed to query value from Alternate Sorts key (Status 0x%lx)\n",
Status);
194 goto Quit;
195 }
196 }
197
198
201 {
202 DPRINT1(
"The queried locale is of bad value type or length (Type %lu, DataLength %lu)\n",
205 goto Quit;
206 }
207
208
210 Status = ZwQueryValueKey(LangGroupKey,
211 &LocaleIdString,
213 BufferKey,
214 sizeof(ValueBuffer),
217 {
218 DPRINT1(
"Failed to query value from Language Groups key (Status 0x%lx)\n",
Status);
219 goto Quit;
220 }
221
222
223
224
225
226
228 {
229 DPRINT1(
"The locale data is not valid!\n");
231 }
232
233Quit:
234 if (LangGroupKey !=
NULL)
235 {
237 }
238
239 if (AltSortKey !=
NULL)
240 {
242 }
243
244 if (NlsLocaleKey !=
NULL)
245 {
247 }
248
250}
_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()
Definition at line 396 of file locale.c.
398{
401
402
404 {
405
407 {
408
410 }
411
412
413 if (UserProfile)
414 {
415
417 }
418 else
419 {
420
422 }
423 }
425 {
426
428 }
430
431
433}
LONG NTAPI ExSystemExceptionFilter(VOID)
#define KeGetPreviousMode()
LCID PsDefaultSystemLocaleId
ULONG NTAPI MmGetSessionLocaleId(VOID)
#define _SEH2_GetExceptionCode()
#define _SEH2_EXCEPT(...)
#define ProbeForWriteLangId(Ptr)
Referenced by BaseSrvNLSInit(), find_entry(), GetSystemDefaultLCID(), GetUserDefaultLCID(), and UserInitHardErrorsCache().
◆ NtQueryDefaultUILanguage()
Definition at line 645 of file locale.c.
646{
650
651
653
654
656 {
657
659 {
660
662 }
663
665 {
666
667 *LanguageId = SafeLanguageId;
668 }
669 else
670 {
671
672
674 }
675 }
677 {
678
680 }
682
683
685}
LANGID PsInstallUILanguageId
NTSTATUS NTAPI ExpGetCurrentUserUILanguage(IN PCWSTR MuiName, OUT LANGID *LanguageId)
#define _SEH2_YIELD(__stmt)
Referenced by GetUserDefaultUILanguage().
◆ NtQueryInstallUILanguage()
◆ NtSetDefaultLocale()
Definition at line 437 of file locale.c.
439{
446 WCHAR ValueBuffer[20];
449 UCHAR KeyValueBuffer[256];
452
453
455 {
457 }
458
459
460 if (UserProfile)
461 {
462
465
466
469 }
470 else
471 {
472
474 L"\\Registry\\Machine\\System\\CurrentControlSet"
475 L"\\Control\\Nls\\Language");
477 }
478
479
483 UserKey,
485
486
487 if (!DefaultLocaleId)
488 {
489
492 {
494 }
495
496
501 KeyValueInformation,
502 sizeof(KeyValueBuffer),
505 {
507 }
508
509
512 {
513
514 DefaultLocaleId = *((
ULONG*)KeyValueInformation->
Data);
515 }
516
518 {
519
523
524
526 }
527 else
528 {
530 }
531 }
532 else
533 {
534
537 {
538
541 {
542
543 if (UserProfile)
544 {
545
548 (
ULONG)DefaultLocaleId);
549 }
550 else
551 {
552
555 (
ULONG)DefaultLocaleId & 0xFFFF);
556 }
557
558
560
561
564 0,
566 ValueBuffer,
568 }
569 }
570 }
571
573
574
576 {
578 }
579
580
581 if (UserKey)
582 {
584 }
585
586
588 {
589
590 if (UserProfile)
591 {
592
593 MmSetSessionLocaleId(DefaultLocaleId);
594 }
595 else
596 {
597
599 }
600 }
601
602
604}
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 692 of file locale.c.
693{
696
697
698 if (LanguageId)
699 {
700
702 }
703 else
704 {
705
708 {
710 }
711
712
714 }
715
717}
NTSTATUS NTAPI ExpSetCurrentUserUILanguage(IN PCWSTR MuiName, IN LANGID LanguageId)
Referenced by LOCALE_Init().
◆ PsDefaultSystemLocaleId
LCID PsDefaultSystemLocaleId = 0x00000409 |
◆ PsDefaultThreadLocaleId
LCID PsDefaultThreadLocaleId = 0x00000409 |
◆ PsDefaultUILanguageId
◆ PsInstallUILanguageId