PiCreateDriverSwDevices

__int64 __fastcall PiCreateDriverSwDevices(__int64 a1){
  DEVICE_OBJECT *v2; 
  int v3; 
  __int64 v4; 
  int v5; 
  __int128 v7; 
  HANDLE v8; 
  HANDLE Handle; 
  Handle = 0i64;
  v8 = 0i64;
  v2 = *(DEVICE_OBJECT **)(a1 + 32);
  v7 = 0i64;
  v3 = PnpDeviceObjectToDeviceInstance(v2, &Handle, 0x20019ui64);
  if( v3 >= 0 )
  {
    if( PiPnpRtlCtx )
      v4 = *(_QWORD *)(PiPnpRtlCtx + 224);
    else
      v4 = 0i64;
    v5 = SysCtxRegOpenKey(v4, (char *)Handle, L"Devices", 0, 0x20019u, &v8);
    v3 = v5;
    if( v5 >= 0 )
    {
      DWORD2(v7) = 0;
      *(_QWORD *)&v7 = a1;
      v3 = PnpCtxRegEnumKeyWithCallback(PiPnpRtlCtx, v8, (__int64)PiCreateDriverSwDeviceCallback, (__int64)&v7);
      if( v3 >= 0 && (SDWORD2(v7) & 0x80000000) != 0 )
        v3 = DWORD2(v7);
    }
    else if( v5 == -1073741772 )
    {
      v3 = 0;
    }
  }
  if( v8 )
    ZwClose(v8);
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)v3;
}

Referenced by:

PipProcessStartPhase3