PnpCreateObject

__int64 __fastcall PnpCreateObject(__int64 a1, __int64 a2, unsigned int a3, int a4, HANDLE *a5){
  __int64 v5; 
  __int64(__fastcall *v9)(__int64, __int64, _QWORD, __int64, int, _DWORD *); 
  int v10; 
  int ObjectDispatch; 
  int v12; 
  int v14; 
  int v15; 
  int v16; 
  _DWORD result[4]; 
  int v18; 
  HANDLE Handle; 
  char v20[4]; 
  int v21; 
  v5 = PiPnpRtlCtx;
  memset((INT64)result, 0i64);
  v9 = *(__int64(__fastcall **)(__int64, __int64, _QWORD, __int64, int, _DWORD *))(v5 + 488);
  if( a4 || (v18 = 1, a5) )
    v18 = a4;
  v21 = 0;
  if( v9 )
  {
    v10 = v9(v5, a2, a3, 3i64, 1, result);
    if( v10 == -1073741822 )
    {
      v9 = 0i64;
    }
    else
    {
      if( v10 == -1073741536 )
        goto LABEL_18;
      if( v10 )
      {
        v12 = -1073741595;
        goto LABEL_16;
      }
    }
  }
  ObjectDispatch = PnpCreateObjectDispatch(v5, a2, a3, v18, (__int64 *)&Handle, v20, v21);
  v12 = ObjectDispatch;
  if( !v9 )
    goto LABEL_7;
  result[0] = ObjectDispatch;
  v14 = v9(v5, a2, a3, 3i64, 2, result);
  v15 = v14;
  if( v14 == -1073741822 )
    goto LABEL_7;
  if( v14 == -1073741536 )
  {
LABEL_18:
    v12 = result[0];
    goto LABEL_7;
  }
  v16 = v12;
  if( v15 )
    v16 = -1073741595;
  v12 = v16;
LABEL_7:
  if( v12 >= 0 && a5 )
  {
    *a5 = Handle;
    return(unsigned int)v12;
  }
LABEL_16:
  if( Handle )
    ZwClose(Handle);
  return(unsigned int)v12;
}

Referenced by:

PiCMCreateObject
PiCMOpenObjectKey