CmpLockIXLockIntent

BOOL __fastcall CmpLockIXLockIntent(UINT64 *a1, INT64 a2){
  UINT64 PoolWithTag; 
  UINT64 v5; 
  __int64 v6; 
  UINT64 v7; 
  LODWORD(PoolWithTag) = *(_DWORD *)a1;
  if( !*(_DWORD *)a1 )
  {
    *(_DWORD *)a1 = 1;
    a1[1] = a2;
LABEL_9:
    *(_QWORD *)(a2 + 16) = a1;
    goto LABEL_4;
  }
  if( (PoolWithTag & 0x80000000) == 0i64 )
  {
    if( (_DWORD)PoolWithTag == 1 )
    {
      v5 = a1[1];
      if( CmEqualTrans(*(_QWORD *)(v5 + 56), *(_QWORD *)(a2 + 56)) )
        goto LABEL_4;
      PoolWithTag = (UINT64)ExAllocatePoolWithTag(PagedPool, 0x10ui64, 0x78494D43ui64);
      if( PoolWithTag )
      {
        a1[1] = PoolWithTag;
        *(_QWORD *)PoolWithTag = v5;
        PoolWithTag = a1[1];
        *(_QWORD *)(PoolWithTag + 8) = a2;
LABEL_18:
        ++*(_DWORD *)a1;
        goto LABEL_9;
      }
    }
    else
    {
      v6 = 0i64;
      if( (_DWORD)PoolWithTag )
      {
        while( !CmEqualTrans(*(_QWORD *)(*(_QWORD *)(a1[1] + 8 * v6) + 56i64), *(_QWORD *)(a2 + 56)) )
        {
          LODWORD(PoolWithTag) = *(_DWORD *)a1;
          v6 = (unsigned int)(v6 + 1);
          if( (unsigned int)v6 >= *(_DWORD *)a1 )
            goto LABEL_16;
        }
        goto LABEL_4;
      }
LABEL_16:
      PoolWithTag = (UINT64)ExAllocatePoolWithTag(PagedPool, 8i64 * (unsigned int)(PoolWithTag + 1), 0x78494D43ui64);
      v7 = PoolWithTag;
      if( PoolWithTag )
      {
        memmove((UINT8 *)PoolWithTag, (UINT8 *)a1[1], 8i64 * *(unsigned int *)a1);
        ExFreePoolWithTag((PVOID)a1[1], 0x78494D43u);
        PoolWithTag = *(unsigned int *)a1;
        a1[1] = v7;
        *(_QWORD *)(v7 + 8 * PoolWithTag) = a2;
        goto LABEL_18;
      }
    }
LABEL_10:
    LOBYTE(PoolWithTag) = 0;
    return PoolWithTag;
  }
  if( !CmEqualTrans(*(_QWORD *)(a1[1] + 56), *(_QWORD *)(a2 + 56)) )
    goto LABEL_10;
LABEL_4:
  LOBYTE(PoolWithTag) = 1;
  return PoolWithTag;
}

Referenced by:

CmDeleteValueKey
CmSetKeyFlags
CmSetLastWriteTimeKey
CmSetValueKey
CmpCreateChild
CmpUndoDeleteKeyForTrans