WriteFile function Null safety kernel32

int WriteFile (
  1. int hFile,
  2. Pointer<NativeType> lpBuffer,
  3. int nNumberOfBytesToWrite,
  4. Pointer<Uint32> lpNumberOfBytesWritten,
  5. Pointer<OVERLAPPED> lpOverlapped
)

Writes data to the specified file or input/output (I/O) device.

BOOL WriteFile(
  HANDLE       hFile,
  LPCVOID      lpBuffer,
  DWORD        nNumberOfBytesToWrite,
  LPDWORD      lpNumberOfBytesWritten,
  LPOVERLAPPED lpOverlapped
);

Implementation

int WriteFile(int hFile, Pointer lpBuffer, int nNumberOfBytesToWrite,
    Pointer<Uint32> lpNumberOfBytesWritten, Pointer<OVERLAPPED> lpOverlapped) {
  final _WriteFile = _kernel32.lookupFunction<
      Int32 Function(
          IntPtr hFile,
          Pointer lpBuffer,
          Uint32 nNumberOfBytesToWrite,
          Pointer<Uint32> lpNumberOfBytesWritten,
          Pointer<OVERLAPPED> lpOverlapped),
      int Function(
          int hFile,
          Pointer lpBuffer,
          int nNumberOfBytesToWrite,
          Pointer<Uint32> lpNumberOfBytesWritten,
          Pointer<OVERLAPPED> lpOverlapped)>('WriteFile');
  return _WriteFile(hFile, lpBuffer, nNumberOfBytesToWrite,
      lpNumberOfBytesWritten, lpOverlapped);
}