VBoxVMInfo.cpp revision d65680efa46fa49e8bf14e67b29b782510ff934c
/* $Id$ */
/** @file
* VBoxVMInfo - Virtual machine (guest) information for the host.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* Sun Microsystems, Inc. confidential
* All rights reserved
*/
#include "VBoxService.h"
#include "VBoxVMInfo.h"
#include "VBoxVMInfoAdditions.h"
#include "VBoxVMInfoUser.h"
#include "VBoxVMInfoNet.h"
#include "VBoxVMInfoOS.h"
static VBOXINFORMATIONCONTEXT gCtx = {0};
{
int rc = VINF_SUCCESS;
return VERR_INVALID_PARAMETER;
/* Append base path. */
RTStrPrintf(szKeyTemp, sizeof(szKeyTemp), "/VirtualBox/%s", a_pszKey); /** @todo r=bird: Why didn't you hardcode this into the strings before calling this function? */
if (a_pszValue != NULL)
{
if (!RT_SUCCESS(rc)) {
LogRel(("vboxVMInfoThread: Failed to convert the value name \"%s\" to Utf8! Error: %Rrc\n", a_pszValue, rc));
goto cleanup;
}
}
rc = VbglR3GuestPropWriteValue(a_pCtx->iInfoSvcClientID, szKeyTemp, (a_pszValue == NULL) ? NULL : pszValue);
if (!RT_SUCCESS(rc))
{
LogRel(("vboxVMInfoThread: Failed to store the property \"%s\"=\"%s\"! ClientID: %d, Error: %Rrc\n", szKeyTemp, pszValue, a_pCtx->iInfoSvcClientID, rc));
goto cleanup;
}
else
return rc;
}
{
}
{
Log(("vboxVMInfoThread: Init.\n"));
if (!RT_SUCCESS(rc))
else
{
/* Loading dynamic APIs. */
{
gCtx.pfnWTSGetActiveConsoleSessionId = (fnWTSGetActiveConsoleSessionId)GetProcAddress(hKernel32, "WTSGetActiveConsoleSessionId");
}
*pfStartThread = true;
*ppInstance = &gCtx;
}
return 0;
}
{
if (!RT_SUCCESS(rc))
Log(("vboxVMInfoThread: Destroyed.\n"));
return;
}
{
bool fTerminate = false;
Log(("vboxVMInfoThread: Started.\n"));
Log(("vboxVMInfoThread: Invalid context!\n"));
return -1;
}
DWORD cbReturned = 0;
/* Required for network information. */
Log(("vboxVMInfoThread: WSAStartup failed! Error: %Rrc\n", RTErrConvertFromWin32(WSAGetLastError())));
return -1;
}
do
{
if (dwCnt++ < 5)
{
/* Sleep a bit to not eat too much CPU. */
Log(("vboxVMInfoThread: Invalid stop event!\n"));
{
Log(("vboxVMInfoThread: Got stop event, terminating ...\n"));
fTerminate = true;
break;
}
continue;
}
dwCnt = 0;
}
while (!fTerminate);
WSACleanup();
return 0;
}