DuplicateHandle function Null safety kernel32

int DuplicateHandle(
  1. int hSourceProcessHandle,
  2. int hSourceHandle,
  3. int hTargetProcessHandle,
  4. Pointer<IntPtr> lpTargetHandle,
  5. int dwDesiredAccess,
  6. int bInheritHandle,
  7. int dwOptions
)

Duplicates an object handle.

BOOL DuplicateHandle(
  HANDLE   hSourceProcessHandle,
  HANDLE   hSourceHandle,
  HANDLE   hTargetProcessHandle,
  LPHANDLE lpTargetHandle,
  DWORD    dwDesiredAccess,
  BOOL     bInheritHandle,
  DWORD    dwOptions
);

Implementation

int DuplicateHandle(
    int hSourceProcessHandle,
    int hSourceHandle,
    int hTargetProcessHandle,
    Pointer<IntPtr> lpTargetHandle,
    int dwDesiredAccess,
    int bInheritHandle,
    int dwOptions) {
  final _DuplicateHandle = _kernel32.lookupFunction<
      Int32 Function(
          IntPtr hSourceProcessHandle,
          IntPtr hSourceHandle,
          IntPtr hTargetProcessHandle,
          Pointer<IntPtr> lpTargetHandle,
          Uint32 dwDesiredAccess,
          Int32 bInheritHandle,
          Uint32 dwOptions),
      int Function(
          int hSourceProcessHandle,
          int hSourceHandle,
          int hTargetProcessHandle,
          Pointer<IntPtr> lpTargetHandle,
          int dwDesiredAccess,
          int bInheritHandle,
          int dwOptions)>('DuplicateHandle');
  return _DuplicateHandle(
      hSourceProcessHandle,
      hSourceHandle,
      hTargetProcessHandle,
      lpTargetHandle,
      dwDesiredAccess,
      bInheritHandle,
      dwOptions);
}