WriteConsole function Null safety kernel32

int WriteConsole(
  1. int hConsoleOutput,
  2. Pointer<NativeType> lpBuffer,
  3. int nNumberOfCharsToWrite,
  4. Pointer<Uint32> lpNumberOfCharsWritten,
  5. Pointer<NativeType> lpReserved
)

Writes a character string to a console screen buffer beginning at the current cursor location.

BOOL WINAPI WriteConsoleW(
  _In_             HANDLE  hConsoleOutput,
  _In_       const VOID    *lpBuffer,
  _In_             DWORD   nNumberOfCharsToWrite,
  _Out_opt_        LPDWORD lpNumberOfCharsWritten,
  _Reserved_       LPVOID  lpReserved
);

Implementation

int WriteConsole(
    int hConsoleOutput,
    Pointer lpBuffer,
    int nNumberOfCharsToWrite,
    Pointer<Uint32> lpNumberOfCharsWritten,
    Pointer lpReserved) {
  final _WriteConsole = _kernel32.lookupFunction<
      Int32 Function(
          IntPtr hConsoleOutput,
          Pointer lpBuffer,
          Uint32 nNumberOfCharsToWrite,
          Pointer<Uint32> lpNumberOfCharsWritten,
          Pointer lpReserved),
      int Function(
          int hConsoleOutput,
          Pointer lpBuffer,
          int nNumberOfCharsToWrite,
          Pointer<Uint32> lpNumberOfCharsWritten,
          Pointer lpReserved)>('WriteConsoleW');
  return _WriteConsole(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite,
      lpNumberOfCharsWritten, lpReserved);
}