Beispiel #1
0
		public static uint WriteCompressedUInt32(this BinaryWriter writer, IWriterError helper, uint value) {
			if (value > 0x1FFFFFFF) {
				helper.Error("UInt32 value is too big and can't be compressed");
				value = 0x1FFFFFFF;
			}
			writer.WriteCompressedUInt32(value);
			return value;
		}
Beispiel #2
0
		public static void Write(this BinaryWriter writer, IWriterError helper, UTF8String s) {
			if (UTF8String.IsNull(s)) {
				helper.Error("UTF8String is null");
				s = UTF8String.Empty;
			}

			writer.WriteCompressedUInt32(helper, (uint)s.DataLength);
			writer.Write(s.Data);
		}
Beispiel #3
0
		public static int WriteCompressedInt32(this BinaryWriter writer, IWriterError helper, int value) {
			if (value < -0x10000000) {
				helper.Error("Int32 value is too small and can't be compressed.");
				value = -0x10000000;
			}
			else if (value > 0x0FFFFFFF) {
				helper.Error("Int32 value is too big and can't be compressed.");
				value = 0x0FFFFFFF;
			}
			writer.WriteCompressedInt32(value);
			return value;
		}
 DeclSecurityWriter(ModuleDef module, IWriterError helper, DataWriterContext context)
 {
     this.module  = module;
     this.helper  = helper;
     this.context = context;
 }
 internal static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper, DataWriterContext context) =>
 new DeclSecurityWriter(module, helper, context).Write(secAttrs);
 /// <summary>
 /// Creates a <c>DeclSecurity</c> blob from <paramref name="secAttrs"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="secAttrs">List of <see cref="SecurityAttribute"/>s</param>
 /// <param name="helper">Helps this class</param>
 /// <returns>A <c>DeclSecurity</c> blob</returns>
 public static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper) =>
 new DeclSecurityWriter(module, helper, null).Write(secAttrs);
Beispiel #7
0
		/// <summary>
		/// Creates a field marshal blob from <paramref name="marshalType"/>
		/// </summary>
		/// <param name="module">Owner module</param>
		/// <param name="marshalType">Marshal type</param>
		/// <param name="helper">Helps this class</param>
		/// <returns>A field marshal blob or <c>null</c> if <paramref name="marshalType"/> is
		/// <c>null</c></returns>
		public static byte[] Write(ModuleDef module, MarshalType marshalType, IWriterError helper) {
			using (var writer = new MarshalBlobWriter(module, helper))
				return writer.Write(marshalType);
		}
Beispiel #8
0
		/// <summary>
		/// Creates a <c>DeclSecurity</c> blob from <paramref name="secAttrs"/>
		/// </summary>
		/// <param name="module">Owner module</param>
		/// <param name="secAttrs">List of <see cref="SecurityAttribute"/>s</param>
		/// <param name="helper">Helps this class</param>
		/// <returns>A <c>DeclSecurity</c> blob</returns>
		public static byte[] Write(ModuleDef module, IList<SecurityAttribute> secAttrs, IWriterError helper) {
			return new DeclSecurityWriter(module, helper).Write(secAttrs);
		}
Beispiel #9
0
 internal static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper, bool optimizeCustomAttributeSerializedTypeNames, DataWriterContext context) =>
 new DeclSecurityWriter(module, helper, optimizeCustomAttributeSerializedTypeNames, context).Write(secAttrs);
 LocalConstantSigBlobWriter(IWriterError helper, Metadata systemMetadata)
 {
     this.helper         = helper;
     this.systemMetadata = systemMetadata;
 }
 private DeclSecurityWriter(ModuleDef module, IWriterError helper)
 {
     this.module = module;
     this.helper = helper;
 }
 /// <summary>
 /// Creates a <c>DeclSecurity</c> blob from <paramref name="secAttrs"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="secAttrs">List of <see cref="SecurityAttribute"/>s</param>
 /// <param name="helper">Helps this class</param>
 /// <returns>A <c>DeclSecurity</c> blob</returns>
 public static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper)
 {
     return(new DeclSecurityWriter(module, helper).Write(secAttrs));
 }
Beispiel #13
0
 /// <summary>
 /// Creates a field marshal blob from <paramref name="marshalType"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="marshalType">Marshal type</param>
 /// <param name="helper">Helps this class</param>
 /// <param name="optimizeCustomAttributeSerializedTypeNames">Optimize serialized type strings in custom attributes.
 /// For more info, see <see cref="MetadataFlags.OptimizeCustomAttributeSerializedTypeNames"/></param>
 /// <returns>A field marshal blob or <c>null</c> if <paramref name="marshalType"/> is
 /// <c>null</c></returns>
 public static byte[] Write(ModuleDef module, MarshalType marshalType, IWriterError helper, bool optimizeCustomAttributeSerializedTypeNames)
 {
     using (var writer = new MarshalBlobWriter(module, helper, optimizeCustomAttributeSerializedTypeNames))
         return(writer.Write(marshalType));
 }
Beispiel #14
0
 /// <summary>
 /// Creates a <c>DeclSecurity</c> blob from <paramref name="secAttrs"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="secAttrs">List of <see cref="SecurityAttribute"/>s</param>
 /// <param name="helper">Helps this class</param>
 /// <returns>A <c>DeclSecurity</c> blob</returns>
 public static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper) =>
 Write(module, secAttrs, helper, false);
        public static void Write(IWriterError helper, Metadata systemMetadata, DataWriter writer, TypeSig type, object value)
        {
            var sigWriter = new LocalConstantSigBlobWriter(helper, systemMetadata);

            sigWriter.Write(writer, type, value);
        }
Beispiel #16
0
 /// <summary>
 /// Creates a <c>DeclSecurity</c> blob from <paramref name="secAttrs"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="secAttrs">List of <see cref="SecurityAttribute"/>s</param>
 /// <param name="helper">Helps this class</param>
 /// <param name="optimizeCustomAttributeSerializedTypeNames">Optimize serialized type strings in custom attributes.
 /// For more info, see <see cref="MetadataFlags.OptimizeCustomAttributeSerializedTypeNames"/></param>
 /// <returns>A <c>DeclSecurity</c> blob</returns>
 public static byte[] Write(ModuleDef module, IList <SecurityAttribute> secAttrs, IWriterError helper, bool optimizeCustomAttributeSerializedTypeNames) =>
 new DeclSecurityWriter(module, helper, optimizeCustomAttributeSerializedTypeNames, null).Write(secAttrs);
 public SerializerMethodContext(IWriterError helper)
 {
     toOffset    = new Dictionary <Instruction, uint>();
     this.helper = helper;
 }
Beispiel #18
0
 /// <summary>
 /// Creates a field marshal blob from <paramref name="marshalType"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="marshalType">Marshal type</param>
 /// <param name="helper">Helps this class</param>
 /// <returns>A field marshal blob or <c>null</c> if <paramref name="marshalType"/> is
 /// <c>null</c></returns>
 public static byte[] Write(ModuleDef module, MarshalType marshalType, IWriterError helper) =>
 Write(module, marshalType, helper, false);
Beispiel #19
0
 ImportScopeBlobWriter(IWriterError helper, Metadata systemMetadata, BlobHeap blobHeap)
 {
     this.helper         = helper;
     this.systemMetadata = systemMetadata;
     this.blobHeap       = blobHeap;
 }
Beispiel #20
0
		DeclSecurityWriter(ModuleDef module, IWriterError helper) {
			this.module = module;
			this.helper = helper;
		}
Beispiel #21
0
        public static void Write(IWriterError helper, Metadata systemMetadata, DataWriter writer, BlobHeap blobHeap, IList <PdbImport> imports)
        {
            var blobWriter = new ImportScopeBlobWriter(helper, systemMetadata, blobHeap);

            blobWriter.Write(writer, imports);
        }
Beispiel #22
0
		MarshalBlobWriter(ModuleDef module, IWriterError helper) {
			this.module = module;
			this.outStream = new MemoryStream();
			this.writer = new BinaryWriter(outStream);
			this.helper = helper;
		}
Beispiel #23
0
 /// <summary>
 /// Creates a field marshal blob from <paramref name="marshalType"/>
 /// </summary>
 /// <param name="module">Owner module</param>
 /// <param name="marshalType">Marshal type</param>
 /// <param name="helper">Helps this class</param>
 /// <returns>A field marshal blob or <c>null</c> if <paramref name="marshalType"/> is
 /// <c>null</c></returns>
 public static byte[] Write(ModuleDef module, MarshalType marshalType, IWriterError helper)
 {
     using (var writer = new MarshalBlobWriter(module, helper))
         return(writer.Write(marshalType));
 }