コード例 #1
0
 /// <summary>
 /// Reads a signature from the #Blob stream
 /// </summary>
 /// <param name="readerModule">Reader module</param>
 /// <param name="sig">#Blob stream offset of signature</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CallingConventionSig"/> instance or <c>null</c> if
 /// <paramref name="sig"/> is invalid.</returns>
 public static CallingConventionSig ReadSig(ModuleDefMD readerModule, uint sig, GenericParamContext gpContext)
 {
     try {
         var reader = new SignatureReader(readerModule, sig, gpContext);
         if (reader.reader.Length == 0)
         {
             return(null);
         }
         var csig = reader.ReadSig();
         if (csig is not null)
         {
             csig.ExtraData = reader.GetExtraData();
         }
         return(csig);
     }
     catch {
         return(null);
     }
 }
コード例 #2
0
 /// <summary>
 /// Reads a <see cref="TypeSig"/> signature
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="signature">The signature reader</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <param name="extraData">If there's any extra data after the signature, it's saved
 /// here, else this will be <c>null</c></param>
 /// <returns>A new <see cref="TypeSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static TypeSig ReadTypeSig(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, DataReader signature, GenericParamContext gpContext, out byte[] extraData)
 {
     try {
         var     reader = new SignatureReader(helper, corLibTypes, ref signature, gpContext);
         TypeSig ts;
         try {
             ts = reader.ReadType();
         }
         catch (IOException) {
             reader.reader.Position = 0;
             ts = null;
         }
         extraData = reader.GetExtraData();
         return(ts);
     }
     catch {
         extraData = null;
         return(null);
     }
 }
コード例 #3
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="reader">The signature data</param>
 /// <param name="gpContext">Generic parameter context</param>
 SignatureReader(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, ref DataReader reader, GenericParamContext gpContext)
 {
     this.helper      = helper;
     this.corLibTypes = corLibTypes;
     this.reader      = reader;
     this.gpContext   = gpContext;
     recursionCounter = new RecursionCounter();
 }
コード例 #4
0
 /// <summary>
 /// Reads a <see cref="TypeSig"/> signature
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="signature">The signature reader</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="TypeSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static TypeSig ReadTypeSig(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, DataReader signature, GenericParamContext gpContext) =>
 ReadTypeSig(helper, corLibTypes, signature, gpContext, out var extraData);
コード例 #5
0
 /// <summary>
 /// Reads a <see cref="TypeSig"/> signature
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="signature">The signature data</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <param name="extraData">If there's any extra data after the signature, it's saved
 /// here, else this will be <c>null</c></param>
 /// <returns>A new <see cref="TypeSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static TypeSig ReadTypeSig(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, byte[] signature, GenericParamContext gpContext, out byte[] extraData) =>
 ReadTypeSig(helper, corLibTypes, ByteArrayDataReaderFactory.CreateReader(signature), gpContext, out extraData);
コード例 #6
0
 /// <summary>
 /// Reads a <see cref="TypeSig"/> signature
 /// </summary>
 /// <param name="module">The module where the signature is located in</param>
 /// <param name="signature">The signature data</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="TypeSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static TypeSig ReadTypeSig(ModuleDefMD module, byte[] signature, GenericParamContext gpContext) =>
 ReadTypeSig(module, module.CorLibTypes, ByteArrayDataReaderFactory.CreateReader(signature), gpContext);
コード例 #7
0
 /// <summary>
 /// Reads a <see cref="TypeSig"/> signature
 /// </summary>
 /// <param name="module">The module where the signature is located in</param>
 /// <param name="signature">The signature reader</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="TypeSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static TypeSig ReadTypeSig(ModuleDefMD module, DataReader signature, GenericParamContext gpContext) =>
 ReadTypeSig(module, module.CorLibTypes, signature, gpContext);
コード例 #8
0
 /// <summary>
 /// Reads a <see cref="CallingConventionSig"/> signature
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="signature">The signature data</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CallingConventionSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static CallingConventionSig ReadSig(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, byte[] signature, GenericParamContext gpContext) =>
 ReadSig(helper, corLibTypes, ByteArrayDataReaderFactory.CreateReader(signature), gpContext);
コード例 #9
0
 /// <summary>
 /// Reads a <see cref="CallingConventionSig"/> signature
 /// </summary>
 /// <param name="helper">Token resolver</param>
 /// <param name="corLibTypes">A <see cref="ICorLibTypes"/> instance</param>
 /// <param name="signature">The signature reader</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CallingConventionSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static CallingConventionSig ReadSig(ISignatureReaderHelper helper, ICorLibTypes corLibTypes, DataReader signature, GenericParamContext gpContext)
 {
     try {
         var reader = new SignatureReader(helper, corLibTypes, ref signature, gpContext);
         if (reader.reader.Length == 0)
         {
             return(null);
         }
         return(reader.ReadSig());
     }
     catch {
         return(null);
     }
 }
コード例 #10
0
 /// <summary>
 /// Reads a <see cref="CallingConventionSig"/> signature
 /// </summary>
 /// <param name="module">The module where the signature is located in</param>
 /// <param name="signature">The signature reader</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A new <see cref="CallingConventionSig"/> instance or <c>null</c> if
 /// <paramref name="signature"/> is invalid.</returns>
 public static CallingConventionSig ReadSig(ModuleDefMD module, DataReader signature, GenericParamContext gpContext) =>
 ReadSig(module, module.CorLibTypes, signature, gpContext);
コード例 #11
0
 DeclSecurityReader(ModuleDef module, DataReader reader, GenericParamContext gpContext)
 {
     this.reader    = reader;
     this.module    = module;
     this.gpContext = gpContext;
 }
コード例 #12
0
        /// <summary>
        /// Reads a <c>DeclSecurity</c> blob
        /// </summary>
        /// <param name="module">Module that will own the returned list</param>
        /// <param name="signature"><c>DeclSecurity</c> stream that will be owned by us</param>
        /// <param name="gpContext">Generic parameter context</param>
        /// <returns>A list of <see cref="SecurityAttribute"/>s</returns>
        public static IList <SecurityAttribute> Read(ModuleDef module, DataReader signature, GenericParamContext gpContext)
        {
            var reader = new DeclSecurityReader(module, signature, gpContext);

            return(reader.Read());
        }
コード例 #13
0
 /// <summary>
 /// Reads a <c>DeclSecurity</c> blob
 /// </summary>
 /// <param name="module">Module that will own the returned list</param>
 /// <param name="blob"><c>DeclSecurity</c> blob</param>
 /// <param name="gpContext">Generic parameter context</param>///
 /// <returns>A list of <see cref="SecurityAttribute"/>s</returns>
 public static IList <SecurityAttribute> Read(ModuleDef module, byte[] blob, GenericParamContext gpContext) => Read(module, ByteArrayDataReaderFactory.CreateReader(blob), gpContext);
コード例 #14
0
 /// <summary>
 /// Reads a <c>DeclSecurity</c> blob
 /// </summary>
 /// <param name="module">Module that will own the returned list</param>
 /// <param name="sig"><c>#Blob</c> offset of <c>DeclSecurity</c> signature</param>
 /// <param name="gpContext">Generic parameter context</param>
 /// <returns>A list of <see cref="SecurityAttribute"/>s</returns>
 public static IList <SecurityAttribute> Read(ModuleDefMD module, uint sig, GenericParamContext gpContext) => Read(module, module.BlobStream.CreateReader(sig), gpContext);