ReadFile function kernel32

Win32Result<bool> ReadFile(
  1. HANDLE hFile,
  2. Pointer<Uint8>? 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.

To learn more, see learn.microsoft.com/windows/win32/api/fileapi/nf-fileapi-readfile.

Implementation

Win32Result<bool> ReadFile(
  HANDLE hFile,
  Pointer<Uint8>? lpBuffer,
  int nNumberOfBytesToRead,
  Pointer<Uint32>? lpNumberOfBytesRead,
  Pointer<OVERLAPPED>? lpOverlapped,
) {
  final result_ = ReadFile_Wrapper(
    hFile,
    lpBuffer ?? nullptr,
    nNumberOfBytesToRead,
    lpNumberOfBytesRead ?? nullptr,
    lpOverlapped ?? nullptr,
  );
  return Win32Result(value: result_.value.i32 != FALSE, error: result_.error);
}