CreateNamedPipe function Null safety kernel32

int CreateNamedPipe(
  1. Pointer<Utf16> lpName,
  2. int dwOpenMode,
  3. int dwPipeMode,
  4. int nMaxInstances,
  5. int nOutBufferSize,
  6. int nInBufferSize,
  7. int nDefaultTimeOut,
  8. Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes
)

Creates an instance of a named pipe and returns a handle for subsequent pipe operations. A named pipe server process uses this function either to create the first instance of a specific named pipe and establish its basic attributes or to create a new instance of an existing named pipe.

HANDLE CreateNamedPipeW(
  LPCWSTR                lpName,
  DWORD                 dwOpenMode,
  DWORD                 dwPipeMode,
  DWORD                 nMaxInstances,
  DWORD                 nOutBufferSize,
  DWORD                 nInBufferSize,
  DWORD                 nDefaultTimeOut,
  LPSECURITY_ATTRIBUTES lpSecurityAttributes);

Implementation

int CreateNamedPipe(
    Pointer<Utf16> lpName,
    int dwOpenMode,
    int dwPipeMode,
    int nMaxInstances,
    int nOutBufferSize,
    int nInBufferSize,
    int nDefaultTimeOut,
    Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes) {
  final _CreateNamedPipe = _kernel32.lookupFunction<
          IntPtr Function(
              Pointer<Utf16> lpName,
              Uint32 dwOpenMode,
              Uint32 dwPipeMode,
              Uint32 nMaxInstances,
              Uint32 nOutBufferSize,
              Uint32 nInBufferSize,
              Uint32 nDefaultTimeOut,
              Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes),
          int Function(
              Pointer<Utf16> lpName,
              int dwOpenMode,
              int dwPipeMode,
              int nMaxInstances,
              int nOutBufferSize,
              int nInBufferSize,
              int nDefaultTimeOut,
              Pointer<SECURITY_ATTRIBUTES> lpSecurityAttributes)>(
      'CreateNamedPipeW');
  return _CreateNamedPipe(lpName, dwOpenMode, dwPipeMode, nMaxInstances,
      nOutBufferSize, nInBufferSize, nDefaultTimeOut, lpSecurityAttributes);
}