ExpGetGlobalLocaleSection
NTSTATUS __stdcall ExpGetGlobalLocaleSection(
VOID **SectionPointer,
UINT64 *CurrentVersion,
INT64 a3,
INT64 a4,
INT64 a5,
INT64 a6,
INT64 a7,
INT64 a8){
VOID *v8;
int v10;
NTSTATUS result;
VOID *v12;
int Section;
_ETHREAD *CurrentThread;
PVOID v15;
PVOID v16;
char v17;
unsigned __int64 *p_TrapFrame;
__int64 v19;
__int16 *v20;
__int16 v21;
__int16 *v22;
NTSTATUS v23;
VOID *v24;
INT64 Length;
UINT64 Lengtha;
UINT64 *ResultLength;
UINT64 *ResultLengtha;
INT64 v29;
INT64 v30;
VOID *FileHandle;
PVOID Object;
_OBJECT_ATTRIBUTES ObjectAttributes;
UINT64 v34;
VOID *KeyHandle;
VOID *SectionHandle;
_UNICODE_STRING DestinationString;
_IO_STATUS_BLOCK IoStatusBlock;
char KeyValueInformation[4];
int v40;
int v41;
int v42;
__int16 pszDest[264];
v8 = NlsLocaleSectionPointer;
*(&ObjectAttributes.Length + 1) = 0;
*(&ObjectAttributes.Attributes + 1) = 0;
IoStatusBlock = 0i64;
FileHandle = 0i64;
SectionHandle = 0i64;
v10 = 0;
KeyHandle = 0i64;
LODWORD(v34) = 0;
DestinationString = 0i64;
if( (unsigned __int64)NlsLocaleSectionPointer > 1 )
{
ObfReferenceObject(NlsLocaleSectionPointer);
LABEL_3:
*SectionPointer = v8;
return 0;
}
ObjectAttributes.RootDirectory = 0i64;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)L"ln";
ObjectAttributes.Length = 48;
ObjectAttributes.Attributes = 576;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
if( ZwOpenKey(&KeyHandle, 1ui64, &ObjectAttributes, a4, Length, (INT64)ResultLength, v29, v30) >= 0 )
{
LODWORD(Lengtha) = 20;
if( ZwQueryValueKey(
KeyHandle,
(_UNICODE_STRING *)&NlsTableVersionKeyName,
KeyValuePartialInformation,
KeyValueInformation,
Lengtha,
&v34) >= 0
&& v40 == 4
&& v41 == 4 )
{
v10 = v42;
p_TrapFrame = 0i64;
if( v42 == 5243136 )
p_TrapFrame = &stru_1407D9590.TrapFrame;
if( p_TrapFrame )
{
v19 = 260i64;
v20 = pszDest;
do
{
if( v19 == -2147483386 )
break;
v21 = *(__int16 *)((char *)v20 + (char *)&stru_1407D9590._MxCsr - (char *)pszDest);
if( !v21 )
break;
*v20++ = v21;
--v19;
}
while( v19 );
v22 = v20 - 1;
if( v19 )
v22 = v20;
*v22 = 0;
if( v19 && RtlStringCchCatW((WCHAR *)pszDest, 0x104ui64, (WCHAR *)p_TrapFrame) >= 0 )
{
RtlInitUnicodeString(&DestinationString, (PCWSTR)pszDest);
LODWORD(ResultLengtha) = 0;
ObjectAttributes.ObjectName = &DestinationString;
ObjectAttributes.Length = 48;
ObjectAttributes.RootDirectory = 0i64;
ObjectAttributes.Attributes = 576;
LODWORD(Lengtha) = 1;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
v23 = ZwOpenFile(&FileHandle, 0x100000ui64, &ObjectAttributes, &IoStatusBlock, Lengtha, (UINT64)ResultLengtha);
v24 = FileHandle;
if( v23 < 0 )
v24 = 0i64;
FileHandle = v24;
}
}
}
ZwClose((_HANDLE)KeyHandle);
}
v12 = FileHandle;
if( FileHandle )
{
LABEL_11:
LODWORD(ResultLengtha) = 0x8000000;
ObjectAttributes.Length = 48;
ObjectAttributes.RootDirectory = 0i64;
ObjectAttributes.Attributes = 576;
ObjectAttributes.ObjectName = 0i64;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
LODWORD(Lengtha) = 2;
Section = ZwCreateSection(
(UINT64)&SectionHandle,
4ui64,
(INT64)&ObjectAttributes,
0i64,
Lengtha,
(INT64)ResultLengtha,
(UINT64)v12);
ZwClose((_HANDLE)FileHandle);
if( Section < 0 )
return Section;
Object = 0i64;
Section = ObReferenceObjectByHandle(SectionHandle, 0xF001Fui64, MmSectionObjectType, 0, &Object, 0i64);
v8 = Object;
ZwClose((_HANDLE)SectionHandle);
if( Section < 0 )
return Section;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
ExAcquirePushLockExclusiveEx(&NlsSectionLock, 0i64);
v15 = NlsLocaleSectionPointer;
if( NlsLocaleSectionPointer == (PVOID)1 )
{
v16 = Object;
NlsTableVersion = v10;
ObfReferenceObject(Object);
NlsLocaleSectionPointer = v16;
}
else if( NlsLocaleSectionPointer )
{
HalPutDmaAdapter((PADAPTER_OBJECT)Object);
v8 = v15;
ObfReferenceObject(v15);
}
v17 = _InterlockedExchangeAdd64(&NlsSectionLock._bf_0, 0xFFFFFFFFFFFFFFFFui64);
if( (v17 & 2) != 0 && (v17 & 4) == 0 )
ExfTryToWakePushLock(&NlsSectionLock);
KeAbPostRelease(&NlsSectionLock);
KeLeaveCriticalRegionThread(&CurrentThread->Tcb);
goto LABEL_3;
}
LODWORD(ResultLengtha) = 0;
ObjectAttributes.ObjectName = (_UNICODE_STRING *)L">@";
ObjectAttributes.Length = 48;
ObjectAttributes.RootDirectory = 0i64;
ObjectAttributes.Attributes = 576;
LODWORD(Lengtha) = 1;
*(_OWORD *)&ObjectAttributes.SecurityDescriptor = 0i64;
result = ZwOpenFile(&FileHandle, 0x100000ui64, &ObjectAttributes, &IoStatusBlock, Lengtha, (UINT64)ResultLengtha);
if( result >= 0 )
{
v12 = FileHandle;
v10 = 263424;
goto LABEL_11;
}
return result;
}Referenced by:
NtInitializeNlsFiles