CmIsDeviceInContainer

NTSTATUS __stdcall CmIsDeviceInContainer(
        HPNPCTX *hPnpCtx,
        VOID *ContainerRootKey,
        WCHAR *ContainerId,
        WCHAR *BaseContainerId,
        WCHAR *DeviceInstanceId,
        UINT8 *BaseInContainer,
        UINT8 *DeviceInContainer){
  UINT8 *v7; 
  UINT8 *v9; 
  HPNPCTX *v10; 
  NTSTATUS Value; 
  __int64 v12; 
  __int64 v13; 
  WCHAR *v15; 
  VOID *v16; 
  VOID *KeyHandle; 
  VOID *Handle; 
  UINT64 v19; 
  __int64 v20; 

  v7 = BaseInContainer;
  v9 = DeviceInContainer;
  v10 = hPnpCtx;
  v19 = 0i64;
  Handle = 0i64;
  KeyHandle = 0i64;
  LODWORD(v20) = 0;
  *BaseInContainer = 0;
  *v9 = 0;
  if( hPnpCtx )
    hPnpCtx = (HPNPCTX *)*((_QWORD *)hPnpCtx + 28);
  Value = SysCtxRegOpenKey((__int64)hPnpCtx, ContainerRootKey, ContainerId, 0, 1u, (VOID **)&v19);
  if( Value >= 0 )
  {
    v12 = v10 ? *((_QWORD *)v10 + 28) : 0i64;
    Value = SysCtxRegOpenKey(v12, (VOID *)v19, L"BaseContainers", 0, 1u, &Handle);
    if( Value >= 0 )
    {
      v13 = v10 ? *((_QWORD *)v10 + 28) : 0i64;
      Value = SysCtxRegOpenKey(v13, Handle, BaseContainerId, 0, 1u, &KeyHandle);
      if( Value >= 0 )
      {
        v15 = DeviceInstanceId;
        v16 = KeyHandle;
        *v7 = 1;
        Value = RegRtlQueryValue(v16, v15, 0i64, 0i64, (__int64)&v20);
        if( Value >= 0 )
          *v9 = 1;
      }
    }
  }
  if( Value == -1073741772 || Value == -1073741444 )
    Value = 0;
  if( KeyHandle )
    ZwClose((_HANDLE)KeyHandle);
  if( Handle )
    ZwClose((_HANDLE)Handle);
  if( v19 )
    ZwClose(v19);
  return Value;
}

Referenced by:

CmGetDeviceContainerIdFromBase