svcmain.cpp revision dced478b440a327fb550155c0f73c1ac968ad93b
/** @file
*
* SVCMAIN - COM out-of-proc server main entry
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <stdio.h>
#include "svchlp.h"
#include "MachineImpl.h"
#include "HardDiskImpl.h"
#include "DVDImageImpl.h"
#include "FloppyImageImpl.h"
#include "GuestOSTypeImpl.h"
#include "ProgressImpl.h"
#include "SystemPropertiesImpl.h"
#include "VirtualBoxImpl.h"
#include "Logging.h"
#include <atlbase.h>
#include <atlcom.h>
#define _ATL_FREE_THREADED
class CExeModule : public CComModule
{
public:
void MonitorShutdown();
bool StartMonitor();
bool bActivity;
};
/* Passed to CreateThread to monitor the shutdown event */
{
p->MonitorShutdown();
return 0;
}
{
if (l == 0)
{
bActivity = true;
}
return l;
}
/* Monitors the shutdown event */
void CExeModule::MonitorShutdown()
{
while (1)
{
do
{
bActivity = false;
} while (dwWait == WAIT_OBJECT_0);
/* timed out */
{
if (!bActivity && m_nLockCnt == 0)
#endif
break;
}
}
}
bool CExeModule::StartMonitor()
{
if (hEventShutdown == NULL)
return false;
return (h != NULL);
}
{
{
{
if (*p1 == *p)
p = CharNext(p);
}
}
return NULL;
}
{
{
}
return 0;
}
/////////////////////////////////////////////////////////////////////////////
//
{
/*
* Initialize the VBox runtime without loading
* the support driver.
*/
RTR3Init();
#else
#endif
/*
* Need to initialize security to access performance enumerators.
*/
NULL,
-1,
NULL,
NULL,
int nRet = 0;
{
{
break;
}
{
break;
}
{
break;
}
{
L"/RegServer:\tregister COM out-of-proc server\n"
L"/UnregServer:\tunregister COM out-of-proc server\n"
L"/ReregServer:\tunregister and register COM server\n"
L"no options:\trun the server";
nRet = -1;
break;
}
{
Log (("SVCMAIN: Processing Helper request (cmdline=\"%ls\")...\n",
lpszToken + 6));
int vrc = VINF_SUCCESS;
if (lpszToken)
{
++ lpszToken;
{
if (lpszToken2)
}
}
if (VBOX_SUCCESS (vrc))
{
/* do the helper job */
if (VBOX_SUCCESS (vrc))
}
if (VBOX_FAILURE (vrc))
{
"Failed to process Helper request (%Vrc).", vrc);
}
/* don't run the COM server */
break;
}
}
if (bRun)
{
hRes = CoResumeClassObjects();
#else
#endif
while (GetMessage(&msg, 0, 0, 0))
}
Log(("SVCMAIN: Returning, COM server process ends.\n"));
return nRet;
}