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


C# ModuleBuilder.GetTimeDateStamp方法代码示例

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


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

示例1: WriteModuleImpl


//.........这里部分代码省略.........
			// Export Directory
			if (code.ExportDirectoryLength != 0)
			{
				writer.Headers.OptionalHeader.DataDirectory[0].VirtualAddress = code.ExportDirectoryRVA;
				writer.Headers.OptionalHeader.DataDirectory[0].Size = code.ExportDirectoryLength;
			}

			// Import Directory
			if (code.ImportDirectoryLength != 0)
			{
				writer.Headers.OptionalHeader.DataDirectory[1].VirtualAddress = code.ImportDirectoryRVA;
				writer.Headers.OptionalHeader.DataDirectory[1].Size = code.ImportDirectoryLength;
			}

			// Import Address Table Directory
			if (code.ImportAddressTableLength != 0)
			{
				writer.Headers.OptionalHeader.DataDirectory[12].VirtualAddress = code.ImportAddressTableRVA;
				writer.Headers.OptionalHeader.DataDirectory[12].Size = code.ImportAddressTableLength;
			}

			// COM Descriptor Directory
			writer.Headers.OptionalHeader.DataDirectory[14].VirtualAddress = code.ComDescriptorRVA;
			writer.Headers.OptionalHeader.DataDirectory[14].Size = code.ComDescriptorLength;

			// Debug Directory
			if (code.DebugDirectoryLength != 0)
			{
				writer.Headers.OptionalHeader.DataDirectory[6].VirtualAddress = code.DebugDirectoryRVA;
				writer.Headers.OptionalHeader.DataDirectory[6].Size = code.DebugDirectoryLength;
			}

			// Set the PE File timestamp
			writer.Headers.FileHeader.TimeDateStamp = moduleBuilder.GetTimeDateStamp();

			// we need to start by computing the number of sections, because code.PointerToRawData depends on that
			writer.Headers.FileHeader.NumberOfSections = 2;

			if (moduleBuilder.initializedData.Length != 0)
			{
				// .sdata
				writer.Headers.FileHeader.NumberOfSections++;
			}

			if (resources != null)
			{
				// .rsrc
				writer.Headers.FileHeader.NumberOfSections++;
			}

			SectionHeader text = new SectionHeader();
			text.Name = ".text";
			text.VirtualAddress = code.BaseRVA;
			text.VirtualSize = (uint)code.Length;
			text.PointerToRawData = code.PointerToRawData;
			text.SizeOfRawData = writer.ToFileAlignment((uint)code.Length);
			text.Characteristics = SectionHeader.IMAGE_SCN_CNT_CODE | SectionHeader.IMAGE_SCN_MEM_EXECUTE | SectionHeader.IMAGE_SCN_MEM_READ;

			SectionHeader sdata = new SectionHeader();
			sdata.Name = ".sdata";
			sdata.VirtualAddress = text.VirtualAddress + writer.ToSectionAlignment(text.VirtualSize);
			sdata.VirtualSize = (uint)moduleBuilder.initializedData.Length;
			sdata.PointerToRawData = text.PointerToRawData + text.SizeOfRawData;
			sdata.SizeOfRawData = writer.ToFileAlignment((uint)moduleBuilder.initializedData.Length);
			sdata.Characteristics = SectionHeader.IMAGE_SCN_CNT_INITIALIZED_DATA | SectionHeader.IMAGE_SCN_MEM_READ | SectionHeader.IMAGE_SCN_MEM_WRITE;
开发者ID:JokerMisfits,项目名称:linux-packaging-mono,代码行数:66,代码来源:ModuleWriter.cs


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