-
-
Notifications
You must be signed in to change notification settings - Fork 766
Expand file tree
/
Copy pathCOMProxyRegistration.h
More file actions
60 lines (53 loc) · 2.28 KB
/
COMProxyRegistration.h
File metadata and controls
60 lines (53 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/*
This file is a part of the NVDA project.
URL: http://www.nvda-project.org/
Copyright (C) 2017 NV Access Limited.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2.0, as published by
the Free Software Foundation.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
This license can be found at:
http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
*/
#ifndef NVDAHELPER_COMPROXYREGISTRATION
#define NVDAHELPER_COMPROXYREGISTRATION
#include <string>
#include <locale>
#include <codecvt>
#include <vector>
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <objbase.h>
// Tracks information about a COM interface registered in-process
typedef struct {
// The name of the interface (for debugging)
std::wstring name;
// The unique identifier of the interface
IID iid;
// The CLSID of the original class object that handled creating / proxying of this interface.
// Used when unregistering, so we can put things back the way they were
CLSID clsid;
} PSClsidBackup_t;
// Represents the registration of a COM proxy dll and its interfaces.
// this can be used for later unregistration of the COM proxy dll
typedef struct {
// The path to the dll (for debugging)
std::wstring dllPath;
// The cookie returned by CoRegisterClassObject, for later unregistration via CoRevokeClassObject
ULONG_PTR classObjectRegistrationCookie;
// Information for all the interfaces registered for this proxy dll via CoRegisterPSClsid
std::vector<PSClsidBackup_t> psClsidBackups;
} COMProxyRegistration_t;
/* Registers a COM proxy dll and all its interfaces for this process so that they can be marshalled to/from other processes
@param dllPath the relative path to the proxy dll (relative from this dll)
@return registration data which can be later passed to UnregisterCOMProxy.
*/
COMProxyRegistration_t* registerCOMProxy(const wchar_t* dllPath);
/* Unregisters a COM proxy dll originally registered with registerCOMProxy
@param reg the registration data returned by registerCOMProxy.
@return true if successful, false otherwise
*/
bool unregisterCOMProxy(COMProxyRegistration_t* reg);
#endif