process-win.cpp revision ad6025fdf797313667d02b6dd49b0be9b58d4a05
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Incredibly Portable Runtime - Process, Win32.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
45e9809aff7304721fddb95654901b32195c9c7avboxsync * available from http://www.virtualbox.org. This file is free software;
45e9809aff7304721fddb95654901b32195c9c7avboxsync * you can redistribute it and/or modify it under the terms of the GNU
45e9809aff7304721fddb95654901b32195c9c7avboxsync * General Public License (GPL) as published by the Free Software
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * The contents of this file may alternatively be used under the terms
45e9809aff7304721fddb95654901b32195c9c7avboxsync * of the Common Development and Distribution License Version 1.0
45e9809aff7304721fddb95654901b32195c9c7avboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * VirtualBox OSE distribution, in which case the provisions of the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * CDDL are applicable instead of those of the GPL.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * You may elect to license modified versions of this file under the
45e9809aff7304721fddb95654901b32195c9c7avboxsync * terms and conditions of either the GPL or the CDDL or both.
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
45e9809aff7304721fddb95654901b32195c9c7avboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
45e9809aff7304721fddb95654901b32195c9c7avboxsync * additional information or have any questions.
45e9809aff7304721fddb95654901b32195c9c7avboxsync/*******************************************************************************
45e9809aff7304721fddb95654901b32195c9c7avboxsync* Header Files *
45e9809aff7304721fddb95654901b32195c9c7avboxsync*******************************************************************************/
45e9809aff7304721fddb95654901b32195c9c7avboxsync * This is from Winternl.h. It has been copied here
45e9809aff7304721fddb95654901b32195c9c7avboxsync * because the header does not define a calling convention for
45e9809aff7304721fddb95654901b32195c9c7avboxsync * its prototypes and just assumes that _stdcall is the standard
45e9809aff7304721fddb95654901b32195c9c7avboxsync * calling convention.
45e9809aff7304721fddb95654901b32195c9c7avboxsynctypedef struct _PEB {
typedef enum _PROCESSINFOCLASS {
RTR3DECL(int) RTProcCreate(const char *pszExec, const char * const *papszArgs, RTENV Env, unsigned fFlags, PRTPROCESS pProcess)
if (pProcess)
#if defined(RT_ARCH_AMD64)
static bool fInitialized = false;
if (!fInitialized)
if (hmodKernel32)
fInitialized = true;
if (pfnGetProcessId)
if (!*pProcess)
return rc;
if (Status != 0)
int rc = ERROR_INTERNAL_ERROR; /* (we don't have a valid conversion here, but this shouldn't happen anyway.) */
AssertMsgFailed(("failed to get pid from hProcess=%#x rc=%Vrc Status=%#x\n", hProcess, rc, Status));
return rc;
return VINF_SUCCESS;
return rc;
AssertReturn(!(fFlags & ~(RTPROCWAIT_FLAGS_BLOCK | RTPROCWAIT_FLAGS_NOBLOCK)), VERR_INVALID_PARAMETER);
switch (WaitRc)
case WAIT_OBJECT_0:
if (pProcStatus)
return VINF_SUCCESS;
case WAIT_TIMEOUT:
return VERR_PROCESS_RUNNING;
case WAIT_FAILED:
case WAIT_ABANDONED:
AssertFailed();
return VERR_GENERAL_FAILURE;
return VERR_GENERAL_FAILURE;
if (fRc)
return VINF_SUCCESS;
BOOL fRc = GetProcessAffinityMask(GetCurrentProcess(), &dwProcessAffinityMask, &dwSystemAffinityMask);
return dwProcessAffinityMask;
return pszExecName;
return NULL;