PiPnpRtlObjectEventCreate

NTSTATUS __stdcall PiPnpRtlObjectEventCreate(
        WCHAR *ObjectName,
        PNP_OBJECT_TYPE ObjectType,
        PI_PNPRTL_OPERATION *Operation,
        PI_PNPRTL_OBJECT_EVENT **ObjectEvent){
  _PI_DM_OBJECT *v8; 
  int v9; 
  _PI_PNPRTL_OBJECT_EVENT **v10; 
  _PI_PNPRTL_OBJECT_EVENT *v11; 
  NTSTATUS v13; 
  VOID **PoolWithTag; 
  VOID **v15; 
  _PI_DM_OBJECT *v16; 
  VOID *inserted; 
  _TABLE_SEARCH_RESULT SearchResult; 
  _PI_DM_OBJECT *Object; 
  _PI_PNPRTL_OBJECT_EVENT *ObjectEventa; 
  VOID *NodeOrParent; 
  __int64 *Buffer; 
  __int64 v23[10]; 
  _PI_DM_OBJECT ComparisonObject[28]; 

  memset(ComparisonObject, 0i64, sizeof(ComparisonObject));
  memset(v23, 0i64, sizeof(v23));
  NodeOrParent = 0i64;
  SearchResult = TableEmptyTree;
  v8 = 0i64;
  Buffer = v23;
  *ObjectEvent = 0i64;
  Object = 0i64;
  v9 = PiDmInitializeComparisonObject(ObjectName, ObjectType, ComparisonObject);
  if( v9 >= 0 )
  {
    v23[1] = (__int64)ComparisonObject;
    v10 = (_PI_PNPRTL_OBJECT_EVENT **)RtlLookupElementGenericTableFullAvl(
                                        (_RTL_AVL_TABLE *)(Operation + 6),
                                        &Buffer,
                                        &NodeOrParent,
                                        &SearchResult);
    if( v10 )
      v11 = *v10;
    else
      v11 = 0i64;
    if( v11 )
      goto LABEL_5;
    v13 = PiDmGetObject(ObjectType, ObjectName, &Object);
    v9 = v13;
    if( v13 == -1073741772 )
    {
      v8 = Object;
      v9 = 0;
      goto LABEL_14;
    }
    if( v13 < 0 )
    {
      v8 = Object;
LABEL_18:
      if( v11 )
        PiPnpRtlObjectEventRelease(v11);
      goto LABEL_20;
    }
    PoolWithTag = ExAllocatePoolWithTag(1ui64, 0xF0ui64, 1097887312i64);
    ObjectEventa = (_PI_PNPRTL_OBJECT_EVENT *)PoolWithTag;
    v15 = PoolWithTag;
    if( PoolWithTag )
    {
      memset(PoolWithTag, 0i64, 0x50u);
      v16 = Object;
      *(_DWORD *)v15 = 1;
      *((_DWORD *)v15 + 18) = 5;
      v8 = 0i64;
      v15[1] = v16;
      inserted = RtlInsertElementGenericTableFullAvl(
                   (_RTL_AVL_TABLE *)(Operation + 6),
                   &ObjectEventa,
                   8ui64,
                   0i64,
                   NodeOrParent,
                   SearchResult);
      v11 = ObjectEventa;
      if( inserted )
      {
LABEL_5:
        *ObjectEvent = v11;
        return v9;
      }
      v9 = -1073741670;
      goto LABEL_18;
    }
    v8 = Object;
    v9 = -1073741670;
  }
LABEL_20:
  *ObjectEvent = 0i64;
LABEL_14:
  if( v8 )
    PiDmObjectRelease(v8);
  return v9;
}

Referenced by:

PiPnpRtlCacheObjectBaseKey
PiPnpRtlEnsureObjectCached
PiPnpRtlObjectEventWorker