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 |
|
---|
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 | RT_C_DECLS_BEGIN
|
---|
35 | // C wrapper for using in proxy
|
---|
36 | void SetupClientRpcChannelHook(void);
|
---|
37 | RT_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 | */
|
---|
48 | class CRpcChannelHook : public IChannelHook
|
---|
49 | {
|
---|
50 | public:
|
---|
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 |
|
---|
67 | protected:
|
---|
68 | static bool IsChannelHookRegistered();
|
---|
69 | static void RegisterChannelHook();
|
---|
70 |
|
---|
71 | protected:
|
---|
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
|
---|