NtSetDefaultLocale
NTSTATUS __stdcall NtSetDefaultLocale(UINT8 UserProfile, UINT64 DefaultLocaleId){
_UNICODE_STRING *v2;
int v3;
NTSTATUS result;
INT64 v6;
unsigned int v7;
int v8;
int *v9;
unsigned int i;
int v11;
unsigned int v12;
_EPROCESS *Process;
_MM_SESSION_SPACE *Session;
_OBJECT_TYPE *v15;
unsigned int v16;
_WORD *v17;
__int16 *v18;
__int16 *v19;
unsigned int v20;
__int16 v21;
VOID **Length;
UINT64 Lengtha;
UINT64 *ResultLength;
UINT64 *ResultLengtha;
VOID *KeyHandle;
INT64 v27;
void *userContext;
_UNICODE_STRING userContext_8;
_UNICODE_STRING DestinationString_8;
_OBJECT_ATTRIBUTES ObjectAttributes;
__int16 KeyValueInformation[2];
int v33;
unsigned int v34;
int v35;
*(&ObjectAttributes.Length + 1) = 0;
*(&ObjectAttributes.Attributes + 1) = 0;
v3 = DefaultLocaleId;
userContext = 0i64;
KeyHandle = 0i64;
LODWORD(v27) = 0;
DestinationString_8 = 0i64;
userContext_8 = 0i64;
if( UserProfile )
{
result = OpenGlobalizationUserSettingsKey(UserProfile, (VOID **)DefaultLocaleId, &userContext, v2, Length);
if( result < 0 )
return result;
RtlInitUnicodeString(&userContext_8, L"Locale");
RtlInitUnicodeString(&DestinationString_8, L"Control Panel\\International");
v7 = 1600;
}
else
{
result = ExCheckFullProcessInformationAccess(KeGetCurrentThread()->PreviousMode);
if( result < 0 )
return result;
RtlInitUnicodeString(&userContext_8, L"Default");
RtlInitUnicodeString(
&DestinationString_8,
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Nls\\Language");
v7 = 576;
}
ObjectAttributes.RootDirectory = userContext;
ObjectAttributes.ObjectName = &DestinationString_8;
ObjectAttributes.Length = 48;
ObjectAttributes.Attributes = v7;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
if( v3 )
{
if( !UserProfile || RtlIsMultiSessionSku() )
{
v8 = ZwOpenKey(
&KeyHandle,
0x40000000ui64,
&ObjectAttributes,
v6,
(INT64)Length,
(INT64)ResultLength,
(INT64)KeyHandle,
v27);
if( v8 < 0 )
goto LABEL_17;
v16 = v3;
v17 = (__int16 *)((char *)KeyValueInformation + (UserProfile != 0 ? 16i64 : 8i64));
*v17 = 0;
v18 = v17 - 1;
if( v18 >= KeyValueInformation )
{
do
{
v19 = v18 - 1;
v20 = v16 & 0xF;
v21 = 48;
if( v20 > 9 )
v21 = 55;
v16 >>= 4;
*v18-- = v20 + v21;
}
while( v19 >= KeyValueInformation );
}
LODWORD(ResultLengtha) = UserProfile != 0 ? 18 : 10;
v8 = ZwSetValueKey(KeyHandle, &userContext_8, 0i64, 1ui64, KeyValueInformation, (UINT64)ResultLengtha);
}
else
{
v8 = ZwOpenKey(
&KeyHandle,
0x40000000ui64,
&ObjectAttributes,
v6,
(INT64)Length,
(INT64)ResultLength,
(INT64)KeyHandle,
v27);
if( v8 < 0 )
goto LABEL_17;
ZwDeleteValueKey(KeyHandle, &userContext_8, v15);
}
goto LABEL_16;
}
v8 = ZwOpenKey(
&KeyHandle,
0x80000000ui64,
&ObjectAttributes,
v6,
(INT64)Length,
(INT64)ResultLength,
(INT64)KeyHandle,
v27);
if( v8 >= 0 )
{
LODWORD(Lengtha) = 256;
v8 = ZwQueryValueKey(
KeyHandle,
&userContext_8,
KeyValuePartialInformation,
KeyValueInformation,
Lengtha,
(UINT64 *)&v27);
if( v8 >= 0 )
{
if( v33 == 1 )
{
v9 = &v35;
for( i = 0; i < v34; v3 = v12 | (16 * v3) )
{
v11 = *(unsigned __int16 *)v9;
v9 = (int *)((char *)v9 + 2);
if( (unsigned __int16)(v11 - 48) > 9u )
{
if( (unsigned __int16)(v11 - 65) <= 5u )
{
v12 = v11 - 55;
}
else
{
if( (unsigned __int16)(v11 - 97) > 5u )
break;
v12 = v11 - 87;
}
}
else
{
v12 = v11 - 48;
}
if( v12 >= 0x10 )
break;
i += 2;
}
}
else if( v33 == 4 && v34 == 4 )
{
v3 = v35;
}
else
{
v8 = -1073741823;
}
}
LABEL_16:
ZwClose((_HANDLE)KeyHandle);
}
LABEL_17:
if( userContext )
ZwClose((_HANDLE)userContext);
if( v8 >= 0 )
{
if( UserProfile )
{
Process = KeGetCurrentThread()->ApcState.Process;
Session = Process->Session;
if( !Session || (Process->Flags3 & 0x1000) != 0 )
PsDefaultThreadLocaleId = v3;
else
*((_DWORD *)Session + 24) = v3;
}
else
{
PsDefaultSystemLocaleId = v3;
}
}
return v8;
}Referenced by:
No references.