CmpRundownUnitOfWork

INT64 __fastcall CmpRundownUnitOfWork(ULONG_PTR BugCheckParameter4){
  ULONG_PTR v1; 
  ULONG_PTR v3; 
  __int64 v4; 
  _QWORD *v5; 
  INT64 result; 
  __int64 v7; 
  volatile INT64 *v8; 
  _QWORD *v9; 
  unsigned int v10; 
  unsigned int v11; 
  __int64 i; 
  unsigned int v13; 
  __int64 v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 
  __int64 v18; 
  __int64 *v19; 
  __int64 v20; 
  __int64 j; 
  unsigned int v22; 
  __int64 v23; 
  __int64 v24; 
  __int64 v25; 
  __int64 v26; 
  __int64 v27; 
  __int64 *v28; 
  __int64 v29; 
  v1 = *(_QWORD *)(BugCheckParameter4 + 16);
  if( v1 )
  {
    *(_QWORD *)(BugCheckParameter4 + 16) = 0i64;
    v10 = *(_DWORD *)v1 & 0x7FFFFFFF;
    if( v10 == 1 )
    {
      if( *(_QWORD *)(v1 + 8) != BugCheckParameter4 )
        KeBugCheckEx(0x51u, 0x12ui64, 1ui64, v1, BugCheckParameter4);
      *(_DWORD *)v1 = 0;
      *(_QWORD *)(v1 + 8) = 0i64;
    }
    else
    {
      for( i = 0i64; (unsigned int)i < v10; i = (unsigned int)(i + 1) )
      {
        if( *(_QWORD *)(*(_QWORD *)(v1 + 8) + 8 * i) == BugCheckParameter4 )
          break;
      }
      if( (_DWORD)i == v10 )
        KeBugCheckEx(0x51u, 0x12ui64, 2ui64, v1, BugCheckParameter4);
      v13 = v10 - 1;
      if( (unsigned int)i < v10 - 1 )
      {
        v14 = 8i64 * (unsigned int)i;
        v15 = 8i64 * (unsigned int)(i + 1);
        v16 = v13 - (unsigned int)i;
        do
        {
          v17 = *(_QWORD *)(v1 + 8);
          v18 = *(_QWORD *)(v15 + v17);
          v15 += 8i64;
          *(_QWORD *)(v14 + v17) = v18;
          v14 += 8i64;
          --v16;
        }
        while( v16 );
      }
      if( --*(_DWORD *)v1 == 1 )
      {
        v19 = *(__int64 **)(v1 + 8);
        v20 = *v19;
        ExFreePoolWithTag(v19, 0x78494D43u);
        *(_QWORD *)(v1 + 8) = v20;
      }
    }
  }
  v3 = *(_QWORD *)(BugCheckParameter4 + 24);
  if( v3 )
  {
    *(_QWORD *)(BugCheckParameter4 + 24) = 0i64;
    v11 = *(_DWORD *)v3 & 0x7FFFFFFF;
    if( v11 == 1 )
    {
      if( *(_QWORD *)(v3 + 8) != BugCheckParameter4 )
        KeBugCheckEx(0x51u, 0x12ui64, 1ui64, v3, BugCheckParameter4);
      *(_DWORD *)v3 = 0;
      *(_QWORD *)(v3 + 8) = 0i64;
    }
    else
    {
      for( j = 0i64; (unsigned int)j < v11; j = (unsigned int)(j + 1) )
      {
        if( *(_QWORD *)(*(_QWORD *)(v3 + 8) + 8 * j) == BugCheckParameter4 )
          break;
      }
      if( (_DWORD)j == v11 )
        KeBugCheckEx(0x51u, 0x12ui64, 2ui64, v3, BugCheckParameter4);
      v22 = v11 - 1;
      if( (unsigned int)j < v22 )
      {
        v23 = 8i64 * (unsigned int)j;
        v24 = 8i64 * (unsigned int)(j + 1);
        v25 = v22 - (unsigned int)j;
        do
        {
          v26 = *(_QWORD *)(v3 + 8);
          v27 = *(_QWORD *)(v24 + v26);
          v24 += 8i64;
          *(_QWORD *)(v23 + v26) = v27;
          v23 += 8i64;
          --v25;
        }
        while( v25 );
      }
      if( --*(_DWORD *)v3 == 1 )
      {
        v28 = *(__int64 **)(v3 + 8);
        v29 = *v28;
        ExFreePoolWithTag(v28, 0x78494D43u);
        *(_QWORD *)(v3 + 8) = v29;
      }
    }
  }
  if( *(_QWORD *)BugCheckParameter4 != BugCheckParameter4 )
  {
    LOCK_TRANSACTION_LIST();
    v4 = *(_QWORD *)BugCheckParameter4;
    if( *(_QWORD *)(*(_QWORD *)BugCheckParameter4 + 8i64) != BugCheckParameter4 )
      goto LABEL_40;
    v5 = *(_QWORD **)(BugCheckParameter4 + 8);
    if( *v5 != BugCheckParameter4 )
      goto LABEL_40;
    *v5 = v4;
    *(_QWORD *)(v4 + 8) = v5;
    UNLOCK_TRANSACTION_LIST();
    *(_QWORD *)(BugCheckParameter4 + 56) = 0i64;
  }
  result = BugCheckParameter4 + 32;
  v7 = *(_QWORD *)(BugCheckParameter4 + 32);
  if( v7 == BugCheckParameter4 + 32 )
    return result;
  v8 = *(volatile INT64 **)(BugCheckParameter4 + 48);
  if( *(_QWORD *)(v7 + 8) != result || (v9 = *(_QWORD **)(BugCheckParameter4 + 40), *v9 != result) )
LABEL_40:
    __fastfail(3u);
  *v9 = v7;
  *(_QWORD *)(v7 + 8) = v9;
  result = CmpDereferenceKeyControlBlockUnsafe(v8);
  *(_QWORD *)(BugCheckParameter4 + 48) = 0i64;
  return result;
}

Referenced by:

CmDeleteValueKey
CmRenameKey
CmSetKeyFlags
CmSetLastWriteTimeKey
CmSetValueKey
CmpCreateChild
CmpSetKeySecurity
CmpTransMgrFreeVolatileData
CmpUndoDeleteKeyForTrans