CmCreateDevice

__int64 __fastcall CmCreateDevice(__int64 a1, const wchar_t *a2, int a3, HANDLE *a4, _BYTE *a5, int a6){
  __int64(__fastcall *v10)(__int64, const wchar_t *, __int64); 
  int v11; 
  int v12; 
  int v13; 
  int v14; 
  int v15; 
  int v16; 
  _DWORD result[4]; 
  int v19; 
  HANDLE Handle; 
  bool v21; 
  int v22; 
  memset((INT64)result, 0i64);
  v10 = *(__int64(__fastcall **)(__int64, const wchar_t *, __int64))(a1 + 504);
  if( a3 || (v19 = 1, a4) )
    v19 = a3;
  v22 = a6;
  if( v10 )
  {
    v11 = ((__int64(__fastcall *)(__int64, const wchar_t *, __int64, __int64, int, _DWORD *))v10)(
            a1,
            a2,
            1i64,
            2i64,
            1,
            result);
    if( v11 == -1073741822 )
    {
      v10 = 0i64;
    }
    else
    {
      if( v11 == -1073741536 )
        goto LABEL_20;
      if( v11 )
      {
        v13 = -1073741595;
        goto LABEL_25;
      }
    }
  }
  v12 = CmCreateDeviceWorker(a1, a2, v19, (__int64 *)&Handle, &v21, v22);
  v13 = v12;
  if( !v10 )
    goto LABEL_13;
  result[0] = v12;
  v14 = v10(a1, a2, 1i64);
  v15 = v14;
  if( v14 == -1073741822 )
    goto LABEL_13;
  if( v14 == -1073741536 )
  {
LABEL_20:
    v13 = result[0];
    goto LABEL_13;
  }
  v16 = v13;
  if( v15 )
    v16 = -1073741595;
  v13 = v16;
LABEL_13:
  if( v13 >= 0 && a4 )
  {
    *a4 = Handle;
    goto LABEL_16;
  }
LABEL_25:
  if( Handle )
    ZwClose(Handle);
LABEL_16:
  if( v13 >= 0 && a5 )
    *a5 = v21;
  return(unsigned int)v13;
}

Referenced by:

IoReportDetectedDevice
IoReportRootDevice
IopInitializePlugPlayServices
PiCMCreateDevice
PiCMGenerateDeviceInstance
PiCreateDeviceInstanceKey
PiDevCfgInitDriverDatabaseCallback
PnpDispatchDevice