1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5/*****************************************************************************
6 ** **
7 ** Cor.h - general header for the Runtime. **
8 ** **
9 *****************************************************************************/
10
11
12#ifndef _COR_H_
13#define _COR_H_
14
15//*****************************************************************************
16// Required includes
17#include <ole2.h> // Definitions of OLE types.
18#include <specstrings.h>
19#include "corerror.h"
20
21//*****************************************************************************
22
23#if defined(_MSC_VER) && !defined(USE_DEPRECATED_CLR_API_WITHOUT_WARNING)
24#define DEPRECATED_CLR_API_MESG "This API has been deprecated. Refer to http://go.microsoft.com/fwlink/?LinkId=143720 for more details."
25#define DECLARE_DEPRECATED __declspec(deprecated(DEPRECATED_CLR_API_MESG))
26#define DEPRECATED_CLR_STDAPI EXTERN_C DECLARE_DEPRECATED HRESULT STDAPICALLTYPE
27#define DEPRECATED_CLR_STDAPI_(type) EXTERN_C DECLARE_DEPRECATED type STDAPICALLTYPE
28#else // _MSC_VER && !USE_DEPRECATED_CLR_API_WITHOUT_WARNING
29#define DECLARE_DEPRECATED
30#define DEPRECATED_CLR_STDAPI STDAPI
31#define DEPRECATED_CLR_STDAPI_(type) STDAPI_(type)
32#endif // _MSC_VER && !USE_DEPRECATED_CLR_API_WITHOUT_WARNING
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38// {BED7F4EA-1A96-11d2-8F08-00A0C9A6186D}
39EXTERN_GUID(LIBID_ComPlusRuntime, 0xbed7f4ea, 0x1a96, 0x11d2, 0x8f, 0x8, 0x0, 0xa0, 0xc9, 0xa6, 0x18, 0x6d);
40
41// {90883F05-3D28-11D2-8F17-00A0C9A6186D}
42EXTERN_GUID(GUID_ExportedFromComPlus, 0x90883f05, 0x3d28, 0x11d2, 0x8f, 0x17, 0x0, 0xa0, 0xc9, 0xa6, 0x18, 0x6d);
43
44// {0F21F359-AB84-41e8-9A78-36D110E6D2F9}
45EXTERN_GUID(GUID_ManagedName, 0xf21f359, 0xab84, 0x41e8, 0x9a, 0x78, 0x36, 0xd1, 0x10, 0xe6, 0xd2, 0xf9);
46
47// {54FC8F55-38DE-4703-9C4E-250351302B1C}
48EXTERN_GUID(GUID_Function2Getter, 0x54fc8f55, 0x38de, 0x4703, 0x9c, 0x4e, 0x25, 0x3, 0x51, 0x30, 0x2b, 0x1c);
49
50// CLSID_CorMetaDataDispenserRuntime: {1EC2DE53-75CC-11d2-9775-00A0C9B4D50C}
51// Dispenser coclass for version 1.5 and 2.0 meta data. To get the "latest" bind
52// to CLSID_MetaDataDispenser.
53EXTERN_GUID(CLSID_CorMetaDataDispenserRuntime, 0x1ec2de53, 0x75cc, 0x11d2, 0x97, 0x75, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
54
55// {CD2BC5C9-F452-4326-B714-F9C539D4DA58}
56EXTERN_GUID(GUID_DispIdOverride, 0xcd2bc5c9, 0xf452, 0x4326, 0xb7, 0x14, 0xf9, 0xc5, 0x39, 0xd4, 0xda, 0x58);
57
58// {B64784EB-D8D4-4d9b-9ACD-0E30806426F7}
59EXTERN_GUID(GUID_ForceIEnumerable, 0xb64784eb, 0xd8d4, 0x4d9b, 0x9a, 0xcd, 0x0e, 0x30, 0x80, 0x64, 0x26, 0xf7);
60
61// {2941FF83-88D8-4F73-B6A9-BDF8712D000D}
62EXTERN_GUID(GUID_PropGetCA, 0x2941ff83, 0x88d8, 0x4f73, 0xb6, 0xa9, 0xbd, 0xf8, 0x71, 0x2d, 0x00, 0x0d);
63
64// {29533527-3683-4364-ABC0-DB1ADD822FA2}
65EXTERN_GUID(GUID_PropPutCA, 0x29533527, 0x3683, 0x4364, 0xab, 0xc0, 0xdb, 0x1a, 0xdd, 0x82, 0x2f, 0xa2);
66
67// CLSID_CLR_v1_MetaData: {005023CA-72B1-11D3-9FC4-00C04F79A0A3}
68// Used to generate v1 metadata (for v1.0 and v1.1 CLR compatibility).
69EXTERN_GUID(CLSID_CLR_v1_MetaData, 0x005023ca, 0x72b1, 0x11d3, 0x9f, 0xc4, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
70
71// CLSID_CLR_v2_MetaData: {EFEA471A-44FD-4862-9292-0C58D46E1F3A}
72EXTERN_GUID(CLSID_CLR_v2_MetaData, 0xefea471a, 0x44fd, 0x4862, 0x92, 0x92, 0xc, 0x58, 0xd4, 0x6e, 0x1f, 0x3a);
73
74
75// CLSID_CorMetaDataRuntime:
76// This will can always be used to generate the "latest" metadata available.
77#define CLSID_CorMetaDataRuntime CLSID_CLR_v2_MetaData
78
79
80// {30FE7BE8-D7D9-11D2-9F80-00C04F79A0A3}
81EXTERN_GUID(MetaDataCheckDuplicatesFor, 0x30fe7be8, 0xd7d9, 0x11d2, 0x9f, 0x80, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
82
83// {DE3856F8-D7D9-11D2-9F80-00C04F79A0A3}
84EXTERN_GUID(MetaDataRefToDefCheck, 0xde3856f8, 0xd7d9, 0x11d2, 0x9f, 0x80, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
85
86// {E5D71A4C-D7DA-11D2-9F80-00C04F79A0A3}
87EXTERN_GUID(MetaDataNotificationForTokenMovement, 0xe5d71a4c, 0xd7da, 0x11d2, 0x9f, 0x80, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
88
89// {2eee315c-d7db-11d2-9f80-00c04f79a0a3}
90EXTERN_GUID(MetaDataSetUpdate, 0x2eee315c, 0xd7db, 0x11d2, 0x9f, 0x80, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
91#define MetaDataSetENC MetaDataSetUpdate
92
93// Use this guid in SetOption to indicate if the import enumerator should skip over
94// delete items or not. The default is yes.
95//
96// {79700F36-4AAC-11d3-84C3-009027868CB1}
97EXTERN_GUID(MetaDataImportOption, 0x79700f36, 0x4aac, 0x11d3, 0x84, 0xc3, 0x0, 0x90, 0x27, 0x86, 0x8c, 0xb1);
98
99// Use this guid in the SetOption if compiler wants to have MetaData API to take reader/writer lock
100//
101// {F7559806-F266-42ea-8C63-0ADB45E8B234}
102EXTERN_GUID(MetaDataThreadSafetyOptions, 0xf7559806, 0xf266, 0x42ea, 0x8c, 0x63, 0xa, 0xdb, 0x45, 0xe8, 0xb2, 0x34);
103
104// Use this guid in the SetOption if compiler wants error when some tokens are emitted out of order
105// {1547872D-DC03-11d2-9420-0000F8083460}
106EXTERN_GUID(MetaDataErrorIfEmitOutOfOrder, 0x1547872d, 0xdc03, 0x11d2, 0x94, 0x20, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60);
107
108// Use this guid in the SetOption to indicate if the tlbimporter should generate the
109// TCE adapters for COM connection point containers.
110// {DCC9DE90-4151-11d3-88D6-00902754C43A}
111EXTERN_GUID(MetaDataGenerateTCEAdapters, 0xdcc9de90, 0x4151, 0x11d3, 0x88, 0xd6, 0x0, 0x90, 0x27, 0x54, 0xc4, 0x3a);
112
113// Use this guid in the SetOption to specifiy a non-default namespace for typelib import.
114// {F17FF889-5A63-11d3-9FF2-00C04FF7431A}
115EXTERN_GUID(MetaDataTypeLibImportNamespace, 0xf17ff889, 0x5a63, 0x11d3, 0x9f, 0xf2, 0x0, 0xc0, 0x4f, 0xf7, 0x43, 0x1a);
116
117// Use this guid in the SetOption to specify the behavior of UnmarkAll. See CorLinkerOptions.
118// {47E099B6-AE7C-4797-8317-B48AA645B8F9}
119EXTERN_GUID(MetaDataLinkerOptions, 0x47e099b6, 0xae7c, 0x4797, 0x83, 0x17, 0xb4, 0x8a, 0xa6, 0x45, 0xb8, 0xf9);
120
121// Use this guid in the SetOption to specify the runtime version stored in the CLR metadata.
122// {47E099B7-AE7C-4797-8317-B48AA645B8F9}
123EXTERN_GUID(MetaDataRuntimeVersion, 0x47e099b7, 0xae7c, 0x4797, 0x83, 0x17, 0xb4, 0x8a, 0xa6, 0x45, 0xb8, 0xf9);
124
125// Use this guid in the SetOption to specify the behavior of the merger.
126// {132D3A6E-B35D-464e-951A-42EFB9FB6601}
127EXTERN_GUID(MetaDataMergerOptions, 0x132d3a6e, 0xb35d, 0x464e, 0x95, 0x1a, 0x42, 0xef, 0xb9, 0xfb, 0x66, 0x1);
128
129// Use this guid in SetOption to disable optimizing module-local refs to defs
130// {a55c0354-e91b-468b-8648-7cc31035d533}
131EXTERN_GUID(MetaDataPreserveLocalRefs, 0xa55c0354, 0xe91b, 0x468b, 0x86, 0x48, 0x7c, 0xc3, 0x10, 0x35, 0xd5, 0x33);
132
133interface IMetaDataImport;
134interface IMetaDataAssemblyEmit;
135interface IMetaDataAssemblyImport;
136interface IMetaDataEmit;
137interface ICeeGen;
138
139
140typedef UNALIGNED void const *UVCP_CONSTANT;
141
142
143// Constant for connection id and task id
144#define INVALID_CONNECTION_ID 0x0
145#define INVALID_TASK_ID 0x0
146#define MAX_CONNECTION_NAME MAX_PATH
147
148//*****************************************************************************
149//*****************************************************************************
150//
151// D L L P U B L I C E N T R Y P O I N T D E C L A R A T I O N S
152//
153//*****************************************************************************
154//*****************************************************************************
155
156BOOL STDMETHODCALLTYPE _CorDllMain(HINSTANCE hInst, DWORD dwReason, LPVOID lpReserved);
157__int32 STDMETHODCALLTYPE _CorExeMain();
158__int32 STDMETHODCALLTYPE _CorExeMainInternal();
159__int32 STDMETHODCALLTYPE _CorExeMain2( // Executable exit code.
160 PBYTE pUnmappedPE, // -> memory mapped code
161 DWORD cUnmappedPE, // Size of memory mapped code
162 _In_ LPWSTR pImageNameIn, // -> Executable Name
163 _In_ LPWSTR pLoadersFileName, // -> Loaders Name
164 _In_ LPWSTR pCmdLine); // -> Command Line
165
166STDAPI _CorValidateImage(PVOID *ImageBase, LPCWSTR FileName);
167STDAPI_(VOID) _CorImageUnloading(PVOID ImageBase);
168
169DEPRECATED_CLR_STDAPI CoInitializeEE(DWORD fFlags);
170DEPRECATED_CLR_STDAPI_(void) CoUninitializeEE(BOOL fFlags);
171DEPRECATED_CLR_STDAPI_(void) CoEEShutDownCOM(void);
172
173
174
175#define MAIN_CLR_MODULE_NAME_W W("coreclr")
176#define MAIN_CLR_MODULE_NAME_A "coreclr"
177
178#define MAIN_CLR_DLL_NAME_W MAKEDLLNAME_W(MAIN_CLR_MODULE_NAME_W)
179#define MAIN_CLR_DLL_NAME_A MAKEDLLNAME_A(MAIN_CLR_MODULE_NAME_A)
180
181
182
183#define MSCOREE_SHIM_W MAIN_CLR_DLL_NAME_W
184#define MSCOREE_SHIM_A MAIN_CLR_DLL_NAME_A
185
186#define SWITCHOUT_HANDLE_VALUE ((HANDLE)(LONG_PTR)-2)
187
188
189//
190// CoInitializeCor flags.
191//
192typedef enum tagCOINITCOR
193{
194 COINITCOR_DEFAULT = 0x0 // Default initialization mode.
195} COINITICOR;
196
197//
198// CoInitializeEE flags.
199//
200typedef enum tagCOINITEE
201{
202 COINITEE_DEFAULT = 0x0, // Default initialization mode.
203 COINITEE_DLL = 0x1, // Initialization mode for loading DLL.
204 COINITEE_MAIN = 0x2 // Initialize prior to entering the main routine
205} COINITIEE;
206
207//
208// CoInitializeEE flags.
209//
210typedef enum tagCOUNINITEE
211{
212 COUNINITEE_DEFAULT = 0x0, // Default uninitialization mode.
213 COUNINITEE_DLL = 0x1 // Uninitialization mode for unloading DLL.
214} COUNINITIEE;
215
216//*****************************************************************************
217//*****************************************************************************
218//
219// I L & F I L E F O R M A T D E C L A R A T I O N S
220//
221//*****************************************************************************
222//*****************************************************************************
223
224
225//
226#ifndef _WINDOWS_UPDATES_
227#include <corhdr.h>
228#endif // <windows.h> updates
229
230//*****************************************************************************
231//*****************************************************************************
232//
233// D L L P U B L I C E N T R Y P O I N T D E C L A R A T I O N S
234//
235//*****************************************************************************
236//*****************************************************************************
237
238DEPRECATED_CLR_STDAPI CoInitializeCor(DWORD fFlags);
239DEPRECATED_CLR_STDAPI_(void) CoUninitializeCor(void);
240
241//
242//*****************************************************************************
243//*****************************************************************************
244
245// CLSID_Cor: {bee00000-ee77-11d0-a015-00c04fbbb884}
246EXTERN_GUID(CLSID_Cor, 0xbee00010, 0xee77, 0x11d0, 0xa0, 0x15, 0x00, 0xc0, 0x4f, 0xbb, 0xb8, 0x84);
247
248// CLSID_CorMetaDataDispenser: {E5CB7A31-7512-11d2-89CE-0080C792E5D8}
249// This is the "Master Dispenser", always guaranteed to be the most recent
250// dispenser on the machine.
251EXTERN_GUID(CLSID_CorMetaDataDispenser, 0xe5cb7a31, 0x7512, 0x11d2, 0x89, 0xce, 0x0, 0x80, 0xc7, 0x92, 0xe5, 0xd8);
252
253
254// CLSID_CorMetaDataDispenserReg: {435755FF-7397-11d2-9771-00A0C9B4D50C}
255// Dispenser coclass for version 1.0 meta data. To get the "latest" bind
256// to CLSID_CorMetaDataDispenser.
257EXTERN_GUID(CLSID_CorMetaDataDispenserReg, 0x435755ff, 0x7397, 0x11d2, 0x97, 0x71, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
258
259
260// CLSID_CorMetaDataReg: {87F3A1F5-7397-11d2-9771-00A0C9B4D50C}
261// For COM+ Meta Data, Data Driven Registration
262EXTERN_GUID(CLSID_CorMetaDataReg, 0x87f3a1f5, 0x7397, 0x11d2, 0x97, 0x71, 0x0, 0xa0, 0xc9, 0xb4, 0xd5, 0xc);
263
264
265interface IMetaDataDispenser;
266
267//-------------------------------------
268//--- IMetaDataError
269//-------------------------------------
270// {B81FF171-20F3-11d2-8DCC-00A0C9B09C19}
271EXTERN_GUID(IID_IMetaDataError, 0xb81ff171, 0x20f3, 0x11d2, 0x8d, 0xcc, 0x0, 0xa0, 0xc9, 0xb0, 0x9c, 0x19);
272
273//---
274#undef INTERFACE
275#define INTERFACE IMetaDataError
276DECLARE_INTERFACE_(IMetaDataError, IUnknown)
277{
278 STDMETHOD(OnError)(HRESULT hrError, mdToken token) PURE;
279};
280
281//-------------------------------------
282//--- IMapToken
283//-------------------------------------
284// IID_IMapToken: {06A3EA8B-0225-11d1-BF72-00C04FC31E12}
285EXTERN_GUID(IID_IMapToken, 0x6a3ea8b, 0x225, 0x11d1, 0xbf, 0x72, 0x0, 0xc0, 0x4f, 0xc3, 0x1e, 0x12);
286
287//---
288#undef INTERFACE
289#define INTERFACE IMapToken
290DECLARE_INTERFACE_(IMapToken, IUnknown)
291{
292 STDMETHOD(Map)(mdToken tkImp, mdToken tkEmit) PURE;
293};
294
295//-------------------------------------
296//--- IMetaDataDispenser
297//-------------------------------------
298// {809C652E-7396-11D2-9771-00A0C9B4D50C}
299EXTERN_GUID(IID_IMetaDataDispenser, 0x809c652e, 0x7396, 0x11d2, 0x97, 0x71, 0x00, 0xa0, 0xc9, 0xb4, 0xd5, 0x0c);
300
301//---
302#undef INTERFACE
303#define INTERFACE IMetaDataDispenser
304DECLARE_INTERFACE_(IMetaDataDispenser, IUnknown)
305{
306 STDMETHOD(DefineScope)( // Return code.
307 REFCLSID rclsid, // [in] What version to create.
308 DWORD dwCreateFlags, // [in] Flags on the create.
309 REFIID riid, // [in] The interface desired.
310 IUnknown **ppIUnk) PURE; // [out] Return interface on success.
311
312 STDMETHOD(OpenScope)( // Return code.
313 LPCWSTR szScope, // [in] The scope to open.
314 DWORD dwOpenFlags, // [in] Open mode flags.
315 REFIID riid, // [in] The interface desired.
316 IUnknown **ppIUnk) PURE; // [out] Return interface on success.
317
318 STDMETHOD(OpenScopeOnMemory)( // Return code.
319 LPCVOID pData, // [in] Location of scope data.
320 ULONG cbData, // [in] Size of the data pointed to by pData.
321 DWORD dwOpenFlags, // [in] Open mode flags.
322 REFIID riid, // [in] The interface desired.
323 IUnknown **ppIUnk) PURE; // [out] Return interface on success.
324};
325
326//-------------------------------------
327//--- IMetaDataEmit
328//-------------------------------------
329// {BA3FEE4C-ECB9-4e41-83B7-183FA41CD859}
330EXTERN_GUID(IID_IMetaDataEmit, 0xba3fee4c, 0xecb9, 0x4e41, 0x83, 0xb7, 0x18, 0x3f, 0xa4, 0x1c, 0xd8, 0x59);
331
332//---
333#undef INTERFACE
334#define INTERFACE IMetaDataEmit
335DECLARE_INTERFACE_(IMetaDataEmit, IUnknown)
336{
337 STDMETHOD(SetModuleProps)( // S_OK or error.
338 LPCWSTR szName) PURE; // [IN] If not NULL, the name of the module to set.
339
340 STDMETHOD(Save)( // S_OK or error.
341 LPCWSTR szFile, // [IN] The filename to save to.
342 DWORD dwSaveFlags) PURE; // [IN] Flags for the save.
343
344 STDMETHOD(SaveToStream)( // S_OK or error.
345 IStream *pIStream, // [IN] A writable stream to save to.
346 DWORD dwSaveFlags) PURE; // [IN] Flags for the save.
347
348 STDMETHOD(GetSaveSize)( // S_OK or error.
349 CorSaveSize fSave, // [IN] cssAccurate or cssQuick.
350 DWORD *pdwSaveSize) PURE; // [OUT] Put the size here.
351
352 STDMETHOD(DefineTypeDef)( // S_OK or error.
353 LPCWSTR szTypeDef, // [IN] Name of TypeDef
354 DWORD dwTypeDefFlags, // [IN] CustomAttribute flags
355 mdToken tkExtends, // [IN] extends this TypeDef or typeref
356 mdToken rtkImplements[], // [IN] Implements interfaces
357 mdTypeDef *ptd) PURE; // [OUT] Put TypeDef token here
358
359 STDMETHOD(DefineNestedType)( // S_OK or error.
360 LPCWSTR szTypeDef, // [IN] Name of TypeDef
361 DWORD dwTypeDefFlags, // [IN] CustomAttribute flags
362 mdToken tkExtends, // [IN] extends this TypeDef or typeref
363 mdToken rtkImplements[], // [IN] Implements interfaces
364 mdTypeDef tdEncloser, // [IN] TypeDef token of the enclosing type.
365 mdTypeDef *ptd) PURE; // [OUT] Put TypeDef token here
366
367 STDMETHOD(SetHandler)( // S_OK.
368 IUnknown *pUnk) PURE; // [IN] The new error handler.
369
370 STDMETHOD(DefineMethod)( // S_OK or error.
371 mdTypeDef td, // Parent TypeDef
372 LPCWSTR szName, // Name of member
373 DWORD dwMethodFlags, // Member attributes
374 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
375 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
376 ULONG ulCodeRVA,
377 DWORD dwImplFlags,
378 mdMethodDef *pmd) PURE; // Put member token here
379
380 STDMETHOD(DefineMethodImpl)( // S_OK or error.
381 mdTypeDef td, // [IN] The class implementing the method
382 mdToken tkBody, // [IN] Method body - MethodDef or MethodRef
383 mdToken tkDecl) PURE; // [IN] Method declaration - MethodDef or MethodRef
384
385 STDMETHOD(DefineTypeRefByName)( // S_OK or error.
386 mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef.
387 LPCWSTR szName, // [IN] Name of the TypeRef.
388 mdTypeRef *ptr) PURE; // [OUT] Put TypeRef token here.
389
390 STDMETHOD(DefineImportType)( // S_OK or error.
391 IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the TypeDef.
392 const void *pbHashValue, // [IN] Hash Blob for Assembly.
393 ULONG cbHashValue, // [IN] Count of bytes.
394 IMetaDataImport *pImport, // [IN] Scope containing the TypeDef.
395 mdTypeDef tdImport, // [IN] The imported TypeDef.
396 IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the TypeDef is imported.
397 mdTypeRef *ptr) PURE; // [OUT] Put TypeRef token here.
398
399 STDMETHOD(DefineMemberRef)( // S_OK or error
400 mdToken tkImport, // [IN] ClassRef or ClassDef importing a member.
401 LPCWSTR szName, // [IN] member's name
402 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
403 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
404 mdMemberRef *pmr) PURE; // [OUT] memberref token
405
406 STDMETHOD(DefineImportMember)( // S_OK or error.
407 IMetaDataAssemblyImport *pAssemImport, // [IN] Assembly containing the Member.
408 const void *pbHashValue, // [IN] Hash Blob for Assembly.
409 ULONG cbHashValue, // [IN] Count of bytes.
410 IMetaDataImport *pImport, // [IN] Import scope, with member.
411 mdToken mbMember, // [IN] Member in import scope.
412 IMetaDataAssemblyEmit *pAssemEmit, // [IN] Assembly into which the Member is imported.
413 mdToken tkParent, // [IN] Classref or classdef in emit scope.
414 mdMemberRef *pmr) PURE; // [OUT] Put member ref here.
415
416 STDMETHOD(DefineEvent) (
417 mdTypeDef td, // [IN] the class/interface on which the event is being defined
418 LPCWSTR szEvent, // [IN] Name of the event
419 DWORD dwEventFlags, // [IN] CorEventAttr
420 mdToken tkEventType, // [IN] a reference (mdTypeRef or mdTypeRef) to the Event class
421 mdMethodDef mdAddOn, // [IN] required add method
422 mdMethodDef mdRemoveOn, // [IN] required remove method
423 mdMethodDef mdFire, // [IN] optional fire method
424 mdMethodDef rmdOtherMethods[], // [IN] optional array of other methods associate with the event
425 mdEvent *pmdEvent) PURE; // [OUT] output event token
426
427 STDMETHOD(SetClassLayout) (
428 mdTypeDef td, // [IN] typedef
429 DWORD dwPackSize, // [IN] packing size specified as 1, 2, 4, 8, or 16
430 COR_FIELD_OFFSET rFieldOffsets[], // [IN] array of layout specification
431 ULONG ulClassSize) PURE; // [IN] size of the class
432
433 STDMETHOD(DeleteClassLayout) (
434 mdTypeDef td) PURE; // [IN] typedef whose layout is to be deleted.
435
436 STDMETHOD(SetFieldMarshal) (
437 mdToken tk, // [IN] given a fieldDef or paramDef token
438 PCCOR_SIGNATURE pvNativeType, // [IN] native type specification
439 ULONG cbNativeType) PURE; // [IN] count of bytes of pvNativeType
440
441 STDMETHOD(DeleteFieldMarshal) (
442 mdToken tk) PURE; // [IN] given a fieldDef or paramDef token
443
444 STDMETHOD(DefinePermissionSet) (
445 mdToken tk, // [IN] the object to be decorated.
446 DWORD dwAction, // [IN] CorDeclSecurity.
447 void const *pvPermission, // [IN] permission blob.
448 ULONG cbPermission, // [IN] count of bytes of pvPermission.
449 mdPermission *ppm) PURE; // [OUT] returned permission token.
450
451 STDMETHOD(SetRVA)( // S_OK or error.
452 mdMethodDef md, // [IN] Method for which to set offset
453 ULONG ulRVA) PURE; // [IN] The offset
454
455 STDMETHOD(GetTokenFromSig)( // S_OK or error.
456 PCCOR_SIGNATURE pvSig, // [IN] Signature to define.
457 ULONG cbSig, // [IN] Size of signature data.
458 mdSignature *pmsig) PURE; // [OUT] returned signature token.
459
460 STDMETHOD(DefineModuleRef)( // S_OK or error.
461 LPCWSTR szName, // [IN] DLL name
462 mdModuleRef *pmur) PURE; // [OUT] returned
463
464 // <TODO>@FUTURE: This should go away once everyone starts using SetMemberRefProps.</TODO>
465 STDMETHOD(SetParent)( // S_OK or error.
466 mdMemberRef mr, // [IN] Token for the ref to be fixed up.
467 mdToken tk) PURE; // [IN] The ref parent.
468
469 STDMETHOD(GetTokenFromTypeSpec)( // S_OK or error.
470 PCCOR_SIGNATURE pvSig, // [IN] TypeSpec Signature to define.
471 ULONG cbSig, // [IN] Size of signature data.
472 mdTypeSpec *ptypespec) PURE; // [OUT] returned TypeSpec token.
473
474 STDMETHOD(SaveToMemory)( // S_OK or error.
475 void *pbData, // [OUT] Location to write data.
476 ULONG cbData) PURE; // [IN] Max size of data buffer.
477
478 STDMETHOD(DefineUserString)( // Return code.
479 LPCWSTR szString, // [IN] User literal string.
480 ULONG cchString, // [IN] Length of string.
481 mdString *pstk) PURE; // [OUT] String token.
482
483 STDMETHOD(DeleteToken)( // Return code.
484 mdToken tkObj) PURE; // [IN] The token to be deleted
485
486 STDMETHOD(SetMethodProps)( // S_OK or error.
487 mdMethodDef md, // [IN] The MethodDef.
488 DWORD dwMethodFlags, // [IN] Method attributes.
489 ULONG ulCodeRVA, // [IN] Code RVA.
490 DWORD dwImplFlags) PURE; // [IN] Impl flags.
491
492 STDMETHOD(SetTypeDefProps)( // S_OK or error.
493 mdTypeDef td, // [IN] The TypeDef.
494 DWORD dwTypeDefFlags, // [IN] TypeDef flags.
495 mdToken tkExtends, // [IN] Base TypeDef or TypeRef.
496 mdToken rtkImplements[]) PURE; // [IN] Implemented interfaces.
497
498 STDMETHOD(SetEventProps)( // S_OK or error.
499 mdEvent ev, // [IN] The event token.
500 DWORD dwEventFlags, // [IN] CorEventAttr.
501 mdToken tkEventType, // [IN] A reference (mdTypeRef or mdTypeRef) to the Event class.
502 mdMethodDef mdAddOn, // [IN] Add method.
503 mdMethodDef mdRemoveOn, // [IN] Remove method.
504 mdMethodDef mdFire, // [IN] Fire method.
505 mdMethodDef rmdOtherMethods[]) PURE;// [IN] Array of other methods associate with the event.
506
507 STDMETHOD(SetPermissionSetProps)( // S_OK or error.
508 mdToken tk, // [IN] The object to be decorated.
509 DWORD dwAction, // [IN] CorDeclSecurity.
510 void const *pvPermission, // [IN] Permission blob.
511 ULONG cbPermission, // [IN] Count of bytes of pvPermission.
512 mdPermission *ppm) PURE; // [OUT] Permission token.
513
514 STDMETHOD(DefinePinvokeMap)( // Return code.
515 mdToken tk, // [IN] FieldDef or MethodDef.
516 DWORD dwMappingFlags, // [IN] Flags used for mapping.
517 LPCWSTR szImportName, // [IN] Import name.
518 mdModuleRef mrImportDLL) PURE; // [IN] ModuleRef token for the target DLL.
519
520 STDMETHOD(SetPinvokeMap)( // Return code.
521 mdToken tk, // [IN] FieldDef or MethodDef.
522 DWORD dwMappingFlags, // [IN] Flags used for mapping.
523 LPCWSTR szImportName, // [IN] Import name.
524 mdModuleRef mrImportDLL) PURE; // [IN] ModuleRef token for the target DLL.
525
526 STDMETHOD(DeletePinvokeMap)( // Return code.
527 mdToken tk) PURE; // [IN] FieldDef or MethodDef.
528
529 // New CustomAttribute functions.
530 STDMETHOD(DefineCustomAttribute)( // Return code.
531 mdToken tkOwner, // [IN] The object to put the value on.
532 mdToken tkCtor, // [IN] Constructor of the CustomAttribute type (MemberRef/MethodDef).
533 void const *pCustomAttribute, // [IN] The custom value data.
534 ULONG cbCustomAttribute, // [IN] The custom value data length.
535 mdCustomAttribute *pcv) PURE; // [OUT] The custom value token value on return.
536
537 STDMETHOD(SetCustomAttributeValue)( // Return code.
538 mdCustomAttribute pcv, // [IN] The custom value token whose value to replace.
539 void const *pCustomAttribute, // [IN] The custom value data.
540 ULONG cbCustomAttribute) PURE;// [IN] The custom value data length.
541
542 STDMETHOD(DefineField)( // S_OK or error.
543 mdTypeDef td, // Parent TypeDef
544 LPCWSTR szName, // Name of member
545 DWORD dwFieldFlags, // Member attributes
546 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
547 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
548 DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_*
549 void const *pValue, // [IN] constant value
550 ULONG cchValue, // [IN] size of constant value (string, in wide chars).
551 mdFieldDef *pmd) PURE; // [OUT] Put member token here
552
553 STDMETHOD(DefineProperty)(
554 mdTypeDef td, // [IN] the class/interface on which the property is being defined
555 LPCWSTR szProperty, // [IN] Name of the property
556 DWORD dwPropFlags, // [IN] CorPropertyAttr
557 PCCOR_SIGNATURE pvSig, // [IN] the required type signature
558 ULONG cbSig, // [IN] the size of the type signature blob
559 DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_*
560 void const *pValue, // [IN] constant value
561 ULONG cchValue, // [IN] size of constant value (string, in wide chars).
562 mdMethodDef mdSetter, // [IN] optional setter of the property
563 mdMethodDef mdGetter, // [IN] optional getter of the property
564 mdMethodDef rmdOtherMethods[], // [IN] an optional array of other methods
565 mdProperty *pmdProp) PURE; // [OUT] output property token
566
567 STDMETHOD(DefineParam)(
568 mdMethodDef md, // [IN] Owning method
569 ULONG ulParamSeq, // [IN] Which param
570 LPCWSTR szName, // [IN] Optional param name
571 DWORD dwParamFlags, // [IN] Optional param flags
572 DWORD dwCPlusTypeFlag, // [IN] flag for value type. selected ELEMENT_TYPE_*
573 void const *pValue, // [IN] constant value
574 ULONG cchValue, // [IN] size of constant value (string, in wide chars).
575 mdParamDef *ppd) PURE; // [OUT] Put param token here
576
577 STDMETHOD(SetFieldProps)( // S_OK or error.
578 mdFieldDef fd, // [IN] The FieldDef.
579 DWORD dwFieldFlags, // [IN] Field attributes.
580 DWORD dwCPlusTypeFlag, // [IN] Flag for the value type, selected ELEMENT_TYPE_*
581 void const *pValue, // [IN] Constant value.
582 ULONG cchValue) PURE; // [IN] size of constant value (string, in wide chars).
583
584 STDMETHOD(SetPropertyProps)( // S_OK or error.
585 mdProperty pr, // [IN] Property token.
586 DWORD dwPropFlags, // [IN] CorPropertyAttr.
587 DWORD dwCPlusTypeFlag, // [IN] Flag for value type, selected ELEMENT_TYPE_*
588 void const *pValue, // [IN] Constant value.
589 ULONG cchValue, // [IN] size of constant value (string, in wide chars).
590 mdMethodDef mdSetter, // [IN] Setter of the property.
591 mdMethodDef mdGetter, // [IN] Getter of the property.
592 mdMethodDef rmdOtherMethods[]) PURE;// [IN] Array of other methods.
593
594 STDMETHOD(SetParamProps)( // Return code.
595 mdParamDef pd, // [IN] Param token.
596 LPCWSTR szName, // [IN] Param name.
597 DWORD dwParamFlags, // [IN] Param flags.
598 DWORD dwCPlusTypeFlag, // [IN] Flag for value type. selected ELEMENT_TYPE_*.
599 void const *pValue, // [OUT] Constant value.
600 ULONG cchValue) PURE; // [IN] size of constant value (string, in wide chars).
601
602 // Specialized Custom Attributes for security.
603 STDMETHOD(DefineSecurityAttributeSet)( // Return code.
604 mdToken tkObj, // [IN] Class or method requiring security attributes.
605 COR_SECATTR rSecAttrs[], // [IN] Array of security attribute descriptions.
606 ULONG cSecAttrs, // [IN] Count of elements in above array.
607 ULONG *pulErrorAttr) PURE; // [OUT] On error, index of attribute causing problem.
608
609 STDMETHOD(ApplyEditAndContinue)( // S_OK or error.
610 IUnknown *pImport) PURE; // [IN] Metadata from the delta PE.
611
612 STDMETHOD(TranslateSigWithScope)(
613 IMetaDataAssemblyImport *pAssemImport, // [IN] importing assembly interface
614 const void *pbHashValue, // [IN] Hash Blob for Assembly.
615 ULONG cbHashValue, // [IN] Count of bytes.
616 IMetaDataImport *import, // [IN] importing interface
617 PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope
618 ULONG cbSigBlob, // [IN] count of bytes of signature
619 IMetaDataAssemblyEmit *pAssemEmit, // [IN] emit assembly interface
620 IMetaDataEmit *emit, // [IN] emit interface
621 PCOR_SIGNATURE pvTranslatedSig, // [OUT] buffer to hold translated signature
622 ULONG cbTranslatedSigMax,
623 ULONG *pcbTranslatedSig) PURE;// [OUT] count of bytes in the translated signature
624
625 STDMETHOD(SetMethodImplFlags)( // [IN] S_OK or error.
626 mdMethodDef md, // [IN] Method for which to set ImplFlags
627 DWORD dwImplFlags) PURE;
628
629 STDMETHOD(SetFieldRVA)( // [IN] S_OK or error.
630 mdFieldDef fd, // [IN] Field for which to set offset
631 ULONG ulRVA) PURE; // [IN] The offset
632
633 STDMETHOD(Merge)( // S_OK or error.
634 IMetaDataImport *pImport, // [IN] The scope to be merged.
635 IMapToken *pHostMapToken, // [IN] Host IMapToken interface to receive token remap notification
636 IUnknown *pHandler) PURE; // [IN] An object to receive to receive error notification.
637
638 STDMETHOD(MergeEnd)() PURE; // S_OK or error.
639
640 // This interface is sealed. Do not change, add, or remove anything. Instead, derive a new iterface.
641
642}; // IMetaDataEmit
643
644//-------------------------------------
645//--- IMetaDataEmit2
646//-------------------------------------
647// {F5DD9950-F693-42e6-830E-7B833E8146A9}
648EXTERN_GUID(IID_IMetaDataEmit2, 0xf5dd9950, 0xf693, 0x42e6, 0x83, 0xe, 0x7b, 0x83, 0x3e, 0x81, 0x46, 0xa9);
649
650//---
651#undef INTERFACE
652#define INTERFACE IMetaDataEmit2
653DECLARE_INTERFACE_(IMetaDataEmit2, IMetaDataEmit)
654{
655 STDMETHOD(DefineMethodSpec)(
656 mdToken tkParent, // [IN] MethodDef or MemberRef
657 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of COM+ signature
658 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
659 mdMethodSpec *pmi) PURE; // [OUT] method instantiation token
660
661 STDMETHOD(GetDeltaSaveSize)( // S_OK or error.
662 CorSaveSize fSave, // [IN] cssAccurate or cssQuick.
663 DWORD *pdwSaveSize) PURE; // [OUT] Put the size here.
664
665 STDMETHOD(SaveDelta)( // S_OK or error.
666 LPCWSTR szFile, // [IN] The filename to save to.
667 DWORD dwSaveFlags) PURE; // [IN] Flags for the save.
668
669 STDMETHOD(SaveDeltaToStream)( // S_OK or error.
670 IStream *pIStream, // [IN] A writable stream to save to.
671 DWORD dwSaveFlags) PURE; // [IN] Flags for the save.
672
673 STDMETHOD(SaveDeltaToMemory)( // S_OK or error.
674 void *pbData, // [OUT] Location to write data.
675 ULONG cbData) PURE; // [IN] Max size of data buffer.
676
677 STDMETHOD(DefineGenericParam)( // S_OK or error.
678 mdToken tk, // [IN] TypeDef or MethodDef
679 ULONG ulParamSeq, // [IN] Index of the type parameter
680 DWORD dwParamFlags, // [IN] Flags, for future use (e.g. variance)
681 LPCWSTR szname, // [IN] Name
682 DWORD reserved, // [IN] For future use (e.g. non-type parameters)
683 mdToken rtkConstraints[], // [IN] Array of type constraints (TypeDef,TypeRef,TypeSpec)
684 mdGenericParam *pgp) PURE; // [OUT] Put GenericParam token here
685
686 STDMETHOD(SetGenericParamProps)( // S_OK or error.
687 mdGenericParam gp, // [IN] GenericParam
688 DWORD dwParamFlags, // [IN] Flags, for future use (e.g. variance)
689 LPCWSTR szName, // [IN] Optional name
690 DWORD reserved, // [IN] For future use (e.g. non-type parameters)
691 mdToken rtkConstraints[]) PURE;// [IN] Array of type constraints (TypeDef,TypeRef,TypeSpec)
692
693 STDMETHOD(ResetENCLog)() PURE; // S_OK or error.
694
695};
696
697//-------------------------------------
698//--- IMetaDataImport
699//-------------------------------------
700// {7DAC8207-D3AE-4c75-9B67-92801A497D44}
701EXTERN_GUID(IID_IMetaDataImport, 0x7dac8207, 0xd3ae, 0x4c75, 0x9b, 0x67, 0x92, 0x80, 0x1a, 0x49, 0x7d, 0x44);
702
703//---
704#undef INTERFACE
705#define INTERFACE IMetaDataImport
706DECLARE_INTERFACE_(IMetaDataImport, IUnknown)
707{
708 STDMETHOD_(void, CloseEnum)(HCORENUM hEnum) PURE;
709 STDMETHOD(CountEnum)(HCORENUM hEnum, ULONG *pulCount) PURE;
710 STDMETHOD(ResetEnum)(HCORENUM hEnum, ULONG ulPos) PURE;
711 STDMETHOD(EnumTypeDefs)(HCORENUM *phEnum, mdTypeDef rTypeDefs[],
712 ULONG cMax, ULONG *pcTypeDefs) PURE;
713 STDMETHOD(EnumInterfaceImpls)(HCORENUM *phEnum, mdTypeDef td,
714 mdInterfaceImpl rImpls[], ULONG cMax,
715 ULONG* pcImpls) PURE;
716 STDMETHOD(EnumTypeRefs)(HCORENUM *phEnum, mdTypeRef rTypeRefs[],
717 ULONG cMax, ULONG* pcTypeRefs) PURE;
718
719 STDMETHOD(FindTypeDefByName)( // S_OK or error.
720 LPCWSTR szTypeDef, // [IN] Name of the Type.
721 mdToken tkEnclosingClass, // [IN] TypeDef/TypeRef for Enclosing class.
722 mdTypeDef *ptd) PURE; // [OUT] Put the TypeDef token here.
723
724 STDMETHOD(GetScopeProps)( // S_OK or error.
725 _Out_writes_to_opt_(cchName, *pchName)
726 LPWSTR szName, // [OUT] Put the name here.
727 ULONG cchName, // [IN] Size of name buffer in wide chars.
728 ULONG *pchName, // [OUT] Put size of name (wide chars) here.
729 GUID *pmvid) PURE; // [OUT, OPTIONAL] Put MVID here.
730
731 STDMETHOD(GetModuleFromScope)( // S_OK.
732 mdModule *pmd) PURE; // [OUT] Put mdModule token here.
733
734 STDMETHOD(GetTypeDefProps)( // S_OK or error.
735 mdTypeDef td, // [IN] TypeDef token for inquiry.
736 _Out_writes_to_opt_(cchTypeDef, *pchTypeDef)
737 LPWSTR szTypeDef, // [OUT] Put name here.
738 ULONG cchTypeDef, // [IN] size of name buffer in wide chars.
739 ULONG *pchTypeDef, // [OUT] put size of name (wide chars) here.
740 DWORD *pdwTypeDefFlags, // [OUT] Put flags here.
741 mdToken *ptkExtends) PURE; // [OUT] Put base class TypeDef/TypeRef here.
742
743 STDMETHOD(GetInterfaceImplProps)( // S_OK or error.
744 mdInterfaceImpl iiImpl, // [IN] InterfaceImpl token.
745 mdTypeDef *pClass, // [OUT] Put implementing class token here.
746 mdToken *ptkIface) PURE; // [OUT] Put implemented interface token here.
747
748 STDMETHOD(GetTypeRefProps)( // S_OK or error.
749 mdTypeRef tr, // [IN] TypeRef token.
750 mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef.
751 _Out_writes_to_opt_(cchName, *pchName)
752 LPWSTR szName, // [OUT] Name of the TypeRef.
753 ULONG cchName, // [IN] Size of buffer.
754 ULONG *pchName) PURE; // [OUT] Size of Name.
755
756 STDMETHOD(ResolveTypeRef)(mdTypeRef tr, REFIID riid, IUnknown **ppIScope, mdTypeDef *ptd) PURE;
757
758 STDMETHOD(EnumMembers)( // S_OK, S_FALSE, or error.
759 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
760 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
761 mdToken rMembers[], // [OUT] Put MemberDefs here.
762 ULONG cMax, // [IN] Max MemberDefs to put.
763 ULONG *pcTokens) PURE; // [OUT] Put # put here.
764
765 STDMETHOD(EnumMembersWithName)( // S_OK, S_FALSE, or error.
766 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
767 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
768 LPCWSTR szName, // [IN] Limit results to those with this name.
769 mdToken rMembers[], // [OUT] Put MemberDefs here.
770 ULONG cMax, // [IN] Max MemberDefs to put.
771 ULONG *pcTokens) PURE; // [OUT] Put # put here.
772
773 STDMETHOD(EnumMethods)( // S_OK, S_FALSE, or error.
774 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
775 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
776 mdMethodDef rMethods[], // [OUT] Put MethodDefs here.
777 ULONG cMax, // [IN] Max MethodDefs to put.
778 ULONG *pcTokens) PURE; // [OUT] Put # put here.
779
780 STDMETHOD(EnumMethodsWithName)( // S_OK, S_FALSE, or error.
781 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
782 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
783 LPCWSTR szName, // [IN] Limit results to those with this name.
784 mdMethodDef rMethods[], // [OU] Put MethodDefs here.
785 ULONG cMax, // [IN] Max MethodDefs to put.
786 ULONG *pcTokens) PURE; // [OUT] Put # put here.
787
788 STDMETHOD(EnumFields)( // S_OK, S_FALSE, or error.
789 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
790 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
791 mdFieldDef rFields[], // [OUT] Put FieldDefs here.
792 ULONG cMax, // [IN] Max FieldDefs to put.
793 ULONG *pcTokens) PURE; // [OUT] Put # put here.
794
795 STDMETHOD(EnumFieldsWithName)( // S_OK, S_FALSE, or error.
796 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
797 mdTypeDef cl, // [IN] TypeDef to scope the enumeration.
798 LPCWSTR szName, // [IN] Limit results to those with this name.
799 mdFieldDef rFields[], // [OUT] Put MemberDefs here.
800 ULONG cMax, // [IN] Max MemberDefs to put.
801 ULONG *pcTokens) PURE; // [OUT] Put # put here.
802
803
804 STDMETHOD(EnumParams)( // S_OK, S_FALSE, or error.
805 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
806 mdMethodDef mb, // [IN] MethodDef to scope the enumeration.
807 mdParamDef rParams[], // [OUT] Put ParamDefs here.
808 ULONG cMax, // [IN] Max ParamDefs to put.
809 ULONG *pcTokens) PURE; // [OUT] Put # put here.
810
811 STDMETHOD(EnumMemberRefs)( // S_OK, S_FALSE, or error.
812 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
813 mdToken tkParent, // [IN] Parent token to scope the enumeration.
814 mdMemberRef rMemberRefs[], // [OUT] Put MemberRefs here.
815 ULONG cMax, // [IN] Max MemberRefs to put.
816 ULONG *pcTokens) PURE; // [OUT] Put # put here.
817
818 STDMETHOD(EnumMethodImpls)( // S_OK, S_FALSE, or error
819 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
820 mdTypeDef td, // [IN] TypeDef to scope the enumeration.
821 mdToken rMethodBody[], // [OUT] Put Method Body tokens here.
822 mdToken rMethodDecl[], // [OUT] Put Method Declaration tokens here.
823 ULONG cMax, // [IN] Max tokens to put.
824 ULONG *pcTokens) PURE; // [OUT] Put # put here.
825
826 STDMETHOD(EnumPermissionSets)( // S_OK, S_FALSE, or error.
827 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
828 mdToken tk, // [IN] if !NIL, token to scope the enumeration.
829 DWORD dwActions, // [IN] if !0, return only these actions.
830 mdPermission rPermission[], // [OUT] Put Permissions here.
831 ULONG cMax, // [IN] Max Permissions to put.
832 ULONG *pcTokens) PURE; // [OUT] Put # put here.
833
834 STDMETHOD(FindMember)(
835 mdTypeDef td, // [IN] given typedef
836 LPCWSTR szName, // [IN] member name
837 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
838 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
839 mdToken *pmb) PURE; // [OUT] matching memberdef
840
841 STDMETHOD(FindMethod)(
842 mdTypeDef td, // [IN] given typedef
843 LPCWSTR szName, // [IN] member name
844 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
845 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
846 mdMethodDef *pmb) PURE; // [OUT] matching memberdef
847
848 STDMETHOD(FindField)(
849 mdTypeDef td, // [IN] given typedef
850 LPCWSTR szName, // [IN] member name
851 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
852 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
853 mdFieldDef *pmb) PURE; // [OUT] matching memberdef
854
855 STDMETHOD(FindMemberRef)(
856 mdTypeRef td, // [IN] given typeRef
857 LPCWSTR szName, // [IN] member name
858 PCCOR_SIGNATURE pvSigBlob, // [IN] point to a blob value of CLR signature
859 ULONG cbSigBlob, // [IN] count of bytes in the signature blob
860 mdMemberRef *pmr) PURE; // [OUT] matching memberref
861
862 STDMETHOD (GetMethodProps)(
863 mdMethodDef mb, // The method for which to get props.
864 mdTypeDef *pClass, // Put method's class here.
865 _Out_writes_to_opt_(cchMethod, *pchMethod)
866 LPWSTR szMethod, // Put method's name here.
867 ULONG cchMethod, // Size of szMethod buffer in wide chars.
868 ULONG *pchMethod, // Put actual size here
869 DWORD *pdwAttr, // Put flags here.
870 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data
871 ULONG *pcbSigBlob, // [OUT] actual size of signature blob
872 ULONG *pulCodeRVA, // [OUT] codeRVA
873 DWORD *pdwImplFlags) PURE; // [OUT] Impl. Flags
874
875 STDMETHOD(GetMemberRefProps)( // S_OK or error.
876 mdMemberRef mr, // [IN] given memberref
877 mdToken *ptk, // [OUT] Put classref or classdef here.
878 _Out_writes_to_opt_(cchMember, *pchMember)
879 LPWSTR szMember, // [OUT] buffer to fill for member's name
880 ULONG cchMember, // [IN] the count of char of szMember
881 ULONG *pchMember, // [OUT] actual count of char in member name
882 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to meta data blob value
883 ULONG *pbSig) PURE; // [OUT] actual size of signature blob
884
885 STDMETHOD(EnumProperties)( // S_OK, S_FALSE, or error.
886 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
887 mdTypeDef td, // [IN] TypeDef to scope the enumeration.
888 mdProperty rProperties[], // [OUT] Put Properties here.
889 ULONG cMax, // [IN] Max properties to put.
890 ULONG *pcProperties) PURE; // [OUT] Put # put here.
891
892 STDMETHOD(EnumEvents)( // S_OK, S_FALSE, or error.
893 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
894 mdTypeDef td, // [IN] TypeDef to scope the enumeration.
895 mdEvent rEvents[], // [OUT] Put events here.
896 ULONG cMax, // [IN] Max events to put.
897 ULONG *pcEvents) PURE; // [OUT] Put # put here.
898
899 STDMETHOD(GetEventProps)( // S_OK, S_FALSE, or error.
900 mdEvent ev, // [IN] event token
901 mdTypeDef *pClass, // [OUT] typedef containing the event declarion.
902 LPCWSTR szEvent, // [OUT] Event name
903 ULONG cchEvent, // [IN] the count of wchar of szEvent
904 ULONG *pchEvent, // [OUT] actual count of wchar for event's name
905 DWORD *pdwEventFlags, // [OUT] Event flags.
906 mdToken *ptkEventType, // [OUT] EventType class
907 mdMethodDef *pmdAddOn, // [OUT] AddOn method of the event
908 mdMethodDef *pmdRemoveOn, // [OUT] RemoveOn method of the event
909 mdMethodDef *pmdFire, // [OUT] Fire method of the event
910 mdMethodDef rmdOtherMethod[], // [OUT] other method of the event
911 ULONG cMax, // [IN] size of rmdOtherMethod
912 ULONG *pcOtherMethod) PURE; // [OUT] total number of other method of this event
913
914 STDMETHOD(EnumMethodSemantics)( // S_OK, S_FALSE, or error.
915 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
916 mdMethodDef mb, // [IN] MethodDef to scope the enumeration.
917 mdToken rEventProp[], // [OUT] Put Event/Property here.
918 ULONG cMax, // [IN] Max properties to put.
919 ULONG *pcEventProp) PURE; // [OUT] Put # put here.
920
921 STDMETHOD(GetMethodSemantics)( // S_OK, S_FALSE, or error.
922 mdMethodDef mb, // [IN] method token
923 mdToken tkEventProp, // [IN] event/property token.
924 DWORD *pdwSemanticsFlags) PURE; // [OUT] the role flags for the method/propevent pair
925
926 STDMETHOD(GetClassLayout) (
927 mdTypeDef td, // [IN] give typedef
928 DWORD *pdwPackSize, // [OUT] 1, 2, 4, 8, or 16
929 COR_FIELD_OFFSET rFieldOffset[], // [OUT] field offset array
930 ULONG cMax, // [IN] size of the array
931 ULONG *pcFieldOffset, // [OUT] needed array size
932 ULONG *pulClassSize) PURE; // [OUT] the size of the class
933
934 STDMETHOD(GetFieldMarshal) (
935 mdToken tk, // [IN] given a field's memberdef
936 PCCOR_SIGNATURE *ppvNativeType, // [OUT] native type of this field
937 ULONG *pcbNativeType) PURE; // [OUT] the count of bytes of *ppvNativeType
938
939 STDMETHOD(GetRVA)( // S_OK or error.
940 mdToken tk, // Member for which to set offset
941 ULONG *pulCodeRVA, // The offset
942 DWORD *pdwImplFlags) PURE; // the implementation flags
943
944 STDMETHOD(GetPermissionSetProps) (
945 mdPermission pm, // [IN] the permission token.
946 DWORD *pdwAction, // [OUT] CorDeclSecurity.
947 void const **ppvPermission, // [OUT] permission blob.
948 ULONG *pcbPermission) PURE; // [OUT] count of bytes of pvPermission.
949
950 STDMETHOD(GetSigFromToken)( // S_OK or error.
951 mdSignature mdSig, // [IN] Signature token.
952 PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to token.
953 ULONG *pcbSig) PURE; // [OUT] return size of signature.
954
955 STDMETHOD(GetModuleRefProps)( // S_OK or error.
956 mdModuleRef mur, // [IN] moduleref token.
957 _Out_writes_to_opt_(cchName, *pchName)
958 LPWSTR szName, // [OUT] buffer to fill with the moduleref name.
959 ULONG cchName, // [IN] size of szName in wide characters.
960 ULONG *pchName) PURE; // [OUT] actual count of characters in the name.
961
962 STDMETHOD(EnumModuleRefs)( // S_OK or error.
963 HCORENUM *phEnum, // [IN|OUT] pointer to the enum.
964 mdModuleRef rModuleRefs[], // [OUT] put modulerefs here.
965 ULONG cmax, // [IN] max memberrefs to put.
966 ULONG *pcModuleRefs) PURE; // [OUT] put # put here.
967
968 STDMETHOD(GetTypeSpecFromToken)( // S_OK or error.
969 mdTypeSpec typespec, // [IN] TypeSpec token.
970 PCCOR_SIGNATURE *ppvSig, // [OUT] return pointer to TypeSpec signature
971 ULONG *pcbSig) PURE; // [OUT] return size of signature.
972
973 STDMETHOD(GetNameFromToken)( // Not Recommended! May be removed!
974 mdToken tk, // [IN] Token to get name from. Must have a name.
975 MDUTF8CSTR *pszUtf8NamePtr) PURE; // [OUT] Return pointer to UTF8 name in heap.
976
977 STDMETHOD(EnumUnresolvedMethods)( // S_OK, S_FALSE, or error.
978 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
979 mdToken rMethods[], // [OUT] Put MemberDefs here.
980 ULONG cMax, // [IN] Max MemberDefs to put.
981 ULONG *pcTokens) PURE; // [OUT] Put # put here.
982
983 STDMETHOD(GetUserString)( // S_OK or error.
984 mdString stk, // [IN] String token.
985 _Out_writes_to_opt_(cchString, *pchString)
986 LPWSTR szString, // [OUT] Copy of string.
987 ULONG cchString, // [IN] Max chars of room in szString.
988 ULONG *pchString) PURE; // [OUT] How many chars in actual string.
989
990 STDMETHOD(GetPinvokeMap)( // S_OK or error.
991 mdToken tk, // [IN] FieldDef or MethodDef.
992 DWORD *pdwMappingFlags, // [OUT] Flags used for mapping.
993 _Out_writes_to_opt_(cchImportName, *pchImportName)
994 LPWSTR szImportName, // [OUT] Import name.
995 ULONG cchImportName, // [IN] Size of the name buffer.
996 ULONG *pchImportName, // [OUT] Actual number of characters stored.
997 mdModuleRef *pmrImportDLL) PURE; // [OUT] ModuleRef token for the target DLL.
998
999 STDMETHOD(EnumSignatures)( // S_OK or error.
1000 HCORENUM *phEnum, // [IN|OUT] pointer to the enum.
1001 mdSignature rSignatures[], // [OUT] put signatures here.
1002 ULONG cmax, // [IN] max signatures to put.
1003 ULONG *pcSignatures) PURE; // [OUT] put # put here.
1004
1005 STDMETHOD(EnumTypeSpecs)( // S_OK or error.
1006 HCORENUM *phEnum, // [IN|OUT] pointer to the enum.
1007 mdTypeSpec rTypeSpecs[], // [OUT] put TypeSpecs here.
1008 ULONG cmax, // [IN] max TypeSpecs to put.
1009 ULONG *pcTypeSpecs) PURE; // [OUT] put # put here.
1010
1011 STDMETHOD(EnumUserStrings)( // S_OK or error.
1012 HCORENUM *phEnum, // [IN/OUT] pointer to the enum.
1013 mdString rStrings[], // [OUT] put Strings here.
1014 ULONG cmax, // [IN] max Strings to put.
1015 ULONG *pcStrings) PURE; // [OUT] put # put here.
1016
1017 STDMETHOD(GetParamForMethodIndex)( // S_OK or error.
1018 mdMethodDef md, // [IN] Method token.
1019 ULONG ulParamSeq, // [IN] Parameter sequence.
1020 mdParamDef *ppd) PURE; // [IN] Put Param token here.
1021
1022 STDMETHOD(EnumCustomAttributes)( // S_OK or error.
1023 HCORENUM *phEnum, // [IN, OUT] COR enumerator.
1024 mdToken tk, // [IN] Token to scope the enumeration, 0 for all.
1025 mdToken tkType, // [IN] Type of interest, 0 for all.
1026 mdCustomAttribute rCustomAttributes[], // [OUT] Put custom attribute tokens here.
1027 ULONG cMax, // [IN] Size of rCustomAttributes.
1028 ULONG *pcCustomAttributes) PURE; // [OUT, OPTIONAL] Put count of token values here.
1029
1030 STDMETHOD(GetCustomAttributeProps)( // S_OK or error.
1031 mdCustomAttribute cv, // [IN] CustomAttribute token.
1032 mdToken *ptkObj, // [OUT, OPTIONAL] Put object token here.
1033 mdToken *ptkType, // [OUT, OPTIONAL] Put AttrType token here.
1034 void const **ppBlob, // [OUT, OPTIONAL] Put pointer to data here.
1035 ULONG *pcbSize) PURE; // [OUT, OPTIONAL] Put size of date here.
1036
1037 STDMETHOD(FindTypeRef)(
1038 mdToken tkResolutionScope, // [IN] ModuleRef, AssemblyRef or TypeRef.
1039 LPCWSTR szName, // [IN] TypeRef Name.
1040 mdTypeRef *ptr) PURE; // [OUT] matching TypeRef.
1041
1042 STDMETHOD(GetMemberProps)(
1043 mdToken mb, // The member for which to get props.
1044 mdTypeDef *pClass, // Put member's class here.
1045 _Out_writes_to_opt_(cchMember, *pchMember)
1046 LPWSTR szMember, // Put member's name here.
1047 ULONG cchMember, // Size of szMember buffer in wide chars.
1048 ULONG *pchMember, // Put actual size here
1049 DWORD *pdwAttr, // Put flags here.
1050 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data
1051 ULONG *pcbSigBlob, // [OUT] actual size of signature blob
1052 ULONG *pulCodeRVA, // [OUT] codeRVA
1053 DWORD *pdwImplFlags, // [OUT] Impl. Flags
1054 DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_*
1055 UVCP_CONSTANT *ppValue, // [OUT] constant value
1056 ULONG *pcchValue) PURE; // [OUT] size of constant string in chars, 0 for non-strings.
1057
1058 STDMETHOD(GetFieldProps)(
1059 mdFieldDef mb, // The field for which to get props.
1060 mdTypeDef *pClass, // Put field's class here.
1061 _Out_writes_to_opt_(cchField, *pchField)
1062 LPWSTR szField, // Put field's name here.
1063 ULONG cchField, // Size of szField buffer in wide chars.
1064 ULONG *pchField, // Put actual size here
1065 DWORD *pdwAttr, // Put flags here.
1066 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data
1067 ULONG *pcbSigBlob, // [OUT] actual size of signature blob
1068 DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_*
1069 UVCP_CONSTANT *ppValue, // [OUT] constant value
1070 ULONG *pcchValue) PURE; // [OUT] size of constant string in chars, 0 for non-strings.
1071
1072 STDMETHOD(GetPropertyProps)( // S_OK, S_FALSE, or error.
1073 mdProperty prop, // [IN] property token
1074 mdTypeDef *pClass, // [OUT] typedef containing the property declarion.
1075 LPCWSTR szProperty, // [OUT] Property name
1076 ULONG cchProperty, // [IN] the count of wchar of szProperty
1077 ULONG *pchProperty, // [OUT] actual count of wchar for property name
1078 DWORD *pdwPropFlags, // [OUT] property flags.
1079 PCCOR_SIGNATURE *ppvSig, // [OUT] property type. pointing to meta data internal blob
1080 ULONG *pbSig, // [OUT] count of bytes in *ppvSig
1081 DWORD *pdwCPlusTypeFlag, // [OUT] flag for value type. selected ELEMENT_TYPE_*
1082 UVCP_CONSTANT *ppDefaultValue, // [OUT] constant value
1083 ULONG *pcchDefaultValue, // [OUT] size of constant string in chars, 0 for non-strings.
1084 mdMethodDef *pmdSetter, // [OUT] setter method of the property
1085 mdMethodDef *pmdGetter, // [OUT] getter method of the property
1086 mdMethodDef rmdOtherMethod[], // [OUT] other method of the property
1087 ULONG cMax, // [IN] size of rmdOtherMethod
1088 ULONG *pcOtherMethod) PURE; // [OUT] total number of other method of this property
1089
1090 STDMETHOD(GetParamProps)( // S_OK or error.
1091 mdParamDef tk, // [IN]The Parameter.
1092 mdMethodDef *pmd, // [OUT] Parent Method token.
1093 ULONG *pulSequence, // [OUT] Parameter sequence.
1094 _Out_writes_to_opt_(cchName, *pchName)
1095 LPWSTR szName, // [OUT] Put name here.
1096 ULONG cchName, // [OUT] Size of name buffer.
1097 ULONG *pchName, // [OUT] Put actual size of name here.
1098 DWORD *pdwAttr, // [OUT] Put flags here.
1099 DWORD *pdwCPlusTypeFlag, // [OUT] Flag for value type. selected ELEMENT_TYPE_*.
1100 UVCP_CONSTANT *ppValue, // [OUT] Constant value.
1101 ULONG *pcchValue) PURE; // [OUT] size of constant string in chars, 0 for non-strings.
1102
1103 STDMETHOD(GetCustomAttributeByName)( // S_OK or error.
1104 mdToken tkObj, // [IN] Object with Custom Attribute.
1105 LPCWSTR szName, // [IN] Name of desired Custom Attribute.
1106 const void **ppData, // [OUT] Put pointer to data here.
1107 ULONG *pcbData) PURE; // [OUT] Put size of data here.
1108
1109 STDMETHOD_(BOOL, IsValidToken)( // True or False.
1110 mdToken tk) PURE; // [IN] Given token.
1111
1112 STDMETHOD(GetNestedClassProps)( // S_OK or error.
1113 mdTypeDef tdNestedClass, // [IN] NestedClass token.
1114 mdTypeDef *ptdEnclosingClass) PURE; // [OUT] EnclosingClass token.
1115
1116 STDMETHOD(GetNativeCallConvFromSig)( // S_OK or error.
1117 void const *pvSig, // [IN] Pointer to signature.
1118 ULONG cbSig, // [IN] Count of signature bytes.
1119 ULONG *pCallConv) PURE; // [OUT] Put calling conv here (see CorPinvokemap).
1120
1121 STDMETHOD(IsGlobal)( // S_OK or error.
1122 mdToken pd, // [IN] Type, Field, or Method token.
1123 int *pbGlobal) PURE; // [OUT] Put 1 if global, 0 otherwise.
1124
1125 // This interface is sealed. Do not change, add, or remove anything. Instead, derive a new iterface.
1126
1127}; // IMetaDataImport
1128
1129//-------------------------------------
1130//--- IMetaDataImport2
1131//-------------------------------------
1132// {FCE5EFA0-8BBA-4f8e-A036-8F2022B08466}
1133EXTERN_GUID(IID_IMetaDataImport2, 0xfce5efa0, 0x8bba, 0x4f8e, 0xa0, 0x36, 0x8f, 0x20, 0x22, 0xb0, 0x84, 0x66);
1134
1135//---
1136#undef INTERFACE
1137#define INTERFACE IMetaDataImport2
1138DECLARE_INTERFACE_(IMetaDataImport2, IMetaDataImport)
1139{
1140 STDMETHOD(EnumGenericParams)(
1141 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1142 mdToken tk, // [IN] TypeDef or MethodDef whose generic parameters are requested
1143 mdGenericParam rGenericParams[], // [OUT] Put GenericParams here.
1144 ULONG cMax, // [IN] Max GenericParams to put.
1145 ULONG *pcGenericParams) PURE; // [OUT] Put # put here.
1146
1147 STDMETHOD(GetGenericParamProps)( // S_OK or error.
1148 mdGenericParam gp, // [IN] GenericParam
1149 ULONG *pulParamSeq, // [OUT] Index of the type parameter
1150 DWORD *pdwParamFlags, // [OUT] Flags, for future use (e.g. variance)
1151 mdToken *ptOwner, // [OUT] Owner (TypeDef or MethodDef)
1152 DWORD *reserved, // [OUT] For future use (e.g. non-type parameters)
1153 _Out_writes_to_opt_(cchName, *pchName)
1154 LPWSTR wzname, // [OUT] Put name here
1155 ULONG cchName, // [IN] Size of buffer
1156 ULONG *pchName) PURE; // [OUT] Put size of name (wide chars) here.
1157
1158 STDMETHOD(GetMethodSpecProps)(
1159 mdMethodSpec mi, // [IN] The method instantiation
1160 mdToken *tkParent, // [OUT] MethodDef or MemberRef
1161 PCCOR_SIGNATURE *ppvSigBlob, // [OUT] point to the blob value of meta data
1162 ULONG *pcbSigBlob) PURE; // [OUT] actual size of signature blob
1163
1164 STDMETHOD(EnumGenericParamConstraints)(
1165 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1166 mdGenericParam tk, // [IN] GenericParam whose constraints are requested
1167 mdGenericParamConstraint rGenericParamConstraints[], // [OUT] Put GenericParamConstraints here.
1168 ULONG cMax, // [IN] Max GenericParamConstraints to put.
1169 ULONG *pcGenericParamConstraints) PURE; // [OUT] Put # put here.
1170
1171 STDMETHOD(GetGenericParamConstraintProps)( // S_OK or error.
1172 mdGenericParamConstraint gpc, // [IN] GenericParamConstraint
1173 mdGenericParam *ptGenericParam, // [OUT] GenericParam that is constrained
1174 mdToken *ptkConstraintType) PURE; // [OUT] TypeDef/Ref/Spec constraint
1175
1176 STDMETHOD(GetPEKind)( // S_OK or error.
1177 DWORD* pdwPEKind, // [OUT] The kind of PE (0 - not a PE)
1178 DWORD* pdwMAchine) PURE; // [OUT] Machine as defined in NT header
1179
1180 STDMETHOD(GetVersionString)( // S_OK or error.
1181 _Out_writes_to_opt_(ccBufSize, *pccBufSize)
1182 LPWSTR pwzBuf, // [OUT] Put version string here.
1183 DWORD ccBufSize, // [IN] size of the buffer, in wide chars
1184 DWORD *pccBufSize) PURE; // [OUT] Size of the version string, wide chars, including terminating nul.
1185
1186 STDMETHOD(EnumMethodSpecs)(
1187 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1188 mdToken tk, // [IN] MethodDef or MemberRef whose MethodSpecs are requested
1189 mdMethodSpec rMethodSpecs[], // [OUT] Put MethodSpecs here.
1190 ULONG cMax, // [IN] Max tokens to put.
1191 ULONG *pcMethodSpecs) PURE; // [OUT] Put actual count here.
1192
1193}; // IMetaDataImport2
1194
1195//-------------------------------------
1196//--- IMetaDataFilter
1197//-------------------------------------
1198// {D0E80DD1-12D4-11d3-B39D-00C04FF81795}
1199EXTERN_GUID(IID_IMetaDataFilter, 0xd0e80dd1, 0x12d4, 0x11d3, 0xb3, 0x9d, 0x0, 0xc0, 0x4f, 0xf8, 0x17, 0x95);
1200
1201//---
1202#undef INTERFACE
1203#define INTERFACE IMetaDataFilter
1204DECLARE_INTERFACE_(IMetaDataFilter, IUnknown)
1205{
1206 STDMETHOD(UnmarkAll)() PURE;
1207 STDMETHOD(MarkToken)(mdToken tk) PURE;
1208 STDMETHOD(IsTokenMarked)(mdToken tk, BOOL *pIsMarked) PURE;
1209};
1210
1211
1212//-------------------------------------
1213//--- IHostFilter
1214//-------------------------------------
1215// {D0E80DD3-12D4-11d3-B39D-00C04FF81795}
1216EXTERN_GUID(IID_IHostFilter, 0xd0e80dd3, 0x12d4, 0x11d3, 0xb3, 0x9d, 0x0, 0xc0, 0x4f, 0xf8, 0x17, 0x95);
1217
1218//---
1219#undef INTERFACE
1220#define INTERFACE IHostFilter
1221DECLARE_INTERFACE_(IHostFilter, IUnknown)
1222{
1223 STDMETHOD(MarkToken)(mdToken tk) PURE;
1224};
1225
1226
1227//*****************************************************************************
1228// Assembly Declarations
1229//*****************************************************************************
1230
1231typedef struct
1232{
1233 DWORD dwOSPlatformId; // Operating system platform.
1234 DWORD dwOSMajorVersion; // OS Major version.
1235 DWORD dwOSMinorVersion; // OS Minor version.
1236} OSINFO;
1237
1238
1239typedef struct
1240{
1241 USHORT usMajorVersion; // Major Version.
1242 USHORT usMinorVersion; // Minor Version.
1243 USHORT usBuildNumber; // Build Number.
1244 USHORT usRevisionNumber; // Revision Number.
1245 LPWSTR szLocale; // Locale.
1246 ULONG cbLocale; // [IN/OUT] Size of the buffer in wide chars/Actual size.
1247 DWORD *rProcessor; // Processor ID array.
1248 ULONG ulProcessor; // [IN/OUT] Size of the Processor ID array/Actual # of entries filled in.
1249 OSINFO *rOS; // OSINFO array.
1250 ULONG ulOS; // [IN/OUT]Size of the OSINFO array/Actual # of entries filled in.
1251} ASSEMBLYMETADATA;
1252
1253
1254// {211EF15B-5317-4438-B196-DEC87B887693}
1255EXTERN_GUID(IID_IMetaDataAssemblyEmit, 0x211ef15b, 0x5317, 0x4438, 0xb1, 0x96, 0xde, 0xc8, 0x7b, 0x88, 0x76, 0x93);
1256
1257//---
1258#undef INTERFACE
1259#define INTERFACE IMetaDataAssemblyEmit
1260DECLARE_INTERFACE_(IMetaDataAssemblyEmit, IUnknown)
1261{
1262 STDMETHOD(DefineAssembly)( // S_OK or error.
1263 const void *pbPublicKey, // [IN] Public key of the assembly.
1264 ULONG cbPublicKey, // [IN] Count of bytes in the public key.
1265 ULONG ulHashAlgId, // [IN] Hash algorithm used to hash the files.
1266 LPCWSTR szName, // [IN] Name of the assembly.
1267 const ASSEMBLYMETADATA *pMetaData, // [IN] Assembly MetaData.
1268 DWORD dwAssemblyFlags, // [IN] Flags.
1269 mdAssembly *pma) PURE; // [OUT] Returned Assembly token.
1270
1271 STDMETHOD(DefineAssemblyRef)( // S_OK or error.
1272 const void *pbPublicKeyOrToken, // [IN] Public key or token of the assembly.
1273 ULONG cbPublicKeyOrToken, // [IN] Count of bytes in the public key or token.
1274 LPCWSTR szName, // [IN] Name of the assembly being referenced.
1275 const ASSEMBLYMETADATA *pMetaData, // [IN] Assembly MetaData.
1276 const void *pbHashValue, // [IN] Hash Blob.
1277 ULONG cbHashValue, // [IN] Count of bytes in the Hash Blob.
1278 DWORD dwAssemblyRefFlags, // [IN] Flags.
1279 mdAssemblyRef *pmdar) PURE; // [OUT] Returned AssemblyRef token.
1280
1281 STDMETHOD(DefineFile)( // S_OK or error.
1282 LPCWSTR szName, // [IN] Name of the file.
1283 const void *pbHashValue, // [IN] Hash Blob.
1284 ULONG cbHashValue, // [IN] Count of bytes in the Hash Blob.
1285 DWORD dwFileFlags, // [IN] Flags.
1286 mdFile *pmdf) PURE; // [OUT] Returned File token.
1287
1288 STDMETHOD(DefineExportedType)( // S_OK or error.
1289 LPCWSTR szName, // [IN] Name of the Com Type.
1290 mdToken tkImplementation, // [IN] mdFile or mdAssemblyRef or mdExportedType
1291 mdTypeDef tkTypeDef, // [IN] TypeDef token within the file.
1292 DWORD dwExportedTypeFlags, // [IN] Flags.
1293 mdExportedType *pmdct) PURE; // [OUT] Returned ExportedType token.
1294
1295 STDMETHOD(DefineManifestResource)( // S_OK or error.
1296 LPCWSTR szName, // [IN] Name of the resource.
1297 mdToken tkImplementation, // [IN] mdFile or mdAssemblyRef that provides the resource.
1298 DWORD dwOffset, // [IN] Offset to the beginning of the resource within the file.
1299 DWORD dwResourceFlags, // [IN] Flags.
1300 mdManifestResource *pmdmr) PURE; // [OUT] Returned ManifestResource token.
1301
1302 STDMETHOD(SetAssemblyProps)( // S_OK or error.
1303 mdAssembly pma, // [IN] Assembly token.
1304 const void *pbPublicKey, // [IN] Public key of the assembly.
1305 ULONG cbPublicKey, // [IN] Count of bytes in the public key.
1306 ULONG ulHashAlgId, // [IN] Hash algorithm used to hash the files.
1307 LPCWSTR szName, // [IN] Name of the assembly.
1308 const ASSEMBLYMETADATA *pMetaData, // [IN] Assembly MetaData.
1309 DWORD dwAssemblyFlags) PURE; // [IN] Flags.
1310
1311 STDMETHOD(SetAssemblyRefProps)( // S_OK or error.
1312 mdAssemblyRef ar, // [IN] AssemblyRefToken.
1313 const void *pbPublicKeyOrToken, // [IN] Public key or token of the assembly.
1314 ULONG cbPublicKeyOrToken, // [IN] Count of bytes in the public key or token.
1315 LPCWSTR szName, // [IN] Name of the assembly being referenced.
1316 const ASSEMBLYMETADATA *pMetaData, // [IN] Assembly MetaData.
1317 const void *pbHashValue, // [IN] Hash Blob.
1318 ULONG cbHashValue, // [IN] Count of bytes in the Hash Blob.
1319 DWORD dwAssemblyRefFlags) PURE; // [IN] Token for Execution Location.
1320
1321 STDMETHOD(SetFileProps)( // S_OK or error.
1322 mdFile file, // [IN] File token.
1323 const void *pbHashValue, // [IN] Hash Blob.
1324 ULONG cbHashValue, // [IN] Count of bytes in the Hash Blob.
1325 DWORD dwFileFlags) PURE; // [IN] Flags.
1326
1327 STDMETHOD(SetExportedTypeProps)( // S_OK or error.
1328 mdExportedType ct, // [IN] ExportedType token.
1329 mdToken tkImplementation, // [IN] mdFile or mdAssemblyRef or mdExportedType.
1330 mdTypeDef tkTypeDef, // [IN] TypeDef token within the file.
1331 DWORD dwExportedTypeFlags) PURE; // [IN] Flags.
1332
1333 STDMETHOD(SetManifestResourceProps)( // S_OK or error.
1334 mdManifestResource mr, // [IN] ManifestResource token.
1335 mdToken tkImplementation, // [IN] mdFile or mdAssemblyRef that provides the resource.
1336 DWORD dwOffset, // [IN] Offset to the beginning of the resource within the file.
1337 DWORD dwResourceFlags) PURE; // [IN] Flags.
1338
1339}; // IMetaDataAssemblyEmit
1340
1341
1342// {EE62470B-E94B-424e-9B7C-2F00C9249F93}
1343EXTERN_GUID(IID_IMetaDataAssemblyImport, 0xee62470b, 0xe94b, 0x424e, 0x9b, 0x7c, 0x2f, 0x0, 0xc9, 0x24, 0x9f, 0x93);
1344
1345//---
1346#undef INTERFACE
1347#define INTERFACE IMetaDataAssemblyImport
1348DECLARE_INTERFACE_(IMetaDataAssemblyImport, IUnknown)
1349{
1350 STDMETHOD(GetAssemblyProps)( // S_OK or error.
1351 mdAssembly mda, // [IN] The Assembly for which to get the properties.
1352 const void **ppbPublicKey, // [OUT] Pointer to the public key.
1353 ULONG *pcbPublicKey, // [OUT] Count of bytes in the public key.
1354 ULONG *pulHashAlgId, // [OUT] Hash Algorithm.
1355 _Out_writes_to_opt_(cchName, *pchName) LPWSTR szName, // [OUT] Buffer to fill with assembly's simply name.
1356 ULONG cchName, // [IN] Size of buffer in wide chars.
1357 ULONG *pchName, // [OUT] Actual # of wide chars in name.
1358 ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData.
1359 DWORD *pdwAssemblyFlags) PURE; // [OUT] Flags.
1360
1361 STDMETHOD(GetAssemblyRefProps)( // S_OK or error.
1362 mdAssemblyRef mdar, // [IN] The AssemblyRef for which to get the properties.
1363 const void **ppbPublicKeyOrToken, // [OUT] Pointer to the public key or token.
1364 ULONG *pcbPublicKeyOrToken, // [OUT] Count of bytes in the public key or token.
1365 _Out_writes_to_opt_(cchName, *pchName)LPWSTR szName, // [OUT] Buffer to fill with name.
1366 ULONG cchName, // [IN] Size of buffer in wide chars.
1367 ULONG *pchName, // [OUT] Actual # of wide chars in name.
1368 ASSEMBLYMETADATA *pMetaData, // [OUT] Assembly MetaData.
1369 const void **ppbHashValue, // [OUT] Hash blob.
1370 ULONG *pcbHashValue, // [OUT] Count of bytes in the hash blob.
1371 DWORD *pdwAssemblyRefFlags) PURE; // [OUT] Flags.
1372
1373 STDMETHOD(GetFileProps)( // S_OK or error.
1374 mdFile mdf, // [IN] The File for which to get the properties.
1375 _Out_writes_to_opt_(cchName, *pchName) LPWSTR szName, // [OUT] Buffer to fill with name.
1376 ULONG cchName, // [IN] Size of buffer in wide chars.
1377 ULONG *pchName, // [OUT] Actual # of wide chars in name.
1378 const void **ppbHashValue, // [OUT] Pointer to the Hash Value Blob.
1379 ULONG *pcbHashValue, // [OUT] Count of bytes in the Hash Value Blob.
1380 DWORD *pdwFileFlags) PURE; // [OUT] Flags.
1381
1382 STDMETHOD(GetExportedTypeProps)( // S_OK or error.
1383 mdExportedType mdct, // [IN] The ExportedType for which to get the properties.
1384 _Out_writes_to_opt_(cchName, *pchName) LPWSTR szName, // [OUT] Buffer to fill with name.
1385 ULONG cchName, // [IN] Size of buffer in wide chars.
1386 ULONG *pchName, // [OUT] Actual # of wide chars in name.
1387 mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef or mdExportedType.
1388 mdTypeDef *ptkTypeDef, // [OUT] TypeDef token within the file.
1389 DWORD *pdwExportedTypeFlags) PURE; // [OUT] Flags.
1390
1391 STDMETHOD(GetManifestResourceProps)( // S_OK or error.
1392 mdManifestResource mdmr, // [IN] The ManifestResource for which to get the properties.
1393 _Out_writes_to_opt_(cchName, *pchName)LPWSTR szName, // [OUT] Buffer to fill with name.
1394 ULONG cchName, // [IN] Size of buffer in wide chars.
1395 ULONG *pchName, // [OUT] Actual # of wide chars in name.
1396 mdToken *ptkImplementation, // [OUT] mdFile or mdAssemblyRef that provides the ManifestResource.
1397 DWORD *pdwOffset, // [OUT] Offset to the beginning of the resource within the file.
1398 DWORD *pdwResourceFlags) PURE;// [OUT] Flags.
1399
1400 STDMETHOD(EnumAssemblyRefs)( // S_OK or error
1401 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1402 mdAssemblyRef rAssemblyRefs[], // [OUT] Put AssemblyRefs here.
1403 ULONG cMax, // [IN] Max AssemblyRefs to put.
1404 ULONG *pcTokens) PURE; // [OUT] Put # put here.
1405
1406 STDMETHOD(EnumFiles)( // S_OK or error
1407 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1408 mdFile rFiles[], // [OUT] Put Files here.
1409 ULONG cMax, // [IN] Max Files to put.
1410 ULONG *pcTokens) PURE; // [OUT] Put # put here.
1411
1412 STDMETHOD(EnumExportedTypes)( // S_OK or error
1413 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1414 mdExportedType rExportedTypes[], // [OUT] Put ExportedTypes here.
1415 ULONG cMax, // [IN] Max ExportedTypes to put.
1416 ULONG *pcTokens) PURE; // [OUT] Put # put here.
1417
1418 STDMETHOD(EnumManifestResources)( // S_OK or error
1419 HCORENUM *phEnum, // [IN|OUT] Pointer to the enum.
1420 mdManifestResource rManifestResources[], // [OUT] Put ManifestResources here.
1421 ULONG cMax, // [IN] Max Resources to put.
1422 ULONG *pcTokens) PURE; // [OUT] Put # put here.
1423
1424 STDMETHOD(GetAssemblyFromScope)( // S_OK or error
1425 mdAssembly *ptkAssembly) PURE; // [OUT] Put token here.
1426
1427 STDMETHOD(FindExportedTypeByName)( // S_OK or error
1428 LPCWSTR szName, // [IN] Name of the ExportedType.
1429 mdToken mdtExportedType, // [IN] ExportedType for the enclosing class.
1430 mdExportedType *ptkExportedType) PURE; // [OUT] Put the ExportedType token here.
1431
1432 STDMETHOD(FindManifestResourceByName)( // S_OK or error
1433 LPCWSTR szName, // [IN] Name of the ManifestResource.
1434 mdManifestResource *ptkManifestResource) PURE; // [OUT] Put the ManifestResource token here.
1435
1436 STDMETHOD_(void, CloseEnum)(
1437 HCORENUM hEnum) PURE; // Enum to be closed.
1438
1439 STDMETHOD(FindAssembliesByName)( // S_OK or error
1440 LPCWSTR szAppBase, // [IN] optional - can be NULL
1441 LPCWSTR szPrivateBin, // [IN] optional - can be NULL
1442 LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are requesting
1443 IUnknown *ppIUnk[], // [OUT] put IMetaDataAssemblyImport pointers here
1444 ULONG cMax, // [IN] The max number to put
1445 ULONG *pcAssemblies) PURE; // [OUT] The number of assemblies returned.
1446}; // IMetaDataAssemblyImport
1447
1448
1449//*****************************************************************************
1450// End Assembly Declarations
1451//*****************************************************************************
1452
1453//*****************************************************************************
1454// MetaData Validator Declarations
1455//*****************************************************************************
1456
1457// Specifies the type of the module, PE file vs. .obj file.
1458typedef enum
1459{
1460 ValidatorModuleTypeInvalid = 0x0,
1461 ValidatorModuleTypeMin = 0x00000001,
1462 ValidatorModuleTypePE = 0x00000001,
1463 ValidatorModuleTypeObj = 0x00000002,
1464 ValidatorModuleTypeEnc = 0x00000003,
1465 ValidatorModuleTypeIncr = 0x00000004,
1466 ValidatorModuleTypeMax = 0x00000004,
1467} CorValidatorModuleType;
1468
1469
1470// {4709C9C6-81FF-11D3-9FC7-00C04F79A0A3}
1471EXTERN_GUID(IID_IMetaDataValidate, 0x4709c9c6, 0x81ff, 0x11d3, 0x9f, 0xc7, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
1472
1473//---
1474#undef INTERFACE
1475#define INTERFACE IMetaDataValidate
1476DECLARE_INTERFACE_(IMetaDataValidate, IUnknown)
1477{
1478 STDMETHOD(ValidatorInit)( // S_OK or error.
1479 DWORD dwModuleType, // [IN] Specifies the type of the module.
1480 IUnknown *pUnk) PURE; // [IN] Validation error handler.
1481
1482 STDMETHOD(ValidateMetaData)( // S_OK or error.
1483 ) PURE;
1484}; // IMetaDataValidate
1485
1486//*****************************************************************************
1487// End MetaData Validator Declarations
1488//*****************************************************************************
1489
1490//*****************************************************************************
1491// IMetaDataDispenserEx declarations.
1492//*****************************************************************************
1493
1494// {31BCFCE2-DAFB-11D2-9F81-00C04F79A0A3}
1495EXTERN_GUID(IID_IMetaDataDispenserEx, 0x31bcfce2, 0xdafb, 0x11d2, 0x9f, 0x81, 0x0, 0xc0, 0x4f, 0x79, 0xa0, 0xa3);
1496
1497#undef INTERFACE
1498#define INTERFACE IMetaDataDispenserEx
1499DECLARE_INTERFACE_(IMetaDataDispenserEx, IMetaDataDispenser)
1500{
1501 STDMETHOD(SetOption)( // Return code.
1502 REFGUID optionid, // [in] GUID for the option to be set.
1503 const VARIANT *value) PURE; // [in] Value to which the option is to be set.
1504
1505 STDMETHOD(GetOption)( // Return code.
1506 REFGUID optionid, // [in] GUID for the option to be set.
1507 VARIANT *pvalue) PURE; // [out] Value to which the option is currently set.
1508
1509 STDMETHOD(OpenScopeOnITypeInfo)( // Return code.
1510 ITypeInfo *pITI, // [in] ITypeInfo to open.
1511 DWORD dwOpenFlags, // [in] Open mode flags.
1512 REFIID riid, // [in] The interface desired.
1513 IUnknown **ppIUnk) PURE; // [out] Return interface on success.
1514
1515 STDMETHOD(GetCORSystemDirectory)( // Return code.
1516 _Out_writes_to_opt_(cchBuffer, *pchBuffer)
1517 LPWSTR szBuffer, // [out] Buffer for the directory name
1518 DWORD cchBuffer, // [in] Size of the buffer
1519 DWORD* pchBuffer) PURE; // [OUT] Number of characters returned
1520
1521 STDMETHOD(FindAssembly)( // S_OK or error
1522 LPCWSTR szAppBase, // [IN] optional - can be NULL
1523 LPCWSTR szPrivateBin, // [IN] optional - can be NULL
1524 LPCWSTR szGlobalBin, // [IN] optional - can be NULL
1525 LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are requesting
1526 LPCWSTR szName, // [OUT] buffer - to hold name
1527 ULONG cchName, // [IN] the name buffer's size
1528 ULONG *pcName) PURE; // [OUT] the number of characters returend in the buffer
1529
1530 STDMETHOD(FindAssemblyModule)( // S_OK or error
1531 LPCWSTR szAppBase, // [IN] optional - can be NULL
1532 LPCWSTR szPrivateBin, // [IN] optional - can be NULL
1533 LPCWSTR szGlobalBin, // [IN] optional - can be NULL
1534 LPCWSTR szAssemblyName, // [IN] required - this is the assembly you are requesting
1535 LPCWSTR szModuleName, // [IN] required - the name of the module
1536 _Out_writes_to_opt_(cchName, *pcName)
1537 LPWSTR szName, // [OUT] buffer - to hold name
1538 ULONG cchName, // [IN] the name buffer's size
1539 ULONG *pcName) PURE; // [OUT] the number of characters returend in the buffer
1540
1541};
1542
1543//*****************************************************************************
1544//*****************************************************************************
1545//
1546// Registration declarations. Will be replace by Services' Registration
1547// implementation.
1548//
1549//*****************************************************************************
1550//*****************************************************************************
1551// Various flags for use in installing a module or a composite
1552typedef enum
1553{
1554 regNoCopy = 0x00000001, // Don't copy files into destination
1555 regConfig = 0x00000002, // Is a configuration
1556 regHasRefs = 0x00000004 // Has class references
1557} CorRegFlags;
1558
1559typedef GUID CVID;
1560
1561typedef struct {
1562 short Major;
1563 short Minor;
1564 short Sub;
1565 short Build;
1566} CVStruct;
1567
1568
1569//*****************************************************************************
1570//*****************************************************************************
1571//
1572// CeeGen interfaces for generating in-memory Common Language Runtime files
1573//
1574//*****************************************************************************
1575//*****************************************************************************
1576
1577typedef void *HCEESECTION;
1578
1579typedef enum {
1580 sdNone = 0,
1581 sdReadOnly = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_INITIALIZED_DATA,
1582 sdReadWrite = sdReadOnly | IMAGE_SCN_MEM_WRITE,
1583 sdExecute = IMAGE_SCN_MEM_READ | IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE
1584} CeeSectionAttr;
1585
1586//
1587// Relocation types.
1588//
1589
1590typedef enum {
1591 // generate only a section-relative reloc, nothing into .reloc section
1592 srRelocAbsolute,
1593
1594 // generate a .reloc for a pointer sized location,
1595 // This is transformed into BASED_HIGHLOW or BASED_DIR64 based on the platform
1596 srRelocHighLow = 3,
1597
1598 // generate a .reloc for the top 16-bits of a 32 bit number, where the
1599 // bottom 16 bits are included in the next word in the .reloc table
1600 srRelocHighAdj, // Never Used
1601
1602 // generate a token map relocation, nothing into .reloc section
1603 srRelocMapToken,
1604
1605 // relative address fixup
1606 srRelocRelative,
1607
1608 // Generate only a section-relative reloc, nothing into .reloc
1609 // section. This reloc is relative to the file position of the
1610 // section, not the section's virtual address.
1611 srRelocFilePos,
1612
1613 // code relative address fixup
1614 srRelocCodeRelative,
1615
1616 // generate a .reloc for a 64 bit address in an ia64 movl instruction
1617 srRelocIA64Imm64,
1618
1619 // generate a .reloc for a 64 bit address
1620 srRelocDir64,
1621
1622 // generate a .reloc for a 25-bit PC relative address in an ia64 br.call instruction
1623 srRelocIA64PcRel25,
1624
1625 // generate a .reloc for a 64-bit PC relative address in an ia64 brl.call instruction
1626 srRelocIA64PcRel64,
1627
1628 // generate a 30-bit section-relative reloc, used for tagged pointer values
1629 srRelocAbsoluteTagged,
1630
1631
1632 // A sentinel value to help ensure any additions to this enum are reflected
1633 // in PEWriter.cpp's RelocName array.
1634 srRelocSentinel,
1635
1636 // Flags that can be used with the above reloc types
1637
1638 // do not emit base reloc
1639 srNoBaseReloc = 0x4000,
1640
1641 // pre-fixup contents of memory are ptr rather than a section offset
1642 srRelocPtr = 0x8000,
1643
1644 // legal enums which include the Ptr flag
1645 srRelocAbsolutePtr = srRelocPtr + srRelocAbsolute,
1646 srRelocHighLowPtr = srRelocPtr + srRelocHighLow,
1647 srRelocRelativePtr = srRelocPtr + srRelocRelative,
1648 srRelocIA64Imm64Ptr = srRelocPtr + srRelocIA64Imm64,
1649 srRelocDir64Ptr = srRelocPtr + srRelocDir64,
1650
1651} CeeSectionRelocType;
1652
1653typedef union {
1654 USHORT highAdj;
1655} CeeSectionRelocExtra;
1656
1657//-------------------------------------
1658//--- ICeeGen
1659//-------------------------------------
1660// {7ED1BDFF-8E36-11d2-9C56-00A0C9B7CC45}
1661EXTERN_GUID(IID_ICeeGen, 0x7ed1bdff, 0x8e36, 0x11d2, 0x9c, 0x56, 0x0, 0xa0, 0xc9, 0xb7, 0xcc, 0x45);
1662
1663DECLARE_INTERFACE_(ICeeGen, IUnknown)
1664{
1665 STDMETHOD (EmitString) (
1666 _In_
1667 LPWSTR lpString, // [IN] String to emit
1668 ULONG *RVA) PURE; // [OUT] RVA for string emitted string
1669
1670 STDMETHOD (GetString) (
1671 ULONG RVA, // [IN] RVA for string to return
1672 _Out_opt_
1673 LPWSTR *lpString) PURE; // [OUT] Returned string
1674
1675 STDMETHOD (AllocateMethodBuffer) (
1676 ULONG cchBuffer, // [IN] Length of buffer to create
1677 UCHAR **lpBuffer, // [OUT] Returned buffer
1678 ULONG *RVA) PURE; // [OUT] RVA for method
1679
1680 STDMETHOD (GetMethodBuffer) (
1681 ULONG RVA, // [IN] RVA for method to return
1682 UCHAR **lpBuffer) PURE; // [OUT] Returned buffer
1683
1684 STDMETHOD (GetIMapTokenIface) (
1685 IUnknown **pIMapToken) PURE;
1686
1687 STDMETHOD (GenerateCeeFile) () PURE;
1688
1689 STDMETHOD (GetIlSection) (
1690 HCEESECTION *section) PURE;
1691
1692 STDMETHOD (GetStringSection) (
1693 HCEESECTION *section) PURE;
1694
1695 STDMETHOD (AddSectionReloc) (
1696 HCEESECTION section,
1697 ULONG offset,
1698 HCEESECTION relativeTo,
1699 CeeSectionRelocType relocType) PURE;
1700
1701 // use these only if you have special section requirements not handled
1702 // by other APIs
1703 STDMETHOD (GetSectionCreate) (
1704 const char *name,
1705 DWORD flags,
1706 HCEESECTION *section) PURE;
1707
1708 STDMETHOD (GetSectionDataLen) (
1709 HCEESECTION section,
1710 ULONG *dataLen) PURE;
1711
1712 STDMETHOD (GetSectionBlock) (
1713 HCEESECTION section,
1714 ULONG len,
1715 ULONG align=1,
1716 void **ppBytes=0) PURE;
1717
1718 STDMETHOD (TruncateSection) (
1719 HCEESECTION section,
1720 ULONG len) PURE;
1721
1722 STDMETHOD (GenerateCeeMemoryImage) (
1723 void **ppImage) PURE;
1724
1725 STDMETHOD (ComputePointer) (
1726 HCEESECTION section,
1727 ULONG RVA, // [IN] RVA for method to return
1728 UCHAR **lpBuffer) PURE; // [OUT] Returned buffer
1729
1730};
1731
1732//*****************************************************************************
1733//*****************************************************************************
1734//
1735// End of CeeGen declarations.
1736//
1737//*****************************************************************************
1738
1739//**********************************************************************
1740//**********************************************************************
1741//--- IMetaDataTables
1742//-------------------------------------
1743// This API isn't big endian friendly since it indexes directly into the memory that
1744// is stored in little endian format.
1745// {D8F579AB-402D-4b8e-82D9-5D63B1065C68}
1746EXTERN_GUID(IID_IMetaDataTables, 0xd8f579ab, 0x402d, 0x4b8e, 0x82, 0xd9, 0x5d, 0x63, 0xb1, 0x6, 0x5c, 0x68);
1747
1748DECLARE_INTERFACE_(IMetaDataTables, IUnknown)
1749{
1750 STDMETHOD (GetStringHeapSize) (
1751 ULONG *pcbStrings) PURE; // [OUT] Size of the string heap.
1752
1753 STDMETHOD (GetBlobHeapSize) (
1754 ULONG *pcbBlobs) PURE; // [OUT] Size of the Blob heap.
1755
1756 STDMETHOD (GetGuidHeapSize) (
1757 ULONG *pcbGuids) PURE; // [OUT] Size of the Guid heap.
1758
1759 STDMETHOD (GetUserStringHeapSize) (
1760 ULONG *pcbBlobs) PURE; // [OUT] Size of the User String heap.
1761
1762 STDMETHOD (GetNumTables) (
1763 ULONG *pcTables) PURE; // [OUT] Count of tables.
1764
1765 STDMETHOD (GetTableIndex) (
1766 ULONG token, // [IN] Token for which to get table index.
1767 ULONG *pixTbl) PURE; // [OUT] Put table index here.
1768
1769 STDMETHOD (GetTableInfo) (
1770 ULONG ixTbl, // [IN] Which table.
1771 ULONG *pcbRow, // [OUT] Size of a row, bytes.
1772 ULONG *pcRows, // [OUT] Number of rows.
1773 ULONG *pcCols, // [OUT] Number of columns in each row.
1774 ULONG *piKey, // [OUT] Key column, or -1 if none.
1775 const char **ppName) PURE; // [OUT] Name of the table.
1776
1777 STDMETHOD (GetColumnInfo) (
1778 ULONG ixTbl, // [IN] Which Table
1779 ULONG ixCol, // [IN] Which Column in the table
1780 ULONG *poCol, // [OUT] Offset of the column in the row.
1781 ULONG *pcbCol, // [OUT] Size of a column, bytes.
1782 ULONG *pType, // [OUT] Type of the column.
1783 const char **ppName) PURE; // [OUT] Name of the Column.
1784
1785 STDMETHOD (GetCodedTokenInfo) (
1786 ULONG ixCdTkn, // [IN] Which kind of coded token.
1787 ULONG *pcTokens, // [OUT] Count of tokens.
1788 ULONG **ppTokens, // [OUT] List of tokens.
1789 const char **ppName) PURE; // [OUT] Name of the CodedToken.
1790
1791 STDMETHOD (GetRow) (
1792 ULONG ixTbl, // [IN] Which table.
1793 ULONG rid, // [IN] Which row.
1794 void **ppRow) PURE; // [OUT] Put pointer to row here.
1795
1796 STDMETHOD (GetColumn) (
1797 ULONG ixTbl, // [IN] Which table.
1798 ULONG ixCol, // [IN] Which column.
1799 ULONG rid, // [IN] Which row.
1800 ULONG *pVal) PURE; // [OUT] Put the column contents here.
1801
1802 STDMETHOD (GetString) (
1803 ULONG ixString, // [IN] Value from a string column.
1804 const char **ppString) PURE; // [OUT] Put a pointer to the string here.
1805
1806 STDMETHOD (GetBlob) (
1807 ULONG ixBlob, // [IN] Value from a blob column.
1808 ULONG *pcbData, // [OUT] Put size of the blob here.
1809 const void **ppData) PURE; // [OUT] Put a pointer to the blob here.
1810
1811 STDMETHOD (GetGuid) (
1812 ULONG ixGuid, // [IN] Value from a guid column.
1813 const GUID **ppGUID) PURE; // [OUT] Put a pointer to the GUID here.
1814
1815 STDMETHOD (GetUserString) (
1816 ULONG ixUserString, // [IN] Value from a UserString column.
1817 ULONG *pcbData, // [OUT] Put size of the UserString here.
1818 const void **ppData) PURE; // [OUT] Put a pointer to the UserString here.
1819
1820 STDMETHOD (GetNextString) (
1821 ULONG ixString, // [IN] Value from a string column.
1822 ULONG *pNext) PURE; // [OUT] Put the index of the next string here.
1823
1824 STDMETHOD (GetNextBlob) (
1825 ULONG ixBlob, // [IN] Value from a blob column.
1826 ULONG *pNext) PURE; // [OUT] Put the index of the netxt blob here.
1827
1828 STDMETHOD (GetNextGuid) (
1829 ULONG ixGuid, // [IN] Value from a guid column.
1830 ULONG *pNext) PURE; // [OUT] Put the index of the next guid here.
1831
1832 STDMETHOD (GetNextUserString) (
1833 ULONG ixUserString, // [IN] Value from a UserString column.
1834 ULONG *pNext) PURE; // [OUT] Put the index of the next user string here.
1835
1836 // Interface is sealed.
1837
1838};
1839// This API isn't big endian friendly since it indexes directly into the memory that
1840// is stored in little endian format.
1841// {BADB5F70-58DA-43a9-A1C6-D74819F19B15}
1842EXTERN_GUID(IID_IMetaDataTables2, 0xbadb5f70, 0x58da, 0x43a9, 0xa1, 0xc6, 0xd7, 0x48, 0x19, 0xf1, 0x9b, 0x15);
1843
1844DECLARE_INTERFACE_(IMetaDataTables2, IMetaDataTables)
1845{
1846 STDMETHOD (GetMetaDataStorage) ( //@todo: name?
1847 const void **ppvMd, // [OUT] put pointer to MD section here (aka, 'BSJB').
1848 ULONG *pcbMd) PURE; // [OUT] put size of the stream here.
1849
1850 STDMETHOD (GetMetaDataStreamInfo) ( // Get info about the MD stream.
1851 ULONG ix, // [IN] Stream ordinal desired.
1852 const char **ppchName, // [OUT] put pointer to stream name here.
1853 const void **ppv, // [OUT] put pointer to MD stream here.
1854 ULONG *pcb) PURE; // [OUT] put size of the stream here.
1855
1856}; // IMetaDataTables2
1857
1858#ifdef _DEFINE_META_DATA_META_CONSTANTS
1859#ifndef _META_DATA_META_CONSTANTS_DEFINED
1860#define _META_DATA_META_CONSTANTS_DEFINED
1861const unsigned int iRidMax = 63;
1862const unsigned int iCodedToken = 64; // base of coded tokens.
1863const unsigned int iCodedTokenMax = 95;
1864const unsigned int iSHORT = 96; // fixed types.
1865const unsigned int iUSHORT = 97;
1866const unsigned int iLONG = 98;
1867const unsigned int iULONG = 99;
1868const unsigned int iBYTE = 100;
1869const unsigned int iSTRING = 101; // pool types.
1870const unsigned int iGUID = 102;
1871const unsigned int iBLOB = 103;
1872
1873inline int IsRidType(ULONG ix) { return ix <= iRidMax; }
1874inline int IsCodedTokenType(ULONG ix) { return (ix >= iCodedToken) && (ix <= iCodedTokenMax); }
1875inline int IsRidOrToken(ULONG ix) { return ix <= iCodedTokenMax; }
1876inline int IsHeapType(ULONG ix) { return ix >= iSTRING; }
1877inline int IsFixedType(ULONG ix) { return (ix < iSTRING) && (ix > iCodedTokenMax); }
1878#endif
1879#endif
1880
1881//**********************************************************************
1882// End of IMetaDataTables.
1883//**********************************************************************
1884
1885//-------------------------------------
1886//--- IMetaDataInfo
1887//-------------------------------------
1888// {7998EA64-7F95-48B8-86FC-17CAF48BF5CB}
1889EXTERN_GUID(IID_IMetaDataInfo, 0x7998EA64, 0x7F95, 0x48B8, 0x86, 0xFC, 0x17, 0xCA, 0xF4, 0x8B, 0xF5, 0xCB);
1890
1891//---
1892#undef INTERFACE
1893#define INTERFACE IMetaDataInfo
1894DECLARE_INTERFACE_(IMetaDataInfo, IUnknown)
1895{
1896 // Return Values:
1897 // S_OK - All parameters are filled.
1898 // COR_E_NOTSUPPORTED - The API is not supported for this particular scope (e.g. .obj files, scope
1899 // opened without whole file via code:IMetaDataDispenser::OpenScopeOnMemory, etc.).
1900 // E_INVALIDARG - If NULL is passed as parameter.
1901 STDMETHOD(GetFileMapping)(
1902 const void ** ppvData, // [out] Pointer to the start of the mapped file.
1903 ULONGLONG * pcbData, // [out] Size of the mapped memory region.
1904 DWORD * pdwMappingType) PURE; // [out] Type of file mapping (code:CorFileMapping).
1905}; // class IMetaDataInfo
1906
1907
1908//-------------------------------------
1909//--- IMetaDataWinMDImport
1910//-------------------------------------
1911// {969EA0C5-964E-411B-A807-B0F3C2DFCBD4}
1912EXTERN_GUID(IID_IMetaDataWinMDImport, 0x969ea0c5, 0x964e, 0x411b, 0xa8, 0x7, 0xb0, 0xf3, 0xc2, 0xdf, 0xcb, 0xd4);
1913
1914//---
1915#undef INTERFACE
1916#define INTERFACE IMetaDataWinMDImport
1917DECLARE_INTERFACE_(IMetaDataWinMDImport, IUnknown)
1918{
1919 STDMETHOD(GetUntransformedTypeRefProps)( // S_OK or error.
1920 mdTypeRef tr, // [IN] TypeRef token.
1921 mdToken *ptkResolutionScope, // [OUT] Resolution scope, ModuleRef or AssemblyRef.
1922 _Out_writes_to_opt_(cchName, *pchName)
1923 LPWSTR szName, // [OUT] Name of the TypeRef.
1924 ULONG cchName, // [IN] Size of buffer.
1925 ULONG *pchName) PURE; // [OUT] Size of Name.
1926}; // class IMetaDataWinMDImport
1927
1928//**********************************************************************
1929//
1930// Predefined CustomAttribute and structures for these custom value
1931//
1932//**********************************************************************
1933
1934//
1935// Native Link method custom value definitions. This is for N-direct support.
1936//
1937
1938#define COR_NATIVE_LINK_CUSTOM_VALUE L"COMPLUS_NativeLink"
1939#define COR_NATIVE_LINK_CUSTOM_VALUE_ANSI "COMPLUS_NativeLink"
1940
1941// count of chars for COR_NATIVE_LINK_CUSTOM_VALUE(_ANSI)
1942#define COR_NATIVE_LINK_CUSTOM_VALUE_CC 18
1943
1944#include <pshpack1.h>
1945typedef struct
1946{
1947 BYTE m_linkType; // see CorNativeLinkType below
1948 BYTE m_flags; // see CorNativeLinkFlags below
1949 mdMemberRef m_entryPoint; // member ref token giving entry point, format is lib:entrypoint
1950} COR_NATIVE_LINK;
1951#include <poppack.h>
1952
1953typedef enum
1954{
1955 nltNone = 1, // none of the keywords are specified
1956 nltAnsi = 2, // ansi keyword specified
1957 nltUnicode = 3, // unicode keyword specified
1958 nltAuto = 4, // auto keyword specified
1959 nltMaxValue = 7, // used so we can assert how many bits are required for this enum
1960} CorNativeLinkType;
1961
1962typedef enum
1963{
1964 nlfNone = 0x00, // no flags
1965 nlfLastError = 0x01, // setLastError keyword specified
1966 nlfNoMangle = 0x02, // nomangle keyword specified
1967 nlfMaxValue = 0x03, // used so we can assert how many bits are required for this enum
1968} CorNativeLinkFlags;
1969
1970//
1971// Base class for security custom attributes.
1972//
1973
1974#define COR_BASE_SECURITY_ATTRIBUTE_CLASS L"System.Security.Permissions.SecurityAttribute"
1975#define COR_BASE_SECURITY_ATTRIBUTE_CLASS_ANSI "System.Security.Permissions.SecurityAttribute"
1976
1977//
1978// Name of custom attribute used to indicate that per-call security checks should
1979// be disabled for P/Invoke calls.
1980//
1981
1982#define COR_SUPPRESS_UNMANAGED_CODE_CHECK_ATTRIBUTE L"System.Security.SuppressUnmanagedCodeSecurityAttribute"
1983#define COR_SUPPRESS_UNMANAGED_CODE_CHECK_ATTRIBUTE_ANSI "System.Security.SuppressUnmanagedCodeSecurityAttribute"
1984
1985//
1986// Name of custom attribute tagged on module to indicate it contains
1987// unverifiable code.
1988//
1989
1990#define COR_UNVER_CODE_ATTRIBUTE L"System.Security.UnverifiableCodeAttribute"
1991#define COR_UNVER_CODE_ATTRIBUTE_ANSI "System.Security.UnverifiableCodeAttribute"
1992
1993//
1994// Name of custom attribute indicating that a method requires a security object
1995// slot on the caller's stack.
1996//
1997
1998#define COR_REQUIRES_SECOBJ_ATTRIBUTE W("System.Security.DynamicSecurityMethodAttribute")
1999#define COR_REQUIRES_SECOBJ_ATTRIBUTE_ANSI "System.Security.DynamicSecurityMethodAttribute"
2000
2001#define COR_COMPILERSERVICE_DISCARDABLEATTRIBUTE L"System.Runtime.CompilerServices.DiscardableAttribute"
2002#define COR_COMPILERSERVICE_DISCARDABLEATTRIBUTE_ASNI "System.Runtime.CompilerServices.DiscardableAttribute"
2003
2004
2005#ifdef __cplusplus
2006}
2007
2008//*****************************************************************************
2009//*****************************************************************************
2010//
2011// C O M + s i g n a t u r e s u p p o r t
2012//
2013//*****************************************************************************
2014//*****************************************************************************
2015
2016#ifndef FORCEINLINE
2017 #if _MSC_VER < 1200
2018 #define FORCEINLINE inline
2019 #else
2020 #define FORCEINLINE __forceinline
2021 #endif
2022#endif
2023
2024
2025// We need a version that is FORCEINLINE on retail and NOINLINE on debug
2026
2027#ifndef DEBUG_NOINLINE
2028#if defined(_DEBUG)
2029#define DEBUG_NOINLINE __declspec(noinline)
2030#else
2031#define DEBUG_NOINLINE
2032#endif
2033#endif
2034
2035#ifndef DBG_NOINLINE_X86__RET_INLINE
2036#if defined(_DEBUG) && defined(_X86_)
2037#define DBG_NOINLINE_X86__RET_INLINE __declspec(noinline)
2038#else
2039#define DBG_NOINLINE_X86__RET_INLINE FORCEINLINE
2040#endif
2041#endif
2042
2043#ifndef NOINLINE
2044#ifdef _MSC_VER
2045#define NOINLINE __declspec(noinline)
2046#elif defined __GNUC__
2047#define NOINLINE __attribute__ ((noinline))
2048#else
2049#define NOINLINE
2050#endif
2051#endif // !NOINLINE
2052
2053// return true if it is a primitive type, i.e. only need to store CorElementType
2054FORCEINLINE int CorIsPrimitiveType(CorElementType elementtype)
2055{
2056 return (elementtype < ELEMENT_TYPE_PTR || elementtype == ELEMENT_TYPE_I || elementtype == ELEMENT_TYPE_U);
2057}
2058
2059
2060// Return true if element type is a modifier, i.e. ELEMENT_TYPE_MODIFIER bits are
2061// turned on. For now, it is checking for ELEMENT_TYPE_PTR and ELEMENT_TYPE_BYREF
2062// as well. This will be removed when we turn on ELEMENT_TYPE_MODIFIER bits for
2063// these two enum members.
2064//
2065FORCEINLINE int CorIsModifierElementType(CorElementType elementtype)
2066{
2067 if (elementtype == ELEMENT_TYPE_PTR || elementtype == ELEMENT_TYPE_BYREF)
2068 return 1;
2069 return (elementtype & ELEMENT_TYPE_MODIFIER);
2070}
2071
2072// Given a compress byte (*pData), return the size of the uncompressed data.
2073inline ULONG CorSigUncompressedDataSize(
2074 PCCOR_SIGNATURE pData)
2075{
2076 if ((*pData & 0x80) == 0)
2077 return 1;
2078 else if ((*pData & 0xC0) == 0x80)
2079 return 2;
2080 else
2081 return 4;
2082}
2083
2084/////////////////////////////////////////////////////////////////////////////////////////////
2085//
2086// Given a compressed integer(*pData), expand the compressed int to *pDataOut.
2087// Return value is the number of bytes that the integer occupies in the compressed format
2088// It is caller's responsibility to ensure pDataOut has at least 4 bytes to be written to.
2089//
2090// This function returns -1 if pass in with an incorrectly compressed data, such as
2091// (*pBytes & 0xE0) == 0XE0.
2092/////////////////////////////////////////////////////////////////////////////////////////////
2093inline ULONG CorSigUncompressBigData(
2094 PCCOR_SIGNATURE & pData) // [IN,OUT] compressed data
2095{
2096 ULONG res;
2097
2098 // 1 byte data is handled in CorSigUncompressData
2099 // _ASSERTE(*pData & 0x80);
2100
2101 // Medium.
2102 if ((*pData & 0xC0) == 0x80) // 10?? ????
2103 {
2104 res = (ULONG)((*pData++ & 0x3f) << 8);
2105 res |= *pData++;
2106 }
2107 else // 110? ????
2108 {
2109 res = (*pData++ & 0x1f) << 24;
2110 res |= *pData++ << 16;
2111 res |= *pData++ << 8;
2112 res |= *pData++;
2113 }
2114 return res;
2115}
2116FORCEINLINE ULONG CorSigUncompressData(
2117 PCCOR_SIGNATURE & pData) // [IN,OUT] compressed data
2118{
2119 // Handle smallest data inline.
2120 if ((*pData & 0x80) == 0x00) // 0??? ????
2121 return *pData++;
2122 return CorSigUncompressBigData(pData);
2123}
2124
2125inline HRESULT CorSigUncompressData(// return S_OK or E_BADIMAGEFORMAT if the signature is bad
2126 PCCOR_SIGNATURE pData, // [IN] compressed data
2127 DWORD len, // [IN] length of the signature
2128 ULONG * pDataOut, // [OUT] the expanded *pData
2129 ULONG * pDataLen) // [OUT] length of the expanded *pData
2130{
2131 HRESULT hr = S_OK;
2132 BYTE const *pBytes = reinterpret_cast<BYTE const*>(pData);
2133
2134 // Smallest.
2135 if ((*pBytes & 0x80) == 0x00) // 0??? ????
2136 {
2137 if (len < 1)
2138 {
2139 *pDataOut = 0;
2140 *pDataLen = 0;
2141 hr = META_E_BAD_SIGNATURE;
2142 }
2143 else
2144 {
2145 *pDataOut = *pBytes;
2146 *pDataLen = 1;
2147 }
2148 }
2149 // Medium.
2150 else if ((*pBytes & 0xC0) == 0x80) // 10?? ????
2151 {
2152 if (len < 2)
2153 {
2154 *pDataOut = 0;
2155 *pDataLen = 0;
2156 hr = META_E_BAD_SIGNATURE;
2157 }
2158 else
2159 {
2160 *pDataOut = (ULONG)(((*pBytes & 0x3f) << 8 | *(pBytes+1)));
2161 *pDataLen = 2;
2162 }
2163 }
2164 else if ((*pBytes & 0xE0) == 0xC0) // 110? ????
2165 {
2166 if (len < 4)
2167 {
2168 *pDataOut = 0;
2169 *pDataLen = 0;
2170 hr = META_E_BAD_SIGNATURE;
2171 }
2172 else
2173 {
2174 *pDataOut = (ULONG)(((*pBytes & 0x1f) << 24 | *(pBytes+1) << 16 | *(pBytes+2) << 8 | *(pBytes+3)));
2175 *pDataLen = 4;
2176 }
2177 }
2178 else // We don't recognize this encoding
2179 {
2180 *pDataOut = 0;
2181 *pDataLen = 0;
2182 hr = META_E_BAD_SIGNATURE;
2183 }
2184
2185 return hr;
2186}
2187
2188inline ULONG CorSigUncompressData( // return number of bytes of that compressed data occupied in pData
2189 PCCOR_SIGNATURE pData, // [IN] compressed data
2190 ULONG *pDataOut) // [OUT] the expanded *pData
2191{
2192 ULONG dwSizeOfData = 0;
2193
2194 // We don't know how big the signature is, so we'll just say that it's big enough
2195 if (FAILED(CorSigUncompressData(pData, 0xff, pDataOut, &dwSizeOfData)))
2196 {
2197 *pDataOut = 0;
2198 return (ULONG)-1;
2199 }
2200
2201 return dwSizeOfData;
2202}
2203
2204
2205#if !defined(SELECTANY)
2206 #define SELECTANY extern __declspec(selectany)
2207#endif
2208
2209SELECTANY const mdToken g_tkCorEncodeToken[4] ={mdtTypeDef, mdtTypeRef, mdtTypeSpec, mdtBaseType};
2210
2211// uncompress a token
2212inline mdToken CorSigUncompressToken( // return the token.
2213 PCCOR_SIGNATURE &pData) // [IN,OUT] compressed data
2214{
2215 mdToken tk;
2216 mdToken tkType;
2217
2218 tk = CorSigUncompressData(pData);
2219 tkType = g_tkCorEncodeToken[tk & 0x3];
2220 tk = TokenFromRid(tk >> 2, tkType);
2221 return tk;
2222}
2223
2224
2225inline ULONG CorSigUncompressToken( // return number of bytes of that compressed data occupied in pData
2226 PCCOR_SIGNATURE pData, // [IN] compressed data
2227 mdToken * pToken) // [OUT] the expanded *pData
2228{
2229 ULONG cb;
2230 mdToken tk;
2231 mdToken tkType;
2232
2233 cb = CorSigUncompressData(pData, (ULONG *)&tk);
2234 tkType = g_tkCorEncodeToken[tk & 0x3];
2235 tk = TokenFromRid(tk >> 2, tkType);
2236 *pToken = tk;
2237 return cb;
2238}
2239
2240inline HRESULT CorSigUncompressToken(
2241 PCCOR_SIGNATURE pData, // [IN] compressed data
2242 DWORD dwLen, // [IN] Remaining length of sigature
2243 mdToken * pToken, // [OUT] the expanded *pData
2244 DWORD * dwTokenLength) // [OUT] The length of the token in the sigature
2245{
2246 mdToken tk;
2247 mdToken tkType;
2248
2249 HRESULT hr = CorSigUncompressData(pData, dwLen, (ULONG *)&tk, dwTokenLength);
2250
2251 if (SUCCEEDED(hr))
2252 {
2253 tkType = g_tkCorEncodeToken[tk & 0x3];
2254 tk = TokenFromRid(tk >> 2, tkType);
2255 *pToken = tk;
2256 }
2257 else
2258 {
2259 *pToken = mdTokenNil;
2260 }
2261 return hr;
2262}
2263
2264
2265
2266FORCEINLINE ULONG CorSigUncompressCallingConv(
2267 PCCOR_SIGNATURE & pData) // [IN,OUT] Compressed data
2268{
2269 return *pData++;
2270}
2271
2272FORCEINLINE HRESULT CorSigUncompressCallingConv(
2273 PCCOR_SIGNATURE pData, // [IN] Signature
2274 DWORD dwLen, // [IN] Length of signature
2275 ULONG * data) // [OUT] Compressed data
2276{
2277 if (dwLen > 0)
2278 {
2279 *data = *pData;
2280 return S_OK;
2281 }
2282 else
2283 {
2284 *data = 0;
2285 return META_E_BAD_SIGNATURE;
2286 }
2287}
2288
2289
2290enum {
2291 SIGN_MASK_ONEBYTE = 0xffffffc0, // Mask the same size as the missing bits.
2292 SIGN_MASK_TWOBYTE = 0xffffe000, // Mask the same size as the missing bits.
2293 SIGN_MASK_FOURBYTE = 0xf0000000, // Mask the same size as the missing bits.
2294};
2295
2296// uncompress a signed integer
2297inline ULONG CorSigUncompressSignedInt( // return number of bytes of that compressed data occupied in pData
2298 PCCOR_SIGNATURE pData, // [IN] compressed data
2299 int * pInt) // [OUT] the expanded *pInt
2300{
2301 ULONG cb;
2302 ULONG ulSigned;
2303 ULONG iData;
2304
2305 cb = CorSigUncompressData(pData, &iData);
2306 if (cb == (ULONG) -1) return cb;
2307 ulSigned = iData & 0x1;
2308 iData = iData >> 1;
2309 if (ulSigned)
2310 {
2311 if (cb == 1)
2312 {
2313 iData |= SIGN_MASK_ONEBYTE;
2314 }
2315 else if (cb == 2)
2316 {
2317 iData |= SIGN_MASK_TWOBYTE;
2318 }
2319 else
2320 {
2321 iData |= SIGN_MASK_FOURBYTE;
2322 }
2323 }
2324 *pInt = (int)iData;
2325 return cb;
2326}
2327
2328
2329// uncompress encoded element type
2330FORCEINLINE CorElementType CorSigUncompressElementType( // Element type
2331 PCCOR_SIGNATURE & pData) // [IN,OUT] Compressed data
2332{
2333 return (CorElementType)*pData++;
2334}
2335
2336inline ULONG CorSigUncompressElementType( // Return number of bytes of that compressed data occupied in pData
2337 PCCOR_SIGNATURE pData, // [IN] Compressed data
2338 CorElementType * pElementType) // [OUT] The expanded *pData
2339{
2340 *pElementType = (CorElementType)(*pData & 0x7f);
2341 return 1;
2342}
2343
2344
2345/////////////////////////////////////////////////////////////////////////////////////////////
2346//
2347// Given an uncompressed unsigned integer (iLen), Store it to pDataOut in a compressed format.
2348// Return value is the number of bytes that the integer occupies in the compressed format.
2349// It is caller's responsibilityt to ensure *pDataOut has at least 4 bytes to write to.
2350//
2351// Note that this function returns -1 if iLen is too big to be compressed. We currently can
2352// only represent to 0x1FFFFFFF.
2353//
2354/////////////////////////////////////////////////////////////////////////////////////////////
2355inline ULONG CorSigCompressData( // return number of bytes that compressed form of iLen will take
2356 ULONG iLen, // [IN] given uncompressed data
2357 void * pDataOut) // [OUT] buffer where iLen will be compressed and stored.
2358{
2359 BYTE *pBytes = reinterpret_cast<BYTE *>(pDataOut);
2360
2361 if (iLen <= 0x7F)
2362 {
2363 *pBytes = BYTE(iLen);
2364 return 1;
2365 }
2366
2367 if (iLen <= 0x3FFF)
2368 {
2369 *pBytes = BYTE((iLen >> 8) | 0x80);
2370 *(pBytes+1) = BYTE(iLen & 0xff);
2371 return 2;
2372 }
2373
2374 if (iLen <= 0x1FFFFFFF)
2375 {
2376 *pBytes = BYTE((iLen >> 24) | 0xC0);
2377 *(pBytes+1) = BYTE((iLen >> 16) & 0xff);
2378 *(pBytes+2) = BYTE((iLen >> 8) & 0xff);
2379 *(pBytes+3) = BYTE(iLen & 0xff);
2380 return 4;
2381 }
2382 return (ULONG) -1;
2383}
2384
2385// compress a token
2386// The least significant bit of the first compress byte will indicate the token type.
2387//
2388inline ULONG CorSigCompressToken( // return number of bytes that compressed form of the token will take
2389 mdToken tk, // [IN] given token
2390 void * pDataOut) // [OUT] buffer where the token will be compressed and stored.
2391{
2392 RID rid = RidFromToken(tk);
2393 ULONG32 ulTyp = TypeFromToken(tk);
2394
2395 if (rid > 0x3FFFFFF)
2396 // token is too big to be compressed
2397 return (ULONG) -1;
2398
2399 rid = (rid << 2);
2400
2401 // TypeDef is encoded with low bits 00
2402 // TypeRef is encoded with low bits 01
2403 // TypeSpec is encoded with low bits 10
2404 // BaseType is encoded with low bit 11
2405 //
2406 if (ulTyp == g_tkCorEncodeToken[1])
2407 {
2408 // make the last two bits 01
2409 rid |= 0x1;
2410 }
2411 else if (ulTyp == g_tkCorEncodeToken[2])
2412 {
2413 // make last two bits 0
2414 rid |= 0x2;
2415 }
2416 else if (ulTyp == g_tkCorEncodeToken[3])
2417 {
2418 rid |= 0x3;
2419 }
2420 return CorSigCompressData((ULONG)rid, pDataOut);
2421}
2422
2423// compress a signed integer
2424// The least significant bit of the first compress byte will be the signed bit.
2425//
2426inline ULONG CorSigCompressSignedInt( // return number of bytes that compressed form of iData will take
2427 int iData, // [IN] given integer
2428 void * pDataOut) // [OUT] buffer where iLen will be compressed and stored.
2429{
2430 ULONG isSigned = 0;
2431 BYTE *pBytes = reinterpret_cast<BYTE *>(pDataOut);
2432
2433 if (iData < 0)
2434 isSigned = 0x1;
2435
2436 // Note that we cannot use code:CorSigCompressData to pack the iData value, because of negative values
2437 // like: 0xffffe000 (-8192) which has to be encoded as 1 in 2 bytes, i.e. 0x81 0x00
2438 // However CorSigCompressedData would store value 1 as 1 byte: 0x01
2439 if ((iData & SIGN_MASK_ONEBYTE) == 0 || (iData & SIGN_MASK_ONEBYTE) == SIGN_MASK_ONEBYTE)
2440 {
2441 iData = (int)((iData & ~SIGN_MASK_ONEBYTE) << 1 | isSigned);
2442 //_ASSERTE(iData <= 0x7f);
2443 *pBytes = BYTE(iData);
2444 return 1;
2445 }
2446 else if ((iData & SIGN_MASK_TWOBYTE) == 0 || (iData & SIGN_MASK_TWOBYTE) == SIGN_MASK_TWOBYTE)
2447 {
2448 iData = (int)((iData & ~SIGN_MASK_TWOBYTE) << 1 | isSigned);
2449 //_ASSERTE(iData <= 0x3fff);
2450 *pBytes = BYTE((iData >> 8) | 0x80);
2451 *(pBytes + 1) = BYTE(iData & 0xff);
2452 return 2;
2453 }
2454 else if ((iData & SIGN_MASK_FOURBYTE) == 0 || (iData & SIGN_MASK_FOURBYTE) == SIGN_MASK_FOURBYTE)
2455 {
2456 iData = (int)((iData & ~SIGN_MASK_FOURBYTE) << 1 | isSigned);
2457 //_ASSERTE(iData <= 0x1FFFFFFF);
2458 *pBytes = BYTE((iData >> 24) | 0xC0);
2459 *(pBytes + 1) = BYTE((iData >> 16) & 0xff);
2460 *(pBytes + 2) = BYTE((iData >> 8) & 0xff);
2461 *(pBytes + 3) = BYTE(iData & 0xff);
2462 return 4;
2463 }
2464 // Out of compressable range
2465 return (ULONG)-1;
2466} // CorSigCompressSignedInt
2467
2468
2469// uncompress encoded element type
2470inline ULONG CorSigCompressElementType( // return number of bytes of that compressed data occupied in pData
2471 CorElementType et, // [OUT] the expanded *pData
2472 void * pData) // [IN] compressed data
2473{
2474 BYTE *pBytes = (BYTE *)(pData);
2475
2476 *pBytes = BYTE(et);
2477 return 1;
2478}
2479
2480// Compress a pointer (used for internal element types only, never for persisted
2481// signatures).
2482inline ULONG CorSigCompressPointer( // return number of bytes of that compressed data occupied
2483 void * pvPointer, // [IN] given uncompressed data
2484 void * pData) // [OUT] buffer where iLen will be compressed and stored.
2485{
2486 *((void * UNALIGNED *)pData) = pvPointer;
2487 return sizeof(void *);
2488}
2489
2490// Uncompress a pointer (see above for comments).
2491inline ULONG CorSigUncompressPointer( // return number of bytes of that compressed data occupied
2492 PCCOR_SIGNATURE pData, // [IN] compressed data
2493 void ** ppvPointer) // [OUT] the expanded *pData
2494{
2495 *ppvPointer = *(void * const UNALIGNED *)pData;
2496 return sizeof(void *);
2497}
2498
2499#endif // __cplusplus
2500
2501#undef DEPRECATED_CLR_STDAPI_
2502#undef DEPRECATED_CLR_STDAPI
2503#undef DECLARE_DEPRECATED
2504#undef DEPRECATED_CLR_API_MESG
2505
2506#endif // _COR_H_
2507// EOF =======================================================================
2508