ReadConsole function Null safety kernel32

int ReadConsole(
  1. int hConsoleInput,
  2. Pointer<NativeType> lpBuffer,
  3. int nNumberOfCharsToRead,
  4. Pointer<Uint32> lpNumberOfCharsRead,
  5. Pointer<Void> pInputControl
)

Reads character input from the console input buffer and removes it from the buffer.

BOOL WINAPI ReadConsoleW(
  _In_     HANDLE  hConsoleInput,
  _Out_    LPVOID  lpBuffer,
  _In_     DWORD   nNumberOfCharsToRead,
  _Out_    LPDWORD lpNumberOfCharsRead,
  _In_opt_ LPVOID  pInputControl
);

Implementation

int ReadConsole(int hConsoleInput, Pointer lpBuffer, int nNumberOfCharsToRead,
    Pointer<Uint32> lpNumberOfCharsRead, Pointer<Void> pInputControl) {
  final _ReadConsole = _kernel32.lookupFunction<
      Int32 Function(
          IntPtr hConsoleInput,
          Pointer lpBuffer,
          Uint32 nNumberOfCharsToRead,
          Pointer<Uint32> lpNumberOfCharsRead,
          Pointer<Void> pInputControl),
      int Function(
          int hConsoleInput,
          Pointer lpBuffer,
          int nNumberOfCharsToRead,
          Pointer<Uint32> lpNumberOfCharsRead,
          Pointer<Void> pInputControl)>('ReadConsoleW');
  return _ReadConsole(hConsoleInput, lpBuffer, nNumberOfCharsToRead,
      lpNumberOfCharsRead, pInputControl);
}