IopQueryNameInternal
NTSTATUS __stdcall IopQueryNameInternal(
VOID *Object,
UINT8 UseDosDeviceName,
_OBJECT_NAME_INFORMATION *ObjectNameInfo,
UINT64 Length,
UINT64 *ReturnLength,
INT8 Mode){
_QWORD *v6;
__int128 *v7;
char v8;
unsigned int v9;
__int128 *v10;
_DWORD *v11;
int v12;
UINT64 v13;
char *v14;
char v15;
size_t v16;
_DWORD *v17;
_KPROCESSOR_MODE v18;
char v19;
_DWORD *v20;
__int128 *v21;
NTSTATUS FileInformation;
int v23;
size_t v24;
size_t v25;
char *v26;
__int128 *PoolWithTagPriority;
unsigned int v29;
int v30;
UINT64 ReturnedLength;
char *v32;
PVOID P;
__int128 v34[5];
bool v36;
char v37;
char v38;
char v40;
v38 = (char)ObjectNameInfo;
v6 = Object;
LODWORD(ReturnedLength) = 0;
v7 = 0i64;
P = 0i64;
v36 = 0;
v8 = 0;
v34[0] = 0i64;
v9 = 16;
if( (unsigned int)ReturnLength >= 0x10 )
v9 = (unsigned int)ReturnLength;
if( v40 == 1 )
{
if( VfIsVerifierEnabled()
&& ((*(&stru_140CF2E80 + 1826) & 0xFFAFFFFF) != 0
|| (*(&stru_140CF2E80 + 7308) & 2) != 0
|| (*(&stru_140CF2E80 + 7308) & 4) != 0) )
{
PoolWithTagPriority = (__int128 *)ExAllocatePoolWithTagPriority(
PagedPool,
v9,
0x20206F49ui64,
(_EX_POOL_PRIORITY)((MmVerifierData & 0x10 | 0x40) >> 1));
}
else
{
PoolWithTagPriority = (__int128 *)ExAllocatePoolWithTag(1ui64, v9, 538996553i64);
}
v7 = PoolWithTagPriority;
P = PoolWithTagPriority;
if( !PoolWithTagPriority )
{
v12 = -1073741670;
goto LABEL_45;
}
v10 = PoolWithTagPriority;
v6 = Object;
}
else
{
v10 = v34;
if( (unsigned int)ReturnLength >= 0x10 )
v10 = (__int128 *)Length;
}
v11 = (_DWORD *)v6[1];
if( !v38 )
goto LABEL_48;
if( (v11[13] & 0x10) == 0 )
{
v12 = IoVolumeDeviceToDosName(v11, (_UNICODE_STRING *)v10);
LODWORD(ReturnedLength) = *(unsigned __int16 *)v10 + 18;
v6 = Object;
goto LABEL_9;
}
LODWORD(ReturnedLength) = 20;
if( v9 >= 0x14 )
{
v12 = 0;
*(_DWORD *)v10 = 131074;
*((_WORD *)v10 + 8) = 92;
*((_QWORD *)v10 + 1) = v10 + 1;
LABEL_9:
if( v12 >= 0 )
{
v8 = 1;
goto LABEL_11;
}
}
v11 = (_DWORD *)v6[1];
LABEL_48:
v12 = ObQueryNameStringMode(v11, (_OBJECT_NAME_INFORMATION *)v10, v9, &ReturnedLength, 0);
LABEL_11:
if( v12 < 0 )
{
if( v12 != -1073741820 )
goto LABEL_45;
}
else if( !v8 )
{
v36 = *(_WORD *)v10 == 0;
}
v13 = Length;
v14 = (char *)(Length + 16);
v15 = v38;
if( v38 && v8 )
{
if( v9 < (unsigned int)ReturnedLength )
v16 = v9 - 16;
else
v16 = *(unsigned __int16 *)v10;
memmove((VOID *)(Length + 16), *((const VOID **)v10 + 1), v16);
v17 = Object;
v18 = 16;
if( (*(_DWORD *)(*((_QWORD *)Object + 1) + 52i64) & 0x10) == 0 )
{
ExFreePoolWithTag(*((PVOID *)v10 + 1), 0);
v13 = Length;
v15 = v38;
LABEL_20:
v18 = 16;
LABEL_21:
v17 = Object;
goto LABEL_22;
}
v13 = Length;
v15 = v38;
}
else
{
if( v40 != 1 )
goto LABEL_20;
v18 = 16;
if( (unsigned int)ReturnLength < 0x10 || (unsigned int)ReturnedLength > v9 )
goto LABEL_21;
*(_WORD *)Length = *(_WORD *)v10;
*(_WORD *)(Length + 2) = *((_WORD *)v10 + 1);
memmove(v14, v10 + 1, ReturnedLength - 16);
v13 = Length;
v17 = Object;
v15 = v38;
v18 = 16;
}
LABEL_22:
if( v36 )
LODWORD(ReturnedLength) = ReturnedLength + 2;
v19 = 0;
v37 = 0;
if( (unsigned int)ReturnLength < 0x10 || (unsigned int)ReturnedLength > v9 )
{
v20 = (_DWORD *)Mode;
*(_DWORD *)Mode = ReturnedLength;
v19 = 1;
v37 = 1;
}
else
{
*(_QWORD *)(v13 + 8) = v14;
v14 += *(unsigned __int16 *)v10;
v20 = (_DWORD *)Mode;
}
if( v40 == 1 )
{
v21 = v7;
if( !v19 )
v9 = v9 - ReturnedLength + 4;
}
else if( v19 )
{
v21 = v34;
if( (unsigned int)ReturnLength >= 0x10 )
v21 = (__int128 *)v13;
}
else
{
v21 = (__int128 *)(v14 - 4);
LODWORD(v32) = *((_DWORD *)v14 - 1);
v9 = v13 + v9 - ((_DWORD)v14 - 4) - 2;
}
if( (v40 != 1 || v15) && (v17[20] & 2) != 0 )
{
FileInformation = IopGetFileInformation(v17, v9, FileNameInformation, v21, &ReturnedLength);
}
else
{
LOBYTE(v18) = v40;
FileInformation = IopQueryXxxInformation(v17, 9ui64, v9, v18, v21, &ReturnedLength, 1u);
}
v12 = FileInformation;
if( (FileInformation & 0xC0000000) == -1073741824 )
{
v29 = FileInformation + 1073741822;
if( (unsigned int)(v12 + 1073741822) > 0xE )
goto LABEL_45;
v30 = 18435;
if( !_bittest(&v30, v29) )
goto LABEL_45;
LODWORD(ReturnedLength) = 4;
*(_DWORD *)v21 = 0;
*((_WORD *)v21 + 2) = 92;
v12 = 0;
v23 = ReturnedLength;
}
else
{
v23 = ReturnedLength;
if( (unsigned int)ReturnedLength < 4 )
v23 = 4;
LODWORD(ReturnedLength) = v23;
}
if( v37 )
{
*v20 += *(_DWORD *)v21;
v12 = (unsigned int)ReturnLength < 0x10 ? -1073741820 : -2147483643;
}
else
{
v24 = v23 - 4;
v25 = *(_DWORD *)v21;
if( v24 <= *(_DWORD *)v21 )
v25 = v24;
LODWORD(ReturnedLength) = (_DWORD)v14 + *(_DWORD *)v21 - Length;
if( *((_WORD *)v21 + 2) == 92 )
{
if( v40 == 1 )
memmove(v14, (char *)v21 + 4, v25);
else
*(_DWORD *)v21 = (_DWORD)v32;
v26 = &v14[v25];
v32 = v26;
*(_WORD *)v26 = 0;
LODWORD(ReturnedLength) = ReturnedLength + 2;
*v20 = ReturnedLength;
LOWORD(v26) = (_WORD)v26 - Length;
*(_WORD *)Length = (_WORD)v26 - 16;
*(_WORD *)(Length + 2) = (_WORD)v26 - 14;
}
else
{
v12 = -1073741767;
}
}
LABEL_45:
if( v7 )
ExFreePoolWithTag(v7, 0);
return v12;
}Referenced by:
IoQueryFileDosDeviceName
IopQueryName