PiGetRelatedDevice
NTSTATUS __stdcall PiGetRelatedDevice(
_UNICODE_STRING *TargetDeviceInstance,
WCHAR *RelatedDeviceInstance,
UINT64 *RelatedDeviceInstanceLength,
UINT64 Relation){
NTSTATUS v5;
int v6;
_QWORD *v9;
VOID *v10;
__int64 *v11;
__int64 v12;
int v14;
_ETHREAD *CurrentThread;
_QWORD *v16;
int v17;
v5 = 0;
v6 = Relation;
PpDevNodeLockTree(PPL_SIMPLE_READ);
v9 = PnpDeviceObjectFromDeviceInstanceWithTag((__int64)TargetDeviceInstance, 0x43706E50u);
v10 = v9;
if( !v9 || (v11 = *(__int64 **)(v9[39] + 40i64)) == 0i64 || (unsigned int)(*((_DWORD *)v11 + 75) - 787) <= 1 )
{
LABEL_14:
v5 = -1073741810;
goto LABEL_11;
}
switch( v6 )
{
case 1:
v11 = (__int64 *)v11[2];
goto LABEL_6;
case 2:
v11 = (__int64 *)v11[1];
if( !v11
|| (v14 = *((_DWORD *)v11 + 99), (v14 & 0x2000) == 0)
|| *((_DWORD *)v11 + 101) != 24
|| (v14 & 0x1000) == 0 )
{
LABEL_18:
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
--CurrentThread->Tcb.KernelApcDisable;
ExAcquireResourceSharedLite((UINT64)&PnpReplaceEvent + 6688, 1);
if( v11 )
{
while( 1 )
{
if( v11[6] )
{
v16 = PnpDeviceObjectFromDeviceInstanceWithTag((__int64)(v11 + 5), 0x43706E50u);
if( v16 )
break;
}
v11 = (__int64 *)*v11;
if( !v11 )
goto LABEL_22;
}
ObfDereferenceObjectWithTag(v16, 0x43706E50ui64);
}
LABEL_22:
ExReleaseResourceLite((PERESOURCE)((char *)&PnpReplaceEvent + 6688));
KeLeaveCriticalRegion();
LABEL_7:
if( v11 )
{
v12 = *((unsigned __int16 *)v11 + 20);
if( *(_DWORD *)RelatedDeviceInstanceLength <= (unsigned int)v12 )
{
v5 = -1073741789;
LODWORD(v12) = v12 + 2;
}
else
{
memmove(RelatedDeviceInstance, (const VOID *)v11[6], *((unsigned __int16 *)v11 + 20));
*(WCHAR *)((char *)RelatedDeviceInstance + v12) = 0;
}
*(_DWORD *)RelatedDeviceInstanceLength = v12;
goto LABEL_11;
}
goto LABEL_14;
}
goto LABEL_24;
case 3:
do
{
LABEL_24:
v11 = (__int64 *)*v11;
if( !v11 )
break;
v17 = *((_DWORD *)v11 + 99);
if( (v17 & 0x2000) == 0 )
break;
}
while( *((_DWORD *)v11 + 101) == 24 && (v17 & 0x1000) != 0 );
LABEL_6:
if( v6 == 1 )
goto LABEL_7;
goto LABEL_18;
}
v5 = -1073741811;
LABEL_11:
PpDevNodeUnlockTree(PPL_SIMPLE_READ);
if( v10 )
ObfDereferenceObjectWithTag(v10, 0x43706E50ui64);
return v5;
}Referenced by:
PiCMGetRelatedDeviceInstance
PiControlGetRelatedDevice