CmpRundownUnitOfWork

INT64 __fastcall CmpRundownUnitOfWork(PVOID BugCheckParameter4){
  PVOID *v1; 
  PVOID *v3; 
  INT64 v4; 
  _QWORD *v5; 
  PVOID *v6; 
  INT64 result; 
  _QWORD *v8; 
  volatile INT64 *v9; 
  _QWORD *v10; 
  unsigned int v11; 
  unsigned int v12; 
  __int64 i; 
  unsigned int v14; 
  __int64 v15; 
  __int64 v16; 
  __int64 v17; 
  char *v18; 
  __int64 v19; 
  void **v20; 
  void *v21; 
  __int64 j; 
  unsigned int v23; 
  __int64 v24; 
  __int64 v25; 
  __int64 v26; 
  char *v27; 
  __int64 v28; 
  void **v29; 
  void *v30; 

  v1 = (PVOID *)*((_QWORD *)BugCheckParameter4 + 2);
  if( v1 )
  {
    *((_QWORD *)BugCheckParameter4 + 2) = 0i64;
    v11 = *(_DWORD *)v1 & 0x7FFFFFFF;
    if( v11 == 1 )
    {
      if( v1[1] != BugCheckParameter4 )
        KeBugCheckEx(0x51u, (PVOID)0x12, (PVOID)1, v1, BugCheckParameter4);
      *(_DWORD *)v1 = 0;
      v1[1] = 0i64;
    }
    else
    {
      for( i = 0i64; (unsigned int)i < v11; i = (unsigned int)(i + 1) )
      {
        if( *((PVOID *)v1[1] + i) == BugCheckParameter4 )
          break;
      }
      if( (_DWORD)i == v11 )
        KeBugCheckEx(0x51u, (PVOID)0x12, (PVOID)2, v1, BugCheckParameter4);
      v14 = v11 - 1;
      if( (unsigned int)i < v11 - 1 )
      {
        v15 = 8i64 * (unsigned int)i;
        v16 = 8i64 * (unsigned int)(i + 1);
        v17 = v14 - (unsigned int)i;
        do
        {
          v18 = (char *)v1[1];
          v19 = *(_QWORD *)&v18[v16];
          v16 += 8i64;
          *(_QWORD *)&v18[v15] = v19;
          v15 += 8i64;
          --v17;
        }
        while( v17 );
      }
      if( --*(_DWORD *)v1 == 1 )
      {
        v20 = (void **)v1[1];
        v21 = *v20;
        ExFreePoolWithTag(v20, 0x78494D43u);
        v1[1] = v21;
      }
    }
  }
  v3 = (PVOID *)*((_QWORD *)BugCheckParameter4 + 3);
  if( v3 )
  {
    *((_QWORD *)BugCheckParameter4 + 3) = 0i64;
    v12 = *(_DWORD *)v3 & 0x7FFFFFFF;
    if( v12 == 1 )
    {
      if( v3[1] != BugCheckParameter4 )
        KeBugCheckEx(0x51u, (PVOID)0x12, (PVOID)1, v3, BugCheckParameter4);
      *(_DWORD *)v3 = 0;
      v3[1] = 0i64;
    }
    else
    {
      for( j = 0i64; (unsigned int)j < v12; j = (unsigned int)(j + 1) )
      {
        if( *((PVOID *)v3[1] + j) == BugCheckParameter4 )
          break;
      }
      if( (_DWORD)j == v12 )
        KeBugCheckEx(0x51u, (PVOID)0x12, (PVOID)2, v3, BugCheckParameter4);
      v23 = v12 - 1;
      if( (unsigned int)j < v23 )
      {
        v24 = 8i64 * (unsigned int)j;
        v25 = 8i64 * (unsigned int)(j + 1);
        v26 = v23 - (unsigned int)j;
        do
        {
          v27 = (char *)v3[1];
          v28 = *(_QWORD *)&v27[v25];
          v25 += 8i64;
          *(_QWORD *)&v27[v24] = v28;
          v24 += 8i64;
          --v26;
        }
        while( v26 );
      }
      if( --*(_DWORD *)v3 == 1 )
      {
        v29 = (void **)v3[1];
        v30 = *v29;
        ExFreePoolWithTag(v29, 0x78494D43u);
        v3[1] = v30;
      }
    }
  }
  if( *(PVOID *)BugCheckParameter4 != BugCheckParameter4 )
  {
    LOCK_TRANSACTION_LIST();
    v5 = *(_QWORD **)BugCheckParameter4;
    if( *(PVOID *)(*(_QWORD *)BugCheckParameter4 + 8i64) != BugCheckParameter4 )
      goto LABEL_40;
    v6 = (PVOID *)*((_QWORD *)BugCheckParameter4 + 1);
    if( *v6 != BugCheckParameter4 )
      goto LABEL_40;
    *v6 = v5;
    v5[1] = v6;
    UNLOCK_TRANSACTION_LIST((INT64)v6, v4);
    *((_QWORD *)BugCheckParameter4 + 7) = 0i64;
  }
  result = (INT64)BugCheckParameter4 + 32;
  v8 = (_QWORD *)*((_QWORD *)BugCheckParameter4 + 4);
  if( v8 == (_QWORD *)((char *)BugCheckParameter4 + 32) )
    return result;
  v9 = (volatile INT64 *)*((_QWORD *)BugCheckParameter4 + 6);
  if( v8[1] != result || (v10 = (_QWORD *)*((_QWORD *)BugCheckParameter4 + 5), *v10 != result) )
LABEL_40:
    __fastfail(3u);
  *v10 = v8;
  v8[1] = v10;
  result = CmpDereferenceKeyControlBlockUnsafe(v9);
  *((_QWORD *)BugCheckParameter4 + 6) = 0i64;
  return result;
}

Referenced by:

CmDeleteValueKey
CmRenameKey
CmSetKeyFlags
CmSetLastWriteTimeKey
CmSetValueKey
CmpCreateChild
CmpSetKeySecurity
CmpTransMgrFreeVolatileData
CmpUndoDeleteKeyForTrans