PopGenerateDeviceFriendlyName
INT64 __fastcall PopGenerateDeviceFriendlyName(INT64 a1, UNICODE_STRING *a2){
_DEVICE_OBJECT *v2;
NTSTATUS DeviceProperty;
signed int v6;
const _UNICODE_STRING *v7;
ULONG v8;
void *PoolWithTag;
__int64 v10;
_WORD *v11;
int v12;
int v13;
unsigned __int64 Length;
unsigned __int16 v16;
wchar_t *v17;
UNICODE_STRING *v18;
ULONG BufferLength;
*a2 = 0i64;
v2 = *(_DEVICE_OBJECT **)(a1 + 32);
BufferLength = 0;
DeviceProperty = IoGetDeviceProperty(v2, DevicePropertyDeviceDescription, 0, 0i64, &BufferLength);
v6 = DeviceProperty;
if( DeviceProperty == -1073741789 )
{
if( BufferLength > 0xFFFF
|| (v7 = (const _UNICODE_STRING *)(a1 + 128), v8 = *(unsigned __int16 *)(a1 + 128) + BufferLength + 6, v8 > 0xFFFF) )
{
v6 = -2147483643;
goto LABEL_25;
}
PoolWithTag = ExAllocatePoolWithTag(PagedPool, v8, 0x4D584650ui64);
if( PoolWithTag )
{
v6 = IoGetDeviceProperty(v2, DevicePropertyDeviceDescription, BufferLength, PoolWithTag, &BufferLength);
if( v6 < 0 )
goto LABEL_20;
*a2 = 0i64;
v10 = 0x7FFFi64;
v11 = PoolWithTag;
do
{
if( !*v11 )
break;
++v11;
--v10;
}
while( v10 );
v6 = v10 == 0 ? 0xC000000D : 0;
if( v10 )
{
if( a2 )
{
a2->Buffer = (wchar_t *)PoolWithTag;
a2->Length = 2 * (v10 != 0 ? 0x7FFF - v10 : 0);
}
else
{
v6 = -1073741811;
}
}
a2->MaximumLength = v8;
if( v6 < 0 )
goto LABEL_20;
RtlUnicodeStringCatString(a2, (PWCHAR)L" (");
v6 = v12;
if( v12 < 0 )
goto LABEL_20;
v6 = RtlUnicodeStringCat(a2, v7);
if( v6 < 0 )
goto LABEL_20;
RtlUnicodeStringCatString(a2, (PWCHAR)L")");
v6 = v13;
if( v13 < 0 )
goto LABEL_20;
Length = a2->Length;
if( Length > (unsigned __int64)a2->MaximumLength - 2 )
v6 = -2147483643;
else
a2->Buffer[Length >> 1] = 0;
if( v6 < 0 )
goto LABEL_20;
goto LABEL_19;
}
LABEL_27:
v6 = -1073741670;
goto LABEL_25;
}
if( DeviceProperty != -1073741772 )
goto LABEL_22;
v16 = *(_WORD *)(a1 + 128);
v17 = (wchar_t *)ExAllocatePoolWithTag(PagedPool, v16, 0x4D584650ui64);
if( !v17 )
goto LABEL_27;
a2->Buffer = v17;
a2->Length = 0;
a2->MaximumLength = v16;
RtlCopyUnicodeString(a2, (UNICODE_STRING *)(a1 + 128), v18);
LABEL_19:
PoolWithTag = 0i64;
v6 = 0;
LABEL_20:
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0x4D584650u);
LABEL_22:
if( v6 < 0 )
LABEL_25:
*a2 = 0i64;
return(unsigned int)v6;
}Referenced by:
PopDirectedDripsDiagCreateDeviceDescription
PopFxRegisterDevice