VBoxServiceVMInfo-win.cpp revision 9b5bf00cddef78a2e5ab748a141ea830ce47abe2
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * VBoxService - Virtual Machine Information for the Host, Windows specifics.
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * Copyright (C) 2009-2010 Sun Microsystems, Inc.
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * This file is part of VirtualBox Open Source Edition (OSE), as
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * available from http://www.virtualbox.org. This file is free software;
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * you can redistribute it and/or modify it under the terms of the GNU
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * General Public License (GPL) as published by the Free Software
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * Foundation, in version 2 as it comes in the "COPYING" file of the
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * Clara, CA 95054 USA or visit http://www.sun.com if you need
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp * additional information or have any questions.
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp/*******************************************************************************
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp* Header Files *
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp*******************************************************************************/
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp/*******************************************************************************
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp* Global Variables *
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp*******************************************************************************/
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdp/** Function prototypes for dynamic loading. */
27fbcf8a5036d0cea1c401094c8bb0731ddc87ecdpPFNWTSGETACTIVECONSOLESESSIONID g_pfnWTSGetActiveConsoleSessionId = NULL;
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;