FsRtlPrivateLock
UINT8 __fastcall FsRtlPrivateLock(
_FILE_LOCK *FileLock,
_FILE_OBJECT *FileObject,
_LARGE_INTEGER *FileOffset,
_LARGE_INTEGER *Length,
_EPROCESS *ProcessId,
UINT64 Key,
UINT8 FailImmediately,
UINT8 ExclusiveLock,
_IO_STATUS_BLOCK *Iosb,
_IRP *Irp,
VOID *Context,
UINT8 AlreadySynchronized){
UINT64 *v16;
char *LockInformation;
unsigned __int64 QuadPart;
LONGLONG v19;
KIRQL v20;
INT64 v21;
CHAR v22;
_IO_STATUS_BLOCK *v23;
_QWORD *v24;
int v26;
KIRQL NewIrql;
UINT8 v28;
char v29;
int v30;
char *v31;
UINT64 *v32;
__int128 v33;
__int128 v34;
__int128 v35;
__int64 v36;
v29 = 0;
v31 = 0i64;
v16 = 0i64;
v32 = 0i64;
NewIrql = -1;
v33 = 0i64;
v34 = 0i64;
v35 = 0i64;
LockInformation = (char *)FileLock->LockInformation;
v31 = LockInformation;
if( !LockInformation )
{
if( !FsRtlPrivateInitializeFileLock(FileLock, Irp == 0i64) )
goto LABEL_14;
FileLock->FastIoIsQuestionable = 1;
LockInformation = (char *)FileLock->LockInformation;
v31 = LockInformation;
}
QuadPart = FileOffset->QuadPart;
*(_QWORD *)&v33 = QuadPart;
v19 = Length->QuadPart;
*((_QWORD *)&v33 + 1) = v19;
*((_QWORD *)&v35 + 1) = QuadPart + v19 - 1;
DWORD1(v34) = Key;
*((_QWORD *)&v34 + 1) = FileObject;
*(_QWORD *)&v35 = ProcessId;
LOBYTE(v34) = ExclusiveLock;
v16 = (UINT64 *)(LockInformation + 24);
v32 = (UINT64 *)(LockInformation + 24);
if( *((_QWORD *)&v35 + 1) < QuadPart && v19 )
{
v23 = Iosb;
Iosb->Status = -1073741407;
goto LABEL_10;
}
v29 = 1;
KeAcquireSpinLockRaiseToDpc((UINT64 *)LockInformation + 3, QuadPart);
NewIrql = v20;
v21 = (INT64)(LockInformation + 24);
if( ExclusiveLock )
v22 = FsRtlPrivateCheckForExclusiveLockAccess(v21, (LARGE_INTEGER *)&v33);
else
v22 = FsRtlPrivateCheckForSharedLockAccess(v21, (__int64)&v33);
if( v22 )
{
if( FsRtlPrivateInsertLock(LockInformation, (__int64)FileObject, &v33) )
{
v23 = Iosb;
Iosb->Status = 0;
LABEL_10:
v28 = 1;
goto LABEL_29;
}
if( Irp )
{
KeReleaseSpinLock((UINT64 *)LockInformation + 3, NewIrql);
RtlRaiseStatus(-1073741670);
}
}
else
{
if( FailImmediately )
{
v23 = Iosb;
Iosb->Status = -1073741739;
goto LABEL_10;
}
if( Irp )
{
LODWORD(v24) = ExAllocateFromNPagedLookasideList((NPAGED_LOOKASIDE_LIST *)FsRtlWaitingLockLookasideList);
if( !v24 )
{
KeReleaseSpinLock((UINT64 *)LockInformation + 3, NewIrql);
RtlRaiseStatus(-1073741670);
}
v24[3] = Irp;
v24[2] = Context;
v24[1] = *((_QWORD *)LockInformation + 1);
v36 = *((_QWORD *)Irp + 23);
*(_BYTE *)(v36 + 3) |= 1u;
*v24 = 0i64;
if( *((_QWORD *)LockInformation + 6) )
**((_QWORD **)LockInformation + 7) = v24;
else
*((_QWORD *)LockInformation + 6) = v24;
*((_QWORD *)LockInformation + 7) = v24;
*((_QWORD *)Irp + 7) = LockInformation;
_InterlockedExchange64((volatile __int64 *)Irp + 13, (__int64)FsRtlPrivateCancelFileLockIrp);
if( *((_BYTE *)Irp + 68) && _InterlockedExchange64((volatile __int64 *)Irp + 13, 0i64) )
{
*((_BYTE *)Irp + 69) = NewIrql;
FsRtlPrivateCancelFileLockIrp(0i64, Irp);
v29 = 0;
}
v23 = Iosb;
Iosb->Status = 259;
LockInformation = v31;
v16 = v32;
goto LABEL_10;
}
}
LABEL_14:
v28 = 0;
v23 = Iosb;
LABEL_29:
if( v29 )
{
KxReleaseSpinLock(v16);
__writecr8(NewIrql);
}
if( Irp && v23->Status != 259 )
{
v30 = 0;
ObfReferenceObjectWithTag(FileObject, 0x746C6644u);
FsRtlCompleteLockIrpReal(
*((__int64(__fastcall **)(__int64, __int64))LockInformation + 1),
(__int64)Context,
(__int64)Irp,
v23->Status,
&v30,
(__int64)FileObject);
v26 = v30;
if( v30 < 0 && v23->Status >= 0 )
FsRtlPrivateRemoveLock((__int64)LockInformation, (__int64)&v33, 1);
ObfDereferenceObjectWithTag(FileObject, 0x746C6644ui64);
v23->Status = v26;
}
return v28;
}Referenced by:
FsRtlProcessFileLock