summaryrefslogtreecommitdiff
path: root/src/inc/clrprivbinding.idl
blob: 284bc96bf01df31cacab00961cb44e2f1c660613 (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

import "unknwn.idl";
import "objidl.idl";
import "fusion.idl";

// Forward declarations
interface ICLRPrivBinder;
interface ICLRPrivAssembly;

interface ICLRPrivResource;
interface ICLRPrivResourcePath;
interface ICLRPrivResourceStream;
interface ICLRPrivResourceHMODULE;

interface ICLRPrivAssemblyInfo;

typedef LPCSTR LPCUTF8;

/**************************************************************************************
 ** This IDL file defines the assembly binding host interfaces. Some things to keep
 ** in mind:
 **    - Equality is determined by pointer equality: two interface instances
 **      should be considered equal if and only if their pointer values are equal.
 **    - All operations are idempotent: when a method is called more than once with
 **      the same input values, it is required to return identical results. The only
 **      possible exceptions center around transient errors such as E_OUTOFMEMORY.
 **************************************************************************************/

/**************************************************************************************
 ** ICLRPrivBinder - Use to bind to an assembly by name or by metadata reference.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8542),
    version(1.0),
    local
]
interface ICLRPrivBinder : IUnknown
{
    /**********************************************************************************
     ** BindAssemblyByName -- Binds an assembly by name.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **
     ** pAssemblyName - name of the assembly for which a bind is being requested.
     ** ppAssembly - upon success, receives the bound assembly.
     **********************************************************************************/
    HRESULT BindAssemblyByName(
        [in]          IAssemblyName * pAssemblyName,
        [out, retval] ICLRPrivAssembly ** ppAssembly);

    /**********************************************************************************
     ** VerifyBind
     **********************************************************************************/
    HRESULT VerifyBind(
        [in] IAssemblyName * AssemblyName,
        [in] ICLRPrivAssembly * pAssembly,
        [in] ICLRPrivAssemblyInfo * pAssemblyInfo);

    /**********************************************************************************
     ** GetBinderFlags
     **  pBinderFlags, pointer to binder flags.
     **********************************************************************************/
    HRESULT GetBinderFlags(
        [out, retval] DWORD *pBinderFlags);

    /**********************************************************************************
     ** GetBinderID
     **  pBinderId, pointer to binder id. The binder id has the following properties
     **        It is a pointer that does not change over the lifetime of a binder object
     **        It points at an object in memory that will remain allocated for the lifetime of the binder. 
     **        This value should be the same for a set of binder objects that represent the same binder behavior.
     **********************************************************************************/
    HRESULT GetBinderID(
        [out, retval] UINT_PTR *pBinderId);

    /**********************************************************************************
     ** FindAssemblyBySpec -- if it has been previously bound, guarantees that the same
     ** result will be returned; if previous result was successful, the bound
     ** ICLRPrivAssembly will be returned, and if previous result was not successful
     ** the same failure HRESULT will be assigned to *pResult. Returns failure HR if
     ** identity has not been requested previously.
     **
     **  pvAssemblySpec - the AssemblySpec identity to bind.
     **  pResult        - the result of the previous bind request.
     **  ppAssembly     - when successful, contains the corresponding assembly object.
     **********************************************************************************/
    HRESULT FindAssemblyBySpec(
        [in]          LPVOID pvAppDomain,
        [in]          LPVOID pvAssemblySpec,
        [out]         HRESULT * pResult,
        [out]         ICLRPrivAssembly ** ppAssembly);

    /**********************************************************************************
     ** GetLoaderAllocator
     ** Get LoaderAllocator for binders that contain it. For other binders, return
     ** E_FAIL
     **
     **  pLoaderAllocator - when successful, constains the returned LoaderAllocator
     **********************************************************************************/
    HRESULT GetLoaderAllocator(
        [out, retval] LPVOID * pLoaderAllocator);
};

enum CLR_PRIV_BINDER_FLAGS
{
    BINDER_NONE                     = 0x0,
    BINDER_DESIGNER_BINDING_CONTEXT = 0x1,
    BINDER_FINDASSEMBLYBYSPEC_REQUIRES_EXACT_MATCH = 0x2,
};
    
/**************************************************************************************
 ** ASSEMBLY_IMAGE_TYPES - The set of assembly image formats.
 **************************************************************************************/
enum ASSEMBLY_IMAGE_TYPES
{
    // IL image format
    ASSEMBLY_IMAGE_TYPE_IL                      = 0x0001,
    // Native image (NGEN) format
    ASSEMBLY_IMAGE_TYPE_NATIVE                  = 0x0002,
    // Binder's preferred image type
    ASSEMBLY_IMAGE_TYPE_DEFAULT                 = 0x0003,
    // Only supported on CoreCLR
    ASSEMBLY_IMAGE_TYPE_ASSEMBLY                = 0x0004,
};

/**************************************************************************************
 ** ICLRPrivAssembly - Represents an assembly bind result. Extends ICLRPrivBinder, which
 ** implicitly tracks the parent binder, and enables simple assembly-relative binds.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8543),
    version(1.0),
    local
]
interface ICLRPrivAssembly : ICLRPrivBinder
{
    /**********************************************************************************
     ** IsShareable - Use to determine if the assembly should be shared.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **
     ** A binder must adhere to the following contract when marking an assembly as
     ** shareable:
     **   - all assemblies in the full static binding closure must also be shareable.
     **
     ** pbIsShareable - set to TRUE if the assembly can be shared; FALSE otherwise.
     **********************************************************************************/
    HRESULT IsShareable(
        [out, retval] BOOL * pbIsShareable);

    /**********************************************************************************
     ** GetAvailableImageTypes - Use to retrieve the set of images available for an
     ** assembly.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **
     ** pdwImageTypes - set to values from ASSEMBLY_IMAGE_TYPES to indicate
     **     which image formats are available for the assembly.
     **********************************************************************************/
    HRESULT GetAvailableImageTypes(
        [out, retval] LPDWORD pdwImageTypes);

    /**********************************************************************************
     ** GetImageResource - Returns the resource for the given image type. The returned
     ** IUnknown interface is one of the ICLRPrivResource* interfaces defined below.
     ** It is the binder's choice as to which resource type is returned. If
     ** pdwImageType is non-null, then this will be set to indicate the image type
     ** returned.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **********************************************************************************/
    HRESULT GetImageResource(
        [in]  DWORD dwImageType,
        [out] DWORD* pdwImageType,
        [out, retval] ICLRPrivResource ** ppIResource);
};

/**************************************************************************************
 ** ICLRPrivResource - Generic resource that must be queried for more specific
 ** interface.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8547),
    version(1.0),
    local
]
interface ICLRPrivResource : IUnknown
{
    /**********************************************************************************
     ** GetResourceType - use to query the interface IID of the specific resource type.
     **
     ** priid - set to the IID corresponding to the resource type.
     **********************************************************************************/
    HRESULT GetResourceType(
        [out, retval] IID *pIID);
};

/**************************************************************************************
 ** ICLRPrivResourcePath - Encapsulates a resource identified by path.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8544),
    version(1.0),
    local
]
interface ICLRPrivResourcePath : IUnknown
{
    /**********************************************************************************
     ** GetPath - Use to retrieve the resource's absolute file path.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **
     ** cchBuffer - the count of unicode characters available in the buffer.
     **********************************************************************************/
    HRESULT GetPath(
        [in]  DWORD cchBuffer,
        [out] LPDWORD pcchBuffer,
        [out, size_is(cchBuffer), length_is(*pcchBuffer), string, optional] LPWSTR wzBuffer);
};

/**************************************************************************************
 ** ICLRPrivResourceStream - Encapsulates a resource identified by IStream.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8545),
    version(1.0),
    local
]
interface ICLRPrivResourceStream : IUnknown
{
    /**********************************************************************************
     ** GetStream - Use to retrieve IStream instance corresponding to the resource.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **
     ** riid - the IID of the interface to return. Typically IID_IStream.
     ** ppvStream - contains the returned interface.
     **********************************************************************************/
    HRESULT GetStream(
        [in]  REFIID riid,
        [out, iid_is(riid), retval] LPVOID * ppvStream);
};

/**************************************************************************************
 ** ICLRPrivResourceHMODULE - Encapsulates a resource identified by HMODULE.
 **************************************************************************************/
[
    uuid(2601F621-E462-404C-B299-3E1DE72F8546),
    version(1.0),
    local
]
interface ICLRPrivResourceHMODULE : IUnknown
{
    /**********************************************************************************
     ** GetStream - Use to retrieve the resource's HMODULE value. The HMODULE's
     ** reference count is not changed; the ICLRPrivResourceHMODULE instance must be
     ** kept until the HMODULE is either reference counted or no longer used.
     **     NOTE: This method is required to be idempotent. See general comment above.
     **********************************************************************************/
    HRESULT GetHMODULE(
        [out, retval] HMODULE * phModule);
};

[
    uuid(8d2d3cc9-1249-4ad4-977d-b772bd4e8a94),
    version(1.0),
    local
]
interface ICLRPrivResourceAssembly : IUnknown
{
    /**********************************************************************************
     ** GetAssembly - Use to retrieve the resource's BINDER_SPACE::Assembly value. 
     **     NOTE: This method is required to be idempotent. See general comment above.
     **********************************************************************************/
    HRESULT GetAssembly(
        [out, retval] LPVOID * pAssembly);
};

/**************************************************************************************
 ** ICLRPrivAssemblyInfo - Encapsulates assembly image info.
 **************************************************************************************/
[
    uuid(5653946E-800B-48B7-8B09-B1B879B54F68),
    version(1.0),
    local
]
interface ICLRPrivAssemblyInfo : IUnknown
{
    HRESULT GetAssemblyName(
        [in]  DWORD     cchBuffer,
        [out] LPDWORD   pcchBuffer,
        [out, string, optional] LPWSTR wzBuffer);

    HRESULT GetAssemblyVersion(
        [out] USHORT *pMajor,
        [out] USHORT *pMinor,
        [out] USHORT *pBuild,
        [out] USHORT *pRevision);

    HRESULT GetAssemblyPublicKey(
        [in]  DWORD cbBuffer,
        [out] LPDWORD pcbBuffer,
        [out, size_is(cbBuffer), length_is(*pcbBuffer), optional] BYTE *pbBuffer);
};

/**************************************************************************************
 ** ICLRPrivAssemblyID_WinRT - Provides identification for WinRT assembly - allows dynamic casting inside code:CLRPrivAssemblyWinRT.
 **************************************************************************************/
[
    uuid(4372D277-9906-4FED-BF53-30C0B4010896), 
    version(1.0), 
    local
]
interface ICLRPrivAssemblyID_WinRT : IUnknown
{
};

/**************************************************************************************
 ** ICLRPrivWinRtTypeBinder - Provides binding to WinRT types that are already loaded.
 **************************************************************************************/
[
    uuid(6DE2A085-EFF4-4078-9F60-B9D366736398), 
    version(1.0), 
    local
]
interface ICLRPrivWinRtTypeBinder : IUnknown
{
    /**********************************************************************************
     ** FindAssemblyForWinRtTypeIfLoaded
     **  Finds Assembly * for type in AppDomain * if it is loaded.
     **  Returns NULL if assembly is not loaded or type is not found.
     **********************************************************************************/
    void * FindAssemblyForWinRtTypeIfLoaded(
        void *  pAppDomain, 
        LPCUTF8 szNamespace, 
        LPCUTF8 szClassName);
};