public ImageCor20HeaderVM(HexBuffer buffer, HexPosition startOffset) { CbVM = new UInt32HexField(buffer, Name, "cb", startOffset + 0); MajorRuntimeVersionVM = new UInt16HexField(buffer, Name, "MajorRuntimeVersion", startOffset + 4, true); MinorRuntimeVersionVM = new UInt16HexField(buffer, Name, "MinorRuntimeVersion", startOffset + 6, true); MetaDataVM = new DataDirVM(buffer, Name, "MetaData", startOffset + 8); FlagsVM = new UInt32FlagsHexField(buffer, Name, "Flags", startOffset + 0x10); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_IL_Only, 0)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_32BitReqd, 1)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_ILLibrary, 2)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_StrongNameSigned, 3)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_NativeEntryPoint, 4)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_TrackDebugData, 16)); FlagsVM.Add(new BooleanHexBitField(dnSpy_AsmEditor_Resources.HexNode_Cor20Header_Flags_32BitPref, 17)); EntryPointTokenRVAVM = new UInt32HexField(buffer, Name, "EntryPoint Token/RVA", startOffset + 0x14); ResourcesVM = new DataDirVM(buffer, Name, "Resources", startOffset + 0x18); StrongNameSignatureVM = new DataDirVM(buffer, Name, "StrongNameSignature", startOffset + 0x20); CodeManagerTableVM = new DataDirVM(buffer, Name, "CodeManagerTable", startOffset + 0x28); VTableFixupsVM = new DataDirVM(buffer, Name, "VTableFixups", startOffset + 0x30); ExportAddressTableJumpsVM = new DataDirVM(buffer, Name, "ExportAddressTableJumps", startOffset + 0x38); ManagedNativeHeaderVM = new DataDirVM(buffer, Name, "ManagedNativeHeader", startOffset + 0x40); hexFields = new HexField[] { CbVM, MajorRuntimeVersionVM, MinorRuntimeVersionVM, MetaDataVM.RVAVM, MetaDataVM.SizeVM, FlagsVM, EntryPointTokenRVAVM, ResourcesVM.RVAVM, ResourcesVM.SizeVM, StrongNameSignatureVM.RVAVM, StrongNameSignatureVM.SizeVM, CodeManagerTableVM.RVAVM, CodeManagerTableVM.SizeVM, VTableFixupsVM.RVAVM, VTableFixupsVM.SizeVM, ExportAddressTableJumpsVM.RVAVM, ExportAddressTableJumpsVM.SizeVM, ManagedNativeHeaderVM.RVAVM, ManagedNativeHeaderVM.SizeVM, }; }
protected ImageOptionalHeaderVM(HexBuffer buffer, HexPosition startOffset, HexPosition endOffset, ulong offs1, ulong offs2) { MagicVM = new UInt16HexField(buffer, Name, "Magic", startOffset + 0); MajorLinkerVersionVM = new ByteHexField(buffer, Name, "MajorLinkerVersion", startOffset + 2, true); MinorLinkerVersionVM = new ByteHexField(buffer, Name, "MinorLinkerVersion", startOffset + 3, true); SizeOfCodeVM = new UInt32HexField(buffer, Name, "SizeOfCode", startOffset + 4); SizeOfInitializedDataVM = new UInt32HexField(buffer, Name, "SizeOfInitializedData", startOffset + 8); SizeOfUninitializedDataVM = new UInt32HexField(buffer, Name, "SizeOfUninitializedData", startOffset + 0x0C); AddressOfEntryPointVM = new UInt32HexField(buffer, Name, "AddressOfEntryPoint", startOffset + 0x10); BaseOfCodeVM = new UInt32HexField(buffer, Name, "BaseOfCode", startOffset + 0x14); SectionAlignmentVM = new UInt32HexField(buffer, Name, "SectionAlignment", startOffset + offs1 + 0); FileAlignmentVM = new UInt32HexField(buffer, Name, "FileAlignment", startOffset + offs1 + 4); MajorOperatingSystemVersionVM = new UInt16HexField(buffer, Name, "MajorOperatingSystemVersion", startOffset + offs1 + 8, true); MinorOperatingSystemVersionVM = new UInt16HexField(buffer, Name, "MinorOperatingSystemVersion", startOffset + offs1 + 0x0A, true); MajorImageVersionVM = new UInt16HexField(buffer, Name, "MajorImageVersion", startOffset + offs1 + 0x0C, true); MinorImageVersionVM = new UInt16HexField(buffer, Name, "MinorImageVersion", startOffset + offs1 + 0x0E, true); MajorSubsystemVersionVM = new UInt16HexField(buffer, Name, "MajorSubsystemVersion", startOffset + offs1 + 0x10, true); MinorSubsystemVersionVM = new UInt16HexField(buffer, Name, "MinorSubsystemVersion", startOffset + offs1 + 0x12, true); Win32VersionValueVM = new UInt32HexField(buffer, Name, "Win32VersionValue", startOffset + offs1 + 0x14, true); SizeOfImageVM = new UInt32HexField(buffer, Name, "SizeOfImage", startOffset + offs1 + 0x18); SizeOfHeadersVM = new UInt32HexField(buffer, Name, "SizeOfHeaders", startOffset + offs1 + 0x1C); CheckSumVM = new UInt32HexField(buffer, Name, "CheckSum", startOffset + offs1 + 0x20); SubsystemVM = new UInt16FlagsHexField(buffer, Name, "Subsystem", startOffset + offs1 + 0x24); SubsystemVM.Add(new IntegerHexBitField("Subsystem", 0, 16, SubsystemInfos)); DllCharacteristicsVM = new UInt16FlagsHexField(buffer, Name, "DllCharacteristics", startOffset + offs1 + 0x26); DllCharacteristicsVM.Add(new BooleanHexBitField("Reserved1", 0)); DllCharacteristicsVM.Add(new BooleanHexBitField("Reserved2", 1)); DllCharacteristicsVM.Add(new BooleanHexBitField("Reserved3", 2)); DllCharacteristicsVM.Add(new BooleanHexBitField("Reserved4", 3)); DllCharacteristicsVM.Add(new BooleanHexBitField("Reserved5", 4)); DllCharacteristicsVM.Add(new BooleanHexBitField("High Entropy VA", 5)); DllCharacteristicsVM.Add(new BooleanHexBitField("Dynamic Base", 6)); DllCharacteristicsVM.Add(new BooleanHexBitField("Force Integrity", 7)); DllCharacteristicsVM.Add(new BooleanHexBitField("NX Compat", 8)); DllCharacteristicsVM.Add(new BooleanHexBitField("No Isolation", 9)); DllCharacteristicsVM.Add(new BooleanHexBitField("No SEH", 10)); DllCharacteristicsVM.Add(new BooleanHexBitField("No Bind", 11)); DllCharacteristicsVM.Add(new BooleanHexBitField("AppContainer", 12)); DllCharacteristicsVM.Add(new BooleanHexBitField("WDM Driver", 13)); DllCharacteristicsVM.Add(new BooleanHexBitField("Guard CF", 14)); DllCharacteristicsVM.Add(new BooleanHexBitField("Terminal Server Aware", 15)); LoaderFlagsVM = new UInt32HexField(buffer, Name, "LoaderFlags", startOffset + offs2 + 0); NumberOfRvaAndSizesVM = new UInt32HexField(buffer, Name, "NumberOfRvaAndSizes", startOffset + offs2 + 4); ulong doffs = offs2 + 8; DataDir0VM = new DataDirVM(buffer, Name, "Export", startOffset + doffs + 0); DataDir1VM = new DataDirVM(buffer, Name, "Import", startOffset + doffs + 8); DataDir2VM = new DataDirVM(buffer, Name, "Resource", startOffset + doffs + 0x10); DataDir3VM = new DataDirVM(buffer, Name, "Exception", startOffset + doffs + 0x18); DataDir4VM = new DataDirVM(buffer, Name, "Security", startOffset + doffs + 0x20); DataDir5VM = new DataDirVM(buffer, Name, "Base Reloc", startOffset + doffs + 0x28); DataDir6VM = new DataDirVM(buffer, Name, "Debug", startOffset + doffs + 0x30); DataDir7VM = new DataDirVM(buffer, Name, "Architecture", startOffset + doffs + 0x38); DataDir8VM = new DataDirVM(buffer, Name, "Global Ptr", startOffset + doffs + 0x40); DataDir9VM = new DataDirVM(buffer, Name, "TLS", startOffset + doffs + 0x48); DataDir10VM = new DataDirVM(buffer, Name, "Load Config", startOffset + doffs + 0x50); DataDir11VM = new DataDirVM(buffer, Name, "Bound Import", startOffset + doffs + 0x58); DataDir12VM = new DataDirVM(buffer, Name, "IAT", startOffset + doffs + 0x60); DataDir13VM = new DataDirVM(buffer, Name, "Delay Import", startOffset + doffs + 0x68); DataDir14VM = new DataDirVM(buffer, Name, ".NET", startOffset + doffs + 0x70); DataDir15VM = new DataDirVM(buffer, Name, "Reserved15", startOffset + doffs + 0x78); }
protected void AddDataDirs(List<HexField> fields, HexPosition end) { var dataDirs = new DataDirVM[16] { DataDir0VM, DataDir1VM, DataDir2VM, DataDir3VM, DataDir4VM, DataDir5VM, DataDir6VM, DataDir7VM, DataDir8VM, DataDir9VM, DataDir10VM, DataDir11VM, DataDir12VM, DataDir13VM, DataDir14VM, DataDir15VM, }; var position = dataDirs[0].RVAVM.Span.Start; for (int i = 0; i < dataDirs.Length; i++) { var nextPosition = position + 8; if (nextPosition <= end) { fields.Add(dataDirs[i].RVAVM); fields.Add(dataDirs[i].SizeVM); } else dataDirs[i].IsVisible = false; position = nextPosition; } hexFields = fields.ToArray(); }