CreateProcess function Null safety kernel32

int CreateProcess(
  1. Pointer<Utf16> lpApplicationName,
  2. Pointer<Utf16> lpCommandLine,
  3. Pointer<SECURITY_ATTRIBUTES> lpProcessAttributes,
  4. Pointer<SECURITY_ATTRIBUTES> lpThreadAttributes,
  5. int bInheritHandles,
  6. int dwCreationFlags,
  7. Pointer<NativeType> lpEnvironment,
  8. Pointer<Utf16> lpCurrentDirectory,
  9. Pointer<STARTUPINFO> lpStartupInfo,
  10. Pointer<PROCESS_INFORMATION> lpProcessInformation
)

Creates a new process and its primary thread. The new process runs in the security context of the calling process.

BOOL CreateProcessW(
  LPCWSTR               lpApplicationName,
  LPWSTR                lpCommandLine,
  LPSECURITY_ATTRIBUTES lpProcessAttributes,
  LPSECURITY_ATTRIBUTES lpThreadAttributes,
  BOOL                  bInheritHandles,
  DWORD                 dwCreationFlags,
  LPVOID                lpEnvironment,
  LPCWSTR               lpCurrentDirectory,
  LPSTARTUPINFOW        lpStartupInfo,
  LPPROCESS_INFORMATION lpProcessInformation
);

Implementation

int CreateProcess(
    Pointer<Utf16> lpApplicationName,
    Pointer<Utf16> lpCommandLine,
    Pointer<SECURITY_ATTRIBUTES> lpProcessAttributes,
    Pointer<SECURITY_ATTRIBUTES> lpThreadAttributes,
    int bInheritHandles,
    int dwCreationFlags,
    Pointer lpEnvironment,
    Pointer<Utf16> lpCurrentDirectory,
    Pointer<STARTUPINFO> lpStartupInfo,
    Pointer<PROCESS_INFORMATION> lpProcessInformation) {
  final _CreateProcess = _kernel32.lookupFunction<
      Int32 Function(
          Pointer<Utf16> lpApplicationName,
          Pointer<Utf16> lpCommandLine,
          Pointer<SECURITY_ATTRIBUTES> lpProcessAttributes,
          Pointer<SECURITY_ATTRIBUTES> lpThreadAttributes,
          Int32 bInheritHandles,
          Uint32 dwCreationFlags,
          Pointer lpEnvironment,
          Pointer<Utf16> lpCurrentDirectory,
          Pointer<STARTUPINFO> lpStartupInfo,
          Pointer<PROCESS_INFORMATION> lpProcessInformation),
      int Function(
          Pointer<Utf16> lpApplicationName,
          Pointer<Utf16> lpCommandLine,
          Pointer<SECURITY_ATTRIBUTES> lpProcessAttributes,
          Pointer<SECURITY_ATTRIBUTES> lpThreadAttributes,
          int bInheritHandles,
          int dwCreationFlags,
          Pointer lpEnvironment,
          Pointer<Utf16> lpCurrentDirectory,
          Pointer<STARTUPINFO> lpStartupInfo,
          Pointer<PROCESS_INFORMATION> lpProcessInformation)>('CreateProcessW');
  return _CreateProcess(
      lpApplicationName,
      lpCommandLine,
      lpProcessAttributes,
      lpThreadAttributes,
      bInheritHandles,
      dwCreationFlags,
      lpEnvironment,
      lpCurrentDirectory,
      lpStartupInfo,
      lpProcessInformation);
}