当前位置: 首页>>代码示例>>C#>>正文


C# BinaryWriter.WriteZeros方法代码示例

本文整理汇总了C#中System.IO.BinaryWriter.WriteZeros方法的典型用法代码示例。如果您正苦于以下问题:C# BinaryWriter.WriteZeros方法的具体用法?C# BinaryWriter.WriteZeros怎么用?C# BinaryWriter.WriteZeros使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.IO.BinaryWriter的用法示例。


在下文中一共展示了BinaryWriter.WriteZeros方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Write

 public void Write(Stream output)
 {
     BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);
     writer.Write(StringOffset);
     writer.WriteZeros(4);
     writer.Write(StringLength);
     writer.WriteZeros(4);
 }
开发者ID:Last-Bullet-Development,项目名称:GzsTool,代码行数:8,代码来源:FpkString.cs

示例2: Write

        public void Write(Stream outputStream)
        {
            BinaryWriter writer = new BinaryWriter(outputStream, Encoding.Default, true);
            writer.Write(Encoding.Default.GetBytes(Signature));
            writer.Write(LittleEndianMagicNumber);
            writer.Write((byte) Entries.Count);
            writer.WriteZeros(1);
            writer.Write(FfntHeaderSize);
            writer.AlignWrite(16, 0x00);

            long entryHeaderPosition = outputStream.Position;

            outputStream.Position += Entries.Count*FfntEntryHeader.FfntEntryHeaderSize;
            writer.AlignWrite(16, 0x00);

            List<FfntEntryHeader> ffntEntryHeaders = new List<FfntEntryHeader>();

            foreach (var entry in Entries)
            {
                ffntEntryHeaders.Add(entry.GetHeader(outputStream));
                entry.Write(outputStream);
                writer.AlignWrite(16, 0x00);
            }

            outputStream.Position = entryHeaderPosition;

            foreach (var header in ffntEntryHeaders)
            {
                header.Write(outputStream);
            }
        }
开发者ID:kkkkyue,项目名称:FoxEngine.TranslationTool,代码行数:31,代码来源:FfntFile.cs

示例3: WriteAlign

		static void WriteAlign(BinaryWriter writer, ref uint offs) {
			uint align = Utils.AlignUp(offs, HH_ALIGNMENT) - offs;
			offs += align;
			writer.WriteZeros((int)align);
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:5,代码来源:HotHeap.cs

示例4: Serialize

        public void Serialize(uint token, uint key, byte[] fieldLayout)
        {
            using (var ms = new MemoryStream()) {
                var writer = new BinaryWriter(ms);
                foreach (byte i in fieldLayout)
                    switch (i) {
                        case 0:
                            writer.Write((uint)ILCode.Length);
                            break;
                        case 1:
                            writer.Write(MaxStack);
                            break;
                        case 2:
                            writer.Write((uint)EHs.Length);
                            break;
                        case 3:
                            writer.Write((uint)LocalVars.Length);
                            break;
                        case 4:
                            writer.Write(Options);
                            break;
                        case 5:
                            writer.Write(MulSeed);
                            break;
                    }

                writer.Write(ILCode);
                writer.Write(LocalVars);
                foreach (JITEHClause clause in EHs) {
                    writer.Write(clause.Flags);
                    writer.Write(clause.TryOffset);
                    writer.Write(clause.TryLength);
                    writer.Write(clause.HandlerOffset);
                    writer.Write(clause.HandlerLength);
                    writer.Write(clause.ClassTokenOrFilterOffset);
                }
                writer.WriteZeros(4 - ((int)ms.Length & 3)); // pad to 4 bytes
                Body = ms.ToArray();
            }
            Debug.Assert(Body.Length % 4 == 0);
            // encrypt body
            uint state = token * key;
            uint counter = state;
            for (uint i = 0; i < Body.Length; i += 4) {
                uint data = Body[i] | (uint)(Body[i + 1] << 8) | (uint)(Body[i + 2] << 16) | (uint)(Body[i + 3] << 24);
                Body[i + 0] ^= (byte)(state >> 0);
                Body[i + 1] ^= (byte)(state >> 8);
                Body[i + 2] ^= (byte)(state >> 16);
                Body[i + 3] ^= (byte)(state >> 24);
                state += data ^ counter;
                counter ^= (state >> 5) | (state << 27);
            }
        }
开发者ID:2sic4you,项目名称:ConfuserEx,代码行数:53,代码来源:JITBody.cs

示例5: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			RVA rva2 = rva;
			foreach (var resourceData in resources) {
				writer.Write(resourceData.GetFileLength());
				resourceData.VerifyWriteTo(writer);
				rva2 += 4 + resourceData.GetFileLength();
				int padding = (int)rva2.AlignUp(alignment) - (int)rva2;
				writer.WriteZeros(padding);
				rva2 += (uint)padding;
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:12,代码来源:NetResources.cs

示例6: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			WriteToImpl(writer);
			writer.WriteZeros((int)(Utils.AlignUp(GetRawLength(), ALIGNMENT) - GetRawLength()));
		}
开发者ID:Excelion,项目名称:dnlib,代码行数:5,代码来源:HeapBase.cs

示例7: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			writer.Write(code);
			if (HasExtraSections) {
				RVA rva2 = rva + (uint)code.Length;
				writer.WriteZeros((int)rva2.AlignUp(EXTRA_SECTIONS_ALIGNMENT) - (int)rva2);
				writer.Write(extraSections);
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:9,代码来源:MethodBody.cs

示例8: Write

 public void Write(Stream output)
 {
     BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);
     writer.Write(DataOffset);
     writer.WriteZeros(4);
     writer.Write(DataSize);
     writer.WriteZeros(4);
     FilePathFpkString.Write(output);
     writer.Write(Md5Hash);
 }
开发者ID:engrin,项目名称:GzsTool,代码行数:10,代码来源:FpkEntry.cs

示例9: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			uint offset = 0;

			// The order here must be the same as in SetOffset()

			foreach (var dir in dirList) {
				uint padding = Utils.AlignUp(offset, RESOURCE_DIR_ALIGNMENT) - offset;
				writer.WriteZeros((int)padding);
				offset += padding;
				if (dirDict[dir] != offset)
					throw new ModuleWriterException("Invalid Win32 resource directory offset");
				offset += WriteTo(writer, dir);
			}

			foreach (var dataHeader in dataHeaderList) {
				uint padding = Utils.AlignUp(offset, RESOURCE_DATA_HEADER_ALIGNMENT) - offset;
				writer.WriteZeros((int)padding);
				offset += padding;
				if (dataHeaderDict[dataHeader] != offset)
					throw new ModuleWriterException("Invalid Win32 resource data header offset");
				offset += WriteTo(writer, dataHeader);
			}

			foreach (var s in stringsList) {
				uint padding = Utils.AlignUp(offset, RESOURCE_STRING_ALIGNMENT) - offset;
				writer.WriteZeros((int)padding);
				offset += padding;
				if (stringsDict[s] != offset)
					throw new ModuleWriterException("Invalid Win32 resource string offset");

				var bytes = Encoding.Unicode.GetBytes(s);
				if (bytes.Length / 2 > ushort.MaxValue)
					throw new ModuleWriterException("Win32 resource entry name is too long");
				writer.Write((ushort)(bytes.Length / 2));
				writer.Write(bytes);
				offset += 2 + (uint)bytes.Length;
			}

			byte[] dataBuffer = new byte[0x2000];
			foreach (var data in dataList) {
				uint padding = Utils.AlignUp(offset, RESOURCE_DATA_ALIGNMENT) - offset;
				writer.WriteZeros((int)padding);
				offset += padding;
				if (dataDict[data] != offset)
					throw new ModuleWriterException("Invalid Win32 resource data offset");

				data.Position = 0;
				offset += data.WriteTo(writer, dataBuffer);
			}

			writer.WriteZeros((int)(Utils.AlignUp(length, ModuleWriterBase.DEFAULT_WIN32_RESOURCES_ALIGNMENT) - length));
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:53,代码来源:Win32ResourcesChunk.cs

示例10: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			writer.Write(options.Signature ?? MetaDataHeaderOptions.DEFAULT_SIGNATURE);
			writer.Write(options.MajorVersion ?? 1);
			writer.Write(options.MinorVersion ?? 1);
			writer.Write(options.Reserved1 ?? 0);
			var s = GetVersionString();
			writer.Write(Utils.AlignUp(s.Length, 4));
			writer.Write(s);
			writer.WriteZeros(Utils.AlignUp(s.Length, 4) - s.Length);
			writer.Write((byte)(options.StorageFlags ?? 0));
			writer.Write(options.Reserved2 ?? 0);
			writer.Write((ushort)heaps.Count);
			foreach (var heap in heaps) {
				writer.Write((uint)(heap.FileOffset - offset));
				writer.Write(heap.GetFileLength());
				writer.Write(s = GetAsciizName(heap.Name));
				if (s.Length > 32)
					throw new ModuleWriterException(string.Format("Heap name '{0}' is > 32 bytes", heap.Name));
				writer.WriteZeros(Utils.AlignUp(s.Length, 4) - s.Length);
			}
		}
开发者ID:SAD1992,项目名称:justdecompile-plugins,代码行数:22,代码来源:MetaDataHeader.cs

示例11: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			writer.Write((uint)importLookupTableRVA);
			writer.Write(0);	// DateTimeStamp
			writer.Write(0);	// ForwarderChain
			writer.Write((uint)mscoreeDllRVA);	// Name
			writer.Write((uint)ImportAddressTable.RVA);
			writer.Write(0UL);
			writer.Write(0UL);
			writer.Write(0);

			// ImportLookupTable
			writer.Write((uint)corXxxMainRVA);
			writer.Write(0);

			writer.WriteZeros(stringsPadding);
			writer.Write((ushort)0);
			writer.Write(Encoding.UTF8.GetBytes(IsExeFile ? "_CorExeMain\0" : "_CorDllMain\0"));
			writer.Write(Encoding.UTF8.GetBytes("mscoree.dll\0"));

			writer.Write((byte)0);
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:22,代码来源:ImportDirectory.cs

示例12: FullWriteTo

		/// <summary>
		/// Writes the full table to the hot table
		/// </summary>
		/// <param name="writer">Writer</param>
		void FullWriteTo(BinaryWriter writer) {
			CreateFullData();

			var startPos = writer.BaseStream.Position;
			writer.Write(mdTable.Rows);	// hot records
			writer.Write(0);			// offset of 1st level table
			writer.Write(0);			// offset of 2nd level table
			if (version == HotHeapVersion.CLR40)
				writer.Write(0);		// offset of indexes table
			writer.Write(alignedHotTableHeaderSize);	// offset of hot data (4-byte aligned)
			writer.Write((ushort)0);	// shift count
			writer.WriteZeros(alignedHotTableHeaderSize - (int)(writer.BaseStream.Position - startPos));
			writer.Write(data);
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:18,代码来源:HotTable.cs

示例13: PartialWriteTo

		/// <inheritdoc/>
		internal override void PartialWriteTo(BinaryWriter writer) {
			var startPos = writer.BaseStream.Position;
			writer.Write(partialData.Count);// hot records
			writer.Write(firstLevelOffset);	// any alignment, all bits are used
			writer.Write(secondLevelOffset);// any alignment, all bits are used
			writer.Write(indexesOffset);// any alignment, all bits are used
			writer.Write(dataOffset);	// any alignment, all bits are used
			writer.Write((ushort)shift);// shift count
			writer.WriteZeros(alignedHotTableHeaderSize - (int)(writer.BaseStream.Position - startPos));

			uint offs;

			// Data
			offs = (uint)(writer.BaseStream.Position - startPos);
			writer.WriteZeros((int)(dataOffset - offs));
			WritePartialData(writer);

			// First level table
			offs = (uint)(writer.BaseStream.Position - startPos);
			writer.WriteZeros((int)(firstLevelOffset - offs));
			WriteFirstLevelTable(writer);

			// Second level table
			offs = (uint)(writer.BaseStream.Position - startPos);
			writer.WriteZeros((int)(secondLevelOffset - offs));
			WriteSecondLevelTable(writer);

			// Indexes table
			offs = (uint)(writer.BaseStream.Position - startPos);
			writer.WriteZeros((int)(indexesOffset - offs));
			WriteIndexesTable(writer);
		}
开发者ID:EmilZhou,项目名称:dnlib,代码行数:33,代码来源:HotTable.cs

示例14: WriteTo

		/// <inheritdoc/>
		public void WriteTo(BinaryWriter writer) {
			writer.WriteZeros((int)padding);
			writer.Write((byte)0xFF);
			writer.Write((byte)0x25);
			writer.Write((uint)PEHeaders.ImageBase + (uint)ImportDirectory.IatCorXxxMainRVA);
		}
开发者ID:GodLesZ,项目名称:ConfuserDeobfuscator,代码行数:7,代码来源:StartupStub.cs

示例15: Write

        public override void Write(Stream output, IDirectory inputDirectory)
        {
            BinaryWriter writer = new BinaryWriter(output, Encoding.Default, true);
            const int headerSize = 48;
            int indicesSize = 48*Entries.Count;
            int referenceSize = 16*References.Count;

            long startPosition = output.Position;
            output.Position += headerSize + indicesSize + referenceSize;

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteFilePath(output);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.WriteFilePath(output);
            }
            output.AlignWrite(16, 0x00);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.WriteData(output, inputDirectory);
                output.AlignWrite(16, 0x00);
            }

            uint fileSize = (uint) output.Position;

            output.Position = startPosition;

            writer.Write(0x66786f66); // foxf
            writer.Write((ushort) 0x6B70); //pk
            writer.Write((byte) FpkType);
            writer.Write((byte) 0x77); // w
            writer.Write((ushort) 0x6E69); // in
            writer.Write(fileSize);
            writer.WriteZeros(18);
            writer.Write(0x00000002);
            writer.Write(Entries.Count);
            writer.Write(References.Count);
            writer.WriteZeros(4);

            foreach (var fpkEntry in Entries)
            {
                fpkEntry.Write(output);
            }
            foreach (var fpkReference in References)
            {
                fpkReference.Write(output);
            }
        }
开发者ID:engrin,项目名称:GzsTool,代码行数:51,代码来源:FpkFile.cs


注:本文中的System.IO.BinaryWriter.WriteZeros方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。