FsRtlFastUnlockSingleExclusive

INT64 __fastcall FsRtlFastUnlockSingleExclusive(
        INT64 a1,
        RTL_SPLAY_LINKS *a2,
        LARGE_INTEGER *a3,
        RTL_SPLAY_LINKS **a4,
        RTL_SPLAY_LINKS *a5,
        INT64 a6,
        INT64 a7,
        CHAR a8,
        CHAR a9){
  unsigned __int64 QuadPart; 
  UINT64 *v10; 
  _RTL_SPLAY_LINKS *v14; 
  unsigned int v15; 
  unsigned __int8 v16; 
  unsigned __int64 v17; 
  RTL_SPLAY_LINKS *v19; 
  RTL_SPLAY_LINKS *v20; 
  int v21; 
  bool v22; 
  UINT64 v23; 
  char v24; 
  _LARGE_INTEGER EndingByte; 
  _LARGE_INTEGER StartingByte; 
  RTL_SPLAY_LINKS **v27; 
  v27 = a4;
  QuadPart = a3->QuadPart;
  v10 = (UINT64 *)(a1 + 24);
  StartingByte = *a3;
  KeAcquireSpinLockRaiseToDpc((UINT64 *)(a1 + 24), (UINT64)a2);
  v14 = (_RTL_SPLAY_LINKS *)v10[2];
  v15 = 0;
  v17 = v16;
  if( !v14
    || (EndingByte.QuadPart = (LONGLONG)*a4 + QuadPart - 1,
        FsRtlFindFirstOverlappingExclusiveNode(v14, &StartingByte, &EndingByte, 0i64, 0i64),
        (v20 = v19) == 0i64) )
  {
LABEL_2:
    KxReleaseSpinLock(v10);
    v15 = -1073741698;
    goto LABEL_3;
  }
  v21 = a6;
  while( 1 )
  {
    if( v20[2].Parent == a2 && v20[2].LeftChild == a5 && HIDWORD(v20[1].RightChild) == v21 )
    {
      v22 = v20[1].Parent <= (_RTL_SPLAY_LINKS *)QuadPart;
      if( v20[1].Parent != (_RTL_SPLAY_LINKS *)QuadPart )
        goto LABEL_23;
      if( v20[1].LeftChild == *v27 )
        break;
    }
    v22 = v20[1].Parent <= (_RTL_SPLAY_LINKS *)QuadPart;
LABEL_23:
    if( v22 )
    {
      v20 = RtlRealSuccessor(v20);
      if( v20 )
        continue;
    }
    goto LABEL_2;
  }
  if( a2[5].Parent == &v20[1] )
    a2[5].Parent = 0i64;
  v10[2] = (UINT64)RtlDelete(v20);
  if( *(_RTL_SPLAY_LINKS **)a1 == v20[1].Parent )
    FsRtlPrivateResetLowestLockOffset((__int64 *)a1);
  if( !a8 && *(_QWORD *)(a1 + 16) )
  {
    KxReleaseSpinLock(v10);
    __writecr8(v17);
    (*(void(__fastcall **)(INT64, RTL_SPLAY_LINKS *))(a1 + 16))(a7, v20 + 1);
    KeAcquireSpinLockRaiseToDpc(v10, v23);
    LOBYTE(v17) = v24;
  }
  ExFreeToNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)FsRtlExclusiveLockLookasideList, v20);
  if( a9 && v10[3] )
    FsRtlPrivateCheckWaitingLocks(a1, v10, v17);
  KxReleaseSpinLock(v10);
LABEL_3:
  __writecr8((unsigned __int8)v17);
  return v15;
}

Referenced by:

FsRtlFastUnlockSingle
FsRtlPrivateRemoveLock