PiPnpRtlObjectEventRelease

INT64 __fastcall PiPnpRtlObjectEventRelease(
        _CM_KEY_CONTROL_BLOCK *Key,
        UINT *SecurityInformation,
        VOID *ModificationDescriptor,
        VOID **ObjectsSecurityDescriptor,
        _POOL_TYPE PoolType,
        _GENERIC_MAPPING *GenericMapping,
        _CM_TRANS *CmTrans,
        _CM_KCB_UOW *UoW){
  INT64 result; 
  CHAR *v10; 
  void *v11; 
  unsigned int i; 
  void *v13; 
  result = (unsigned int)_InterlockedExchangeAdd((volatile signed __int32 *)Key, 0xFFFFFFFF);
  if( (_DWORD)result == 1 )
  {
    v10 = (CHAR *)*((_QWORD *)Key + 1);
    if( v10 )
      PiDmObjectRelease(v10);
    v11 = *(void **)&Key->KeyHash.ConvKey.Hash;
    if( v11 )
      ZwClose(v11);
    if( (Key->RefCount & 0x400000000i64) != 0 )
      SeReleaseSubjectContext((_SECURITY_SUBJECT_CONTEXT *)&Key->NextHash);
    for( i = 0; i < HIDWORD(Key->ParentKcb); ++i )
    {
      v13 = (void *)*((_QWORD *)&Key->LinkTarget + 4 * i);
      if( v13 )
        ExFreePoolWithTag(v13, 0x41706E50u);
    }
    ExFreePoolWithTag(Key, 0x41706E50u);
  }
  return result;
}

Referenced by:

PiDqObjectManagerServiceActionQueue
PiPnpRtlObjectEventCreate