1

Since the Length parameter of SetFileIoOverlappedRange is ULONG only, how can I lock a 4GB or larger memory block?

Say I allocate a contiguous 4 GB memory block to be used in overlapped I/O and call SetFileIoOverlappedRange twice, once for each half of the block. Both calls return a success (non-zero) status code. Are the calls additive, resulting in locking the whole 4 GB block? Or does the second call "override" the first? How can I tell?

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
  • 2
    The [documentation](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365540.aspx) points out, that *"after a range is associated with a file handle, it cannot be disassociated."* – IInspectable Jul 25 '16 at 13:40
  • @IInspectable Does that mean that the calls are additive? How can I check? Thanks! – Ondrej Kelle Jul 25 '16 at 13:41
  • 1
    Same kind of limitation that exists in MapViewOfFile(), the view cannot be larger than 4GB. Something structural inside the kernel, no idea why it exists. – Hans Passant Jul 25 '16 at 13:59
  • 1
    @HansPassant - ZwMapViewOfSection no limitation for 4Gb on x64 system – RbMm Jul 25 '16 at 14:45
  • 1
    @HansPassant But `dwNumberOfBytesToMap` in [MapViewOfFile](https://msdn.microsoft.com/en-us/library/windows/desktop/aa366761(v=vs.85).aspx) is declared as `SIZE_T`. – Ondrej Kelle Jul 25 '16 at 21:28

1 Answers1

0

Say I allocate a contiguous 4 GB memory block to be used in overlapped I/O and call SetFileIoOverlappedRange twice

I understand the range is intended for the OVERLAPPED struct, not for the data buffer.

(In reality, for the IO_STATUS_BLOCK struct. See FileIoStatusBlockRangeInformation.)

You probably don't need or have 4GB of OVERLAPPED structures.

user541686
  • 205,094
  • 128
  • 528
  • 886