IopGetRootDevices
NTSTATUS __stdcall IopGetRootDevices(_DEVICE_RELATIONS **DeviceRelations){
VOID **PoolWithTag;
INT64 v3;
_ETHREAD *CurrentThread;
int inited;
unsigned int v6;
NTSTATUS MatchingFilteredDeviceList;
WCHAR *v8;
INT64 v9;
int v10;
__int64 v11;
__int64 v12;
VOID **v13;
_DEVICE_RELATIONS *v14;
VOID *v15;
PADAPTER_OBJECT *v17;
UINT64 DesiredAccess;
VOID *v19;
WCHAR *v20;
_UNICODE_STRING DestinationString;
__int128 Context;
VOID *Src;
_CM_OBJECT_TYPE v24;
VOID *DeviceKey;
*DeviceRelations = 0i64;
DeviceKey = 0i64;
PoolWithTag = 0i64;
Context = 0i64;
DestinationString = 0i64;
Src = ExAllocatePoolWithTag(1ui64, 0x400ui64, 1684303952i64);
if( !Src )
return -1073741670;
CurrentThread = (_ETHREAD *)KeGetCurrentThread();
*(_QWORD *)((char *)&Context + 4) = 128i64;
--CurrentThread->Tcb.KernelApcDisable;
ExAcquireResourceExclusiveLite((UINT64)&PnpReplaceEvent + 6688, 1, v3);
v24 = 2048;
inited = -1073741789;
v6 = 0;
while( v6 < 5 )
{
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
PoolWithTag = ExAllocatePoolWithTag(1ui64, 2i64 * (unsigned int)v24, 1684303952i64);
if( !PoolWithTag )
{
inited = -1073741670;
break;
}
MatchingFilteredDeviceList = CmGetMatchingFilteredDeviceList(
*(&stru_140CF2E80 + 607),
L"Root",
CM_DEVICE_LIST_FILTER_ENUMERATOR,
0i64,
0i64,
(const WCHAR *)PoolWithTag,
v24,
&v24,
v19,
v20,
*(UINT64 *)&DestinationString.Length,
(UINT64 *)DestinationString.Buffer,
Context);
++v6;
inited = MatchingFilteredDeviceList;
if( MatchingFilteredDeviceList != -1073741789 )
{
if( MatchingFilteredDeviceList < 0 )
break;
v8 = (WCHAR *)PoolWithTag;
LODWORD(Context) = 0;
if( *(_WORD *)PoolWithTag )
{
while( 1 )
{
LODWORD(DesiredAccess) = 983103;
inited = CmOpenDeviceRegKey(
*(&stru_140CF2E80 + 607),
v8,
CM_KEY_TYPE_DEVICE_INSTANCE,
0i64,
DesiredAccess,
0,
&DeviceKey,
0i64);
if( inited < 0 )
break;
inited = RtlInitUnicodeStringEx(&DestinationString, v8);
if( inited >= 0 )
{
IopInitializeDeviceInstanceKey(DeviceKey, &DestinationString, &Context, v9);
if( !v10 )
{
ZwClose((_HANDLE)DeviceKey);
goto LABEL_17;
}
}
ZwClose((_HANDLE)DeviceKey);
if( inited < 0 )
break;
v11 = -1i64;
do
++v11;
while( v8[v11] );
v8 += v11 + 1;
if( !*v8 )
goto LABEL_17;
}
LABEL_31:
v12 = DWORD2(Context);
if( !DWORD2(Context) )
goto LABEL_32;
LABEL_21:
if( inited >= 0 )
break;
}
else
{
LABEL_17:
inited = Context;
if( (int)Context < 0 )
goto LABEL_31;
v12 = DWORD2(Context);
if( !DWORD2(Context) )
{
LABEL_32:
inited = -1073741823;
goto LABEL_21;
}
v13 = ExAllocatePoolWithTag(1ui64, 8i64 * DWORD2(Context) + 16, 1684303952i64);
v14 = (_DEVICE_RELATIONS *)v13;
if( v13 )
{
v15 = Src;
*(_DWORD *)v13 = v12;
memmove(v13 + 1, v15, 8 * v12);
*DeviceRelations = v14;
goto LABEL_21;
}
inited = -1073741670;
}
if( (_DWORD)v12 )
{
v17 = (PADAPTER_OBJECT *)Src;
do
{
HalPutDmaAdapter(*v17++);
--v12;
}
while( v12 );
}
break;
}
}
ExReleaseResourceLite((PERESOURCE)((char *)&PnpReplaceEvent + 6688));
KeLeaveCriticalRegionThread(KeGetCurrentThread());
ExFreePoolWithTag(Src, 0);
if( PoolWithTag )
ExFreePoolWithTag(PoolWithTag, 0);
return inited;
}Referenced by:
IopPnPDispatch