ReadFile function Null safety kernel32

int ReadFile(
  1. int hFile,
  2. Pointer<NativeType> lpBuffer,
  3. int nNumberOfBytesToRead,
  4. Pointer<Uint32> lpNumberOfBytesRead,
  5. Pointer<OVERLAPPED> lpOverlapped
)

Reads data from the specified file or input/output (I/O) device. Reads occur at the position specified by the file pointer if supported by the device.

BOOL ReadFile(
  HANDLE       hFile,
  LPVOID       lpBuffer,
  DWORD        nNumberOfBytesToRead,
  LPDWORD      lpNumberOfBytesRead,
  LPOVERLAPPED lpOverlapped
);

Implementation

int ReadFile(int hFile, Pointer lpBuffer, int nNumberOfBytesToRead,
    Pointer<Uint32> lpNumberOfBytesRead, Pointer<OVERLAPPED> lpOverlapped) {
  final _ReadFile = _kernel32.lookupFunction<
      Int32 Function(
          IntPtr hFile,
          Pointer lpBuffer,
          Uint32 nNumberOfBytesToRead,
          Pointer<Uint32> lpNumberOfBytesRead,
          Pointer<OVERLAPPED> lpOverlapped),
      int Function(
          int hFile,
          Pointer lpBuffer,
          int nNumberOfBytesToRead,
          Pointer<Uint32> lpNumberOfBytesRead,
          Pointer<OVERLAPPED> lpOverlapped)>('ReadFile');
  return _ReadFile(
      hFile, lpBuffer, nNumberOfBytesToRead, lpNumberOfBytesRead, lpOverlapped);
}