SshpGenerateDeviceFriendlyName
NTSTATUS __stdcall SshpGenerateDeviceFriendlyName(PDEVICE_OBJECT DeviceObject){
__int64 v1;
unsigned int v2;
_UNICODE_STRING *v3;
_DEVOBJ_EXTENSION *DeviceObjectExtension;
int v5;
_UNICODE_STRING *v6;
__int64 v7;
const _UNICODE_STRING *DeviceNode;
VOID **v10;
int v11;
NTSTATUS DeviceProperty;
int v13;
__int64 v14;
VOID **PoolWithTag;
__int64 v16;
VOID **v17;
signed int v18;
__int64 v19;
VOID **v20;
UINT64 Tag;
_UNICODE_STRING SourceString;
char v24;
DeviceObjectExtension = DeviceObject->DeviceObjectExtension;
v5 = 0;
v6 = v3;
Tag = v2;
v7 = v1;
DeviceNode = (const _UNICODE_STRING *)DeviceObjectExtension->DeviceNode;
v10 = 0i64;
SourceString = 0i64;
if( !DeviceNode )
{
v11 = -1073741811;
goto LABEL_46;
}
DeviceProperty = IoGetDeviceProperty(DeviceObject, 0, 0i64, 0i64, (UINT64 *)((char *)&Tag + 4));
v11 = DeviceProperty;
if( DeviceProperty == -1073741789 )
{
if( HIDWORD(Tag) > 0xFFFF )
{
v11 = -2147483643;
goto LABEL_45;
}
v5 = HIDWORD(Tag) + 4;
}
else if( DeviceProperty != -1073741772 )
{
goto LABEL_44;
}
v13 = DeviceNode[8].Length + v5;
if( v7 )
{
SourceString.Buffer = (wchar_t *)&v24;
*(_DWORD *)&SourceString.Length = 0x400000;
v11 = RtlUnicodeStringPrintf(&SourceString, (WCHAR *)L" (%d)");
if( v11 < 0 )
goto LABEL_45;
v13 += SourceString.Length;
}
if( !v13 )
{
v11 = -1073741811;
goto LABEL_45;
}
v2 = Tag;
v14 = (unsigned int)(v13 + 2);
if( (unsigned int)v14 >= 0xFFFF )
{
v11 = -2147483643;
goto LABEL_46;
}
PoolWithTag = ExAllocatePoolWithTag(1ui64, 2 * v14, (unsigned int)Tag);
v10 = PoolWithTag;
if( !PoolWithTag )
{
v11 = -1073741670;
goto LABEL_45;
}
memset(PoolWithTag, 0i64, v14);
if( HIDWORD(Tag) )
{
v11 = IoGetDeviceProperty(DeviceObject, 0, HIDWORD(Tag), v10, (UINT64 *)((char *)&Tag + 4));
if( v11 < 0 )
goto LABEL_45;
*v6 = 0i64;
v16 = 0x7FFFi64;
v17 = v10;
do
{
if( !*(_WORD *)v17 )
break;
v17 = (VOID **)((char *)v17 + 2);
--v16;
}
while( v16 );
v18 = v16 == 0 ? 0xC000000D : 0;
if( v16 )
{
if( v6 )
{
v6->Buffer = (wchar_t *)v10;
v6->Length = 2 * (v16 != 0 ? 0x7FFF - v16 : 0);
}
else
{
v18 = -1073741811;
}
}
v6->MaximumLength = v14;
v11 = v18;
if( v18 < 0 )
goto LABEL_45;
v11 = RtlUnicodeStringCatString(v6);
}
else
{
*v6 = 0i64;
v19 = 0x7FFFi64;
v20 = v10;
do
{
if( !*(_WORD *)v20 )
break;
v20 = (VOID **)((char *)v20 + 2);
--v19;
}
while( v19 );
if( v19 && v6 )
{
v6->Buffer = (wchar_t *)v10;
v6->Length = 2 * (v19 != 0 ? 0x7FFF - v19 : 0);
}
v6->MaximumLength = v14;
v11 = 0;
}
if( v11 >= 0 )
{
v11 = RtlUnicodeStringCat(v6, DeviceNode + 8);
if( v11 >= 0 )
{
if( HIDWORD(Tag) )
v11 = RtlUnicodeStringCatString(v6);
if( v11 >= 0 )
{
if( v7 )
v11 = RtlUnicodeStringCat(v6, &SourceString);
if( v11 >= 0 )
{
v11 = 0;
LABEL_44:
v10 = 0i64;
if( v11 >= 0 )
return v11;
}
}
}
}
LABEL_45:
v2 = Tag;
LABEL_46:
*v6 = 0i64;
if( v10 )
CmpFreeTransientPoolWithTag(v10, v2);
return v11;
}Referenced by:
SleepstudyHelperCreateBlockerFromComponent
SleepstudyHelperCreateBlockerFromDevice
SleepstudyHelper_GetPdoFriendlyName