Search code examples
winapintfs

Confusion about file offset in Win32 LockFileEx API


According to the LockFileEx() documentation, a file offset is specified in lpOverlapped->Offset/OffsetHigh. But when debugging winword.exe to analyze its file system behaviors, I see it calls LockFileEx() on a 122-byte file with Offset=0xfffffffb and OffsetHigh=0xffffffff, and the call completes successfully. Apparently this is not a valid offset, what does this mean?


Solution

  • From MSDN:

    Locking a region that goes beyond the current end-of-file position is not an error.

    They could be using the lock as some kind of flag or for synchronization.