CmGetDevicesInBaseContainerList
NTSTATUS __stdcall CmGetDevicesInBaseContainerList(
HPNPCTX *hPnpCtx,
WCHAR *ContainerId,
WCHAR *BaseContainerId,
WCHAR **DeviceList){
VOID **v8;
NTSTATUS CachedContextBaseKey;
__int64 v10;
__int64 v11;
__int64 v12;
__int64 v13;
unsigned int v14;
VOID **PoolWithTag;
__int64 v16;
ULONG i;
NTSTATUS v18;
WCHAR *v19;
VOID **v20;
int v22;
VOID *Handle;
UINT64 v24;
UINT64 v25;
__int64 v26[2];
unsigned int v27;
v26[0] = 0i64;
v25 = 0i64;
v24 = 0i64;
Handle = 0i64;
v22 = 0;
v8 = 0i64;
v27 = 0;
*DeviceList = 0i64;
CachedContextBaseKey = PnpCtxGetCachedContextBaseKey(
hPnpCtx,
PNPCTX_BASE_KEY_TYPE_CRITICALDEVICEDATABASE,
(VOID **)v26);
if( CachedContextBaseKey >= 0 )
{
v10 = 0i64;
if( hPnpCtx )
v10 = *((_QWORD *)hPnpCtx + 28);
CachedContextBaseKey = SysCtxRegOpenKey(v10, (VOID *)v26[0], ContainerId, 0, 1u, (VOID **)&v25);
if( CachedContextBaseKey >= 0 )
{
v11 = 0i64;
if( hPnpCtx )
v11 = *((_QWORD *)hPnpCtx + 28);
CachedContextBaseKey = SysCtxRegOpenKey(v11, (VOID *)v25, L"BaseContainers", 0, 1u, (VOID **)&v24);
if( CachedContextBaseKey >= 0 )
{
v12 = 0i64;
if( hPnpCtx )
v12 = *((_QWORD *)hPnpCtx + 28);
CachedContextBaseKey = SysCtxRegOpenKey(v12, (VOID *)v24, BaseContainerId, 0, 3u, &Handle);
if( CachedContextBaseKey >= 0 )
{
CachedContextBaseKey = PnpCtxRegQueryInfoKey(v13, Handle, 0i64, 0i64, &v22, &v27, 0i64);
if( CachedContextBaseKey >= 0 )
{
v14 = v22 * (v27 + 1) + 1;
PoolWithTag = ExAllocatePoolWithTag(1ui64, 2i64 * v14, 1380994640i64);
*DeviceList = (WCHAR *)PoolWithTag;
if( !PoolWithTag )
{
CachedContextBaseKey = -1073741801;
goto LABEL_22;
}
v8 = PoolWithTag;
for( i = 0; ; ++i )
{
v27 = v14 - 1;
v18 = PnpCtxRegEnumValue(v16, (_HANDLE)Handle, i, v8, (INT64)&v27, 0i64, 0i64);
CachedContextBaseKey = v18;
if( v18 == -2147483622 )
break;
if( v18 < 0 )
goto LABEL_19;
v16 = v27 + 1;
v14 -= v16;
v8 = (VOID **)((char *)v8 + 2 * v16);
}
CachedContextBaseKey = 0;
}
}
}
}
}
LABEL_19:
if( CachedContextBaseKey == -1073741772 || CachedContextBaseKey == -1073741444 )
CachedContextBaseKey = 0;
LABEL_22:
v19 = *DeviceList;
if( CachedContextBaseKey < 0 )
{
if( !v19 )
goto LABEL_30;
ExFreePoolWithTag(v19, 0);
}
else
{
if( v19 )
{
*(_WORD *)v8 = 0;
goto LABEL_30;
}
v20 = ExAllocatePoolWithTag(1ui64, 2ui64, 1380994640i64);
*DeviceList = (WCHAR *)v20;
if( !v20 )
{
CachedContextBaseKey = -1073741801;
goto LABEL_30;
}
}
*DeviceList = 0i64;
LABEL_30:
if( Handle )
ZwClose((_HANDLE)Handle);
if( v24 )
ZwClose(v24);
if( v25 )
ZwClose(v25);
return CachedContextBaseKey;
}Referenced by:
CmMoveBaseContainer