1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 #ifndef mozilla_mscom_Registration_h
8 #define mozilla_mscom_Registration_h
10 #include "mozilla/RefPtr.h"
11 #include "mozilla/UniquePtr.h"
23 * (1) The DLL exports GetProxyDllInfo. This is not exported by default; it must
24 * be specified in the EXPORTS section of the DLL's module definition file.
26 class RegisteredProxy
{
28 RegisteredProxy(uintptr_t aModule
, IUnknown
* aClassObject
,
29 uint32_t aRegCookie
, ITypeLib
* aTypeLib
);
30 RegisteredProxy(IUnknown
* aClassObject
, uint32_t aRegCookie
,
32 explicit RegisteredProxy(ITypeLib
* aTypeLib
);
33 RegisteredProxy(RegisteredProxy
&& aOther
);
34 RegisteredProxy
& operator=(RegisteredProxy
&& aOther
);
38 HRESULT
GetTypeInfoForGuid(REFGUID aGuid
, ITypeInfo
** aOutTypeInfo
) const;
40 static bool Find(REFIID aIid
, ITypeInfo
** aOutTypeInfo
);
43 RegisteredProxy() = delete;
44 RegisteredProxy(RegisteredProxy
&) = delete;
45 RegisteredProxy
& operator=(RegisteredProxy
&) = delete;
49 static void AddToRegistry(RegisteredProxy
* aProxy
);
50 static void DeleteFromRegistry(RegisteredProxy
* aProxy
);
53 // Not using Windows types here: We shouldn't #include windows.h
54 // since it might pull in COM code which we want to do very carefully in
57 IUnknown
* mClassObject
;
60 #if defined(MOZILLA_INTERNAL_API)
61 bool mIsRegisteredInMTA
;
62 #endif // defined(MOZILLA_INTERNAL_API)
65 enum class RegistrationFlags
{ eUseBinDirectory
, eUseSystemDirectory
};
67 // For our own DLL that we are currently executing in (ie, xul).
68 // Assumes corresponding TLB is embedded in resources.
69 UniquePtr
<RegisteredProxy
> RegisterProxy();
71 // For DLL files. Assumes corresponding TLB is embedded in resources.
72 UniquePtr
<RegisteredProxy
> RegisterProxy(
73 const wchar_t* aLeafName
,
74 RegistrationFlags aFlags
= RegistrationFlags::eUseBinDirectory
);
75 // For standalone TLB files.
76 UniquePtr
<RegisteredProxy
> RegisterTypelib(
77 const wchar_t* aLeafName
,
78 RegistrationFlags aFlags
= RegistrationFlags::eUseBinDirectory
);
80 #if defined(MOZILLA_INTERNAL_API)
83 * The COM interceptor uses type library information to build its interface
84 * proxies. Unfortunately type libraries do not encode size_is and length_is
85 * annotations that have been specified in IDL. This structure allows us to
86 * explicitly declare such relationships so that the COM interceptor may
87 * be made aware of them.
92 eAllocatedByServer
= 1 // This implies an extra level of indirection
95 ArrayData(REFIID aIid
, ULONG aMethodIndex
, ULONG aArrayParamIndex
,
96 VARTYPE aArrayParamType
, REFIID aArrayParamIid
,
97 ULONG aLengthParamIndex
, Flag aFlag
= Flag::eNone
)
99 mMethodIndex(aMethodIndex
),
100 mArrayParamIndex(aArrayParamIndex
),
101 mArrayParamType(aArrayParamType
),
102 mArrayParamIid(aArrayParamIid
),
103 mLengthParamIndex(aLengthParamIndex
),
106 ArrayData(const ArrayData
& aOther
) { *this = aOther
; }
108 ArrayData
& operator=(const ArrayData
& aOther
) {
110 mMethodIndex
= aOther
.mMethodIndex
;
111 mArrayParamIndex
= aOther
.mArrayParamIndex
;
112 mArrayParamType
= aOther
.mArrayParamType
;
113 mArrayParamIid
= aOther
.mArrayParamIid
;
114 mLengthParamIndex
= aOther
.mLengthParamIndex
;
115 mFlag
= aOther
.mFlag
;
121 ULONG mArrayParamIndex
;
122 VARTYPE mArrayParamType
;
124 ULONG mLengthParamIndex
;
128 void RegisterArrayData(const ArrayData
* aArrayData
, size_t aLength
);
131 inline void RegisterArrayData(const ArrayData (&aData
)[N
]) {
132 RegisterArrayData(aData
, N
);
135 const ArrayData
* FindArrayData(REFIID aIid
, ULONG aMethodIndex
);
137 #endif // defined(MOZILLA_INTERNAL_API)
140 } // namespace mozilla
142 #endif // mozilla_mscom_Registration_h