1 | /* $Id: RpcChannelHook.h 71160 2018-02-28 17:07:35Z 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 |
|
---|
28 | typedef void* PRPC_CHANNEL_HOOK;
|
---|
29 |
|
---|
30 | // {CEDA3E95-A46A-4C41-AA01-EFFD856E455C}
|
---|
31 | static const GUID RPC_CHANNEL_EXTENSION_GUID =
|
---|
32 | { 0xceda3e95, 0xa46a, 0x4c41,{ 0xaa, 0x1, 0xef, 0xfd, 0x85, 0x6e, 0x45, 0x5c } };
|
---|
33 |
|
---|
34 | #if defined(__cplusplus)
|
---|
35 | extern "C"
|
---|
36 | {
|
---|
37 | #endif // #if defined(__cplusplus)
|
---|
38 |
|
---|
39 | // C wrapper for using in proxy
|
---|
40 | void SetupClientRpcChannelHook(void);
|
---|
41 |
|
---|
42 | #if defined(__cplusplus)
|
---|
43 | }
|
---|
44 | #endif // #if defined(__cplusplus)
|
---|
45 |
|
---|
46 |
|
---|
47 | #if defined(__cplusplus)
|
---|
48 |
|
---|
49 | /*
|
---|
50 | * This is RPC channel hook implementation for registering VirtualBox API clients.
|
---|
51 | * This channel hook instantiated in COM client process by VBoxProxyStub
|
---|
52 | * We use it to catch a moment when a new VirtualBox object sucessfully instantiated to
|
---|
53 | * register new API client in a VBoxSDS clients list.
|
---|
54 | */
|
---|
55 | class CRpcChannelHook : public IChannelHook
|
---|
56 | {
|
---|
57 | public:
|
---|
58 | CRpcChannelHook(REFGUID channelHookID = RPC_CHANNEL_EXTENSION_GUID): m_ChannelHookID(channelHookID) {};
|
---|
59 |
|
---|
60 | /* IUnknown Interface methods */
|
---|
61 | STDMETHODIMP QueryInterface(REFIID riid, void **ppv);
|
---|
62 | STDMETHODIMP_(ULONG) AddRef(void);
|
---|
63 | STDMETHODIMP_(ULONG) Release(void);
|
---|
64 |
|
---|
65 | /* IChannelHook Interface methods */
|
---|
66 | STDMETHODIMP_(void) ClientGetSize(REFGUID uExtent, REFIID riid, ULONG *pDataSize);
|
---|
67 | STDMETHODIMP_(void) ClientFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer);
|
---|
68 | STDMETHODIMP_(void) ClientNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep, HRESULT hrFault);
|
---|
69 |
|
---|
70 | STDMETHODIMP_(void) ServerNotify(REFGUID uExtent, REFIID riid, ULONG cbDataSize, void *pDataBuffer, DWORD lDataRep);
|
---|
71 | STDMETHODIMP_(void) ServerGetSize(REFGUID uExtent, REFIID riid, HRESULT hrFault, ULONG *pDataSize);
|
---|
72 | STDMETHODIMP_(void) ServerFillBuffer(REFGUID uExtent, REFIID riid, ULONG *pDataSize, void *pDataBuffer, HRESULT hrFault);
|
---|
73 |
|
---|
74 | protected:
|
---|
75 | static bool IsChannelHookRegistered();
|
---|
76 | static void RegisterChannelHook();
|
---|
77 |
|
---|
78 | protected:
|
---|
79 | const GUID m_ChannelHookID;
|
---|
80 | static volatile bool s_bChannelRegistered;
|
---|
81 | static volatile bool s_bVBpoxSDSCalledOnce;
|
---|
82 | static CRpcChannelHook s_RpcChannelHook;
|
---|
83 |
|
---|
84 | /* C wrapper*/
|
---|
85 | friend void SetupClientRpcChannelHook(void);
|
---|
86 | };
|
---|
87 |
|
---|
88 |
|
---|
89 | #endif // #if defined(__cplusplus)
|
---|
90 |
|
---|
91 |
|
---|
92 | #endif // #ifdef RT_OS_WINDOWS
|
---|
93 |
|
---|
94 | #endif // ____H_RPCCHANNELHOOK
|
---|