1 // Licensed to the .NET Foundation under one or more agreements. 2 // The .NET Foundation licenses this file to you under the MIT license. 3 // See the LICENSE file in the project root for more information. 4 5 using Microsoft.Win32.SafeHandles; 6 using System; 7 using System.Runtime.InteropServices; 8 using System.Threading; 9 internal partial class Interop 10 { 11 internal partial class Kernel32 12 { 13 // Note there are two different WriteFile prototypes - this is to use 14 // the type system to force you to not trip across a "feature" in 15 // Win32's async IO support. You can't do the following three things 16 // simultaneously: overlapped IO, free the memory for the overlapped 17 // struct in a callback (or an EndWrite method called by that callback), 18 // and pass in an address for the numBytesRead parameter. 19 [DllImport(Libraries.Kernel32, SetLastError = true)] WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped)20 internal static extern unsafe int WriteFile(SafeHandle handle, byte* bytes, int numBytesToWrite, IntPtr numBytesWritten_mustBeZero, NativeOverlapped* lpOverlapped); 21 } 22 } 23