// Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. using System; using Internal.Runtime.Augments; namespace Internal.Runtime.TypeLoader { public partial struct ExternalReferencesTable { private unsafe bool Initialize(NativeFormatModuleInfo module, ReflectionMapBlob blobId) { byte* pBlob; uint cbBlob; if (!module.TryFindBlob(blobId, out pBlob, out cbBlob)) { _elements = IntPtr.Zero; _elementsCount = 0; return false; } _elements = (IntPtr)pBlob; _elementsCount = (uint)(cbBlob / sizeof(uint)); return true; } /// <summary> /// Initialize ExternalReferencesTable using the NativeReferences metadata blob on a given module. /// </summary> /// <param name="module">Module handle is used to locate the NativeReferences blob</param> /// <returns>true when the NativeReferences blob was found in the given module, false when not</returns> public bool InitializeNativeReferences(NativeFormatModuleInfo module) { return Initialize(module, ReflectionMapBlob.NativeReferences); } /// <summary> /// Initialize ExternalReferencesTable using the NativeStatics metadata blob on a given module. /// </summary> /// <param name="module">Module handle is used to locate the NativeStatics blob</param> /// <returns>true when the NativeStatics blob was found in the given module, false when not</returns> public bool InitializeNativeStatics(NativeFormatModuleInfo module) { return Initialize(module, ReflectionMapBlob.NativeStatics); } /// <summary> /// Initialize ExternalReferencesTable using the CommonFixupsTable metadata blob on a given module. /// </summary> /// <param name="module">Module handle is used to locate the CommonFixupsTable blob</param> /// <returns>true when the CommonFixupsTable blob was found in the given module, false when not</returns> public bool InitializeCommonFixupsTable(NativeFormatModuleInfo module) { return Initialize(module, ReflectionMapBlob.CommonFixupsTable); } } } |