VirtualBox

source: vbox/trunk/src/VBox/Main/include/RpcChannelHook.h@ 75488

Last change on this file since 75488 was 71716, checked in by vboxsync, 7 years ago

VBoxSDS,VBoxSVC: Replaced the enviornment variable hack (VBOX_SERVICE_PROCESS) for preventing VBoxSDS and VBoxSVC from getting watched as clients, with a special export in the executable (Is_VirtualBox_service_process_like_VBoxSDS_And_VBoxSDS). Some cleanups here and there.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1/* $Id: RpcChannelHook.h 71716 2018-04-06 18:16:30Z vboxsync $ */
2/** @file
3* VBox COM Rpc Channel Hook definition
4*/
5
6/*
7 * Copyright (C) 2017-2018 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ____H_RPCCHANNELHOOK
19#define ____H_RPCCHANNELHOOK
20
21#include <iprt/cdefs.h>
22
23#ifdef RT_OS_WINDOWS
24#include <iprt/win/windows.h>
25#include <ObjIdl.h>
26
27
28typedef void *PRPC_CHANNEL_HOOK;
29
30// {CEDA3E95-A46A-4C41-AA01-EFFD856E455C}
31static const GUID RPC_CHANNEL_EXTENSION_GUID =
32{ 0xceda3e95, 0xa46a, 0x4c41,{ 0xaa, 0x1, 0xef, 0xfd, 0x85, 0x6e, 0x45, 0x5c } };
33
34RT_C_DECLS_BEGIN
35// C wrapper for using in proxy
36void SetupClientRpcChannelHook(void);
37RT_C_DECLS_END
38
39
40#if defined(__cplusplus)
41
42/*
43* This is RPC channel hook implementation for registering VirtualBox API clients.
44* This channel hook instantiated in COM client process by VBoxProxyStub
45* We use it to catch a moment when a new VirtualBox object sucessfully instantiated to
46* register new API client in a VBoxSDS clients list.
47*/
48class CRpcChannelHook : public IChannelHook
49{
50public:
51 CRpcChannelHook(REFGUID channelHookID = RPC_CHANNEL_EXTENSION_GUID): m_ChannelHookID(channelHookID) {};
52
53 /* IUnknown Interface methods */
54 STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
55 STDMETHODIMP_(ULONG) AddRef(void);
56 STDMETHODIMP_(ULONG) Release(void);
57
58 /* IChannelHook Interface methods */
59 STDMETHODIMP_(void) ClientGetSize(REFGUID uExtent, REFIID riid, ULONG *pDataSize);
60 STDMETHODIMP_(void) ClientFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer);
61 STDMETHODIMP_(void) ClientNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep, HRESULT hrFault);
62
63 STDMETHODIMP_(void) ServerNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep);
64 STDMETHODIMP_(void) ServerGetSize(REFGUID uExtent, REFIID riid, HRESULT hrFault, ULONG *pDataSize);
65 STDMETHODIMP_(void) ServerFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer, HRESULT hrFault);
66
67protected:
68 static bool IsChannelHookRegistered();
69 static void RegisterChannelHook();
70
71protected:
72 const GUID m_ChannelHookID;
73 static volatile bool s_fChannelRegistered;
74 static volatile bool s_fVBpoxSDSCalledOnce;
75 static CRpcChannelHook s_RpcChannelHook;
76
77 /* C wrapper*/
78 friend void SetupClientRpcChannelHook(void);
79};
80
81
82#endif // #if defined(__cplusplus)
83
84
85#endif // #ifdef RT_OS_WINDOWS
86
87#endif // ____H_RPCCHANNELHOOK
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette