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 // ===========================================================================
7 // ===========================================================================
13 #endif // _MSC_VER >= 1000
15 // %%Includes: ---------------------------------------------------------------
16 // avoid taking DLL import hit on intra-DLL calls
23 #include "peinformation.h"
26 interface IAssemblyName;
28 // PE images loaded through the runtime.
29 typedef struct _dummyCOR { BYTE b; } *HCORMODULE;
33 // Helper function to get a pointer to the Dispenser interface.
34 STDAPI MetaDataGetDispenser( // Return HRESULT
35 REFCLSID rclsid, // The class to desired.
36 REFIID riid, // Interface wanted on class factory.
37 LPVOID FAR *ppv); // Return interface pointer here.
39 // Helper function to check whether policy allows accessing the file
40 STDAPI RuntimeCheckLocationAccess(LPCWSTR wszLocation);
41 STDAPI RuntimeIsNativeImageOptedOut(IAssemblyName* pAssemblyDef);
43 #ifdef FEATURE_VERSIONING
44 LocaleID RuntimeGetFileSystemLocale();
45 #endif // FEATURE_VERSIONING
47 BOOL RuntimeFileNotFound(HRESULT hr);
49 // Helper function to get an Internal interface with an in-memory metadata section
50 STDAPI GetMetaDataInternalInterface(
51 LPVOID pData, // [IN] in memory metadata section
52 ULONG cbData, // [IN] size of the metadata section
53 DWORD flags, // [IN] CorOpenFlags
54 REFIID riid, // [IN] desired interface
55 void **ppv); // [OUT] returned interface
57 // Helper function to get an internal scopeless interface given a scope.
58 STDAPI GetMetaDataInternalInterfaceFromPublic(
59 IUnknown *pv, // [IN] Given interface
60 REFIID riid, // [IN] desired interface
61 void **ppv); // [OUT] returned interface
63 // Helper function to get an internal scopeless interface given a scope.
64 STDAPI GetMetaDataPublicInterfaceFromInternal(
65 void *pv, // [IN] Given interface
66 REFIID riid, // [IN] desired interface
67 void **ppv); // [OUT] returned interface
69 // Converts an internal MD import API into the read/write version of this API.
70 // This could support edit and continue, or modification of the metadata at
71 // runtime (say for profiling).
72 STDAPI ConvertMDInternalImport( // S_OK or error.
73 IMDInternalImport *pIMD, // [IN] The metadata to be updated.
74 IMDInternalImport **ppIMD); // [OUT] Put RW interface here.
76 STDAPI GetAssemblyMDInternalImport( // Return code.
77 LPCWSTR szFileName, // [IN] The scope to open.
78 REFIID riid, // [IN] The interface desired.
79 IUnknown **ppIUnk); // [OUT] Return interface on success.
81 HRESULT GetAssemblyMDInternalImportFromImage(
82 HCORMODULE hImage, //[IN] pointer to module handle to get the metadata from.
83 REFIID riid, //[IN] The interface desired.
84 IUnknown **ppIUnk); //[OUT] Return Interface on success.
86 STDAPI GetAssemblyMDInternalImportByStream( // Return code.
87 IStream *pIStream, // [IN] The IStream for the file
88 UINT64 AssemblyId, // [IN] Unique Id for the assembly
89 REFIID riid, // [IN] The interface desired.
90 IUnknown **ppIUnk); // [OUT] Return interface on success.
93 enum MDInternalImportFlags
95 MDInternalImport_Default = 0,
96 MDInternalImport_NoCache = 1, // Do not share/cached the results of opening the image
98 MDInternalImport_TrustedNativeImage = 2, // The image is a native image, and so its format can be trusted
99 MDInternalImport_ILMetaData = 4, // Open the IL metadata, even if this is a native image
100 MDInternalImport_TrustedNativeImage_and_IL = MDInternalImport_TrustedNativeImage | MDInternalImport_ILMetaData,
101 MDInternalImport_NativeImageInstall = 0x100, // The image is a native image that is being installed into NIC
103 MDInternalImport_CheckLongPath =8, // also check long version of the path
104 MDInternalImport_CheckShortPath =0x10, // also check long version of the path
105 MDInternalImport_OnlyLookInCache =0x20, // Only look in the cache. (If the cache does not have the image already loaded, return NULL)
106 }; // enum MDInternalImportFlags
110 STDAPI GetAssemblyMDInternalImportEx( // Return code.
111 LPCWSTR szFileName, // [IN] The scope to open.
112 REFIID riid, // [IN] The interface desired.
113 MDInternalImportFlags flags, // [in] Flags to control opening the assembly
114 IUnknown **ppIUnk, // [OUT] Return interface on success.
115 HANDLE hFile = INVALID_HANDLE_VALUE);
117 STDAPI GetAssemblyMDInternalImportByStreamEx( // Return code.
118 IStream *pIStream, // [IN] The IStream for the file
119 UINT64 AssemblyId, // [IN] Unique Id for the assembly
120 REFIID riid, // [IN] The interface desired.
121 MDInternalImportFlags flags, // [in] Flags to control opening the assembly
122 IUnknown **ppIUnk); // [OUT] Return interface on success.
125 // Returns part of the "Zap string" which describes the properties of a native image
127 __success(SUCCEEDED(return))
128 STDAPI GetNativeImageDescription(
129 __in_z LPCWSTR wzCustomString, // [IN] Custom string of the native image
130 DWORD dwConfigMask, // [IN] Config mask of the native image
131 __out_ecount_part_opt(*pdwLength,*pdwLength) LPWSTR pwzZapInfo,// [OUT] The description string. Can be NULL to find the size of buffer to allocate
132 LPDWORD pdwLength); // [IN/OUT] Length of the pwzZapInfo buffer on IN.
133 // Number of WCHARs (including termintating NULL) on OUT
139 // predefined constant for parent token for global functions
140 #define COR_GLOBAL_PARENT_TOKEN TokenFromRid(1, mdtTypeDef)
144 //////////////////////////////////////////////////////////////////////////
146 //////////////////////////////////////////////////////////////////////////
148 // %%Interfaces: -------------------------------------------------------------
150 // interface IMetaDataHelper
152 // {AD93D71D-E1F2-11d1-9409-0000F8083460}
153 EXTERN_GUID(IID_IMetaDataHelper, 0xad93d71d, 0xe1f2, 0x11d1, 0x94, 0x9, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60);
156 #define INTERFACE IMetaDataHelper
157 DECLARE_INTERFACE_(IMetaDataHelper, IUnknown)
160 // This function is exposing the ability to translate signature from a given
161 // source scope to a given target scope.
163 STDMETHOD(TranslateSigWithScope)(
164 IMetaDataAssemblyImport *pAssemImport, // [IN] importing assembly interface
165 const void *pbHashValue, // [IN] Hash Blob for Assembly.
166 ULONG cbHashValue, // [IN] Count of bytes.
167 IMetaDataImport *import, // [IN] importing interface
168 PCCOR_SIGNATURE pbSigBlob, // [IN] signature in the importing scope
169 ULONG cbSigBlob, // [IN] count of bytes of signature
170 IMetaDataAssemblyEmit *pAssemEmit, // [IN] emit assembly interface
171 IMetaDataEmit *emit, // [IN] emit interface
172 PCOR_SIGNATURE pvTranslatedSig, // [OUT] buffer to hold translated signature
173 ULONG cbTranslatedSigMax,
174 ULONG *pcbTranslatedSig) PURE;// [OUT] count of bytes in the translated signature
176 STDMETHOD(GetMetadata)(
177 ULONG ulSelect, // [IN] Selector.
178 void **ppData) PURE; // [OUT] Put pointer to data here.
180 STDMETHOD_(IUnknown *, GetCachedInternalInterface)(BOOL fWithLock) PURE; // S_OK or error
181 STDMETHOD(SetCachedInternalInterface)(IUnknown * pUnk) PURE; // S_OK or error
182 STDMETHOD_(UTSemReadWrite*, GetReaderWriterLock)() PURE; // return the reader writer lock
183 STDMETHOD(SetReaderWriterLock)(UTSemReadWrite * pSem) PURE;
184 }; // IMetaDataHelper
187 EXTERN_GUID(IID_IMetaDataEmitHelper, 0x5c240ae4, 0x1e09, 0x11d3, 0x94, 0x24, 0x0, 0x0, 0xf8, 0x8, 0x34, 0x60);
190 #define INTERFACE IMetaDataEmitHelper
191 DECLARE_INTERFACE_(IMetaDataEmitHelper, IUnknown)
193 // emit helper functions
194 STDMETHOD(DefineMethodSemanticsHelper)(
195 mdToken tkAssociation, // [IN] property or event token
196 DWORD dwFlags, // [IN] semantics
197 mdMethodDef md) PURE; // [IN] method to associated with
199 STDMETHOD(SetFieldLayoutHelper)( // Return hresult.
200 mdFieldDef fd, // [IN] field to associate the layout info
201 ULONG ulOffset) PURE; // [IN] the offset for the field
203 STDMETHOD(DefineEventHelper) (
204 mdTypeDef td, // [IN] the class/interface on which the event is being defined
205 LPCWSTR szEvent, // [IN] Name of the event
206 DWORD dwEventFlags, // [IN] CorEventAttr
207 mdToken tkEventType, // [IN] a reference (mdTypeRef or mdTypeRef) to the Event class
208 mdEvent *pmdEvent) PURE; // [OUT] output event token
210 STDMETHOD(AddDeclarativeSecurityHelper) (
211 mdToken tk, // [IN] Parent token (typedef/methoddef)
212 DWORD dwAction, // [IN] Security action (CorDeclSecurity)
213 void const *pValue, // [IN] Permission set blob
214 DWORD cbValue, // [IN] Byte count of permission set blob
215 mdPermission*pmdPermission) PURE; // [OUT] Output permission token
217 STDMETHOD(SetResolutionScopeHelper)( // Return hresult.
218 mdTypeRef tr, // [IN] TypeRef record to update
219 mdToken rs) PURE; // [IN] new ResolutionScope
221 STDMETHOD(SetManifestResourceOffsetHelper)( // Return hresult.
222 mdManifestResource mr, // [IN] The manifest token
223 ULONG ulOffset) PURE; // [IN] new offset
225 STDMETHOD(SetTypeParent)( // Return hresult.
226 mdTypeDef td, // [IN] Type definition
227 mdToken tkExtends) PURE; // [IN] parent type
229 STDMETHOD(AddInterfaceImpl)( // Return hresult.
230 mdTypeDef td, // [IN] Type definition
231 mdToken tkInterface) PURE; // [IN] interface type
233 }; // IMetaDataEmitHelper
235 //////////////////////////////////////////////////////////////////////////////
236 // enum CorElementTypeZapSig defines some additional internal ELEMENT_TYPE's
237 // values that are only used by ZapSig signatures.
238 //////////////////////////////////////////////////////////////////////////////
239 typedef enum CorElementTypeZapSig
241 // ZapSig encoding for ELEMENT_TYPE_VAR and ELEMENT_TYPE_MVAR. It is always followed
242 // by the RID of a GenericParam token, encoded as a compressed integer.
243 ELEMENT_TYPE_VAR_ZAPSIG = 0x3b,
245 // ZapSig encoding for an array MethodTable to allow it to remain such after decoding
246 // (rather than being transformed into the TypeHandle representing that array)
248 // The element is always followed by ELEMENT_TYPE_SZARRAY or ELEMENT_TYPE_ARRAY
249 ELEMENT_TYPE_NATIVE_ARRAY_TEMPLATE_ZAPSIG = 0x3c,
251 // ZapSig encoding for native value types in IL stubs. IL stub signatures may contain
252 // ELEMENT_TYPE_INTERNAL followed by ParamTypeDesc with ELEMENT_TYPE_VALUETYPE element
253 // type. It acts like a modifier to the underlying structure making it look like its
254 // unmanaged view (size determined by unmanaged layout, blittable, no GC pointers).
256 // ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG is used when encoding such types to NGEN images.
257 // The signature looks like this: ET_NATIVE_VALUETYPE_ZAPSIG ET_VALUETYPE <token>.
258 // See code:ZapSig.GetSignatureForTypeHandle and code:SigPointer.GetTypeHandleThrowing
259 // where the encoding/decoding takes place.
260 ELEMENT_TYPE_NATIVE_VALUETYPE_ZAPSIG = 0x3d,
262 ELEMENT_TYPE_CANON_ZAPSIG = 0x3e, // zapsig encoding for [mscorlib]System.__Canon
263 ELEMENT_TYPE_MODULE_ZAPSIG = 0x3f, // zapsig encoding for external module id#
265 } CorElementTypeZapSig;
267 typedef enum CorCallingConventionInternal
269 // IL stub signatures containing types that need to be restored have the highest
270 // bit of the calling convention set.
271 IMAGE_CEE_CS_CALLCONV_NEEDSRESTORE = 0x80,
273 } CorCallingConventionInternal;
275 //////////////////////////////////////////////////////////////////////////
276 // Obsoleted ELEMENT_TYPE values which are not supported anymore.
277 // They are not part of CLI ECMA spec, they were only experimental before v1.0 RTM.
278 // They are needed for indexing arrays initialized using file:corTypeInfo.h
279 // 0x17 ... VALUEARRAY <type> <bound>
280 // 0x1a ... CPU native floating-point type
281 //////////////////////////////////////////////////////////////////////////
282 #define ELEMENT_TYPE_VALUEARRAY_UNSUPPORTED ((CorElementType) 0x17)
283 #define ELEMENT_TYPE_R_UNSUPPORTED ((CorElementType) 0x1a)
285 // Use this guid in the SetOption if Reflection.Emit wants to control size of the initially allocated
286 // MetaData. See values: code:CorMetaDataInitialSize.
288 // {2675b6bf-f504-4cb4-a4d5-084eea770ddc}
289 EXTERN_GUID(MetaDataInitialSize, 0x2675b6bf, 0xf504, 0x4cb4, 0xa4, 0xd5, 0x08, 0x4e, 0xea, 0x77, 0x0d, 0xdc);
291 // Allowed values for code:MetaDataInitialSize option.
292 typedef enum CorMetaDataInitialSize
294 MDInitialSizeDefault = 0,
295 MDInitialSizeMinimal = 1
296 } CorMetaDataInitialSize;
298 // Internal extension of open flags code:CorOpenFlags
299 typedef enum CorOpenFlagsInternal
301 #ifdef FEATURE_METADATA_LOAD_TRUSTED_IMAGES
302 // Flag code:ofTrustedImage is used by mscordbi.dll, therefore defined in file:CorPriv.h
303 ofTrustedImage = ofReserved3 // We trust this PE file (we are willing to do a LoadLibrary on it).
304 // It is optional and only an (VM) optimization - typically for NGEN images
305 // opened by debugger.
307 } CorOpenFlagsInternal;
309 #ifdef FEATURE_METADATA_LOAD_TRUSTED_IMAGES
310 #define IsOfTrustedImage(x) ((x) & ofTrustedImage)
313 // %%Classes: ----------------------------------------------------------------
315 #define offsetof(s,f) ((ULONG)(&((s*)0)->f))
318 #define lengthof(rg) (sizeof(rg)/sizeof(rg[0]))
321 #define COR_MODULE_CLASS "<Module>"
322 #define COR_WMODULE_CLASS W("<Module>")
324 STDAPI RuntimeOpenImage(LPCWSTR pszFileName, HCORMODULE* hHandle);
325 STDAPI RuntimeOpenImageInternal(LPCWSTR pszFileName, HCORMODULE* hHandle,
326 DWORD *pdwLength, MDInternalImportFlags flags, HANDLE hFile = INVALID_HANDLE_VALUE);
327 STDAPI RuntimeOpenImageByStream(IStream* pIStream, UINT64 AssemblyId, DWORD dwModuleId,
328 HCORMODULE* hHandle, DWORD *pdwLength, MDInternalImportFlags flags);
330 void RuntimeAddRefHandle(HCORMODULE hHandle);
331 STDAPI RuntimeReleaseHandle(HCORMODULE hHandle);
332 STDAPI RuntimeGetImageBase(HCORMODULE hHandle, LPVOID* base, BOOL bMapped, COUNT_T* dwSize);
333 STDAPI RuntimeGetImageKind(HCORMODULE hHandle, DWORD* pdwKind, DWORD* pdwMachine);
334 STDAPI RuntimeOSHandle(HCORMODULE hHandle, HMODULE* hModule);
335 STDAPI RuntimeGetAssemblyStrongNameHashForModule(HCORMODULE hModule,
336 IMetaDataImport *pMDimport,
339 STDAPI RuntimeGetMDInternalImport(HCORMODULE hHandle,
340 MDInternalImportFlags flags,
341 IMDInternalImport** ppMDImport);
344 void ReleaseHCorModule(HCORMODULE hModule)
346 HRESULT hr = RuntimeReleaseHandle(hModule);
347 _ASSERTE(SUCCEEDED(hr));
350 typedef Wrapper<HCORMODULE, DoNothing<HCORMODULE>, ReleaseHCorModule, (UINT_PTR) NULL> HCORMODULEHolder;
353 // ===========================================================================
354 // ISNAssemblySignature (similar to IAssemblySignature in V1)
356 // This is a private interface that allows querying of the strong name
358 // This can be used for (strong-named) assemblies added to the GAC as
359 // a unique identifier.
362 // {848845BC-0C4A-42e3-8915-DC850112443D}
363 EXTERN_GUID(IID_ISNAssemblySignature, 0x848845BC, 0x0C4A, 0x42e3, 0x89, 0x15, 0xDC, 0x85, 0x01, 0x12, 0x44, 0x3D);
366 #define INTERFACE ISNAssemblySignature
367 DECLARE_INTERFACE_(ISNAssemblySignature, IUnknown)
369 // Returns the strong-name signature if the assembly is strong-name-signed
370 // Returns the MVID if the assembly is delay-signed.
371 // Fails if the assembly is not signed at all.
372 STDMETHOD(GetSNAssemblySignature) (
373 BYTE *pbSig, // [IN, OUT] Buffer to write signature
374 DWORD *pcbSig // [IN, OUT] Size of buffer, bytes written
378 //-------------------------------------
379 //--- ICeeGenInternal
380 //-------------------------------------
381 // {9fd3c7af-dc4e-4b9b-be22-9cf8cc577489}
382 EXTERN_GUID(IID_ICeeGenInternal, 0x9fd3c7af, 0xdc4e, 0x4b9b, 0xbe, 0x22, 0x9c, 0xf8, 0xcc, 0x57, 0x74, 0x89);
385 #define INTERFACE ICeeGenInternal
386 DECLARE_INTERFACE_(ICeeGenInternal, IUnknown)
388 STDMETHOD (SetInitialGrowth) (DWORD growth) PURE;
391 // ===========================================================================
392 #ifdef FEATURE_PREJIT
393 // ===========================================================================
395 #define CLR_OPTIMIZATION_SERVICE_DLL_NAME W("mscorsvc.dll")
396 #define CLR_OPT_SVC_ENTRY_POINT "CorGetSvc"
398 // Use the default JIT compiler
399 #define DEFAULT_NGEN_COMPILER_DLL_NAME W("clrjit.dll")
402 struct CORCOMPILE_ASSEMBLY_SIGNATURE;
405 // IGetIMDInternalImport
407 // Private interface exposed by
408 // AssemblyMDInternalImport - gives us access to the internally stored IMDInternalImport*.
410 // RegMeta, WinMDImport - supports the internal GetMetaDataInternalInterfaceFromPublic() "api".
412 // {92B2FEF9-F7F5-420d-AD42-AECEEE10A1EF}
413 EXTERN_GUID(IID_IGetIMDInternalImport, 0x92b2fef9, 0xf7f5, 0x420d, 0xad, 0x42, 0xae, 0xce, 0xee, 0x10, 0xa1, 0xef);
415 #define INTERFACE IGetIMDInternalImport
416 DECLARE_INTERFACE_(IGetIMDInternalImport, IUnknown)
418 STDMETHOD(GetIMDInternalImport) (
419 IMDInternalImport ** ppIMDInternalImport // [OUT] Buffer to receive IMDInternalImport*
425 #ifndef DACCESS_COMPILE
427 /* --------------------------------------------------------------------------- *
429 * --------------------------------------------------------------------------- */
430 #include "mscorsvc.h"
432 struct ICorSvcLogger;
439 void ReleaseLogger();
440 void SetSvcLogger(ICorSvcLogger *pCorSvcLoggerArg);
442 ICorSvcLogger* GetSvcLogger();
443 void Printf(const CHAR *format, ...);
444 void SvcPrintf(const CHAR *format, ...);
445 void Printf(const WCHAR *format, ...);
446 void Printf(CorSvcLogLevel logLevel, const WCHAR *format, ...);
447 void SvcPrintf(const WCHAR *format, ...);
448 void Log(const WCHAR *message, CorSvcLogLevel logLevel = LogLevel_Warning);
449 //Need to add this to allocate StackSString, as we don't want static class
453 void LogHelper(SString s, CorSvcLogLevel logLevel = LogLevel_Success);
454 //instantiations that need VM services like contracts in dllmain.
458 ICorSvcLogger *pCorSvcLogger;
459 }; // class SvcLogger
461 SvcLogger *GetSvcLogger();
463 #endif // #ifndef DACCESS_COMPILE
465 // ===========================================================================
466 #endif // #ifdef FEATURE_PREJIT
467 // ===========================================================================
469 struct CORCOMPILE_ASSEMBLY_SIGNATURE;
470 struct CORCOMPILE_VERSION_INFO;
471 struct CORCOMPILE_DEPENDENCY;
472 typedef GUID CORCOMPILE_NGEN_SIGNATURE;
474 #ifdef FEATURE_FUSION
475 //**********************************************************************
476 // Gets the dependancies of a native image. If these change, then
477 // the native image cannot be used.
479 // IMetaDataImport::GetAssemblyRefProps() can be used to obtain information about
480 // the mdAssemblyRefs.
481 //*****************************************************************************
483 // {814C9E35-3F3F-4975-977A-371F0A878AC7}
484 EXTERN_GUID(IID_INativeImageDependency, 0x814c9e35, 0x3f3f, 0x4975, 0x97, 0x7a, 0x37, 0x1f, 0xa, 0x87, 0x8a, 0xc7);
486 DECLARE_INTERFACE_(INativeImageDependency, IUnknown)
488 // Get the referenced assembly
489 STDMETHOD (GetILAssemblyRef) (
490 mdAssemblyRef * pAssemblyRef // [OUT]
493 // Get the post-policy assembly actually used
494 STDMETHOD (GetILAssemblyDef) (
495 mdAssemblyRef * ppAssemblyDef, // [OUT]
496 CORCOMPILE_ASSEMBLY_SIGNATURE * pSign // [OUT]
499 // Get the native image corresponding to GetILAssemblyDef() IF
500 // there is a hard-bound (directly-referenced) native dependancy
502 // We do not need the configStrig because configStrings have to
503 // be an exact part. Any partial matches are factored out into GetConfigMask()
504 STDMETHOD (GetNativeAssemblyDef) (
505 CORCOMPILE_NGEN_SIGNATURE * pNativeSign // [OUT] INVALID_NGEN_SIGNATURE if there is no hard-bound dependancy
508 // Get PEKIND of the referenced assembly
509 STDMETHOD (GetPEKind) (
510 PEKIND * CorPEKind // [OUT]
513 }; // INativeImageDependency
515 //*****************************************************************************
517 // Fusion uses IFusionNativeImageInfo to obtain (and cache) informaton
518 // about a native image being installed into the native image cache.
519 // This allows Fusion to bind directly to native images
520 // without requiring (expensively) binding to the IL assembly first.
522 // IMetaDataAssemblyImport can be queried for this interface
524 //*****************************************************************************
525 // {0EA273D0-B4DA-4008-A60D-8D6EFFDD6E91}
526 EXTERN_GUID(IID_INativeImageInstallInfo, 0xea273d0, 0xb4da, 0x4008, 0xa6, 0xd, 0x8d, 0x6e, 0xff, 0xdd, 0x6e, 0x91);
528 DECLARE_INTERFACE_(INativeImageInstallInfo, IUnknown)
530 // Signature of the ngen image
531 // This matches the argument type of INativeImageDependency::GetNativeAssemblyDef
533 STDMETHOD (GetSignature) (
534 CORCOMPILE_NGEN_SIGNATURE * pNgenSign // [OUT]
538 // CLR timestamp, CPU, compile options, OS type and other attributes of the
539 // NI image. This can be used to verify that the NI image was built
540 // with the running CLR.
542 STDMETHOD (GetVersionInfo) (
543 CORCOMPILE_VERSION_INFO * pVersionInfo // [OUT]
547 // Signature of the source IL assembly. This can be used to
548 // verify that the IL image matches a candidate ngen image.
549 // This matches the argument type of IAssemblyRuntimeSignature::CheckSignature
552 STDMETHOD (GetILSignature) (
553 CORCOMPILE_ASSEMBLY_SIGNATURE * pILSign // [OUT]
556 // A partial match is allowed for the current NativeImage to be valid
558 STDMETHOD (GetConfigMask) (
559 DWORD * pConfigMask // [OUT]
563 // Dependancy assemblies. The native image is only valid
564 // if the dependancies have not changed.
567 STDMETHOD (EnumDependencies) (
568 HCORENUM * phEnum, // [IN/OUT] - Pointer to the enum
569 INativeImageDependency *rDeps[], // [OUT]
570 ULONG cMax, // [IN] Max dependancies to enumerate in this iteration
571 DWORD * pdwCount // [OUT] - Number of dependancies actually enumerated
575 // Retrieve a specific dependency by the ngen signature.
577 STDMETHOD (GetDependency) (
578 const CORCOMPILE_NGEN_SIGNATURE *pcngenSign, // [IN] ngenSig of dependency you want
579 CORCOMPILE_DEPENDENCY *pDep // [OUT] matching dependency
582 }; // INativeImageInstallInfo
584 //*****************************************************************************
586 // Runtime callback made by Fusion into the CLR to determine if the NativeAssembly
587 // can be used. The pUnkBindSink argument of CAssemblyName::BindToObject() can
588 // be queried for this interface
590 //*****************************************************************************
591 // {065AA013-9BDC-447c-922F-FEE929908447}
592 EXTERN_GUID(IID_INativeImageEvaluate, 0x65aa013, 0x9bdc, 0x447c, 0x92, 0x2f, 0xfe, 0xe9, 0x29, 0x90, 0x84, 0x47);
595 #pragma warning(push)
596 #pragma warning(disable:28718)
606 DECLARE_INTERFACE_(INativeImageEvaluate, IUnknown)
608 // This will be called before the assemblies are actually loaded.
610 // Returns S_FALSE if the native-image cannot be used.
612 STDMETHOD (Evaluate) (
613 IAssembly *pILAssembly, // [IN] IL assembly in question
614 IAssembly *pNativeAssembly, // [IN] NGen image we are trying to use for pILAssembly
615 BYTE * pbCachedData, // [IN] Data cached when the native-image was generated
616 DWORD dwDataSize // [IN] Size of the pbCachedData buffer
618 }; // INativeImageEvaluate
620 #endif // FEATURE_FUSION
622 //**********************************************************************
623 // Internal versions of shim functions for use by the CLR.
625 STDAPI LoadLibraryShimInternal(
631 STDAPI GetCORSystemDirectoryInternaL(
635 //LONGPATH:TODO: Remove this once Desktop usage has been removed
636 STDAPI GetCORSystemDirectoryInternal(
637 __out_ecount_part_opt(cchBuffer, *pdwLength) LPWSTR pBuffer,
639 __out_opt DWORD* pdwLength
642 STDAPI GetCORVersionInternal(
643 __out_ecount_z_opt(cchBuffer) LPWSTR pBuffer,
645 __out DWORD *pdwLength);
647 STDAPI GetRequestedRuntimeInfoInternal(LPCWSTR pExe,
649 LPCWSTR pConfigurationFile,
651 DWORD runtimeInfoFlags,
652 __out_ecount_opt(dwDirectory) LPWSTR pDirectory,
654 __out_opt DWORD *pdwDirectoryLength,
655 __out_ecount_opt(cchBuffer) LPWSTR pVersion,
657 __out_opt DWORD* pdwLength);
660 #ifdef FEATURE_PREJIT
662 //**********************************************************************
663 // Access to native image validation logic in the runtime.
665 // An interface only a mother could live as this logic should really be encapsulated in
666 // the native binder. But for historical reasons, it lives in the VM directory
667 // and is shared by the desktop and coreclr's which have separate native binders.
668 // Hence, this interface inherits a lot of "baggage."
670 #ifdef FEATURE_FUSION
671 interface IFusionBindLog;
672 interface IAssemblyName;
673 #endif // FEATURE_FUSION
676 // A small shim around PEAssemblies/IBindResult that allow us to write Fusion/CLR-agnostic code
677 // for logging native bind failures to the Fusion log/CLR log.
679 // These objects are stack-based and non-thread-safe. They are created for the duration of a single RuntimeVerify call.
680 // The methods are expected to compute their data lazily as they are only used in bind failures or in checked builds.
682 // This class also exposes the IFusionBindLog pointer. This isn't really the appropriate place to expose that but
683 // it serves to avoid compiling references to IFUsionBindLog into code that doesn't define FEATURE_FUSION.
684 class LoggableAssembly
687 virtual SString DisplayString() = 0; // Returns an unspecified representation suitable for injecting into log messages.
688 #ifdef FEATURE_FUSION
689 virtual IAssemblyName* FusionAssemblyName() = 0; // Can return NULL. Caller must NOT release result.
690 virtual IFusionBindLog* FusionBindLog() = 0; // Can return NULL. Caller must NOT release result.
691 #endif // FEATURE_FUSION
695 // Validates that an NI matches the running CLR, OS, CPU, etc.
696 BOOL RuntimeVerifyNativeImageVersion(const CORCOMPILE_VERSION_INFO *pVerInfo, LoggableAssembly *pLogAsm);
698 // Validates that an NI matches the required flavor (debug, instrumented, etc.)
699 BOOL RuntimeVerifyNativeImageFlavor(const CORCOMPILE_VERSION_INFO *pVerInfo, LoggableAssembly *pLogAsm);
701 // Validates that a hard-dep matches the a parent NI's compile-time hard-dep.
702 BOOL RuntimeVerifyNativeImageDependency(const CORCOMPILE_NGEN_SIGNATURE &ngenSigExpected,
703 const CORCOMPILE_VERSION_INFO *pActual,
704 LoggableAssembly *pLogAsm);
706 BOOL RuntimeVerifyNativeImageDependency(const CORCOMPILE_DEPENDENCY *pExpected,
707 const CORCOMPILE_VERSION_INFO *pActual,
708 LoggableAssembly *pLogAsm);
710 #endif // FEATURE_PREJIT
715 #endif // _CORPRIV_H_
716 // EOF =======================================================================