FsRtlPrivateInsertSharedLock

char __fastcall FsRtlPrivateInsertSharedLock(__int64 a1, _QWORD *a2){
  _RTL_SPLAY_LINKS **v2; 
  RTL_SPLAY_LINKS **v4; 
  _RTL_SPLAY_LINKS *v5; 
  _RTL_SPLAY_LINKS *FirstOverlappingSharedNode; 
  RTL_SPLAY_LINKS *v7; 
  __int64 v8; 
  RTL_SPLAY_LINKS *v9; 
  _RTL_SPLAY_LINKS *v10; 
  __int64 v11; 
  _RTL_SPLAY_LINKS *Parent; 
  __int64 *v13; 
  _RTL_SPLAY_LINKS *v14; 
  __int64 v15; 
  RTL_SPLAY_LINKS *v16; 
  _RTL_SPLAY_LINKS *v17; 
  RTL_SPLAY_LINKS *v18; 
  RTL_SPLAY_LINKS *v19; 
  UINT8 v21; 
  _RTL_SPLAY_LINKS *v22; 
  v2 = (_RTL_SPLAY_LINKS **)(a2 + 6);
  v4 = (RTL_SPLAY_LINKS **)(a1 + 8);
  v5 = *(_RTL_SPLAY_LINKS **)(a1 + 8);
  v22 = 0i64;
  v21 = 0;
  FirstOverlappingSharedNode = FsRtlFindFirstOverlappingSharedNode(
                                 v5,
                                 (_LARGE_INTEGER *)a2 + 1,
                                 (_LARGE_INTEGER *)a2 + 6,
                                 &v22,
                                 &v21);
  v7 = FirstOverlappingSharedNode;
  if( FirstOverlappingSharedNode )
  {
    v11 = (__int64)&FirstOverlappingSharedNode[-1];
    Parent = FirstOverlappingSharedNode[-1].Parent;
    v13 = (__int64 *)v11;
    if( Parent )
    {
      v14 = (_RTL_SPLAY_LINKS *)a2[1];
      do
      {
        if( v14 < Parent->LeftChild || v14 == Parent->LeftChild && (!a2[2] || Parent->RightChild) )
          break;
        v13 = (__int64 *)Parent;
        Parent = Parent->Parent;
      }
      while( Parent );
    }
    v15 = *v13;
    if( !*v13 )
    {
      v7[1].Parent = (_RTL_SPLAY_LINKS *)a2;
      v15 = *v13;
    }
    *a2 = v15;
    *v13 = (__int64)a2;
    *v4 = RtlSplay(v7);
    if( *v2 > v7[-1].RightChild )
    {
      v7[-1].RightChild = *v2;
      while( 1 )
      {
        v18 = RtlRealSuccessor(v7);
        v19 = v18;
        if( !v18 )
          break;
        v16 = v18 - 1;
        v17 = v18[-1].Parent;
        if( v17->LeftChild > v7[-1].RightChild )
          break;
        if( !LOBYTE(v7[-1].LeftChild) && LOBYTE(v16->LeftChild) )
        {
          FsRtlSplitLocks((__int64)&v18[-1], 0i64, 0i64, 0i64);
          v17 = v16->Parent;
        }
        v7[1].Parent->Parent = v17;
        v7[1].Parent = v16[2].Parent;
        if( v16->RightChild > v7[-1].RightChild )
        {
          if( LOBYTE(v16->LeftChild) )
            LOBYTE(v7[-1].LeftChild) = 1;
          v7[-1].RightChild = v16->RightChild;
        }
        RtlDeleteNoSplay(v19, v4);
        ExFreeToNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)FsRtlLockTreeNodeLookasideList, &v19[-1]);
      }
    }
    if( LOBYTE(v7[-1].LeftChild) )
      FsRtlSplitLocks(v11, 0i64, 0i64, 0i64);
  }
  else
  {
    LODWORD(v8) = ExAllocateFromNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)FsRtlLockTreeNodeLookasideList);
    if( !v8 )
      return v8;
    v9 = (RTL_SPLAY_LINKS *)(v8 + 24);
    *(_BYTE *)(v8 + 8) = 0;
    *(_QWORD *)(v8 + 48) = a2;
    *(_QWORD *)v8 = a2;
    *(_QWORD *)(v8 + 24) = v8 + 24;
    *(_QWORD *)(v8 + 32) = 0i64;
    *(_QWORD *)(v8 + 40) = 0i64;
    *(_QWORD *)(v8 + 16) = *v2;
    v10 = v22;
    *a2 = 0i64;
    if( v10 )
    {
      if( v21 )
        v10->LeftChild = v9;
      else
        v10->RightChild = v9;
      v9->Parent = v10;
      v9 = RtlSplay(v9);
    }
    *v4 = v9;
  }
  LOBYTE(v8) = 1;
  return v8;
}

Referenced by:

No references.