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 "WriteFile" in kernel32

.

    private static extern bool WriteFile(IntPtr handle,

.

        bool result = WriteFile(_handle, buffer, (uint)count, ref written, IntPtr.Zero);

.

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.

.

        if (!WriteFile(hDevice, pBuffer, dwBytesToWrite, ref lpNumberOfBytesWritten, ref lpOverlapped) &&

.

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.

.

WriteFile, WriteFileGather, ReadFileScatter

.
Summary
.

static extern bool WriteFile(IntPtr hFile, byte [] lpBuffer,

.

static extern unsafe int WriteFile(IntPtr handle, IntPtr buffer,

.

    static extern bool WriteFile(IntPtr hFile, System.Text.StringBuilder lpBuffer,

.

    static extern bool WriteFile(IntPtr hFile, System.Text.StringBuilder lpBuffer,

.

  Private Shared Function WriteFile(ByVal hFile As IntPtr, ByVal Buffer As IntPtr,

.

<DllImport("kernel32.dll", SetlastError:=True)> Friend Shared Function WriteFile( _

.

    Public Shared Function WriteFile( _

.

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 WriteFileScatter).

.

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.

.

    If WriteFile(hDriver, ip, DataLength + 6, dwBytesWritten, Nothing) Then

.

ReadFile, WriteFileGather, ReadFileScatter

.
Documentation
[WriteFile] on MSDN
.
Summary
.

static extern bool WriteFileEx(IntPtr hFile, byte [] lpBuffer,

.

   WriteFileCompletionDelegate lpCompletionRoutine);

.

  public delegate void WriteFileCompletionDelegate(UInt32 dwErrorCode,

.

  static extern bool WriteFileEx(IntPtr hFile, byte [] lpBuffer,

.

    WriteFileCompletionDelegate lpCompletionRoutine);

.

    WriteFileEx(hfile, new byte[] { (byte)'t', (byte)'e', (byte)'s', (byte)'t' }, 4, ref ol, new WriteFileCompletionDelegate(Class1.callback));

.
Documentation
[WriteFileEx] on MSDN
.
Summary
.

static extern bool WriteFileGather(IntPtr hFile, [Out] FILE_SEGMENT_ELEMENT []

.

static extern unsafe int WriteFileGather(IntPtr hFile,

.
Documentation
[WriteFileGather] on MSDN
.

This function is provided for compatibility with 16-bit versions of Windows. New applications should use the WriteFile function.


 
Access PInvoke.net directly from VS: