Пример #1
0
        public bool IsWow64Process(SafeProcessHandle process)
        {
            IntPtr handle = process == null?GetCurrentProcess() : process.DangerousGetHandle();

            if (IO.Windows.FileSystemWin.StaticIsOSVersionGreaterOrEqual(IO.Windows.FileSystemWin.MinWindowsVersionThatSupportsWow64Processes))
            {
                return(ExternIsWow64Process(handle, out bool result) && result);
            }

            return(false);
        }
Пример #2
0
 private static extern CreateDetouredProcessStatus ExternCreateDetouredProcess(
     [MarshalAs(UnmanagedType.LPWStr)] string lpcwCommandLine,
     int dwCreationFlags,
     IntPtr lpEnvironment,
     [MarshalAs(UnmanagedType.LPWStr)] string lpcwWorkingDirectory,
     SafeHandle hStdInput,
     SafeHandle hStdOutput,
     SafeHandle hStdError,
     SafeHandle hJob,
     IntPtr injector,
     bool addProcessToSilo,
     out SafeProcessHandle phProcess,
     out SafeThreadHandle phThread,
     out int pdwProcessId);
Пример #3
0
        /// <inheritdoc />
        public CreateDetouredProcessStatus CreateDetouredProcess(
            string lpcwCommandLine,
            int dwCreationFlags,
            IntPtr lpEnvironment,
            string lpcwWorkingDirectory,
            SafeHandle hStdInput,
            SafeHandle hStdOutput,
            SafeHandle hStdError,
            SafeHandle hJob,
            IProcessInjector injector,
            bool addProcessToSilo,
            out SafeProcessHandle phProcess,
            out SafeThreadHandle phThread,
            out int pdwProcessId,
            out int errorCode)
        {
            Assert64Process();

            var status = ExternCreateDetouredProcess(
                lpcwCommandLine,
                dwCreationFlags,
                lpEnvironment,
                lpcwWorkingDirectory,
                hStdInput,
                hStdOutput,
                hStdError,
                hJob,
                injector == null ? IntPtr.Zero : injector.Injector(),
                addProcessToSilo,
                out phProcess,
                out phThread,
                out pdwProcessId);

            errorCode = status == CreateDetouredProcessStatus.Succeeded ? 0 : Marshal.GetLastWin32Error();

            // TODO: Enforce this postcondition.
            // Contract.Assume(status == CreateDetouredProcessStatus.Succeeded || errorCode != 0, "Expected a valid error code on failure.");
            return(status);
        }
Пример #4
0
 /// <inheritdoc />
 public bool GetExitCodeProcess(SafeProcessHandle hProcess, out int exitCode)
 => ExternGetExitCodeProcess(hProcess, out exitCode);
Пример #5
0
 /// <inheritdoc />
 public bool TerminateProcess(SafeProcessHandle hProcess, int exitCode)
 => ExternTerminateProcess(hProcess, exitCode);
Пример #6
0
 private static extern uint ExternGetModuleFileNameEx(
     SafeProcessHandle hProcess,
     IntPtr hModule,
     [Out] StringBuilder lpBaseName,
     uint nSize);
Пример #7
0
 private static extern bool ExternIsProcessInJob(SafeProcessHandle hProcess, IntPtr hJob, [MarshalAs(UnmanagedType.Bool)] out bool result);
Пример #8
0
 private static extern bool ExternGetExitCodeProcess(SafeProcessHandle processHandle, out int exitCode);
Пример #9
0
 private static extern bool ExternTerminateProcess(SafeProcessHandle hProcess, int exitCode);
Пример #10
0
 /// <inheritdoc />
 public uint GetModuleFileNameEx(SafeProcessHandle hProcess, IntPtr hModule, StringBuilder lpBaseName, uint nSize)
 => ExternGetModuleFileNameEx(hProcess, hModule, lpBaseName, nSize);
Пример #11
0
 /// <inheritdoc />
 public bool IsProcessInJob(SafeProcessHandle hProcess, IntPtr hJob, out bool result)
 => ExternIsProcessInJob(hProcess, hJob, out result);