Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There is no such limit. You are mistaken.</p> <p>Clearly you are limited by address space and the requirement that the buffer is a contiguous block of virtual memory. On a 32 bit system each process can only address 2GB of virtual memory. What's more you will not be able to allocate a 2GB contiguous block of memory.</p> <p>But these are general limitations. The <code>ReadFile</code> API will happily read into as big a buffer as your can allocate.</p> <p>You claim to have hit a limit of 8KB but I have just successfully written and read a 1GB file using <code>WriteFile</code> and <code>ReadFile</code>. Clearly you have some problem but it's just not what you think it is. If you could show the rest of the code, especially that which calls your p/invoke then I'm sure it would become obvious.</p> <hr> <p>And now that you have posted your full code we can see what the issue is. You are not reading a file but instead performing read of the physical disk. I see now that's what you meant by "reading directly from a disk" but I think you could have been a bit more specific!</p> <p>Anyway, I don't know the details of what's happening here, but the issue is clearly not <code>ReadFile</code> per se, but that fact that your handle is to the physical disk rather than a file.</p> <p>The documentation for <code>CreateFile</code> states:</p> <blockquote> <p>A volume contains one or more mounted file systems. Volume handles can be opened as noncached at the discretion of the particular file system, even when the noncached option is not specified in CreateFile. You should assume that all Microsoft file systems open volume handles as noncached. The restrictions on noncached I/O for files also apply to volumes.</p> <p>A file system may or may not require buffer alignment even though the data is noncached. However, if the noncached option is specified when opening a volume, buffer alignment is enforced regardless of the file system on the volume. It is recommended on all file systems that you open volume handles as noncached, and follow the noncached I/O restrictions.</p> </blockquote> <p>I think you should consider asking a new question about how to read from physical disks.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload