using System; using System.Configuration.Assemblies; using System.Globalization; using System.IO; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Security; using System.Security.Cryptography; using System.Text; using Mono.Security; using Mono.Security.Cryptography; namespace System.Reflection { /// Describes an assembly's unique identity in full. // Token: 0x0200022E RID: 558 [ComDefaultInterface(typeof(_AssemblyName))] [ComVisible(true)] [ClassInterface(ClassInterfaceType.None)] [Serializable] public sealed class AssemblyName : ICloneable, ISerializable, _AssemblyName, IDeserializationCallback { /// Initializes a new instance of the class. // Token: 0x06001D7A RID: 7546 RVA: 0x0006E218 File Offset: 0x0006C418 public AssemblyName() { this.versioncompat = AssemblyVersionCompatibility.SameMachine; } /// Initializes a new instance of the class with the specified display name. /// The display name of the assembly, as returned by the property. /// /// is null. /// /// is a zero length string. // Token: 0x06001D7B RID: 7547 RVA: 0x0006E228 File Offset: 0x0006C428 public AssemblyName(string assemblyName) { if (assemblyName == null) { throw new ArgumentNullException("assemblyName"); } if (assemblyName.Length < 1) { throw new ArgumentException("assemblyName cannot have zero length."); } if (!AssemblyName.ParseName(this, assemblyName)) { throw new FileLoadException("The assembly name is invalid."); } } // Token: 0x06001D7C RID: 7548 RVA: 0x0006E27C File Offset: 0x0006C47C internal AssemblyName(SerializationInfo si, StreamingContext sc) { this.name = si.GetString("_Name"); this.codebase = si.GetString("_CodeBase"); this.version = (Version)si.GetValue("_Version", typeof(Version)); this.publicKey = (byte[])si.GetValue("_PublicKey", typeof(byte[])); this.keyToken = (byte[])si.GetValue("_PublicKeyToken", typeof(byte[])); this.hashalg = (AssemblyHashAlgorithm)((int)si.GetValue("_HashAlgorithm", typeof(AssemblyHashAlgorithm))); this.keypair = (StrongNameKeyPair)si.GetValue("_StrongNameKeyPair", typeof(StrongNameKeyPair)); this.versioncompat = (AssemblyVersionCompatibility)((int)si.GetValue("_VersionCompatibility", typeof(AssemblyVersionCompatibility))); this.flags = (AssemblyNameFlags)((int)si.GetValue("_Flags", typeof(AssemblyNameFlags))); int @int = si.GetInt32("_CultureInfo"); if (@int != -1) { this.cultureinfo = new CultureInfo(@int); } } /// Maps a set of names to a corresponding set of dispatch identifiers. /// Reserved for future use. Must be IID_NULL. /// Passed-in array of names to be mapped. /// Count of the names to be mapped. /// The locale context in which to interpret the names. /// Caller-allocated array that receives the IDs corresponding to the names. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001D7D RID: 7549 RVA: 0x0006E3B0 File Offset: 0x0006C5B0 void _AssemblyName.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId) { throw new NotImplementedException(); } /// Retrieves the type information for an object, which can then be used to get the type information for an interface. /// The type information to return. /// The locale identifier for the type information. /// Receives a pointer to the requested type information object. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001D7E RID: 7550 RVA: 0x0006E3B8 File Offset: 0x0006C5B8 void _AssemblyName.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo) { throw new NotImplementedException(); } /// Retrieves the number of type information interfaces that an object provides (either 0 or 1). /// Points to a location that receives the number of type information interfaces provided by the object. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001D7F RID: 7551 RVA: 0x0006E3C0 File Offset: 0x0006C5C0 void _AssemblyName.GetTypeInfoCount(out uint pcTInfo) { throw new NotImplementedException(); } /// Provides access to properties and methods exposed by an object. /// Identifies the member. /// Reserved for future use. Must be IID_NULL. /// The locale context in which to interpret arguments. /// Flags describing the context of the call. /// Pointer to a structure containing an array of arguments, an array of argument DispIDs for named arguments, and counts for the number of elements in the arrays. /// Pointer to the location where the result is to be stored. /// Pointer to a structure that contains exception information. /// The index of the first argument that has an error. /// Late-bound access using the COM IDispatch interface is not supported. // Token: 0x06001D80 RID: 7552 RVA: 0x0006E3C8 File Offset: 0x0006C5C8 void _AssemblyName.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr) { throw new NotImplementedException(); } // Token: 0x06001D81 RID: 7553 [MethodImpl(MethodImplOptions.InternalCall)] private static extern bool ParseName(AssemblyName aname, string assemblyName); /// Gets or sets a value that identifies the processor and bits-per-word of the platform targeted by an executable. /// One of the values that identifies the processor and bits-per-word of the platform targeted by an executable. // Token: 0x1700054D RID: 1357 // (get) Token: 0x06001D82 RID: 7554 RVA: 0x0006E3D0 File Offset: 0x0006C5D0 // (set) Token: 0x06001D83 RID: 7555 RVA: 0x0006E3D8 File Offset: 0x0006C5D8 [MonoTODO("Not used, as the values are too limited; Mono supports more")] public ProcessorArchitecture ProcessorArchitecture { get { return this.processor_architecture; } set { this.processor_architecture = value; } } /// Gets or sets the simple name of the assembly. This is usually, but not necessarily, the file name of the manifest file of the assembly, minus its extension. /// A String that is the simple name of the assembly. // Token: 0x1700054E RID: 1358 // (get) Token: 0x06001D84 RID: 7556 RVA: 0x0006E3E4 File Offset: 0x0006C5E4 // (set) Token: 0x06001D85 RID: 7557 RVA: 0x0006E3EC File Offset: 0x0006C5EC public string Name { get { return this.name; } set { this.name = value; } } /// Gets or sets the location of the assembly as a URL. /// A string that is the URL location of the assembly. // Token: 0x1700054F RID: 1359 // (get) Token: 0x06001D86 RID: 7558 RVA: 0x0006E3F8 File Offset: 0x0006C5F8 // (set) Token: 0x06001D87 RID: 7559 RVA: 0x0006E400 File Offset: 0x0006C600 public string CodeBase { get { return this.codebase; } set { this.codebase = value; } } /// Gets the URI, including escape characters, that represents the codebase. /// A URI with escape characters. // Token: 0x17000550 RID: 1360 // (get) Token: 0x06001D88 RID: 7560 RVA: 0x0006E40C File Offset: 0x0006C60C public string EscapedCodeBase { get { if (this.codebase == null) { return null; } return Uri.EscapeString(this.codebase, false, true, true); } } /// Gets or sets the culture supported by the assembly. /// A object representing the culture supported by the assembly. // Token: 0x17000551 RID: 1361 // (get) Token: 0x06001D89 RID: 7561 RVA: 0x0006E42C File Offset: 0x0006C62C // (set) Token: 0x06001D8A RID: 7562 RVA: 0x0006E434 File Offset: 0x0006C634 public CultureInfo CultureInfo { get { return this.cultureinfo; } set { this.cultureinfo = value; } } /// Gets or sets the attributes of the assembly. /// An object representing the attributes of the assembly. // Token: 0x17000552 RID: 1362 // (get) Token: 0x06001D8B RID: 7563 RVA: 0x0006E440 File Offset: 0x0006C640 // (set) Token: 0x06001D8C RID: 7564 RVA: 0x0006E448 File Offset: 0x0006C648 public AssemblyNameFlags Flags { get { return this.flags; } set { this.flags = value; } } /// Gets the full name of the assembly, also known as the display name. /// A string that is the full name of the assembly, also known as the display name. // Token: 0x17000553 RID: 1363 // (get) Token: 0x06001D8D RID: 7565 RVA: 0x0006E454 File Offset: 0x0006C654 public string FullName { get { if (this.name == null) { return string.Empty; } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(this.name); if (this.Version != null) { stringBuilder.Append(", Version="); stringBuilder.Append(this.Version.ToString()); } if (this.cultureinfo != null) { stringBuilder.Append(", Culture="); if (this.cultureinfo.LCID == CultureInfo.InvariantCulture.LCID) { stringBuilder.Append("neutral"); } else { stringBuilder.Append(this.cultureinfo.Name); } } byte[] array = this.InternalGetPublicKeyToken(); if (array != null) { if (array.Length == 0) { stringBuilder.Append(", PublicKeyToken=null"); } else { stringBuilder.Append(", PublicKeyToken="); for (int i = 0; i < array.Length; i++) { stringBuilder.Append(array[i].ToString("x2")); } } } if ((this.Flags & AssemblyNameFlags.Retargetable) != AssemblyNameFlags.None) { stringBuilder.Append(", Retargetable=Yes"); } return stringBuilder.ToString(); } } /// Gets or sets the hash algorithm used by the assembly manifest. /// An AssemblyHashAlgorithm object representing the hash algorithm used by the assembly manifest. // Token: 0x17000554 RID: 1364 // (get) Token: 0x06001D8E RID: 7566 RVA: 0x0006E58C File Offset: 0x0006C78C // (set) Token: 0x06001D8F RID: 7567 RVA: 0x0006E594 File Offset: 0x0006C794 public AssemblyHashAlgorithm HashAlgorithm { get { return this.hashalg; } set { this.hashalg = value; } } /// Gets or sets the public and private cryptographic key pair that is used to create a strong name signature for the assembly. /// A object containing the public and private cryptographic key pair to be used to create a strong name for the assembly. // Token: 0x17000555 RID: 1365 // (get) Token: 0x06001D90 RID: 7568 RVA: 0x0006E5A0 File Offset: 0x0006C7A0 // (set) Token: 0x06001D91 RID: 7569 RVA: 0x0006E5A8 File Offset: 0x0006C7A8 public StrongNameKeyPair KeyPair { get { return this.keypair; } set { this.keypair = value; } } /// Gets or sets the major, minor, build, and revision numbers of the assembly. /// A object representing the major, minor, build, and revision numbers of the assembly. // Token: 0x17000556 RID: 1366 // (get) Token: 0x06001D92 RID: 7570 RVA: 0x0006E5B4 File Offset: 0x0006C7B4 // (set) Token: 0x06001D93 RID: 7571 RVA: 0x0006E5BC File Offset: 0x0006C7BC public Version Version { get { return this.version; } set { this.version = value; if (value == null) { this.major = (this.minor = (this.build = (this.revision = 0))); } else { this.major = value.Major; this.minor = value.Minor; this.build = value.Build; this.revision = value.Revision; } } } /// Gets or sets the information related to the assembly's compatibility with other assemblies. /// An AssemblyVersionCompatibility object representing information about the assembly's compatibility with other assemblies. // Token: 0x17000557 RID: 1367 // (get) Token: 0x06001D94 RID: 7572 RVA: 0x0006E634 File Offset: 0x0006C834 // (set) Token: 0x06001D95 RID: 7573 RVA: 0x0006E63C File Offset: 0x0006C83C public AssemblyVersionCompatibility VersionCompatibility { get { return this.versioncompat; } set { this.versioncompat = value; } } /// Returns the full name of the assembly, also known as the display name. /// A String that is the full name of the assembly, or the class name if the full name of the assembly cannot be determined. // Token: 0x06001D96 RID: 7574 RVA: 0x0006E648 File Offset: 0x0006C848 public override string ToString() { string fullName = this.FullName; return (fullName == null) ? base.ToString() : fullName; } /// Gets the public key of the assembly. /// An array of type byte containing the public key of the assembly. /// A public key was provided (for example, by using the method), but no public key token was provided. // Token: 0x06001D97 RID: 7575 RVA: 0x0006E670 File Offset: 0x0006C870 public byte[] GetPublicKey() { return this.publicKey; } /// Gets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which the application or assembly is signed. /// An array of type byte containing the public key token. // Token: 0x06001D98 RID: 7576 RVA: 0x0006E678 File Offset: 0x0006C878 public byte[] GetPublicKeyToken() { if (this.keyToken != null) { return this.keyToken; } if (this.publicKey == null) { return null; } if (this.publicKey.Length == 0) { return new byte[0]; } if (!this.IsPublicKeyValid) { throw new SecurityException("The public key is not valid."); } this.keyToken = this.ComputePublicKeyToken(); return this.keyToken; } // Token: 0x17000558 RID: 1368 // (get) Token: 0x06001D99 RID: 7577 RVA: 0x0006E6E0 File Offset: 0x0006C8E0 private bool IsPublicKeyValid { get { if (this.publicKey.Length == 16) { int i = 0; int num = 0; while (i < this.publicKey.Length) { num += (int)this.publicKey[i++]; } if (num == 4) { return true; } } byte b = this.publicKey[0]; if (b != 6) { if (b != 7) { if (b == 0) { if (this.publicKey.Length > 12 && this.publicKey[12] == 6) { try { CryptoConvert.FromCapiPublicKeyBlob(this.publicKey, 12); return true; } catch (CryptographicException) { } } } } } else { try { CryptoConvert.FromCapiPublicKeyBlob(this.publicKey); return true; } catch (CryptographicException) { } } return false; } } // Token: 0x06001D9A RID: 7578 RVA: 0x0006E7F0 File Offset: 0x0006C9F0 private byte[] InternalGetPublicKeyToken() { if (this.keyToken != null) { return this.keyToken; } if (this.publicKey == null) { return null; } if (this.publicKey.Length == 0) { return new byte[0]; } if (!this.IsPublicKeyValid) { throw new SecurityException("The public key is not valid."); } return this.ComputePublicKeyToken(); } // Token: 0x06001D9B RID: 7579 RVA: 0x0006E84C File Offset: 0x0006CA4C private byte[] ComputePublicKeyToken() { HashAlgorithm hashAlgorithm = SHA1.Create(); byte[] array = hashAlgorithm.ComputeHash(this.publicKey); byte[] array2 = new byte[8]; Array.Copy(array, array.Length - 8, array2, 0, 8); Array.Reverse(array2, 0, 8); return array2; } /// Returns a value indicating whether the loader resolves two assembly names to the same assembly. /// true if the loader resolves to the same assembly as ; otherwise, false. /// The reference assembly name. /// The assembly name that is compared to the reference assembly. // Token: 0x06001D9C RID: 7580 RVA: 0x0006E88C File Offset: 0x0006CA8C [MonoTODO] public static bool ReferenceMatchesDefinition(AssemblyName reference, AssemblyName definition) { if (reference == null) { throw new ArgumentNullException("reference"); } if (definition == null) { throw new ArgumentNullException("definition"); } if (reference.Name != definition.Name) { return false; } throw new NotImplementedException(); } /// Sets the public key identifying the assembly. /// A byte array containing the public key of the assembly. // Token: 0x06001D9D RID: 7581 RVA: 0x0006E8D8 File Offset: 0x0006CAD8 public void SetPublicKey(byte[] publicKey) { if (publicKey == null) { this.flags ^= AssemblyNameFlags.PublicKey; } else { this.flags |= AssemblyNameFlags.PublicKey; } this.publicKey = publicKey; } /// Sets the public key token, which is the last 8 bytes of the SHA-1 hash of the public key under which the application or assembly is signed. /// A byte array containing the public key token of the assembly. // Token: 0x06001D9E RID: 7582 RVA: 0x0006E914 File Offset: 0x0006CB14 public void SetPublicKeyToken(byte[] publicKeyToken) { this.keyToken = publicKeyToken; } /// Gets serialization information with all of the data needed to recreate an instance of this AssemblyName. /// The object to be populated with serialization information. /// The destination context of the serialization. /// /// is null. // Token: 0x06001D9F RID: 7583 RVA: 0x0006E920 File Offset: 0x0006CB20 public void GetObjectData(SerializationInfo info, StreamingContext context) { if (info == null) { throw new ArgumentNullException("info"); } info.AddValue("_Name", this.name); info.AddValue("_PublicKey", this.publicKey); info.AddValue("_PublicKeyToken", this.keyToken); info.AddValue("_CultureInfo", (this.cultureinfo == null) ? (-1) : this.cultureinfo.LCID); info.AddValue("_CodeBase", this.codebase); info.AddValue("_Version", this.Version); info.AddValue("_HashAlgorithm", this.hashalg); info.AddValue("_HashAlgorithmForControl", AssemblyHashAlgorithm.None); info.AddValue("_StrongNameKeyPair", this.keypair); info.AddValue("_VersionCompatibility", this.versioncompat); info.AddValue("_Flags", this.flags); info.AddValue("_HashForControl", null); } /// Makes a copy of this AssemblyName object. /// An object that is a copy of this AssemblyName object. // Token: 0x06001DA0 RID: 7584 RVA: 0x0006EA2C File Offset: 0x0006CC2C public object Clone() { return new AssemblyName { name = this.name, codebase = this.codebase, major = this.major, minor = this.minor, build = this.build, revision = this.revision, version = this.version, cultureinfo = this.cultureinfo, flags = this.flags, hashalg = this.hashalg, keypair = this.keypair, publicKey = this.publicKey, keyToken = this.keyToken, versioncompat = this.versioncompat }; } /// Implements the interface and is called back by the deserialization event when deserialization is complete. /// The source of the deserialization event. // Token: 0x06001DA1 RID: 7585 RVA: 0x0006EAE8 File Offset: 0x0006CCE8 public void OnDeserialization(object sender) { this.Version = this.version; } /// Gets the AssemblyName for a given file. /// An AssemblyName object representing the given file. /// The path for the assembly whose AssemblyName is to be returned. /// /// is null. /// /// is invalid, such as an assembly with an invalid culture. /// /// is not found. /// The caller does not have path discovery permission. /// /// is not a valid assembly. /// An assembly or module was loaded twice with two different sets of evidence. /// /// /// // Token: 0x06001DA2 RID: 7586 RVA: 0x0006EAF8 File Offset: 0x0006CCF8 public static AssemblyName GetAssemblyName(string assemblyFile) { if (assemblyFile == null) { throw new ArgumentNullException("assemblyFile"); } AssemblyName assemblyName = new AssemblyName(); Assembly.InternalGetAssemblyName(Path.GetFullPath(assemblyFile), assemblyName); return assemblyName; } // Token: 0x040009EB RID: 2539 private string name; // Token: 0x040009EC RID: 2540 private string codebase; // Token: 0x040009ED RID: 2541 private int major; // Token: 0x040009EE RID: 2542 private int minor; // Token: 0x040009EF RID: 2543 private int build; // Token: 0x040009F0 RID: 2544 private int revision; // Token: 0x040009F1 RID: 2545 private CultureInfo cultureinfo; // Token: 0x040009F2 RID: 2546 private AssemblyNameFlags flags; // Token: 0x040009F3 RID: 2547 private AssemblyHashAlgorithm hashalg; // Token: 0x040009F4 RID: 2548 private StrongNameKeyPair keypair; // Token: 0x040009F5 RID: 2549 private byte[] publicKey; // Token: 0x040009F6 RID: 2550 private byte[] keyToken; // Token: 0x040009F7 RID: 2551 private AssemblyVersionCompatibility versioncompat; // Token: 0x040009F8 RID: 2552 private Version version; // Token: 0x040009F9 RID: 2553 private ProcessorArchitecture processor_architecture; } }