VBoxServiceVMInfo-win.cpp revision 2dbca53b2c122d346cb55db24009d1b1e31e1539
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * VBoxService - Virtual Machine Information for the Host, Windows specifics.
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * Copyright (C) 2009-2010 Sun Microsystems, Inc.
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * available from http://www.virtualbox.org. This file is free software;
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * you can redistribute it and/or modify it under the terms of the GNU
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * General Public License (GPL) as published by the Free Software
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync * additional information or have any questions.
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync/*******************************************************************************
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync* Header Files *
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync*******************************************************************************/
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync#include <Ntsecapi.h> /* Needed for process security information. */
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync/*******************************************************************************
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync* Global Variables *
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync*******************************************************************************/
eac7f6a9d289691723e12e02061b5cf51a6bea58vboxsync/** Function prototypes for dynamic loading. */
aa4bcf0a4b2db3ac352b56a291d49cb8d4b66d32vboxsyncPFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId = NULL;
#ifndef TARGET_NT4
if (h == NULL)
switch (tkClass)
case TokenStatistics:
if (pvTokenInfo)
switch (tkClass)
case TokenStatistics:
CloseHandle(h);
return rc;
if (!pvNew)
} while (cProcesses <= 32768); /* Should be enough; see: http://blogs.technet.com/markrussinovich/archive/2009/07/08/3261309.aspx */
if (paProcs)
return rc;
bool VBoxServiceVMInfoWinSessionHasProcesses(PLUID pSession, VBOXSERVICEVMINFOPROC const *paProcs, DWORD cProcs)
static void VBoxServiceVMInfoWinSafeCopy(PWCHAR pwszDst, size_t cbDst, LSA_UNICODE_STRING const *pSrc, const char *pszWhat)
if (cbCopy)
if (!a_pSession)
if (pSessionData)
if (!pSessionData)
bool fFoundUser = false;
VBoxServiceVMInfoWinSafeCopy(a_pUserInfo->wszAuthenticationPackage, sizeof(a_pUserInfo->wszAuthenticationPackage),
&enmOwnerType))
/* The session ID increments/decrements on Vista often! So don't compare
int iState = 0;
&pBuffer,
&cbRet))
/*VBoxServiceVerbose(3, ("Users: WTSQuerySessionInformation returned %ld bytes, p=%p, state=%d\n", cbRet, pBuffer, pBuffer != NULL ? (INT)*pBuffer : -1));*/
if(cbRet)
fFoundUser = true;
if (pBuffer)
fFoundUser = true;
return fFoundUser;
int rc;
#ifdef RT_ARCH_AMD64
#ifndef TARGET_NT4
# ifdef RT_ARCH_AMD64
VBoxServiceGetFileVersionString(aVBoxFiles[i].pszFilePath, aVBoxFiles[i].pszFileName, szVer, sizeof(szVer));
RTStrPrintf(szPropPath, sizeof(szPropPath), "/VirtualBox/GuestAdd/Components/%s", aVBoxFiles[i].pszFileName);
return VINF_SUCCESS;