PnpBuildUnsafeRemovalDeviceList
void __fastcall PnpBuildUnsafeRemovalDeviceList(__int64 a1, _RELATION_LIST *a2, _QWORD *a3){
int v5;
__int64 v6;
size_t v7;
VOID **PoolWithTag;
VOID **v9;
_QWORD *DeviceNode;
const VOID *v11;
_DEVICE_RELATION_LEVEL RelationLevel;
int v13;
_RELATION_LIST_MARKER Marker;
_DEVICE_OBJECT *DeviceObject;
v13 = HIDWORD(a1);
DeviceObject = 0i64;
RelationLevel = RELATION_LEVEL_REMOVE_EJECT;
*a3 = 0i64;
if( a2 )
{
v5 = 0;
Marker = 0i64;
while( IopEnumerateRelations(a2, &Marker, &DeviceObject, &RelationLevel, 0i64) )
{
if( RelationLevel
&& !PnpIsBeingRemovedSafely((_DWORD *)DeviceObject->DeviceObjectExtension->DeviceNode, RelationLevel) )
{
if( *(_QWORD *)(v6 + 48) )
v5 += *(unsigned __int16 *)(v6 + 40) + 2;
}
}
if( v5 )
{
v7 = v5 + 2;
PoolWithTag = ExAllocatePoolWithTag(1ui64, (unsigned int)(v5 + 2), 1265659472i64);
*a3 = PoolWithTag;
v9 = PoolWithTag;
if( PoolWithTag )
{
memset(PoolWithTag, 0i64, v7);
Marker = (_RELATION_LIST_MARKER)2i64;
while( IopEnumerateRelations(a2, &Marker, &DeviceObject, &RelationLevel, 0i64) )
{
if( RelationLevel )
{
DeviceNode = DeviceObject->DeviceObjectExtension->DeviceNode;
if( !PnpIsBeingRemovedSafely(DeviceNode, RelationLevel) )
{
v11 = (const VOID *)DeviceNode[6];
if( v11 )
{
memmove(v9, v11, *((unsigned __int16 *)DeviceNode + 20));
v9 = (VOID **)((char *)v9 + 2 * ((unsigned __int64)*((unsigned __int16 *)DeviceNode + 20) >> 1) + 2);
}
}
}
}
*(_WORD *)v9 = 0;
}
}
}
}Referenced by:
PnpProcessQueryRemoveAndEject