GuestImpl.h revision bd0ffc0b469d1642b02d98f8cd729a3427c3731e
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson/** @file
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson *
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * VirtualBox COM class implementation
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson */
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson/*
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * Copyright (C) 2006-2007 Oracle Corporation
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson *
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * This file is part of VirtualBox Open Source Edition (OSE), as
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * available from http://www.virtualbox.org. This file is free software;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * you can redistribute it and/or modify it under the terms of the GNU
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * General Public License (GPL) as published by the Free Software
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * Foundation, in version 2 as it comes in the "COPYING" file of the
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac */
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac
8cf870d281dc8c242f083d14dfef05f24aa5fceeJnRouvignac#ifndef ____H_GUESTIMPL
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#define ____H_GUESTIMPL
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#include "VirtualBoxBase.h"
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#include <VBox/ostypes.h>
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
94e4fd51556092f22a664c3c8080cb4688f09140sin#ifdef VBOX_WITH_GUEST_CONTROL
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson# include <VBox/HostServices/GuestControlSvc.h>
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson# include <hgcm/HGCM.h>
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suterusing namespace guestControl;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#endif
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilsontypedef enum
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson{
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GUESTSTATTYPE_CPUUSER = 0,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GUESTSTATTYPE_CPUKERNEL = 1,
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GUESTSTATTYPE_CPUIDLE = 2,
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GUESTSTATTYPE_MEMTOTAL = 3,
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GUESTSTATTYPE_MEMFREE = 4,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GUESTSTATTYPE_MEMBALLOON = 5,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GUESTSTATTYPE_MEMCACHE = 6,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GUESTSTATTYPE_PAGETOTAL = 7,
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GUESTSTATTYPE_PAGEFREE = 8,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GUESTSTATTYPE_MAX = 9
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson} GUESTSTATTYPE;
53247d28ba99538f841a13ea2cde01c3faa3ef36kenneth_suter
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilsonclass Console;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#ifdef VBOX_WITH_GUEST_CONTROL
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilsonclass Progress;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson#endif
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilsonclass ATL_NO_VTABLE Guest :
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson public VirtualBoxSupportErrorInfoImpl<Guest, IGuest>,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public VirtualBoxSupportTranslation<Guest>,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift public VirtualBoxBase,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift VBOX_SCRIPTABLE_IMPL(IGuest)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift{
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilsonpublic:
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson DECLARE_NOT_AGGREGATABLE(Guest)
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson DECLARE_PROTECT_FINAL_CONSTRUCT()
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson BEGIN_COM_MAP(Guest)
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson COM_INTERFACE_ENTRY(ISupportErrorInfo)
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson COM_INTERFACE_ENTRY(IGuest)
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift COM_INTERFACE_ENTRY(IDispatch)
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson END_COM_MAP()
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson DECLARE_EMPTY_CTOR_DTOR (Guest)
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson HRESULT FinalConstruct();
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson void FinalRelease();
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson // public initializer/uninitializer for internal purposes only
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson HRESULT init (Console *aParent);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson void uninit();
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson // IGuest properties
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(COMGETTER(OSTypeId)) (BSTR *aOSTypeId);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(COMGETTER(AdditionsActive)) (BOOL *aAdditionsActive);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(COMGETTER(AdditionsVersion)) (BSTR *aAdditionsVersion);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMGETTER(SupportsSeamless)) (BOOL *aSupportsSeamless);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(COMGETTER(SupportsGraphics)) (BOOL *aSupportsGraphics);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMGETTER(SharedPagingEnabled)) (BOOL *enabled);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMSETTER(SharedPagingEnabled)) (BOOL enabled);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(COMGETTER(MemoryBalloonSize)) (ULONG *aMemoryBalloonSize);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMSETTER(MemoryBalloonSize)) (ULONG aMemoryBalloonSize);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMGETTER(StatisticsUpdateInterval)) (ULONG *aUpdateInterval);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(COMSETTER(StatisticsUpdateInterval)) (ULONG aUpdateInterval);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift // IGuest methods
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(SetCredentials)(IN_BSTR aUserName, IN_BSTR aPassword,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift IN_BSTR aDomain, BOOL aAllowInteractiveLogon);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(ExecuteProcess)(IN_BSTR aCommand, ULONG aFlags,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift IN_BSTR aStdIn, IN_BSTR aStdOut, IN_BSTR aStdErr,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift IN_BSTR aUserName, IN_BSTR aPassword,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG aTimeoutMS, ULONG *aPID, IProgress **aProgress);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson STDMETHOD(GetProcessOutput)(ULONG aPID, ULONG aFlags, ULONG aTimeoutMS, ULONG64 aSize, ComSafeArrayOut(BYTE, aData));
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(GetProcessStatus)(ULONG aPID, ULONG *aExitCode, ULONG *aFlags, ULONG *aStatus);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift STDMETHOD(InternalGetStatistics)(ULONG *aCpuUser, ULONG *aCpuKernel, ULONG *aCpuIdle,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG *aMemTotal, ULONG *aMemFree, ULONG *aMemBalloon, ULONG *aMemShared, ULONG *aMemCache,
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG *aPageTotal, ULONG *aMemAllocTotal, ULONG *aMemFreeTotal, ULONG *aMemBalloonTotal, ULONG *aMemSharedTotal);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift // public methods that are not in IDL
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift void setAdditionsVersion (Bstr aVersion, VBOXOSTYPE aOsType);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift void setSupportsSeamless (BOOL aSupportsSeamless);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift void setSupportsGraphics (BOOL aSupportsGraphics);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift HRESULT SetStatistic(ULONG aCpuId, GUESTSTATTYPE enmType, ULONG aVal);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift // for VirtualBoxSupportErrorInfoImpl
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift static const wchar_t *getComponentName() { return L"Guest"; }
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift# ifdef VBOX_WITH_GUEST_CONTROL
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /** Static callback for handling guest notifications. */
94e4fd51556092f22a664c3c8080cb4688f09140sin static DECLCALLBACK(int) doGuestCtrlNotification(void *pvExtension, uint32_t u32Function, void *pvParms, uint32_t cbParms);
94e4fd51556092f22a664c3c8080cb4688f09140sin# endif
94e4fd51556092f22a664c3c8080cb4688f09140sin
94e4fd51556092f22a664c3c8080cb4688f09140sinprivate:
94e4fd51556092f22a664c3c8080cb4688f09140sin
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift# ifdef VBOX_WITH_GUEST_CONTROL
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson struct CallbackContext
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift uint32_t mContextID;
e595b7115481489471844679dc84222cf121a754boli eVBoxGuestCtrlCallbackType mType;
e595b7115481489471844679dc84222cf121a754boli void *pvData;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift uint32_t cbData;
e595b7115481489471844679dc84222cf121a754boli /** Atomic flag whether callback was called. */
e595b7115481489471844679dc84222cf121a754boli volatile bool bCalled;
e595b7115481489471844679dc84222cf121a754boli /** Pointer to user-supplied IProgress. */
e595b7115481489471844679dc84222cf121a754boli ComObjPtr<Progress> pProgress;
e595b7115481489471844679dc84222cf121a754boli };
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift typedef std::list< CallbackContext > CallbackList;
e595b7115481489471844679dc84222cf121a754boli typedef std::list< CallbackContext >::iterator CallbackListIter;
e595b7115481489471844679dc84222cf121a754boli typedef std::list< CallbackContext >::const_iterator CallbackListIterConst;
e595b7115481489471844679dc84222cf121a754boli
e595b7115481489471844679dc84222cf121a754boli struct GuestProcess
e595b7115481489471844679dc84222cf121a754boli {
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift uint32_t mPID;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift uint32_t mStatus;
e595b7115481489471844679dc84222cf121a754boli uint32_t mFlags;
e595b7115481489471844679dc84222cf121a754boli uint32_t mExitCode;
e595b7115481489471844679dc84222cf121a754boli };
e595b7115481489471844679dc84222cf121a754boli typedef std::list< GuestProcess > GuestProcessList;
e595b7115481489471844679dc84222cf121a754boli typedef std::list< GuestProcess >::iterator GuestProcessIter;
e595b7115481489471844679dc84222cf121a754boli typedef std::list< GuestProcess >::const_iterator GuestProcessIterConst;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift int prepareExecuteEnv(const char *pszEnv, void **ppvList, uint32_t *pcbList, uint32_t *pcEnv);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /** Handler for guest execution control notifications. */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift int notifyCtrlExec(uint32_t u32Function, PHOSTEXECCALLBACKDATA pData);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift int notifyCtrlExecOut(uint32_t u32Function, PHOSTEXECOUTCALLBACKDATA pData);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift CallbackListIter getCtrlCallbackContextByID(uint32_t u32ContextID);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift GuestProcessIter getProcessByPID(uint32_t u32PID);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift void destroyCtrlCallbackContext(CallbackListIter it);
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift uint32_t addCtrlCallbackContext(eVBoxGuestCtrlCallbackType enmType, void *pvData, uint32_t cbData, Progress* pProgress);
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson# endif
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift struct Data
e595b7115481489471844679dc84222cf121a754boli {
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson Data() : mAdditionsActive (FALSE), mSupportsSeamless (FALSE),
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift mSupportsGraphics (FALSE) {}
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Bstr mOSTypeId;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift BOOL mAdditionsActive;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Bstr mAdditionsVersion;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift BOOL mSupportsSeamless;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift BOOL mSupportsGraphics;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift };
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG mMemoryBalloonSize;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG mStatUpdateInterval;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift ULONG mCurrentGuestStat[GUESTSTATTYPE_MAX];
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Console *mParent;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift Data mData;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift# ifdef VBOX_WITH_GUEST_CONTROL
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift /** General extension callback for guest control. */
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift HGCMSVCEXTHANDLE mhExtCtrl;
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson volatile uint32_t mNextContextID;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson CallbackList mCallbackList;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson GuestProcessList mGuestProcessList;
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson# endif
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift};
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift#endif // ____H_GUESTIMPL
7185b49f58c4cdb16d035ecc45e38ec9b1cd9bd0matthew_swift/* vi: set tabstop=4 shiftwidth=4 expandtab: */
0218789478dbe859fd4593d9dd37360750a43893neil_a_wilson