Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

Search Results for "ReadFile" in [All]

Structures

.
Summary
The COMMTIMEOUTS structure is used in the SetCommTimeouts and GetCommTimeouts functions to set and query the time-out parameters for a communications device. The parameters determine the behavior of ReadFile, WriteFile, ReadFileEx, and WriteFileEx operations on the device.
.

Maximum time allowed to elapse between the arrival of two bytes on the communications line, in milliseconds. During a ReadFile operation, the time period begins when the first byte is received. If the interval between the arrival of any two bytes exceeds this amount, the ReadFile operation is completed and any buffered data is returned. A value of zero indicates that interval time-outs are not used.

.

If an application sets ReadIntervalTimeout and ReadTotalTimeoutMultiplier to MAXDWORD and sets ReadTotalTimeoutConstant to a value greater than zero and less than MAXDWORD, one of the following occurs when the ReadFile function is called:

.

->If there are any bytes in the input buffer, ReadFile returns immediately with the bytes in the buffer.

.

->If there are no bytes in the input buffer, ReadFile waits until a byte arrives and then returns immediately.

.

->If no bytes arrive within the time specified by ReadTotalTimeoutConstant, ReadFile times out.

rapi

. .

public static extern bool CeReadFile(

.
Documentation
[CeReadFile] on MSDN

kernel32

.

    private static extern bool ReadFile(IntPtr handle,

.

        // first read the data into an internal buffer since ReadFile cannot read into a buf at

.

        bool f = ReadFile(_handle, buf, (uint)count, ref read, IntPtr.Zero);

.

        throw new Win32Exception(Marshal.GetLastWin32Error(), "ReadFile failed");

.

   if (!Win32.ReadFile(handle, data, length, out len, IntPtr.Zero))

.

     FsctlReadFileUsnData = (EFileDevice.FileSystem << 16) | (58 << 2) | EMethod.Neither | (0 << 14),

.

    private void ReadFile() {

.

Warning! GetOverlappedResult writes to the address of the buffer specified in the ORIGINAL OPERATION (ie/ ReadFile or WriteFile). .NET may move the address of the buffer before GetOverlappedResult returns, resulting in a buffer overflow. Use AllocHGlobal and FreeHGlobal or otherwise ensure the buffer is pinned between the two calls.

.
Summary
.

static extern bool ReadFile(IntPtr hFile, [Out] byte[] lpBuffer,

.

static extern unsafe int ReadFile(IntPtr handle, IntPtr bytes, uint numBytesToRead,

.

static extern bool ReadFile(IntPtr hFile, [Out] byte[] lpBuffer, uint nNumberOfBytesToRead,

.

static extern unsafe bool ReadFile(

.

  Private Shared Function ReadFile(ByVal hFile As IntPtr, ByVal Buffer As IntPtr, _

.

<DllImport("kernel32.dll")> Friend Shared Function ReadFile( _

.

The documentation states that if using unbuffered IO, the memory must be "storage aligned" (aligned to the sector size of the storage device). Either this is not enforced, or managed allocations (specifically byte arrays) are automatically storage aligned because there seems to be no problem using it. Note that storage aligned and page aligned are not the same, and managed allocations are not in general page aligned (required for ReadFileScatter).

.

Regarding the above note, my experience shows that failing to provide a storage-aligned buffer causes ReadFile to perform all IO synchronously. I.e. it always blocks until the operation is complete and never returns ERROR_IO_PENDING.

.

Warning! GetOverlappedResult writes to the address of the buffer specified in the ORIGINAL OPERATION (ie/ ReadFile or WriteFile). .NET may move the address of the buffer before GetOverlappedResult returns, resulting in a buffer overflow. Use AllocHGlobal and FreeHGlobal or otherwise ensure the buffer is pinned between the two calls. The same applies to the overlapped structure.

.

    If ReadFile(hDriver, ip, Marshal.SizeOf(erg), dwBytesReceived, Nothing) Then

.

        public unsafe byte[] CT_ReadFile(int InputReportByteLength)

.

            if (ReadFile(HidHandle, BufBytes, InputReportByteLength, ref BytesRead, null))

.

WriteFile, WriteFileGather, ReadFileScatter

.
Documentation
[ReadFile] on MSDN
.
Summary
.

static extern bool ReadFileEx(IntPtr hFile, [Out] byte [] lpBuffer,

.

ReadFileCompletionDelegate <- need to define this

.
Documentation
[ReadFileEx] on MSDN
.
Summary
.

static extern bool ReadFileScatter(IntPtr hFile, FILE_SEGMENT_ELEMENT []

.
Documentation
[ReadFileScatter] on MSDN
.

Warning! GetOverlappedResult writes to the address of the buffer specified in the ORIGINAL OPERATION (ie/ ReadFile or WriteFile). .NET may move the address of the buffer before GetOverlappedResult returns, resulting in a buffer overflow. Use AllocHGlobal and FreeHGlobal or otherwise ensure the buffer is pinned between the two calls.

.

ReadFile, WriteFileGather, ReadFileScatter

.

ReadFileScatter

setupapi

.

Private Declare Function ReadFile Lib “kernel32″ _

advapi32

13: Tyde
.

ReadFile


 
Access PInvoke.net directly from VS: