--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public class BadImageException : Exception {\r
+\r
+ public BadImageException() : base()\r
+ {\r
+ }\r
+\r
+ public BadImageException(string msg) : base(msg)\r
+ {\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// IMAGE_FILE_HEADER\r
+ /// </summary>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct COFFHeader {\r
+\r
+ internal MachineId machine;\r
+ internal short sections;\r
+ internal uint tdStampRaw;\r
+ internal uint symTabPtr;\r
+ internal uint numSymbols;\r
+ internal short optHeaderSize;\r
+ internal Characteristics characteristics;\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Machine identifier.\r
+ /// </summary>\r
+ public MachineId Machine {\r
+ get {\r
+ return machine;\r
+ }\r
+ set {\r
+ machine = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public short NumberOfSections {\r
+ get {\r
+ return sections;\r
+ }\r
+ set {\r
+ sections = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public uint TimeDateStamp {\r
+ get {\r
+ return tdStampRaw;\r
+ }\r
+ set {\r
+ tdStampRaw = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public DateTime TimeStamp {\r
+ get {\r
+ return (new DateTime(1970, 1, 1) +\r
+ TimeSpan.FromSeconds(tdStampRaw)).ToLocalTime();\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public uint PointerToSymbolTable {\r
+ get {\r
+ return symTabPtr;\r
+ }\r
+ set {\r
+ symTabPtr = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public uint NumberOfSymbols {\r
+ get {\r
+ return numSymbols;\r
+ }\r
+ set {\r
+ numSymbols = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public short SizeOfOptionalHeader {\r
+ get {\r
+ return optHeaderSize;\r
+ }\r
+ set {\r
+ optHeaderSize = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public Characteristics Characteristics {\r
+ get {\r
+ return characteristics;\r
+ }\r
+ set {\r
+ characteristics = value;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public void Read(BinaryReader reader) {\r
+ fixed (void* pThis = &this) {\r
+ PEUtils.ReadStruct(reader, pThis, sizeof (COFFHeader), typeof (COFFHeader));\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <param name="writer"></param>\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine(\r
+ "Machine ID : {0}" + Environment.NewLine +\r
+ "Sections : {1}" + Environment.NewLine +\r
+ "timestamp : {2}" + Environment.NewLine +\r
+ "Characteristics : {3}" + Environment.NewLine,\r
+ machine, sections,\r
+ TimeStamp + " (" + tdStampRaw.ToString("X") + ")",\r
+ characteristics + " (0x" + characteristics.ToString("X") + ")"\r
+ );\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+\r
+\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ [Flags]\r
+ public enum Characteristics : ushort {\r
+\r
+\r
+ /// <summary>\r
+ /// Relocation info stripped from file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_RELOCS_STRIPPED\r
+ /// </remarks>\r
+ RELOCS_STRIPPED = 0x0001,\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// File is executable\r
+ /// (i.e. file is neither object file nor library file,\r
+ /// so there are no unresolved externel references).\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_EXECUTABLE_IMAGE\r
+ /// </remarks>\r
+ EXECUTABLE_IMAGE = 0x0002,\r
+\r
+\r
+ /// <summary>\r
+ /// Line nunbers stripped from file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_LINE_NUMS_STRIPPED\r
+ /// </remarks>\r
+ LINE_NUMS_STRIPPED = 0x0004,\r
+\r
+\r
+ /// <summary>\r
+ /// Local symbols stripped from file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_LOCAL_SYMS_STRIPPED\r
+ /// </remarks>\r
+ LOCAL_SYMS_STRIPPED = 0x0008,\r
+\r
+\r
+ /// <summary>\r
+ /// Agressively trim working set\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_AGGRESIVE_WS_TRIM\r
+ /// </remarks>\r
+ AGGRESIVE_WS_TRIM = 0x0010,\r
+\r
+\r
+ /// <summary>\r
+ /// App can handle >2gb addresses\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_LARGE_ADDRESS_AWARE\r
+ /// </remarks>\r
+ LARGE_ADDRESS_AWARE = 0x0020,\r
+\r
+\r
+ /// <summary>\r
+ /// Bytes of machine word are reversed.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_BYTES_REVERSED_LO\r
+ /// </remarks>\r
+ BYTES_REVERSED_LO = 0x0080,\r
+\r
+\r
+ /// <summary>\r
+ /// 32 bit word machine.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_32BIT_MACHINE\r
+ /// </remarks>\r
+ MACHINE_32BIT = 0x0100,\r
+\r
+\r
+ /// <summary>\r
+ /// Debugging info stripped from file in .DBG file\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_DEBUG_STRIPPED\r
+ /// </remarks>\r
+ DEBUG_STRIPPED = 0x0200,\r
+\r
+\r
+ /// <summary>\r
+ /// If Image is on removable media, copy and run from the swap file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP\r
+ /// </remarks>\r
+ REMOVABLE_RUN_FROM_SWAP = 0x0400,\r
+\r
+\r
+ /// <summary>\r
+ /// If Image is on Net, copy and run from the swap file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_NET_RUN_FROM_SWAP\r
+ /// </remarks>\r
+ NET_RUN_FROM_SWAP = 0x0800,\r
+\r
+\r
+ /// <summary>\r
+ /// This flag is used to indicate that the file\r
+ /// is a system sile, such as device driver.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_SYSTEM\r
+ /// </remarks>\r
+ SYSTEM = 0x1000,\r
+\r
+\r
+ /// <summary>\r
+ /// This flag indicates that the file\r
+ /// is a dynamic library (DLL).\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_DLL\r
+ /// </remarks>\r
+ DLL = 0x2000,\r
+\r
+\r
+ /// <summary>\r
+ /// File should only be run on a uni-processor (UP) machine.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_UP_SYSTEM_ONLY\r
+ /// </remarks>\r
+ UP_SYSTEM_ONLY = 0x4000,\r
+\r
+\r
+ /// <summary>\r
+ /// Bytes of machine word are reversed.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_BYTES_REVERSED_HI\r
+ /// </remarks>\r
+ BYTES_REVERSED_HI = 0x8000,\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Default flags that must be set in CIL-only image.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, 24.2.2.1\r
+ /// </remarks>\r
+ CIL_DEFAULT = LINE_NUMS_STRIPPED |\r
+ LOCAL_SYMS_STRIPPED |\r
+ DEBUG_STRIPPED\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+// see http://cvs.winehq.com/cvsweb/wine/dlls/imagehlp/modify.c\r
+// starting from Revision 1.8\r
+\r
+using System;\r
+using System.IO;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public sealed class CheckSum {\r
+\r
+ private CheckSum()\r
+ {\r
+ // Never instantiated.\r
+ }\r
+\r
+\r
+ public static uint Calc(string peFile)\r
+ {\r
+ uint res = 0;\r
+\r
+ FileInfo pe = new FileInfo(peFile);\r
+ if (!pe.Exists) {\r
+ throw new Exception("CheckSum : Invalid file path.");\r
+ }\r
+\r
+ using (BinaryReader reader = new BinaryReader(pe.OpenRead())) {\r
+ if (!reader.BaseStream.CanSeek) {\r
+ throw new Exception("Can't seek.");\r
+ }\r
+\r
+ DOSHeader dosHdr = new DOSHeader();\r
+ COFFHeader coffHdr = new COFFHeader();\r
+ PEHeader peHdr = new PEHeader();\r
+\r
+ dosHdr.Read (reader);\r
+ reader.BaseStream.Position = dosHdr.lfanew;\r
+ ExeSignature peSig = (ExeSignature) reader.ReadUInt16();\r
+ if (peSig != ExeSignature.NT) {\r
+ throw new BadImageException("Checksum : Invalid image format, cannot find PE signature.");\r
+ }\r
+ \r
+ peSig = (ExeSignature) reader.ReadUInt16();\r
+ if (peSig != ExeSignature.NT2) {\r
+ throw new BadImageException("Checksum : Invalid image format, cannot find PE signature.");\r
+ }\r
+\r
+ coffHdr.Read(reader);\r
+ peHdr.Read(reader);\r
+\r
+ uint oldSum = peHdr.CheckSum;\r
+ reader.BaseStream.Position = 0;\r
+ long len = pe.Length;\r
+ long whole = len >> 1;\r
+ uint sum = 0;\r
+ uint hi, lo;\r
+ for (long i = whole; --i >= 0;) {\r
+ sum += reader.ReadUInt16();\r
+ hi = sum >> 16;\r
+ if (hi != 0) {\r
+ sum = hi + (sum & 0xFFFF);\r
+ }\r
+ }\r
+ if ((len & 1L) != 0) {\r
+ sum += (uint) reader.ReadByte();\r
+ hi = sum >> 16;\r
+ if (hi != 0) {\r
+ sum = hi + (sum & 0xFFFF);\r
+ }\r
+ }\r
+\r
+ // fix low word of checksum\r
+ lo = oldSum & 0xFFFF;\r
+ if ((sum & 0xFFFF) >= lo) {\r
+ sum -= lo;\r
+ } else {\r
+ sum = (((sum & 0xFFFF) - lo) & 0xFFFF) - 1;\r
+ }\r
+\r
+ // fix high word of checksum\r
+ hi = oldSum >> 16;\r
+ if ((sum & 0xFFFF) >= hi) {\r
+ sum -= hi;\r
+ } else {\r
+ sum = (((sum & 0xFFFF) - hi) & 0xFFFF) - 1;\r
+ }\r
+ }\r
+\r
+ return res;\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+\r
+using Mono.PEToolkit.Metadata;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ [Flags]\r
+ public enum CorFlags : uint {\r
+ /// <summary>\r
+ /// COMIMAGE_FLAGS_ILONLY\r
+ /// </summary>\r
+ ILONLY = 0x00000001,\r
+ \r
+ /// <summary>\r
+ /// COMIMAGE_FLAGS_32BITREQUIRED\r
+ /// </summary>\r
+ REQUIRED_32BIT = 0x00000002,\r
+ \r
+ /// <summary>\r
+ /// COMIMAGE_FLAGS_IL_LIBRARY\r
+ /// </summary>\r
+ IL_LIBRARY = 0x00000004,\r
+ \r
+ /// <summary>\r
+ /// COMIMAGE_FLAGS_TRACKDEBUGDATA\r
+ /// </summary>\r
+ TRACKDEBUGDATA = 0x00010000,\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// CLR 2.0 header structure.\r
+ /// IMAGE_COR20_HEADER\r
+ /// </summary>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct CorHeader {\r
+ // Header versioning\r
+ internal uint cb;\r
+ internal short runtimeMaj;\r
+ internal short runtimeMin;\r
+\r
+ // Symbol table and startup information.\r
+ internal DataDir meta;\r
+ internal CorFlags flags;\r
+ internal uint entryTok;\r
+\r
+ // Binding information.\r
+ internal DataDir rsrc;\r
+ internal DataDir strongSig;\r
+\r
+ // Regular fixup and binding information.\r
+ internal DataDir codeManTab;\r
+ internal DataDir vtab;\r
+ internal DataDir jumps;\r
+\r
+ // Managed Native Code.\r
+ internal DataDir eeInfo;\r
+ internal DataDir helper;\r
+ internal DataDir dynInfo;\r
+ internal DataDir delayInfo;\r
+ internal DataDir modImg;\r
+ internal DataDir extFixups;\r
+ internal DataDir ridMap;\r
+ internal DataDir dbgMap;\r
+\r
+ // obsolete?\r
+ internal DataDir ipMap;\r
+\r
+\r
+ //\r
+ // Accessors\r
+ //\r
+\r
+ public uint Size {\r
+ get {\r
+ return cb;\r
+ }\r
+ set {\r
+ cb = value;\r
+ }\r
+ }\r
+\r
+ public short MajorRuntimeVersion {\r
+ get {\r
+ return runtimeMaj;\r
+ }\r
+ set {\r
+ runtimeMaj = value;\r
+ }\r
+ }\r
+\r
+ public short MinorRuntimeVersion {\r
+ get {\r
+ return runtimeMin;\r
+ }\r
+ set {\r
+ runtimeMin = value;\r
+ }\r
+ }\r
+\r
+ public string RuntimeVersion {\r
+ get {\r
+ return String.Format("{0}.{1}", runtimeMaj, runtimeMin);\r
+ }\r
+ }\r
+\r
+ public DataDir MetaData {\r
+ get {\r
+ return meta;\r
+ }\r
+ set {\r
+ meta = value;\r
+ }\r
+ }\r
+ \r
+ public CorFlags Flags {\r
+ get {\r
+ return flags;\r
+ }\r
+ set {\r
+ flags = value;\r
+ }\r
+ }\r
+ \r
+ public MDToken EntryPointToken {\r
+ get {\r
+ return entryTok;\r
+ }\r
+ set {\r
+ entryTok = value;\r
+ }\r
+ }\r
+\r
+ public DataDir Resources {\r
+ get {\r
+ return rsrc;\r
+ }\r
+ set {\r
+ rsrc = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir StrongNameSignature {\r
+ get {\r
+ return strongSig;\r
+ }\r
+ set {\r
+ strongSig = value;\r
+ }\r
+ }\r
+\r
+ public DataDir CodeManagerTable {\r
+ get {\r
+ return codeManTab;\r
+ }\r
+ set {\r
+ codeManTab = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir VTableFixups {\r
+ get {\r
+ return vtab;\r
+ }\r
+ set {\r
+ vtab = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir ExportAddressTableJumps {\r
+ get {\r
+ return jumps;\r
+ }\r
+ set {\r
+ jumps = value;\r
+ }\r
+ }\r
+\r
+\r
+ public DataDir EEInfoTable {\r
+ get {\r
+ return eeInfo;\r
+ }\r
+ set {\r
+ eeInfo = value;\r
+ }\r
+ }\r
+\r
+ public DataDir HelperTable {\r
+ get {\r
+ return helper;\r
+ }\r
+ set {\r
+ helper = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir DynamicInfo {\r
+ get {\r
+ return dynInfo;\r
+ }\r
+ set {\r
+ dynInfo = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir DelayLoadInfo {\r
+ get {\r
+ return delayInfo;\r
+ }\r
+ set {\r
+ delayInfo = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir ModuleImage {\r
+ get {\r
+ return modImg;\r
+ }\r
+ set {\r
+ modImg = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir ExternalFixups {\r
+ get {\r
+ return extFixups;\r
+ }\r
+ set {\r
+ extFixups = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir RidMap {\r
+ get {\r
+ return ridMap;\r
+ }\r
+ set {\r
+ ridMap = value;\r
+ }\r
+ }\r
+ \r
+ public DataDir DebugMap {\r
+ get {\r
+ return dbgMap;\r
+ }\r
+ set {\r
+ dbgMap = value;\r
+ }\r
+ }\r
+\r
+\r
+ public DataDir IPMap {\r
+ get {\r
+ return ipMap;\r
+ }\r
+ set {\r
+ ipMap = value;\r
+ }\r
+ }\r
+\r
+\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ // TODO: clear structure before reading to initialize/reset\r
+ // unused fields. initblk would be great.\r
+\r
+ // Read exactly the number of bytes as specified in the header.\r
+ // This number is duplicated in PEHeader::CLIHdrDir.\r
+ cb = reader.ReadUInt32();\r
+ if (cb > sizeof(uint)) {\r
+ fixed (void* ptr = &this.runtimeMaj, pThis = &this) {\r
+ PEUtils.ReadStruct(reader, ptr, (int)cb - sizeof (uint));\r
+ if (!System.BitConverter.IsLittleEndian) {\r
+ // fix entries on big-endian machine\r
+ // preserving cb\r
+ uint oldcb = cb;\r
+ PEUtils.ChangeStructEndianess(pThis, typeof (CorHeader));\r
+ cb = oldcb;\r
+ }\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine(String.Format (\r
+ "Header Size : {0}" + Environment.NewLine +\r
+ "Runtime Version : {1}" + Environment.NewLine +\r
+ "MetaData Root : {2}" + Environment.NewLine +\r
+ "Flags : {3}" + Environment.NewLine +\r
+ "Entry Point Token : {4}" + Environment.NewLine +\r
+ "Resources : {5}" + Environment.NewLine +\r
+ "Strong Name Signature : {6}" + Environment.NewLine +\r
+ "Code Manager Table : {7}" + Environment.NewLine +\r
+ "VTable Fixups : {8}" + Environment.NewLine +\r
+ "Export Address Table Jumps : {9}" + Environment.NewLine +\r
+ "EE Info Table : {10}" + Environment.NewLine +\r
+ "Helper Table : {11}" + Environment.NewLine +\r
+ "Dynamic Info : {12}" + Environment.NewLine +\r
+ "Delay Load Info : {13}" + Environment.NewLine +\r
+ "Module Image : {14}" + Environment.NewLine +\r
+ "External Fixups : {15}" + Environment.NewLine +\r
+ "Rid Map : {16}" + Environment.NewLine +\r
+ "Debug Map : {17}" + Environment.NewLine +\r
+ "IP Map : {18}" + Environment.NewLine,\r
+ cb + String.Format(" (0x{0})", cb.ToString("X")),\r
+ RuntimeVersion,\r
+ meta, flags, EntryPointToken,\r
+ rsrc, strongSig,\r
+ codeManTab, vtab, jumps,\r
+ eeInfo, helper, dynInfo, delayInfo, modImg, extFixups,\r
+ ridMap, dbgMap, ipMap\r
+ ));\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString() {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+\r
+ }\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ [StructLayout(LayoutKind.Explicit)]\r
+ public struct DOSHeader {\r
+ // Magic number (ExeSignature.DOS).\r
+ [FieldOffset(0*2)] public ExeSignature magic;\r
+\r
+ // Bytes on last page of file.\r
+ [FieldOffset(1*2)] public short cblp;\r
+\r
+ // Pages in file.\r
+ [FieldOffset(2*2)] public short cp;\r
+\r
+ // Relocations.\r
+ [FieldOffset(3*2)] public short crlc;\r
+\r
+ // Size of header in paragraphs.\r
+ [FieldOffset(4*2)] public short cparhdr;\r
+\r
+ // Minimum extra paragraphs needed.\r
+ [FieldOffset(5*2)] public short minalloc;\r
+\r
+ // Maximum extra paragraphs needed.\r
+ [FieldOffset(6*2)] public short maxalloc;\r
+\r
+ // Initial (relative) SS value.\r
+ [FieldOffset(7*2)] public short ss;\r
+\r
+ // Initial SP value.\r
+ [FieldOffset(8*2)] public short sp;\r
+\r
+ // Checksum.\r
+ [FieldOffset(9*2)] public short csum;\r
+\r
+ // Initial IP value.\r
+ [FieldOffset(10*2)] public short ip;\r
+\r
+ // Initial (relative) CS value.\r
+ [FieldOffset(11*2)] public short cs;\r
+\r
+ // File address of relocation table.\r
+ [FieldOffset(12*2)] public short lfarlc;\r
+\r
+ // Overlay number.\r
+ [FieldOffset(13*2)] public short ovno;\r
+\r
+ // Reserved words.\r
+ // short[4] res;\r
+\r
+ // OEM identifier (for e_oeminfo).\r
+ [FieldOffset(18*2)] public short oemid;\r
+\r
+ // OEM information; e_oemid specific.\r
+ [FieldOffset(19*2)] public short oeminfo;\r
+\r
+ // Reserved words\r
+ // short[10] res2;\r
+\r
+ // File address of new exe header.\r
+ [FieldOffset(30*2)] public uint lfanew;\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ fixed (void* pThis = &this) {\r
+ PEUtils.ReadStruct(reader, pThis, sizeof (DOSHeader), typeof (DOSHeader));\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <param name="writer"></param>\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine(\r
+ "Number of pages : {0}" + Environment.NewLine +\r
+ "Bytes on last pages : {1}" + Environment.NewLine +\r
+ "New header offset : {2}" + Environment.NewLine +\r
+ "Initial CS:IP : {3}:{4}" + Environment.NewLine +\r
+ "Initial SS:SP : {5}:{6}" + Environment.NewLine +\r
+ "Overlay number : {7}" + Environment.NewLine,\r
+ cp, cblp,\r
+ lfanew + " (0x" + lfanew.ToString("X") + ")",\r
+ cs.ToString("X"), ip.ToString("X"),\r
+ ss.ToString("X"), sp.ToString("X"),\r
+ ovno\r
+ );\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// IMAGE_DATA_DIRECTORY.\r
+ /// </summary>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct DataDir {\r
+\r
+ public static readonly DataDir Null;\r
+\r
+ public RVA virtAddr;\r
+ public uint size;\r
+\r
+ static DataDir ()\r
+ {\r
+ Null.virtAddr = 0;\r
+ Null.size = 0;\r
+ }\r
+\r
+\r
+ public RVA VirtualAddress {\r
+ get {\r
+ return virtAddr;\r
+ }\r
+ set {\r
+ virtAddr = value;\r
+ }\r
+ }\r
+\r
+ public uint Size {\r
+ get {\r
+ return size;\r
+ }\r
+ set {\r
+ size = value;\r
+ }\r
+ }\r
+\r
+ public bool IsNull {\r
+ get {\r
+ return (this == Null);\r
+ }\r
+ }\r
+\r
+ public override int GetHashCode()\r
+ {\r
+ return (virtAddr.GetHashCode() ^ (int)(size << 1));\r
+ }\r
+\r
+ public override bool Equals(object obj)\r
+ {\r
+ bool res = (obj is DataDir);\r
+ if (res) {\r
+ DataDir that = (DataDir) obj;\r
+ res = (this.virtAddr == that.virtAddr) &&\r
+ (this.size == that.size);\r
+ }\r
+ return res;\r
+ }\r
+\r
+ public static bool operator == (DataDir d1, DataDir d2)\r
+ {\r
+ return d1.Equals(d2);\r
+ }\r
+\r
+ public static bool operator != (DataDir d1, DataDir d2)\r
+ {\r
+ return !d1.Equals(d2);\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString()\r
+ {\r
+ if (this.IsNull) return "NULL";\r
+ return String.Format("RVA = {0}, size = 0x{1}", virtAddr, size.ToString("X"));\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public enum ExeSignature : ushort {\r
+\r
+ UNKNOWN = 0,\r
+\r
+ /// <summary>\r
+ /// "MZ"\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_DOS_SIGNATURE\r
+ /// </remarks>\r
+ DOS = 0x5A4D,\r
+\r
+\r
+ /// <summary>\r
+ /// "NE"\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_OS2_SIGNATURE\r
+ /// </remarks>\r
+ OS2 = 0x454E,\r
+\r
+\r
+ /// <summary>\r
+ /// "LE"\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_OS2_SIGNATURE_LE\r
+ /// </remarks>\r
+ OS2_LE = 0x454C,\r
+\r
+\r
+ /// <summary>\r
+ /// "LE"\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_VXD_SIGNATURE\r
+ /// </remarks>\r
+ VXD = OS2_LE,\r
+\r
+\r
+ /// <summary>\r
+ /// "PE", the complete signature is "PE\0\0"\r
+ /// (that is, NT followed by NT2).\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_NT_SIGNATURE\r
+ /// </remarks>\r
+ NT = 0x4550,\r
+ NT2 = 0\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Collections;\r
+using System.Runtime.InteropServices;\r
+\r
+using Mono.PEToolkit.Metadata;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public class Image : IDisposable {\r
+\r
+ internal DOSHeader dosHdr;\r
+ internal COFFHeader coffHdr;\r
+ internal PEHeader peHdr;\r
+\r
+ internal CorHeader corHdr;\r
+\r
+ internal Hashtable sections;\r
+ // File position right after PEHeader (NT Optional Header).\r
+ protected long sectionsPos;\r
+\r
+ private MetaDataRoot mdRoot;\r
+\r
+ private string name;\r
+ private bool open;\r
+ internal BinaryReader reader;\r
+\r
+ public Image(string name)\r
+ {\r
+ this.name = name;\r
+ open = false;\r
+ reader = null;\r
+\r
+ mdRoot = null;\r
+\r
+ dosHdr = new DOSHeader();\r
+ coffHdr = new COFFHeader();\r
+ peHdr = new PEHeader();\r
+ corHdr = new CorHeader();\r
+\r
+ sections = new Hashtable();\r
+ sectionsPos = -1;\r
+ }\r
+\r
+ ~Image()\r
+ {\r
+ Close();\r
+ }\r
+\r
+\r
+ public Hashtable Sections {\r
+ get {\r
+ return sections;\r
+ }\r
+ }\r
+\r
+ public void Open()\r
+ {\r
+ lock (this) if (!open) {\r
+ FileInfo pe = new FileInfo(name);\r
+ if (!pe.Exists) {\r
+ throw new Exception("Invalid file path.");\r
+ }\r
+\r
+ reader = new BinaryReader(new BufferedStream(pe.OpenRead()));\r
+ if (!reader.BaseStream.CanSeek) {\r
+ throw new Exception("Can't seek.");\r
+ }\r
+\r
+ open = true;\r
+ }\r
+ }\r
+\r
+ public void Close()\r
+ {\r
+ lock (this) if (open) {\r
+ reader.Close();\r
+ open = false;\r
+ }\r
+ }\r
+\r
+ // IDisposable\r
+ public void Dispose()\r
+ {\r
+ Close();\r
+ }\r
+\r
+\r
+ public bool IsCLI {\r
+ get {\r
+ return peHdr.IsCLIImage;\r
+ }\r
+ }\r
+\r
+ public MetaDataRoot MetadataRoot {\r
+ get {\r
+ return mdRoot;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void ReadHeaders()\r
+ {\r
+ if (!open) {\r
+ throw new Exception("You must open image before trying to read it.");\r
+ }\r
+\r
+ dosHdr.Read(reader);\r
+ reader.BaseStream.Position = dosHdr.lfanew;\r
+ ExeSignature peSig = (ExeSignature) reader.ReadUInt16();\r
+ if (peSig != ExeSignature.NT) {\r
+ throw new Exception ("Invalid image format: cannot find PE signature.");\r
+ }\r
+ peSig = (ExeSignature) reader.ReadUInt16();\r
+ if (peSig != ExeSignature.NT2) {\r
+ throw new Exception ("Invalid image format: cannot find PE signature.");\r
+ }\r
+\r
+ coffHdr.Read(reader);\r
+ peHdr.Read(reader);\r
+ sectionsPos = reader.BaseStream.Position;\r
+ ReadSections();\r
+\r
+ if (this.IsCLI) {\r
+ reader.BaseStream.Position = RVAToVA(peHdr.CLIHdrDir.virtAddr);\r
+ corHdr.Read(reader);\r
+\r
+ mdRoot = new MetaDataRoot(this);\r
+ reader.BaseStream.Position = RVAToVA(corHdr.MetaData.virtAddr);\r
+ mdRoot.Read(reader);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ protected void ReadSections()\r
+ {\r
+ if (sectionsPos < 0) {\r
+ throw new Exception("Read headers first.");\r
+ }\r
+ reader.BaseStream.Position = sectionsPos;\r
+\r
+ int n = coffHdr.NumberOfSections;\r
+ for (int i = n; --i >=0;) {\r
+ Section sect = new Section();\r
+ sect.Read(reader);\r
+ sections [sect.Name] = sect;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <param name="writer"></param>\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine (\r
+ dosHdr.ToString() + Environment.NewLine +\r
+ coffHdr.ToString() + Environment.NewLine +\r
+ peHdr.ToString() + Environment.NewLine +\r
+ corHdr.ToString()\r
+ );\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Returns name of the section for the given RVA.\r
+ /// </summary>\r
+ /// <param name="rva"></param>\r
+ /// <returns></returns>\r
+ public string RVAToSectionName(RVA rva)\r
+ {\r
+ string res = null;\r
+ foreach (Section s in Sections.Values) {\r
+ RVA sva = s.VirtualAddress;\r
+ if (rva >= sva && rva < sva + s.SizeOfRawData) {\r
+ res = s.Name;\r
+ break;\r
+ }\r
+ }\r
+ return res;\r
+ }\r
+\r
+ public long RVAToVA(RVA rva)\r
+ {\r
+ string sectName = RVAToSectionName(rva);\r
+ long res = 0;\r
+ if (sectName != null) {\r
+ Section s = (Section) Sections [sectName];\r
+ res = rva + (s.PointerToRawData - s.VirtualAddress);\r
+ }\r
+ return res;\r
+ }\r
+\r
+ public MetaDataRoot MetaDataRoot {\r
+ get {\r
+ return mdRoot;\r
+ }\r
+ }\r
+\r
+ public void DumpStreamHeader(TextWriter writer, string name)\r
+ {\r
+ if (mdRoot == null || name == null || name == String.Empty || writer == null) return;\r
+ writer.Write(name + " header: ");\r
+ MDStream s = MetaDataRoot.Streams[name] as MDStream;\r
+ if (s != null) {\r
+ writer.WriteLine();\r
+ writer.WriteLine(s);\r
+ } else {\r
+ writer.WriteLine("not present.");\r
+ writer.WriteLine();\r
+ }\r
+ }\r
+\r
+ public void DumpStreamHeader(string name)\r
+ {\r
+ DumpStreamHeader(Console.Out, name);\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+\r
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit bitconverter.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// Little-endian bit converter.\r
+ /// </summary>\r
+ public sealed class LEBitConverter {\r
+\r
+ internal interface IConverter {\r
+\r
+ short ToInt16(byte [] val, int idx);\r
+ ushort ToUInt16(byte [] val, int idx);\r
+ int ToInt32(byte [] val, int idx);\r
+ uint ToUInt32(byte [] val, int idx);\r
+ long ToInt64(byte [] val, int idx);\r
+ ulong ToUInt64(byte [] val, int idx);\r
+\r
+ }\r
+\r
+ public static readonly bool Native = System.BitConverter.IsLittleEndian;\r
+\r
+ private static readonly IConverter impl = System.BitConverter.IsLittleEndian\r
+ ? new LEConverter() as IConverter\r
+ : new BEConverter() as IConverter;\r
+\r
+\r
+\r
+\r
+ private LEBitConverter()\r
+ {\r
+ // Never instantiated.\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static short SwapInt16(short x)\r
+ {\r
+ short* p = stackalloc short [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [1];\r
+ bp [1] = b;\r
+ return *p;\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static ushort SwapUInt16(ushort x)\r
+ {\r
+ ushort* p = stackalloc ushort [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [1];\r
+ bp [1] = b;\r
+ return *p;\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static int SwapInt32(int x)\r
+ {\r
+ int* p = stackalloc int [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [3];\r
+ bp [3] = b;\r
+ b = bp [1];\r
+ bp [1] = bp [2];\r
+ bp [2] = b;\r
+ return *p;\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static uint SwapUInt32(uint x)\r
+ {\r
+ uint* p = stackalloc uint [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [3];\r
+ bp [3] = b;\r
+ b = bp [1];\r
+ bp [1] = bp [2];\r
+ bp [2] = b;\r
+ return *p;\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static long SwapInt64(long x)\r
+ {\r
+ long* p = stackalloc long [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [7];\r
+ bp [7] = b;\r
+ b = bp [1];\r
+ bp [1] = bp [6];\r
+ bp [6] = b;\r
+ b = bp [2];\r
+ bp [2] = bp [5];\r
+ bp [5] = b;\r
+ b = bp [3];\r
+ bp [3] = bp [4];\r
+ bp [4] = b;\r
+ return *p;\r
+ }\r
+\r
+ ///<summary></summary>\r
+ unsafe public static ulong SwapUInt64(ulong x)\r
+ {\r
+ ulong* p = stackalloc ulong [1];\r
+ *p = x;\r
+ byte* bp = (byte*) p;\r
+ byte b = bp [0];\r
+ bp [0] = bp [7];\r
+ bp [7] = b;\r
+ b = bp [1];\r
+ bp [1] = bp [6];\r
+ bp [6] = b;\r
+ b = bp [2];\r
+ bp [2] = bp [5];\r
+ bp [5] = b;\r
+ b = bp [3];\r
+ bp [3] = bp [4];\r
+ bp [4] = b;\r
+ return *p;\r
+ }\r
+\r
+\r
+\r
+\r
+\r
+ internal sealed class LEConverter : IConverter {\r
+ ///<summary></summary>\r
+ public short ToInt16(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToInt16(val, idx);\r
+ }\r
+ ///<summary></summary>\r
+ public ushort ToUInt16(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToUInt16(val, idx);\r
+ }\r
+ ///<summary></summary>\r
+ public int ToInt32(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToInt32(val, idx);\r
+ }\r
+ ///<summary></summary>\r
+ public uint ToUInt32(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToUInt32(val, idx);\r
+ }\r
+ ///<summary></summary>\r
+ public long ToInt64(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToInt64(val, idx);\r
+ }\r
+ ///<summary></summary>\r
+ public ulong ToUInt64(byte [] val, int idx)\r
+ {\r
+ return BitConverter.ToUInt64(val, idx);\r
+ }\r
+\r
+ }\r
+\r
+ internal sealed class BEConverter : IConverter {\r
+ ///<summary></summary>\r
+ public short ToInt16(byte [] val, int idx)\r
+ {\r
+ return SwapInt16(BitConverter.ToInt16(val, idx));\r
+ }\r
+ ///<summary></summary>\r
+ public ushort ToUInt16(byte [] val, int idx)\r
+ {\r
+ return SwapUInt16(BitConverter.ToUInt16(val, idx));\r
+ }\r
+ ///<summary></summary>\r
+ public int ToInt32(byte [] val, int idx)\r
+ {\r
+ return SwapInt32(BitConverter.ToInt32(val, idx));\r
+ }\r
+ ///<summary></summary>\r
+ public uint ToUInt32(byte [] val, int idx)\r
+ {\r
+ return SwapUInt32(BitConverter.ToUInt32(val, idx));\r
+ }\r
+ ///<summary></summary>\r
+ public long ToInt64(byte [] val, int idx)\r
+ {\r
+ return SwapInt64(BitConverter.ToInt64(val, idx));\r
+ }\r
+ ///<summary></summary>\r
+ public ulong ToUInt64(byte [] val, int idx)\r
+ {\r
+ return SwapUInt64(BitConverter.ToUInt64(val, idx));\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+\r
+ ///<summary></summary>\r
+ public static short ToInt16(byte [] val, int idx)\r
+ {\r
+ return impl.ToInt16(val, idx);\r
+ }\r
+\r
+ ///<summary></summary>\r
+ public static ushort ToUInt16(byte [] val, int idx)\r
+ {\r
+ return impl.ToUInt16(val, idx);\r
+ }\r
+\r
+ ///<summary></summary>\r
+ public static int ToInt32(byte [] val, int idx)\r
+ {\r
+ return impl.ToInt32(val, idx);\r
+ }\r
+\r
+ ///<summary></summary>\r
+ public static uint ToUInt32(byte [] val, int idx)\r
+ {\r
+ return impl.ToUInt32(val, idx);\r
+ }\r
+\r
+ ///<summary></summary>\r
+ public static long ToInt64(byte [] val, int idx)\r
+ {\r
+ return impl.ToInt64(val, idx);\r
+ }\r
+\r
+ ///<summary></summary>\r
+ public static ulong ToUInt64(byte [] val, int idx)\r
+ {\r
+ return impl.ToUInt64(val, idx);\r
+ }\r
+\r
+\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public enum MachineId : ushort {\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_UNKNOWN\r
+ /// </remarks>\r
+ UNKNOWN = 0,\r
+\r
+ /// <summary>\r
+ /// Intel 386.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_I386\r
+ /// </remarks>\r
+ I386 = 0x014c,\r
+\r
+ /// <summary>\r
+ /// Intel 486.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ I486 = 0x014d,\r
+\r
+ /// <summary>\r
+ /// Intel Pentium.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ PENTIUM = 0x014e,\r
+\r
+ /// <summary>\r
+ /// MIPS 3K big-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_R3000\r
+ /// </remarks>\r
+ R3000_BE = 0x0160,\r
+\r
+ /// <summary>\r
+ /// MIPS 3K little-endian, 0x160 big-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_R3000\r
+ /// </remarks>\r
+ R3000 = 0x0162,\r
+\r
+ /// <summary>\r
+ /// MIPS 4K little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_R4000\r
+ /// </remarks>\r
+ R4000 = 0x0166,\r
+\r
+ /// <summary>\r
+ /// MIPS little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_R10000\r
+ /// </remarks>\r
+ R10000 = 0x0168,\r
+\r
+ /// <summary>\r
+ /// MIPS little-endian WCE v2\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_WCEMIPSV2\r
+ /// </remarks>\r
+ WCEMIPSV2 = 0x0169,\r
+\r
+ /// <summary>\r
+ /// Alpha_AXP\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_ALPHA\r
+ /// </remarks>\r
+ ALPHA = 0x0184,\r
+\r
+ /// <summary>\r
+ /// SH3 little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_SH3\r
+ /// </remarks>\r
+ SH3 = 0x01a2,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_SH3DSP\r
+ /// </remarks>\r
+ SH3DSP = 0x01a3,\r
+\r
+ /// <summary>\r
+ /// SH3E little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_SH3E\r
+ /// </remarks>\r
+ SH3E = 0x01a4,\r
+\r
+ /// <summary>\r
+ /// SH4 little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_SH4\r
+ /// </remarks>\r
+ SH4 = 0x01a6,\r
+\r
+ /// <summary>\r
+ /// SH5\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_SH5\r
+ /// </remarks>\r
+ SH5 = 0x01a8,\r
+\r
+ /// <summary>\r
+ /// ARM Little-Endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_ARM\r
+ /// </remarks>\r
+ ARM = 0x01c0,\r
+\r
+ /// <summary>\r
+ /// ARM 10 Thumb family CPU.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_THUMB\r
+ /// http://www.arm.com/armtech/ARM10_Thumb?OpenDocument&ExpandSection=2\r
+ /// </remarks>\r
+ THUMB = 0x01c2,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_AM33\r
+ /// </remarks>\r
+ AM33 = 0x01d3,\r
+\r
+ /// <summary>\r
+ /// IBM PowerPC Little-Endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_POWERPC\r
+ /// </remarks>\r
+ POWERPC = 0x01F0,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_POWERPCFP\r
+ /// </remarks>\r
+ POWERPCFP = 0x01f1,\r
+\r
+ /// <summary>\r
+ /// Intel 64\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_IA64\r
+ /// </remarks>\r
+ IA64 = 0x0200,\r
+\r
+ /// <summary>\r
+ /// MIPS\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_MIPS16\r
+ /// </remarks>\r
+ MIPS16 = 0x0266,\r
+\r
+ /// <summary>\r
+ /// ALPHA64\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_ALPHA64\r
+ /// </remarks>\r
+ ALPHA64 = 0x0284,\r
+\r
+ /// <summary>\r
+ /// MIPS\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_MIPSFPU\r
+ /// </remarks>\r
+ MIPSFPU = 0x0366,\r
+\r
+ /// <summary>\r
+ /// MIPS\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_MIPSFPU16\r
+ /// </remarks>\r
+ MIPSFPU16 = 0x0466,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_AXP64\r
+ /// </remarks>\r
+ AXP64 = ALPHA64,\r
+\r
+ /// <summary>\r
+ /// Infineon\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_TRICORE\r
+ /// http://www.infineon.com/tricore\r
+ /// </remarks>\r
+ TRICORE = 0x0520,\r
+\r
+ /// <summary>\r
+ /// Common Executable Format (Windows CE).\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_CEF\r
+ /// </remarks>\r
+ CEF = 0x0CEF,\r
+\r
+ /// <summary>\r
+ /// EFI Byte Code\r
+ /// </summary>\r
+ EBC = 0x0EBC,\r
+\r
+ /// <summary>\r
+ /// AMD64 (K8)\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_AMD64\r
+ /// </remarks>\r
+ AMD64 = 0x8664,\r
+\r
+ /// <summary>\r
+ /// M32R little-endian\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_M32R\r
+ /// </remarks>\r
+ M32R = 0x9104,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_FILE_MACHINE_CEE\r
+ /// </remarks>\r
+ CEE = 0xC0EE,\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ // IMAGE_OPTIONAL_HEADER\r
+\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct PEHeader {\r
+\r
+ /// <summary>\r
+ /// Standard PE/COFF fields.\r
+ /// </summary>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct StdFields {\r
+ internal short magic; // always 0x10B?\r
+ internal byte lMajor;\r
+ internal byte lMinor;\r
+ internal uint codeSize;\r
+ internal uint initDataSize;\r
+ internal uint uninitDataSize;\r
+ internal RVA entryRVA;\r
+ internal RVA codeBase;\r
+ internal RVA dataBase;\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public string LinkerVersion {\r
+ get {\r
+ return String.Format("{0}.{1}", lMajor, lMinor);\r
+ }\r
+ }\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString() {\r
+ return String.Format(\r
+ "Magic : 0x{0}" + Environment.NewLine +\r
+ "Linker ver. : {1}" + Environment.NewLine +\r
+ "Size of code : {2}" + Environment.NewLine +\r
+ "Size of initialized data : {3}" + Environment.NewLine +\r
+ "Size of uinitialized data (BSS) : {4}" + Environment.NewLine,\r
+ magic.ToString("X"), LinkerVersion,\r
+ codeSize, initDataSize, uninitDataSize\r
+ );\r
+ }\r
+ }\r
+ \r
+\r
+ /// <summary>\r
+ /// Windows-specific fields.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, 24.2.3.2\r
+ /// </remarks>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct NTFields {\r
+ internal uint imgBase;\r
+ internal uint sectAlign;\r
+ internal uint fileAlign;\r
+ internal short osMaj;\r
+ internal short osMin;\r
+ internal short imgMaj;\r
+ internal short imgMin;\r
+ internal short subSysMaj;\r
+ internal short subSysMin;\r
+ internal int reserved_win32ver;\r
+ internal uint imgSize;\r
+ internal uint hdrSize;\r
+ internal uint chksum;\r
+ internal Subsystem subSys;\r
+ internal short dllFlags;\r
+ internal uint stackRes;\r
+ internal uint stackCommit;\r
+ internal uint heapRes;\r
+ internal uint heapCommit;\r
+ internal uint ldrFlags;\r
+ internal uint numDirs;\r
+\r
+ public string OSVersion {\r
+ get {\r
+ return String.Format("{0}.{1}", osMaj, osMin);\r
+ }\r
+ }\r
+\r
+ public string ImageVersion {\r
+ get {\r
+ return String.Format("{0}.{1}", imgMaj, imgMin);\r
+ }\r
+ }\r
+\r
+ public string SubsysVersion {\r
+ get {\r
+ return String.Format("{0}.{1}", subSysMaj, subSysMin);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString() {\r
+ return String.Format(\r
+ "Image Base : 0x{0}" + Environment.NewLine +\r
+ "Section Alignment : 0x{1}" + Environment.NewLine +\r
+ "File Alignment : 0x{2}" + Environment.NewLine +\r
+ "OS Version : {3}" + Environment.NewLine +\r
+ "Image Version : {4}" + Environment.NewLine +\r
+ "Subsystem Version : {5}" + Environment.NewLine +\r
+ "Reserved/Win32Ver : {6}" + Environment.NewLine +\r
+ "Image Size : {7}" + Environment.NewLine +\r
+ "Header Size : {8}" + Environment.NewLine +\r
+ "Checksum : 0x{9}" + Environment.NewLine +\r
+ "Subsystem : {10}" + Environment.NewLine +\r
+ "DLL Flags : {11}" + Environment.NewLine +\r
+ "Stack Reserve Size : 0x{12}" + Environment.NewLine +\r
+ "Stack Commit Size : 0x{13}" + Environment.NewLine +\r
+ "Heap Reserve Size : 0x{14}" + Environment.NewLine +\r
+ "Heap Commit Size : 0x{15}" + Environment.NewLine +\r
+ "Loader Flags : {16}" + Environment.NewLine +\r
+ "Number of Directories : {17}" + Environment.NewLine,\r
+ imgBase.ToString("X"), sectAlign.ToString("X"), fileAlign.ToString("X"),\r
+ OSVersion, ImageVersion, SubsysVersion,\r
+ reserved_win32ver,\r
+ imgSize, hdrSize, chksum.ToString("X"), subSys, dllFlags,\r
+ stackRes.ToString("X"), stackCommit.ToString("X"), heapRes.ToString("X"), heapCommit.ToString ("X"),\r
+ ldrFlags, numDirs\r
+ );\r
+ }\r
+ }\r
+\r
+\r
+ internal StdFields stdFlds;\r
+ internal NTFields ntFlds;\r
+\r
+ internal DataDir exportDir;\r
+ internal DataDir importDir;\r
+ internal DataDir resourceDir;\r
+ internal DataDir exceptionDir;\r
+ internal DataDir securityDir;\r
+ internal DataDir baseRelocDir;\r
+ internal DataDir debugDir;\r
+ internal DataDir copyrightDir;\r
+ internal DataDir GPDir;\r
+ internal DataDir TLSDir;\r
+ internal DataDir loadCfgDir;\r
+ internal DataDir boundImpDir;\r
+ internal DataDir IATDir;\r
+ internal DataDir delayImpDir;\r
+ internal DataDir CLIHdrDir;\r
+ internal DataDir reservedDir;\r
+\r
+\r
+ public bool IsCLIImage {\r
+ get {\r
+ return (CLIHdrDir.virtAddr.Value != 0);\r
+ }\r
+ }\r
+\r
+\r
+ //\r
+ // Accessors for standard COFF fields.\r
+ //\r
+ \r
+ public short Magic {\r
+ get {\r
+ return stdFlds.magic;\r
+ }\r
+ set {\r
+ stdFlds.magic = value;\r
+ }\r
+ }\r
+\r
+ public byte MajorLinkerVersion {\r
+ get {\r
+ return stdFlds.lMajor;\r
+ }\r
+ set {\r
+ stdFlds.lMajor = value;\r
+ }\r
+ }\r
+\r
+ public byte MinorLinkerVersion {\r
+ get {\r
+ return stdFlds.lMinor;\r
+ }\r
+ set {\r
+ stdFlds.lMinor = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfCode {\r
+ get {\r
+ return stdFlds.codeSize;\r
+ }\r
+ set {\r
+ stdFlds.codeSize = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfInitializedData {\r
+ get {\r
+ return stdFlds.initDataSize;\r
+ }\r
+ set {\r
+ stdFlds.initDataSize = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfUninitializedData {\r
+ get {\r
+ return stdFlds.uninitDataSize;\r
+ }\r
+ set {\r
+ stdFlds.uninitDataSize = value;\r
+ }\r
+ }\r
+\r
+ public RVA AddressOfEntryPoint {\r
+ get {\r
+ return stdFlds.entryRVA;\r
+ }\r
+ set {\r
+ stdFlds.entryRVA.value = value.value;\r
+ }\r
+ }\r
+\r
+ public RVA BaseOfCode {\r
+ get {\r
+ return stdFlds.codeBase;\r
+ }\r
+ set {\r
+ stdFlds.codeBase.value = value.value;\r
+ }\r
+ }\r
+\r
+ public RVA BaseOfData {\r
+ get {\r
+ return stdFlds.dataBase;\r
+ }\r
+ set {\r
+ stdFlds.dataBase.value = value.value;\r
+ }\r
+ }\r
+\r
+\r
+ //\r
+ // Accessors for Windows-specific fields.\r
+ //\r
+\r
+\r
+ /// <summary>\r
+ /// Preferred address of image when loaded into memory.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// <para>\r
+ /// This is a linear address and not RVA,\r
+ /// and must be a multiple of 64K.\r
+ /// </para>\r
+ /// <para>\r
+ /// Table in the Partition II states that for CIL images\r
+ /// it must be 0x400000.\r
+ /// </para>\r
+ /// </remarks>\r
+ public uint ImageBase {\r
+ get {\r
+ return ntFlds.imgBase;\r
+ }\r
+ set {\r
+ ntFlds.imgBase = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Alignment of section when loaded into memory.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Must be greater or equal to FileAlignment.\r
+ /// Default is the native page size.\r
+ /// According to specs for CIL images it must be set to 8K.\r
+ /// </remarks>\r
+ public uint SectionAlignment {\r
+ get {\r
+ return ntFlds.sectAlign;\r
+ }\r
+ set {\r
+ ntFlds.sectAlign = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Byte alignment of pages in image file.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Valid values are powers of 2 between 512 and 64K.\r
+ /// For CIL images it must be either 512 or 4K.\r
+ /// </remarks>\r
+ public uint FileAlignment {\r
+ get {\r
+ return ntFlds.fileAlign;\r
+ }\r
+ set {\r
+ ntFlds.fileAlign = value;\r
+ }\r
+ }\r
+\r
+\r
+ public short MajorOperatingSystemVersion {\r
+ get {\r
+ return ntFlds.osMaj;\r
+ }\r
+ set {\r
+ ntFlds.osMaj = value;\r
+ }\r
+ }\r
+\r
+ public short MinorOperatingSystemVersion {\r
+ get {\r
+ return ntFlds.osMin;\r
+ }\r
+ set {\r
+ ntFlds.osMin = value;\r
+ }\r
+ }\r
+\r
+ public short MajorImageVersion {\r
+ get {\r
+ return ntFlds.imgMaj;\r
+ }\r
+ set {\r
+ ntFlds.imgMaj = value;\r
+ }\r
+ }\r
+\r
+ public short MinorImageVersion {\r
+ get {\r
+ return ntFlds.imgMin;\r
+ }\r
+ set {\r
+ ntFlds.imgMin = value;\r
+ }\r
+ }\r
+\r
+ public short MajorSubsystemVersion {\r
+ get {\r
+ return ntFlds.subSysMaj;\r
+ }\r
+ set {\r
+ ntFlds.subSysMaj = value;\r
+ }\r
+ }\r
+\r
+ public short MinorSubsystemVersion {\r
+ get {\r
+ return ntFlds.subSysMin;\r
+ }\r
+ set {\r
+ ntFlds.subSysMin = value;\r
+ }\r
+ }\r
+\r
+ public int Win32VersionValue {\r
+ get {\r
+ return ntFlds.reserved_win32ver;\r
+ }\r
+ set {\r
+ ntFlds.reserved_win32ver = value;\r
+ }\r
+ }\r
+\r
+ public int Reserved {\r
+ get {\r
+ return ntFlds.reserved_win32ver;\r
+ }\r
+ set {\r
+ ntFlds.reserved_win32ver = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfImage {\r
+ get {\r
+ return ntFlds.imgSize;\r
+ }\r
+ set {\r
+ ntFlds.imgSize = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfHeaders {\r
+ get {\r
+ return ntFlds.hdrSize;\r
+ }\r
+ set {\r
+ ntFlds.hdrSize = value;\r
+ }\r
+ }\r
+\r
+ public uint CheckSum {\r
+ get {\r
+ return ntFlds.chksum;\r
+ }\r
+ set {\r
+ ntFlds.chksum = value;\r
+ }\r
+ }\r
+\r
+ public Subsystem Subsystem {\r
+ get {\r
+ return ntFlds.subSys;\r
+ }\r
+ set {\r
+ ntFlds.subSys = value;\r
+ }\r
+ }\r
+\r
+ public short DllCharacteristics {\r
+ get {\r
+ return ntFlds.dllFlags;\r
+ }\r
+ set {\r
+ ntFlds.dllFlags = value;\r
+ }\r
+ }\r
+\r
+\r
+ public uint SizeOfStackReserve {\r
+ get {\r
+ return ntFlds.stackRes;\r
+ }\r
+ set {\r
+ ntFlds.stackRes = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfStackCommit {\r
+ get {\r
+ return ntFlds.stackCommit;\r
+ }\r
+ set {\r
+ ntFlds.stackCommit = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfHeapReserve {\r
+ get {\r
+ return ntFlds.heapRes;\r
+ }\r
+ set {\r
+ ntFlds.heapRes = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfHeapCommit {\r
+ get {\r
+ return ntFlds.heapCommit;\r
+ }\r
+ set {\r
+ ntFlds.heapCommit = value;\r
+ }\r
+ }\r
+\r
+ public uint LoaderFlags {\r
+ get {\r
+ return ntFlds.ldrFlags;\r
+ }\r
+ set {\r
+ ntFlds.ldrFlags = value;\r
+ }\r
+ }\r
+\r
+ public uint NumberOfRvaAndSizes {\r
+ get {\r
+ return ntFlds.numDirs;\r
+ }\r
+ set {\r
+ ntFlds.numDirs = value;\r
+ }\r
+ }\r
+\r
+\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ fixed (void* pThis = &this) {\r
+ int hdrSize = sizeof (StdFields) + sizeof (NTFields);\r
+ PEUtils.ReadStruct(reader, pThis, hdrSize);\r
+ PEUtils.ReadStruct(reader, (byte*)pThis + hdrSize, (int) NumberOfRvaAndSizes * sizeof (DataDir));\r
+\r
+ if (!System.BitConverter.IsLittleEndian) {\r
+ PEUtils.ChangeStructEndianess(pThis, typeof (PEHeader));\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ string dirs = String.Format(\r
+ "Export Table : {0}" + Environment.NewLine +\r
+ "Import Table : {1}" + Environment.NewLine +\r
+ "Win32 Resource Table : {2}" + Environment.NewLine +\r
+ "Exception Table : {3}" + Environment.NewLine +\r
+ "Certificate Table : {4}" + Environment.NewLine +\r
+ "Base Relocation Table : {5}" + Environment.NewLine +\r
+ "Debug Table : {6}" + Environment.NewLine +\r
+ "Copyright : {7}" + Environment.NewLine +\r
+ "MIPS Global Ptr : {8}" + Environment.NewLine +\r
+ "TLS Table : {9}" + Environment.NewLine +\r
+ "Load Config Table : {10}" + Environment.NewLine +\r
+ "Bound Import : {11}" + Environment.NewLine +\r
+ "IAT : {12}" + Environment.NewLine +\r
+ "Delay Import Descriptor : {13}" + Environment.NewLine +\r
+ "CLI Header : {14}" + Environment.NewLine +\r
+ "Reserved : {15}" + Environment.NewLine,\r
+ exportDir, importDir, resourceDir, exceptionDir,\r
+ securityDir, baseRelocDir, debugDir, copyrightDir,\r
+ GPDir, TLSDir, loadCfgDir, boundImpDir, IATDir, delayImpDir,\r
+ CLIHdrDir, reservedDir\r
+ );\r
+\r
+ writer.WriteLine(\r
+ stdFlds.ToString() + Environment.NewLine +\r
+ ntFlds.ToString() + Environment.NewLine +\r
+ "Directories: "+ Environment.NewLine +\r
+ dirs\r
+ );\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Reflection;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public sealed class PEUtils {\r
+\r
+ private PEUtils()\r
+ {\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Reads structure from the input stream preserving its endianess.\r
+ /// </summary>\r
+ /// <param name="reader"></param>\r
+ /// <param name="pStruct"></param>\r
+ /// <param name="len"></param>\r
+ unsafe internal static void ReadStruct(BinaryReader reader, void* pStruct, int len)\r
+ {\r
+ byte* p = (byte*) pStruct;\r
+\r
+ if (System.BitConverter.IsLittleEndian) {\r
+ // On a little-endian machine read data in 64-bit chunks,\r
+ // this won't work on big-endian machine because\r
+ // BinaryReader APIs are little-endian while\r
+ // memory writes are platform-native.\r
+ // This seems faster than ReadBytes/Copy method\r
+ // in the "else" clause, especially if used often\r
+ // (no extra memory allocation for byte[]?).\r
+ int whole = len >> 3;\r
+ int rem = len & 7;\r
+\r
+ for (int i = whole; --i >= 0;) {\r
+ long qw = reader.ReadInt64();\r
+ Marshal.WriteInt64((IntPtr) p, qw);\r
+ p += sizeof (long);\r
+ }\r
+ for (int i = rem; --i >= 0;) {\r
+ *p++ = (byte) reader.ReadByte();\r
+ }\r
+ } else {\r
+ byte [] buff = reader.ReadBytes(len);\r
+ Marshal.Copy(buff, 0, (IntPtr) p, len);\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Reads structure from the input stream\r
+ /// changing its endianess if required\r
+ /// (if running on big-endian hardware).\r
+ /// </summary>\r
+ /// <param name="reader"></param>\r
+ /// <param name="pStruct"></param>\r
+ /// <param name="len"></param>\r
+ /// <param name="type"></param>\r
+ unsafe internal static void ReadStruct(BinaryReader reader, void* pStruct, int len, Type type)\r
+ {\r
+ ReadStruct(reader, pStruct, len);\r
+ if (!System.BitConverter.IsLittleEndian) {\r
+ ChangeStructEndianess(pStruct, type);\r
+ }\r
+ }\r
+\r
+\r
+ unsafe private static int SwapByTypeCode(byte* p, TypeCode tcode)\r
+ {\r
+ int inc = 0;\r
+ switch (tcode) {\r
+ case TypeCode.Int16 :\r
+ short* sp = (short*) p;\r
+ short sx = *sp;\r
+ sx = LEBitConverter.SwapInt16(sx);\r
+ *sp = sx;\r
+ inc = sizeof (short);\r
+ break;\r
+ case TypeCode.UInt16 :\r
+ ushort* usp = (ushort*) p;\r
+ ushort usx = *usp;\r
+ usx = LEBitConverter.SwapUInt16(usx);\r
+ *usp = usx;\r
+ inc = sizeof (ushort);\r
+ break;\r
+ case TypeCode.Int32 :\r
+ int* ip = (int*) p;\r
+ int ix = *ip;\r
+ ix = LEBitConverter.SwapInt32(ix);\r
+ *ip = ix;\r
+ inc = sizeof (int);\r
+ break;\r
+ case TypeCode.UInt32 :\r
+ uint* uip = (uint*) p;\r
+ uint uix = *uip;\r
+ uix = LEBitConverter.SwapUInt32(uix);\r
+ *uip = uix;\r
+ inc = sizeof (uint);\r
+ break;\r
+ case TypeCode.Int64 :\r
+ long* lp = (long*) p;\r
+ long lx = *lp;\r
+ lx = LEBitConverter.SwapInt64(lx);\r
+ *lp = lx;\r
+ inc = sizeof (long);\r
+ break;\r
+ case TypeCode.UInt64 :\r
+ ulong* ulp = (ulong*) p;\r
+ ulong ulx = *ulp;\r
+ ulx = LEBitConverter.SwapUInt64(ulx);\r
+ *ulp = ulx;\r
+ inc = sizeof (ulong);\r
+ break;\r
+ case TypeCode.Byte :\r
+ case TypeCode.SByte :\r
+ inc = sizeof (byte);\r
+ break;\r
+ default :\r
+ break;\r
+ }\r
+ return inc;\r
+ }\r
+\r
+ unsafe internal static int ChangeStructEndianess(void* pStruct, Type type)\r
+ {\r
+ if (type == null || !type.IsValueType) return 0;\r
+ if (!type.IsLayoutSequential && !type.IsExplicitLayout) {\r
+ throw new Exception("Internal error: struct must have explicit or sequential layout.");\r
+ }\r
+\r
+ bool seq = type.IsLayoutSequential;\r
+ byte* p = (byte*) pStruct;\r
+ int offs = 0;\r
+ int inc;\r
+ FieldInfo [] fields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);\r
+ \r
+ foreach (FieldInfo fi in fields) {\r
+ if (!seq) offs = Marshal.OffsetOf(type, fi.Name).ToInt32 ();\r
+ Type ft = fi.FieldType;\r
+ TypeCode tcode = Type.GetTypeCode(ft);\r
+ if (tcode == TypeCode.Object) {\r
+ // not a primitive type, process recursively.\r
+ inc = ChangeStructEndianess(p + offs, ft);\r
+ } else {\r
+ inc = SwapByTypeCode(p + offs, tcode);\r
+ }\r
+ if (seq) offs += inc;\r
+ }\r
+\r
+ return offs;\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+The PEToolkit was authored by Sergey Chaban (serge@wildwestsoftware.com)
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// Relative Virtual Address.\r
+ /// </summary>\r
+ public struct RVA {\r
+\r
+ public static readonly RVA Null;\r
+\r
+ public uint value;\r
+\r
+ static RVA()\r
+ {\r
+ Null = new RVA(0);\r
+ }\r
+\r
+\r
+ public RVA(uint val)\r
+ {\r
+ value = val;\r
+ }\r
+\r
+\r
+ public uint Value {\r
+ get {\r
+ return value;\r
+ }\r
+ set {\r
+ this.value = value;\r
+ }\r
+ }\r
+\r
+\r
+ public static implicit operator RVA (uint val)\r
+ {\r
+ return new RVA(val);\r
+ }\r
+\r
+ public static implicit operator uint (RVA rva)\r
+ {\r
+ return rva.value;\r
+ }\r
+\r
+ public override int GetHashCode()\r
+ {\r
+ return (int) value;\r
+ }\r
+\r
+ public override bool Equals(object o)\r
+ {\r
+ bool res = o is RVA;\r
+ if (res) res = (this.value == ((RVA)o).value);\r
+ return res;\r
+ }\r
+\r
+ public static bool operator == (RVA rva1, RVA rva2)\r
+ {\r
+ return rva1.Equals(rva2);\r
+ }\r
+\r
+ public static bool operator != (RVA rva1, RVA rva2)\r
+ {\r
+ return !rva1.Equals(rva2);\r
+ }\r
+\r
+ public static bool operator < (RVA rva1, RVA rva2)\r
+ {\r
+ return (rva1.value < rva2.value);\r
+ }\r
+\r
+ public static bool operator > (RVA rva1, RVA rva2) {\r
+ return (rva1.value > rva2.value);\r
+ }\r
+\r
+ public static bool operator <= (RVA rva1, RVA rva2)\r
+ {\r
+ return (rva1.value <= rva2.value);\r
+ }\r
+\r
+ public static bool operator >= (RVA rva1, RVA rva2)\r
+ {\r
+ return (rva1.value >= rva2.value);\r
+ }\r
+\r
+ public static RVA operator + (RVA rva, uint x)\r
+ {\r
+ return new RVA (rva.value + x);\r
+ }\r
+\r
+ public static RVA operator - (RVA rva, uint x)\r
+ {\r
+ return new RVA (rva.value - x);\r
+ }\r
+\r
+\r
+ public override string ToString()\r
+ {\r
+ if (this == Null) return "NULL";\r
+ return ("0x" + value.ToString("X"));\r
+ }\r
+\r
+ unsafe public static int Size {\r
+ get {\r
+ return sizeof (uint);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Text;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ public class Section {\r
+\r
+ // IMAGE_SECTION_HEADER\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct Header {\r
+ internal uint phAddr_virtSize;\r
+ internal RVA virtAddr;\r
+ internal uint rawSize;\r
+ internal RVA rawDataPtr;\r
+ internal RVA relocPtr;\r
+ internal RVA lineNumPtr;\r
+ internal short relocNum;\r
+ internal short linenumNum;\r
+ internal SectionCharacteristics flags;\r
+ }\r
+\r
+ private string name;\r
+ internal Header hdr;\r
+\r
+ public readonly static Section Invalid;\r
+\r
+ static Section()\r
+ {\r
+ Invalid = new Section();\r
+ }\r
+\r
+ public Section()\r
+ {\r
+ }\r
+\r
+\r
+ public string Name {\r
+ get {\r
+ return name;\r
+ }\r
+ set {\r
+ name = value;\r
+ }\r
+ }\r
+\r
+\r
+ public uint PhysicalAddress {\r
+ get {\r
+ return hdr.phAddr_virtSize;\r
+ }\r
+ set {\r
+ hdr.phAddr_virtSize = value;\r
+ }\r
+ }\r
+\r
+ public uint VirtualSize {\r
+ get {\r
+ return hdr.phAddr_virtSize;\r
+ }\r
+ set {\r
+ hdr.phAddr_virtSize = value;\r
+ }\r
+ }\r
+\r
+ public RVA VirtualAddress {\r
+ get {\r
+ return hdr.virtAddr;\r
+ }\r
+ set {\r
+ hdr.virtAddr = value;\r
+ }\r
+ }\r
+\r
+ public uint SizeOfRawData {\r
+ get {\r
+ return hdr.rawSize;\r
+ }\r
+ set {\r
+ hdr.rawSize = value;\r
+ }\r
+ }\r
+\r
+ public RVA PointerToRawData {\r
+ get {\r
+ return hdr.rawDataPtr;\r
+ }\r
+ set {\r
+ hdr.rawDataPtr = value;\r
+ }\r
+ }\r
+ \r
+ public RVA PointerToRelocations {\r
+ get {\r
+ return hdr.relocPtr;\r
+ }\r
+ set {\r
+ hdr.relocPtr = value;\r
+ }\r
+ }\r
+ \r
+ public RVA PointerToLinenumbers {\r
+ get {\r
+ return hdr.lineNumPtr;\r
+ }\r
+ set {\r
+ hdr.lineNumPtr = value;\r
+ }\r
+ }\r
+ \r
+ public short NumberOfRelocations {\r
+ get {\r
+ return hdr.relocNum;\r
+ }\r
+ set {\r
+ hdr.relocNum = value;\r
+ }\r
+ }\r
+ \r
+ public short NumberOfLinenumbers {\r
+ get {\r
+ return hdr.linenumNum;\r
+ }\r
+ set {\r
+ hdr.linenumNum = value;\r
+ }\r
+ }\r
+ \r
+ public SectionCharacteristics Characteristics {\r
+ get {\r
+ return hdr.flags;\r
+ }\r
+ set {\r
+ hdr.flags = value;\r
+ }\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ sbyte* pName = stackalloc sbyte [8];\r
+ sbyte* p = pName;\r
+\r
+ for (int i = 8; --i >=0;) {\r
+ sbyte c = reader.ReadSByte();\r
+ if (c == 0) break;\r
+ *p++ = c;\r
+ }\r
+\r
+ int len = (int) (p - pName);\r
+ if (len != 0) {\r
+ name = new string(pName, 0, len, Encoding.ASCII);\r
+ } else {\r
+ name = String.Empty;\r
+ }\r
+\r
+ reader.BaseStream.Position += 8 - len - 1;\r
+\r
+ fixed (void* pHdr = &this.hdr) {\r
+ PEUtils.ReadStruct(reader, pHdr, sizeof (Header), typeof (Header));\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ [Flags]\r
+ public enum SectionCharacteristics : uint {\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_REG = 0x00000000,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_DSECT = 0x00000001,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_NOLOAD = 0x00000002,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_GROUP = 0x00000004,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_NO_PAD = 0x00000008,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_COPY = 0x00000010,\r
+\r
+ /// <summary>\r
+ /// Section contains code.\r
+ /// </summary>\r
+ IMAGE_SCN_CNT_CODE = 0x00000020,\r
+\r
+ /// <summary>\r
+ /// Section contains initialized data.\r
+ /// </summary>\r
+ IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,\r
+\r
+ /// <summary>\r
+ /// Section contains uninitialized data.\r
+ /// </summary>\r
+ IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_LNK_OTHER = 0x00000100,\r
+\r
+ /// <summary>\r
+ /// Section contains comments or some other type of information.\r
+ /// </summary>\r
+ IMAGE_SCN_LNK_INFO = 0x00000200,\r
+\r
+ /// <summary>\r
+ /// Reserved.\r
+ /// </summary>\r
+ IMAGE_SCN_TYPE_OVER = 0x00000400,\r
+ \r
+ /// <summary>\r
+ /// Section contents will not become part of image.\r
+ /// </summary>\r
+ IMAGE_SCN_LNK_REMOVE = 0x00000800,\r
+\r
+ /// <summary>\r
+ /// Section contents comdat.\r
+ /// </summary>\r
+ IMAGE_SCN_LNK_COMDAT = 0x00001000,\r
+\r
+\r
+ /// <summary>\r
+ /// Reset speculative exceptions handling bits in the TLB entries for this section.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SCN_MEM_PROTECTED - Obsolete.\r
+ /// </remarks>\r
+ IMAGE_SCN_NO_DEFER_SPEC_EXC = 0x00004000,\r
+\r
+ /// <summary>\r
+ /// Section content can be accessed relative to GP (MIPS).\r
+ /// </summary>\r
+ IMAGE_SCN_GPREL = 0x00008000,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_FARDATA = 0x00008000,\r
+\r
+ /// <summary>\r
+ /// Obsolete.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_PURGEABLE = 0x00020000,\r
+\r
+ /// <summary>\r
+ /// Obsolete.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_16BIT = 0x00020000,\r
+\r
+ /// <summary>\r
+ /// Obsolete.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_LOCKED = 0x00040000,\r
+\r
+ /// <summary>\r
+ /// Obsolete.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_PRELOAD = 0x00080000,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SCN_MEM_SYSHEAP - Obsolete 0x00010000\r
+ /// </remarks>\r
+ IMAGE_SCN_ALIGN_1BYTES = 0x00100000,\r
+\r
+ IMAGE_SCN_ALIGN_2BYTES = 0x00200000,\r
+ IMAGE_SCN_ALIGN_4BYTES = 0x00300000,\r
+ IMAGE_SCN_ALIGN_8BYTES = 0x00400000,\r
+\r
+ // default alignment\r
+ IMAGE_SCN_ALIGN_16BYTES = 0x00500000,\r
+\r
+ IMAGE_SCN_ALIGN_32BYTES = 0x00600000,\r
+ IMAGE_SCN_ALIGN_64BYTES = 0x00700000,\r
+ IMAGE_SCN_ALIGN_128BYTES = 0x00800000,\r
+ IMAGE_SCN_ALIGN_256BYTES = 0x00900000,\r
+ IMAGE_SCN_ALIGN_512BYTES = 0x00A00000,\r
+ IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000,\r
+ IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000,\r
+ IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000,\r
+ IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000,\r
+\r
+ IMAGE_SCN_ALIGN_MASK = 0x00F00000,\r
+\r
+ /// <summary>\r
+ /// Section contains extended relocations.\r
+ /// </summary>\r
+ IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,\r
+ \r
+ /// <summary>\r
+ /// Section can be discarded.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,\r
+ \r
+ /// <summary>\r
+ /// Section is not cachable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,\r
+\r
+ /// <summary>\r
+ /// Section is not pageable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,\r
+ \r
+ /// <summary>\r
+ /// Section is shareable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_SHARED = 0x10000000,\r
+\r
+ /// <summary>\r
+ /// Section is executable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_EXECUTE = 0x20000000,\r
+\r
+ /// <summary>\r
+ /// Section is readable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_READ = 0x40000000,\r
+\r
+ /// <summary>\r
+ /// Section is writeable.\r
+ /// </summary>\r
+ IMAGE_SCN_MEM_WRITE = 0x80000000,\r
+\r
+\r
+ /// <summary>\r
+ /// TLS index is scaled.\r
+ /// </summary>\r
+ IMAGE_SCN_SCALE_INDEX = 0x00000001,\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public enum Subsystem : short {\r
+\r
+ /// <summary>\r
+ /// Unknown subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_UNKNOWN\r
+ /// </remarks>\r
+ UNKNOWN = 0,\r
+\r
+ /// <summary>\r
+ /// Image doesn't require a subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_NATIVE\r
+ /// </remarks>\r
+ NATIVE = 1,\r
+\r
+ /// <summary>\r
+ /// Image runs in the Windows GUI subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_WINDOWS_GUI\r
+ /// </remarks>\r
+ WINDOWS_GUI = 2,\r
+\r
+ /// <summary>\r
+ /// Image runs in the Windows character subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_WINDOWS_CUI\r
+ /// </remarks>\r
+ WINDOWS_CUI = 3,\r
+\r
+ /// <summary>\r
+ /// Image runs in the OS/2 character subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_OS2_CUI\r
+ /// </remarks>\r
+ OS2_CUI = 5,\r
+\r
+ /// <summary>\r
+ /// Image runs in the Posix character subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_POSIX_CUI\r
+ /// </remarks>\r
+ POSIX_CUI = 7,\r
+\r
+ /// <summary>\r
+ /// Image is a native Win9x driver.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_NATIVE_WINDOWS\r
+ /// </remarks>\r
+ NATIVE_WINDOWS = 8,\r
+\r
+ /// <summary>\r
+ /// Image runs in the Windows CE subsystem.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_WINDOWS_CE_GUI\r
+ /// </remarks>\r
+ WINDOWS_CE_GUI = 9,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_EFI_APPLICATION\r
+ /// </remarks>\r
+ EFI_APPLICATION = 10,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER\r
+ /// </remarks>\r
+ EFI_BOOT_SERVICE_DRIVER = 11,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER\r
+ /// </remarks>\r
+ EFI_RUNTIME_DRIVER = 12,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_EFI_ROM\r
+ /// </remarks>\r
+ EFI_ROM = 13,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// IMAGE_SUBSYSTEM_XBOX\r
+ /// </remarks>\r
+ XBOX = 14,\r
+ }\r
+\r
+}\r
--- /dev/null
+using System;\r
+using System.IO;\r
+\r
+using Mono.PEToolkit;\r
+using Mono.PEToolkit.Metadata;\r
+\r
+\r
+public sealed class MDDump {\r
+\r
+ private MDDump() {}\r
+\r
+\r
+ public static uint Dump (string peFile)\r
+ {\r
+\r
+ using (Image pe = new Image (peFile)) {\r
+ pe.Open ();\r
+ pe.ReadHeaders ();\r
+\r
+ Console.WriteLine (pe);\r
+\r
+ if (pe.IsCLI) {\r
+ pe.DumpStreamHeader("#~");\r
+ pe.DumpStreamHeader("#-");\r
+ pe.DumpStreamHeader("#Strings");\r
+ pe.DumpStreamHeader("#US");\r
+ pe.DumpStreamHeader("#GUID");\r
+ pe.DumpStreamHeader("#Blob");\r
+\r
+ Console.WriteLine("CLI image detected, dumping metadata tables.");\r
+ TablesHeap tabs = pe.MetaDataRoot.TablesHeap;\r
+\r
+ foreach (MDTable t in tabs.Tables) {\r
+ t.Dump (Console.Out);\r
+ }\r
+\r
+ /*\r
+ MethodIL il = pe.MetaDataRoot.GetMethodBody(1);\r
+ Console.WriteLine(il);\r
+ il.DumpHexBytecode(Console.Out);\r
+ */\r
+ }\r
+ }\r
+\r
+ return 0;\r
+ }\r
+\r
+\r
+\r
+\r
+\r
+ public static void Main (string [] args) {\r
+ if (args.Length == 0) {\r
+ Console.WriteLine ("mddump <PE file>");\r
+ } else {\r
+ Dump (args [0]);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+<?xml version="1.0"?>\r
+\r
+<project name="PET" default="all" basedir=".">\r
+\r
+ <target name="init">\r
+ <tstamp/>\r
+ <echo message="Init..."/>\r
+ <property name="debug" value="false"/>\r
+ <property name="src.dir" value="..\src"/>\r
+ <property name="bin.dir" value="..\bin"/>\r
+ </target>\r
+\r
+\r
+ <target name="compile" depends="init">\r
+ <csc target="library" output="${bin.dir}/pet.dll" debug="${debug}">\r
+ <arg value="/unsafe"/>\r
+ <sources basedir="..\src\PEToolkit">\r
+ <includes name="**/*.cs"/>\r
+ </sources>\r
+ </csc>\r
+ <csc target="exe" output="${bin.dir}/mddump.exe" debug="${debug}">\r
+ <sources>\r
+ <includes name="mddump.cs"/>\r
+ </sources>\r
+ <arg value="/reference:..\bin\pet.dll"/>\r
+ </csc>\r
+ </target>\r
+\r
+\r
+ <target name="all" depends="init,compile">\r
+ </target>\r
+\r
+</project>
\ No newline at end of file
--- /dev/null
+@echo off\r
+set X=cscript //nologo xslt.wsf /inFile:data\md-schema.xml\r
+\r
+: dir /b /on *.cs > common.src\r
+:cscript //nologo xslt.wsf /inFile:bitconv-types.xml /styleFile:bitconverter.xsl\r
+\r
+\r
+%X% /styleFile:table-id.xsl > code\TableId.cs\r
+%X% /styleFile:coded-id.xsl > code\CodedTokenId.cs\r
+%X% /styleFile:elem-type.xsl > code\ElementType.cs\r
+%X% /styleFile:tabs-decoder.xsl > code\TabsDecoder.cs\r
+%X% /styleFile:tabs-base.xsl > code\TablesHeapBase.cs\r
+%X% /styleFile:rows.xsl > code\Rows.cs\r
+%X% /styleFile:tabs.xsl > code\Tables.cs\r
--- /dev/null
+<types>\r
+ <type name="Int16" short="short" size="2"/>\r
+ <type name="UInt16" short="ushort" size="2"/>\r
+\r
+ <type name="Int32" short="int" size="4"/>\r
+ <type name="UInt32" short="uint" size="4"/>\r
+\r
+ <type name="Int64" short="long" size="8"/>\r
+ <type name="UInt64" short="ulong" size="8"/>\r
+</types>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">\r
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit bitconverter.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit {\r
+\r
+ /// <summary>\r
+ /// Little-endian bit converter.\r
+ /// </summary>\r
+ public sealed class LEBitConverter {\r
+\r
+ internal interface IConverter {\r
+\r
+<xsl:apply-templates select="types/type" mode="ifc"/>\r
+ }\r
+\r
+ public static readonly bool Native = System.BitConverter.IsLittleEndian;\r
+\r
+ private static readonly IConverter impl = System.BitConverter.IsLittleEndian\r
+ ? new LEConverter() as IConverter\r
+ : new BEConverter() as IConverter;\r
+\r
+\r
+\r
+\r
+ private LEBitConverter()\r
+ {\r
+ // Never instantiated.\r
+ }\r
+\r
+<xsl:apply-templates select="types/type" mode="swap"/>\r
+\r
+\r
+\r
+ internal sealed class LEConverter : IConverter {\r
+<xsl:apply-templates select="types/type" mode="le"/>\r
+ }\r
+\r
+ internal sealed class BEConverter : IConverter {\r
+<xsl:apply-templates select="types/type" mode="be"/>\r
+ }\r
+\r
+\r
+\r
+\r
+<xsl:apply-templates select="types/type" mode="main"/>\r
+\r
+ }\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+\r
+<xsl:template match="types/type" mode="ifc">\r
+ <xsl:value-of select="concat('			',@short,' To',@name,'(byte [] val, int idx);
')"/>\r
+</xsl:template>\r
+\r
+\r
+<xsl:template match="types/type" mode="main">\r
+ <xsl:text>		///<summary></summary>
</xsl:text>\r
+ <xsl:value-of select="concat('		public static ',@short,' To',@name,'(byte [] val, int idx)
')"/>\r
+ <xsl:text>		{
</xsl:text>\r
+ <xsl:text>			return impl.To</xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text>(val, idx);
</xsl:text>\r
+ <xsl:text>		}

</xsl:text>\r
+</xsl:template>\r
+\r
+\r
+<xsl:template match="types/type" mode="le">\r
+ <xsl:text>			///<summary></summary>
</xsl:text>\r
+ <xsl:value-of select="concat('			public ',@short,' To',@name,'(byte [] val, int idx)
')"/>\r
+ <xsl:text>			{
</xsl:text>\r
+ <xsl:text>				return BitConverter.To</xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text>(val, idx);
</xsl:text>\r
+ <xsl:text>			}
</xsl:text>\r
+</xsl:template>\r
+\r
+\r
+<xsl:template match="types/type" mode="be">\r
+ <xsl:text>			///<summary></summary>
</xsl:text>\r
+ <xsl:value-of select="concat('			public ',@short,' To',@name,'(byte [] val, int idx)
')"/>\r
+ <xsl:text>			{
</xsl:text>\r
+ <xsl:text>				return Swap</xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text>(BitConverter.To</xsl:text>\r
+ <xsl:value-of select="@name"/>\r
+ <xsl:text>(val, idx));
</xsl:text>\r
+ <xsl:text>			}
</xsl:text>\r
+</xsl:template>\r
+\r
+\r
+<xsl:template match="types/type" mode="swap">\r
+ <xsl:text>		///<summary></summary>
</xsl:text>\r
+ <xsl:value-of select="concat('		unsafe public static ',@short,' Swap',@name,'(',@short,' x)
')"/>\r
+ <xsl:text>		{
</xsl:text>\r
+ <xsl:text>			</xsl:text><xsl:value-of select="concat(@short,'* p = stackalloc ',@short,' [1];')"/><xsl:text>
</xsl:text>\r
+ <xsl:text>			*p = x;
</xsl:text>\r
+ <xsl:text>			byte* bp = (byte*) p;
</xsl:text>\r
+ <xsl:choose>\r
+ <xsl:when test="@size = '2'">\r
+ <xsl:text>			byte b = bp [0];
</xsl:text>\r
+ <xsl:text>			bp [0] = bp [1];
</xsl:text>\r
+ <xsl:text>			bp [1] = b;
</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="@size = '4'">\r
+ <xsl:text>			byte b = bp [0];
</xsl:text>\r
+ <xsl:text>			bp [0] = bp [3];
</xsl:text>\r
+ <xsl:text>			bp [3] = b;
</xsl:text>\r
+ <xsl:text>			b = bp [1];
</xsl:text>\r
+ <xsl:text>			bp [1] = bp [2];
</xsl:text>\r
+ <xsl:text>			bp [2] = b;
</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="@size = '8'">\r
+ <xsl:text>			byte b = bp [0];
</xsl:text>\r
+ <xsl:text>			bp [0] = bp [7];
</xsl:text>\r
+ <xsl:text>			bp [7] = b;
</xsl:text>\r
+ <xsl:text>			b = bp [1];
</xsl:text>\r
+ <xsl:text>			bp [1] = bp [6];
</xsl:text>\r
+ <xsl:text>			bp [6] = b;
</xsl:text>\r
+ <xsl:text>			b = bp [2];
</xsl:text>\r
+ <xsl:text>			bp [2] = bp [5];
</xsl:text>\r
+ <xsl:text>			bp [5] = b;
</xsl:text>\r
+ <xsl:text>			b = bp [3];
</xsl:text>\r
+ <xsl:text>			bp [3] = bp [4];
</xsl:text>\r
+ <xsl:text>			bp [4] = b;
</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>			// Not implemented
</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:text>			return *p;
</xsl:text>\r
+ <xsl:text>		}

</xsl:text>\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or coded-id.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:text><![CDATA[\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public enum CodedTokenId {\r
+\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/coded-tokens/map">\r
+<xsl:text>		</xsl:text><xsl:value-of select="@name"/> = <xsl:value-of select="position() - 1"/>,\r
+</xsl:for-each>\r
+ }\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+<ilasm>\r
+ <opcodes>\r
+ <opcode name="nop" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x0"/>\r
+ <opcode name="break" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Break" o1="0xFF" o2="0x1"/>\r
+ <opcode name="ldarg.0" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x2"/>\r
+ <opcode name="ldarg.1" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x3"/>\r
+ <opcode name="ldarg.2" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x4"/>\r
+ <opcode name="ldarg.3" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5"/>\r
+ <opcode name="ldloc.0" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x6"/>\r
+ <opcode name="ldloc.1" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x7"/>\r
+ <opcode name="ldloc.2" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x8"/>\r
+ <opcode name="ldloc.3" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x9"/>\r
+ <opcode name="stloc.0" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA"/>\r
+ <opcode name="stloc.1" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xB"/>\r
+ <opcode name="stloc.2" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC"/>\r
+ <opcode name="stloc.3" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xD"/>\r
+ <opcode name="ldarg.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xE"/>\r
+ <opcode name="ldarga.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xF"/>\r
+ <opcode name="starg.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x10"/>\r
+ <opcode name="ldloc.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x11"/>\r
+ <opcode name="ldloca.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x12"/>\r
+ <opcode name="stloc.s" size="1" opcode-type="Macro" operand-type="ShortInlineVar" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x13"/>\r
+ <opcode name="ldnull" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop0" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x14"/>\r
+ <opcode name="ldc.i4.m1" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x15"/>\r
+ <opcode name="ldc.i4.0" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x16"/>\r
+ <opcode name="ldc.i4.1" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x17"/>\r
+ <opcode name="ldc.i4.2" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x18"/>\r
+ <opcode name="ldc.i4.3" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x19"/>\r
+ <opcode name="ldc.i4.4" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1A"/>\r
+ <opcode name="ldc.i4.5" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1B"/>\r
+ <opcode name="ldc.i4.6" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1C"/>\r
+ <opcode name="ldc.i4.7" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1D"/>\r
+ <opcode name="ldc.i4.8" size="1" opcode-type="Macro" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1E"/>\r
+ <opcode name="ldc.i4.s" size="1" opcode-type="Macro" operand-type="ShortInlineI" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x1F"/>\r
+ <opcode name="ldc.i4" size="1" opcode-type="Primitive" operand-type="InlineI" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x20"/>\r
+ <opcode name="ldc.i8" size="1" opcode-type="Primitive" operand-type="InlineI8" pop="Pop0" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x21"/>\r
+ <opcode name="ldc.r4" size="1" opcode-type="Primitive" operand-type="ShortInlineR" pop="Pop0" push="Pushr4" flow-ctrl="Next" o1="0xFF" o2="0x22"/>\r
+ <opcode name="ldc.r8" size="1" opcode-type="Primitive" operand-type="InlineR" pop="Pop0" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0x23"/>\r
+ <opcode name="dup" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Push1_push1" flow-ctrl="Next" o1="0xFF" o2="0x25"/>\r
+ <opcode name="pop" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x26"/>\r
+ <opcode name="jmp" size="1" opcode-type="Primitive" operand-type="InlineMethod" pop="Pop0" push="Push0" flow-ctrl="Call" o1="0xFF" o2="0x27"/>\r
+ <opcode name="call" size="1" opcode-type="Primitive" operand-type="InlineMethod" pop="Varpop" push="Varpush" flow-ctrl="Call" o1="0xFF" o2="0x28"/>\r
+ <opcode name="calli" size="1" opcode-type="Primitive" operand-type="InlineSig" pop="Varpop" push="Varpush" flow-ctrl="Call" o1="0xFF" o2="0x29"/>\r
+ <opcode name="ret" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Varpop" push="Push0" flow-ctrl="Return" o1="0xFF" o2="0x2A"/>\r
+ <opcode name="br.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop0" push="Push0" flow-ctrl="Branch" o1="0xFF" o2="0x2B"/>\r
+ <opcode name="brfalse.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Popi" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x2C"/>\r
+ <opcode name="brtrue.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Popi" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x2D"/>\r
+ <opcode name="beq.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x2E"/>\r
+ <opcode name="bge.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x2F"/>\r
+ <opcode name="bgt.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x30"/>\r
+ <opcode name="ble.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x31"/>\r
+ <opcode name="blt.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x32"/>\r
+ <opcode name="bne.un.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x33"/>\r
+ <opcode name="bge.un.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x34"/>\r
+ <opcode name="bgt.un.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x35"/>\r
+ <opcode name="ble.un.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x36"/>\r
+ <opcode name="blt.un.s" size="1" opcode-type="Macro" operand-type="ShortInlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x37"/>\r
+ <opcode name="br" size="1" opcode-type="Primitive" operand-type="InlineBrTarget" pop="Pop0" push="Push0" flow-ctrl="Branch" o1="0xFF" o2="0x38"/>\r
+ <opcode name="brfalse" size="1" opcode-type="Primitive" operand-type="InlineBrTarget" pop="Popi" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x39"/>\r
+ <opcode name="brtrue" size="1" opcode-type="Primitive" operand-type="InlineBrTarget" pop="Popi" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3A"/>\r
+ <opcode name="beq" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3B"/>\r
+ <opcode name="bge" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3C"/>\r
+ <opcode name="bgt" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3D"/>\r
+ <opcode name="ble" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3E"/>\r
+ <opcode name="blt" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x3F"/>\r
+ <opcode name="bne.un" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x40"/>\r
+ <opcode name="bge.un" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x41"/>\r
+ <opcode name="bgt.un" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x42"/>\r
+ <opcode name="ble.un" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x43"/>\r
+ <opcode name="blt.un" size="1" opcode-type="Macro" operand-type="InlineBrTarget" pop="Pop1_pop1" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x44"/>\r
+ <opcode name="switch" size="1" opcode-type="Primitive" operand-type="InlineSwitch" pop="Popi" push="Push0" flow-ctrl="Cond_Branch" o1="0xFF" o2="0x45"/>\r
+ <opcode name="ldind.i1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x46"/>\r
+ <opcode name="ldind.u1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x47"/>\r
+ <opcode name="ldind.i2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x48"/>\r
+ <opcode name="ldind.u2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x49"/>\r
+ <opcode name="ldind.i4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x4A"/>\r
+ <opcode name="ldind.u4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x4B"/>\r
+ <opcode name="ldind.i8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x4C"/>\r
+ <opcode name="ldind.i" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x4D"/>\r
+ <opcode name="ldind.r4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushr4" flow-ctrl="Next" o1="0xFF" o2="0x4E"/>\r
+ <opcode name="ldind.r8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0x4F"/>\r
+ <opcode name="ldind.ref" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x50"/>\r
+ <opcode name="stind.ref" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x51"/>\r
+ <opcode name="stind.i1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x52"/>\r
+ <opcode name="stind.i2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x53"/>\r
+ <opcode name="stind.i4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x54"/>\r
+ <opcode name="stind.i8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi8" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x55"/>\r
+ <opcode name="stind.r4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popr4" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x56"/>\r
+ <opcode name="stind.r8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popr8" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x57"/>\r
+ <opcode name="add" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x58"/>\r
+ <opcode name="sub" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x59"/>\r
+ <opcode name="mul" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5A"/>\r
+ <opcode name="div" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5B"/>\r
+ <opcode name="div.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5C"/>\r
+ <opcode name="rem" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5D"/>\r
+ <opcode name="rem.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5E"/>\r
+ <opcode name="and" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x5F"/>\r
+ <opcode name="or" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x60"/>\r
+ <opcode name="xor" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x61"/>\r
+ <opcode name="shl" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x62"/>\r
+ <opcode name="shr" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x63"/>\r
+ <opcode name="shr.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x64"/>\r
+ <opcode name="neg" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x65"/>\r
+ <opcode name="not" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x66"/>\r
+ <opcode name="conv.i1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x67"/>\r
+ <opcode name="conv.i2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x68"/>\r
+ <opcode name="conv.i4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x69"/>\r
+ <opcode name="conv.i8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x6A"/>\r
+ <opcode name="conv.r4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushr4" flow-ctrl="Next" o1="0xFF" o2="0x6B"/>\r
+ <opcode name="conv.r8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0x6C"/>\r
+ <opcode name="conv.u4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x6D"/>\r
+ <opcode name="conv.u8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x6E"/>\r
+ <opcode name="callvirt" size="1" opcode-type="Objmodel" operand-type="InlineMethod" pop="Varpop" push="Varpush" flow-ctrl="Call" o1="0xFF" o2="0x6F"/>\r
+ <opcode name="cpobj" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x70"/>\r
+ <opcode name="ldobj" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popi" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x71"/>\r
+ <opcode name="ldstr" size="1" opcode-type="Objmodel" operand-type="InlineString" pop="Pop0" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x72"/>\r
+ <opcode name="newobj" size="1" opcode-type="Objmodel" operand-type="InlineMethod" pop="Varpop" push="Pushref" flow-ctrl="Call" o1="0xFF" o2="0x73"/>\r
+ <opcode name="castclass" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popref" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x74"/>\r
+ <opcode name="isinst" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popref" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x75"/>\r
+ <opcode name="conv.r.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0x76"/>\r
+ <opcode name="unbox" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Popref" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x79"/>\r
+ <opcode name="throw" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref" push="Push0" flow-ctrl="Throw" o1="0xFF" o2="0x7A"/>\r
+ <opcode name="ldfld" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Popref" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x7B"/>\r
+ <opcode name="ldflda" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Popref" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x7C"/>\r
+ <opcode name="stfld" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Popref_pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x7D"/>\r
+ <opcode name="ldsfld" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0x7E"/>\r
+ <opcode name="ldsflda" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x7F"/>\r
+ <opcode name="stsfld" size="1" opcode-type="Objmodel" operand-type="InlineField" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x80"/>\r
+ <opcode name="stobj" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Popi_pop1" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x81"/>\r
+ <opcode name="conv.ovf.i1.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x82"/>\r
+ <opcode name="conv.ovf.i2.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x83"/>\r
+ <opcode name="conv.ovf.i4.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x84"/>\r
+ <opcode name="conv.ovf.i8.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x85"/>\r
+ <opcode name="conv.ovf.u1.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x86"/>\r
+ <opcode name="conv.ovf.u2.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x87"/>\r
+ <opcode name="conv.ovf.u4.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x88"/>\r
+ <opcode name="conv.ovf.u8.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x89"/>\r
+ <opcode name="conv.ovf.i.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x8A"/>\r
+ <opcode name="conv.ovf.u.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x8B"/>\r
+ <opcode name="boxval" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Pop1" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x8C"/>\r
+ <opcode name="box" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Pop1" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x8C"/>\r
+ <opcode name="newarr" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popi" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x8D"/>\r
+ <opcode name="ldlen" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x8E"/>\r
+ <opcode name="ldelema" size="1" opcode-type="Objmodel" operand-type="InlineType" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x8F"/>\r
+ <opcode name="ldelem.i1" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x90"/>\r
+ <opcode name="ldelem.u1" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x91"/>\r
+ <opcode name="ldelem.i2" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x92"/>\r
+ <opcode name="ldelem.u2" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x93"/>\r
+ <opcode name="ldelem.i4" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x94"/>\r
+ <opcode name="ldelem.u4" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x95"/>\r
+ <opcode name="ldelem.i8" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0x96"/>\r
+ <opcode name="ldelem.i" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0x97"/>\r
+ <opcode name="ldelem.r4" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushr4" flow-ctrl="Next" o1="0xFF" o2="0x98"/>\r
+ <opcode name="ldelem.r8" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0x99"/>\r
+ <opcode name="ldelem.ref" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi" push="Pushref" flow-ctrl="Next" o1="0xFF" o2="0x9A"/>\r
+ <opcode name="stelem.i" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x9B"/>\r
+ <opcode name="stelem.i1" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x9C"/>\r
+ <opcode name="stelem.i2" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x9D"/>\r
+ <opcode name="stelem.i4" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x9E"/>\r
+ <opcode name="stelem.i8" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popi8" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x9F"/>\r
+ <opcode name="stelem.r4" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popr4" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA0"/>\r
+ <opcode name="stelem.r8" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popr8" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA1"/>\r
+ <opcode name="stelem.ref" size="1" opcode-type="Objmodel" operand-type="InlineNone" pop="Popref_popi_popref" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA2"/>\r
+ <opcode name="conv.ovf.i1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB3"/>\r
+ <opcode name="conv.ovf.u1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB4"/>\r
+ <opcode name="conv.ovf.i2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB5"/>\r
+ <opcode name="conv.ovf.u2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB6"/>\r
+ <opcode name="conv.ovf.i4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB7"/>\r
+ <opcode name="conv.ovf.u4" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xB8"/>\r
+ <opcode name="conv.ovf.i8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0xB9"/>\r
+ <opcode name="conv.ovf.u8" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi8" flow-ctrl="Next" o1="0xFF" o2="0xBA"/>\r
+ <opcode name="refanyval" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xC2"/>\r
+ <opcode name="ckfinite" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushr8" flow-ctrl="Next" o1="0xFF" o2="0xC3"/>\r
+ <opcode name="mkrefany" size="1" opcode-type="Primitive" operand-type="InlineType" pop="Popi" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xC6"/>\r
+ <opcode name="ldtoken" size="1" opcode-type="Primitive" operand-type="InlineTok" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD0"/>\r
+ <opcode name="conv.u2" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD1"/>\r
+ <opcode name="conv.u1" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD2"/>\r
+ <opcode name="conv.i" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD3"/>\r
+ <opcode name="conv.ovf.i" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD4"/>\r
+ <opcode name="conv.ovf.u" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xD5"/>\r
+ <opcode name="add.ovf" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xD6"/>\r
+ <opcode name="add.ovf.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xD7"/>\r
+ <opcode name="mul.ovf" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xD8"/>\r
+ <opcode name="mul.ovf.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xD9"/>\r
+ <opcode name="sub.ovf" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xDA"/>\r
+ <opcode name="sub.ovf.un" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Push1" flow-ctrl="Next" o1="0xFF" o2="0xDB"/>\r
+ <opcode name="endfinally" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Return" o1="0xFF" o2="0xDC"/>\r
+ <opcode name="leave" size="1" opcode-type="Primitive" operand-type="InlineBrTarget" pop="Pop0" push="Push0" flow-ctrl="Branch" o1="0xFF" o2="0xDD"/>\r
+ <opcode name="leave.s" size="1" opcode-type="Primitive" operand-type="ShortInlineBrTarget" pop="Pop0" push="Push0" flow-ctrl="Branch" o1="0xFF" o2="0xDE"/>\r
+ <opcode name="stind.i" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xDF"/>\r
+ <opcode name="conv.u" size="1" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFF" o2="0xE0"/>\r
+ <opcode name="prefix7" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xF8"/>\r
+ <opcode name="prefix6" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xF9"/>\r
+ <opcode name="prefix5" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFA"/>\r
+ <opcode name="prefix4" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFB"/>\r
+ <opcode name="prefix3" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFC"/>\r
+ <opcode name="prefix2" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFD"/>\r
+ <opcode name="prefix1" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFE"/>\r
+ <opcode name="prefixref" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFF" o2="0xFF"/>\r
+ <opcode name="arglist" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x0"/>\r
+ <opcode name="ceq" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x1"/>\r
+ <opcode name="cgt" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x2"/>\r
+ <opcode name="cgt.un" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x3"/>\r
+ <opcode name="clt" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x4"/>\r
+ <opcode name="clt.un" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1_pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x5"/>\r
+ <opcode name="ldftn" size="2" opcode-type="Primitive" operand-type="InlineMethod" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x6"/>\r
+ <opcode name="ldvirtftn" size="2" opcode-type="Primitive" operand-type="InlineMethod" pop="Popref" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x7"/>\r
+ <opcode name="ldarg" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFE" o2="0x9"/>\r
+ <opcode name="ldarga" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0xA"/>\r
+ <opcode name="starg" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0xB"/>\r
+ <opcode name="ldloc" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop0" push="Push1" flow-ctrl="Next" o1="0xFE" o2="0xC"/>\r
+ <opcode name="ldloca" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0xD"/>\r
+ <opcode name="stloc" size="2" opcode-type="Primitive" operand-type="InlineVar" pop="Pop1" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0xE"/>\r
+ <opcode name="localloc" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0xF"/>\r
+ <opcode name="endfilter" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Popi" push="Push0" flow-ctrl="Return" o1="0xFE" o2="0x11"/>\r
+ <opcode name="unaligned." size="2" opcode-type="Prefix" operand-type="ShortInlineI" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFE" o2="0x12"/>\r
+ <opcode name="volatile." size="2" opcode-type="Prefix" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFE" o2="0x13"/>\r
+ <opcode name="tail." size="2" opcode-type="Prefix" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0xFE" o2="0x14"/>\r
+ <opcode name="initobj" size="2" opcode-type="Objmodel" operand-type="InlineType" pop="Popi" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x15"/>\r
+ <opcode name="cpblk" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x17"/>\r
+ <opcode name="initblk" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Popi_popi_popi" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x18"/>\r
+ <opcode name="rethrow" size="2" opcode-type="Objmodel" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Throw" o1="0xFE" o2="0x1A"/>\r
+ <opcode name="sizeof" size="2" opcode-type="Primitive" operand-type="InlineType" pop="Pop0" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x1C"/>\r
+ <opcode name="refanytype" size="2" opcode-type="Primitive" operand-type="InlineNone" pop="Pop1" push="Pushi" flow-ctrl="Next" o1="0xFE" o2="0x1D"/>\r
+\r
+ <opcode name="unused99" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x24"/>\r
+ <opcode name="unused58" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x77"/>\r
+ <opcode name="unused1" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0x78"/>\r
+ <opcode name="unused2" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA3"/>\r
+ <opcode name="unused3" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA4"/>\r
+ <opcode name="unused4" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA5"/>\r
+ <opcode name="unused5" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA6"/>\r
+ <opcode name="unused6" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA7"/>\r
+ <opcode name="unused7" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA8"/>\r
+ <opcode name="unused8" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xA9"/>\r
+ <opcode name="unused9" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAA"/>\r
+ <opcode name="unused10" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAB"/>\r
+ <opcode name="unused11" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAC"/>\r
+ <opcode name="unused12" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAD"/>\r
+ <opcode name="unused13" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAE"/>\r
+ <opcode name="unused14" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xAF"/>\r
+ <opcode name="unused15" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xB0"/>\r
+ <opcode name="unused16" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xB1"/>\r
+ <opcode name="unused17" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xB2"/>\r
+ <opcode name="unused50" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xBB"/>\r
+ <opcode name="unused18" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xBC"/>\r
+ <opcode name="unused19" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xBD"/>\r
+ <opcode name="unused20" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xBE"/>\r
+ <opcode name="unused21" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xBF"/>\r
+ <opcode name="unused22" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC0"/>\r
+ <opcode name="unused23" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC1"/>\r
+ <opcode name="unused24" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC4"/>\r
+ <opcode name="unused25" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC5"/>\r
+ <opcode name="unused59" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC7"/>\r
+ <opcode name="unused60" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC8"/>\r
+ <opcode name="unused61" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xC9"/>\r
+ <opcode name="unused62" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCA"/>\r
+ <opcode name="unused63" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCB"/>\r
+ <opcode name="unused64" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCC"/>\r
+ <opcode name="unused65" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCD"/>\r
+ <opcode name="unused66" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCE"/>\r
+ <opcode name="unused67" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xCF"/>\r
+ <opcode name="unused26" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE1"/>\r
+ <opcode name="unused27" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE2"/>\r
+ <opcode name="unused28" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE3"/>\r
+ <opcode name="unused29" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE4"/>\r
+ <opcode name="unused30" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE5"/>\r
+ <opcode name="unused31" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE6"/>\r
+ <opcode name="unused32" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE7"/>\r
+ <opcode name="unused33" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE8"/>\r
+ <opcode name="unused34" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xE9"/>\r
+ <opcode name="unused35" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xEA"/>\r
+ <opcode name="unused36" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xEB"/>\r
+ <opcode name="unused37" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xEC"/>\r
+ <opcode name="unused38" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xED"/>\r
+ <opcode name="unused39" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xEE"/>\r
+ <opcode name="unused40" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xEF"/>\r
+ <opcode name="unused41" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF0"/>\r
+ <opcode name="unused42" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF1"/>\r
+ <opcode name="unused43" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF2"/>\r
+ <opcode name="unused44" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF3"/>\r
+ <opcode name="unused45" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF4"/>\r
+ <opcode name="unused46" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF5"/>\r
+ <opcode name="unused47" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF6"/>\r
+ <opcode name="unused48" size="1" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFF" o2="0xF7"/>\r
+ <opcode name="unused56" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x08"/>\r
+ <opcode name="unused57" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x10"/>\r
+ <opcode name="unused68" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x16"/>\r
+ <opcode name="unused69" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x19"/>\r
+ <opcode name="unused52" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x1E"/>\r
+ <opcode name="unused53" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x1F"/>\r
+ <opcode name="unused54" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x20"/>\r
+ <opcode name="unused55" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x21"/>\r
+ <opcode name="unused70" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Next" o1="0xFE" o2="0x22"/>\r
+ <opcode name="illegal" size="2" opcode-type="Nternal" operand-type="InlineNone" pop="Pop0" push="Push0" flow-ctrl="Meta" o1="0x00" o2="0x00"/>\r
+ </opcodes>\r
+\r
+\r
+ <directives>\r
+ <directive name=".addon"/>\r
+ <directive name=".algorithm"/>\r
+ <directive name=".assembly"/>\r
+ <directive name=".backing"/>\r
+ <directive name=".blob"/>\r
+ <directive name=".capability"/>\r
+ <directive name=".cctor"/>\r
+ <directive name=".class"/>\r
+ <directive name=".comtype"/>\r
+ <directive name=".config"/>\r
+ <directive name=".corflags"/>\r
+ <directive name=".ctor"/>\r
+ <directive name=".custom"/>\r
+ <directive name=".data"/>\r
+ <directive name=".emitbyte"/>\r
+ <directive name=".entrypoint"/>\r
+ <directive name=".event"/>\r
+ <directive name=".exeloc"/>\r
+ <directive name=".export"/>\r
+ <directive name=".field"/>\r
+ <directive name=".file"/>\r
+ <directive name=".fire"/>\r
+ <directive name=".get"/>\r
+ <directive name=".hash"/>\r
+ <directive name=".implicitcom"/>\r
+ <directive name=".language"/>\r
+ <directive name=".line"/>\r
+ <directive name="#line"/>\r
+ <directive name=".locale"/>\r
+ <directive name=".locals"/>\r
+ <directive name=".manifestres"/>\r
+ <directive name=".maxstack"/>\r
+ <directive name=".method"/>\r
+ <directive name=".mime"/>\r
+ <directive name=".module"/>\r
+ <directive name=".mresource"/>\r
+ <directive name=".namespace"/>\r
+ <directive name=".originator"/>\r
+ <directive name=".os"/>\r
+ <directive name=".other"/>\r
+ <directive name=".override"/>\r
+ <directive name=".pack"/>\r
+ <directive name=".param"/>\r
+ <directive name=".permission"/>\r
+ <directive name=".permissionset"/>\r
+ <directive name=".processor"/>\r
+ <directive name=".property"/>\r
+ <directive name=".publickey"/>\r
+ <directive name=".publickeytoken"/>\r
+ <directive name=".removeon"/>\r
+ <directive name=".set"/>\r
+ <directive name=".size"/>\r
+ <directive name=".subsystem"/>\r
+ <directive name=".title"/>\r
+ <directive name=".try"/>\r
+ <directive name=".ver"/>\r
+ <directive name=".vtable"/>\r
+ <directive name=".vtentry"/>\r
+ <directive name=".vtfixup"/>\r
+ <directive name=".zeroinit"/>\r
+ </directives>\r
+\r
+ <keywords>\r
+ <keyword name="at"/>\r
+ <keyword name="as"/>\r
+ <keyword name="implicitcom"/>\r
+ <keyword name="implicitres"/>\r
+ <keyword name="noappdomain"/>\r
+ <keyword name="noprocess"/>\r
+ <keyword name="nomachine"/>\r
+ <keyword name="extern"/>\r
+ <keyword name="instance"/>\r
+ <keyword name="explicit"/>\r
+ <keyword name="default"/>\r
+ <keyword name="vararg"/>\r
+ <keyword name="unmanaged"/>\r
+ <keyword name="cdecl"/>\r
+ <keyword name="stdcall"/>\r
+ <keyword name="thiscall"/>\r
+ <keyword name="fastcall"/>\r
+ <keyword name="marshal"/>\r
+ <keyword name="in"/>\r
+ <keyword name="out"/>\r
+ <keyword name="opt"/>\r
+ <keyword name="lcid"/>\r
+ <keyword name="retval"/>\r
+ <keyword name="static"/>\r
+ <keyword name="public"/>\r
+ <keyword name="private"/>\r
+ <keyword name="family"/>\r
+ <keyword name="initonly"/>\r
+ <keyword name="rtspecialname"/>\r
+ <keyword name="specialname"/>\r
+ <keyword name="assembly"/>\r
+ <keyword name="famandassem"/>\r
+ <keyword name="famorassem"/>\r
+ <keyword name="privatescope"/>\r
+ <keyword name="literal"/>\r
+ <keyword name="notserialized"/>\r
+ <keyword name="value"/>\r
+ <keyword name="not_in_gc_heap"/>\r
+ <keyword name="interface"/>\r
+ <keyword name="sealed"/>\r
+ <keyword name="abstract"/>\r
+ <keyword name="auto"/>\r
+ <keyword name="sequential"/>\r
+ <keyword name="ansi"/>\r
+ <keyword name="unicode"/>\r
+ <keyword name="autochar"/>\r
+ <keyword name="import"/>\r
+ <keyword name="serializable"/>\r
+ <keyword name="nested"/>\r
+ <keyword name="lateinit"/>\r
+ <keyword name="extends"/>\r
+ <keyword name="implements"/>\r
+ <keyword name="final"/>\r
+ <keyword name="virtual"/>\r
+ <keyword name="hidebysig"/>\r
+ <keyword name="newslot"/>\r
+ <keyword name="unmanagedexp"/>\r
+ <keyword name="pinvokeimpl"/>\r
+ <keyword name="nomangle"/>\r
+ <keyword name="ole"/>\r
+ <keyword name="lasterr"/>\r
+ <keyword name="winapi"/>\r
+ <keyword name="native"/>\r
+ <keyword name="il"/>\r
+ <keyword name="cil"/>\r
+ <keyword name="optil"/>\r
+ <keyword name="managed"/>\r
+ <keyword name="forwardref"/>\r
+ <keyword name="runtime"/>\r
+ <keyword name="internalcall"/>\r
+ <keyword name="synchronized"/>\r
+ <keyword name="noinlining"/>\r
+ <keyword name="custom"/>\r
+ <keyword name="fixed"/>\r
+ <keyword name="sysstring"/>\r
+ <keyword name="array"/>\r
+ <keyword name="variant"/>\r
+ <keyword name="currency"/>\r
+ <keyword name="syschar"/>\r
+ <keyword name="void"/>\r
+ <keyword name="bool"/>\r
+ <keyword name="int8"/>\r
+ <keyword name="int16"/>\r
+ <keyword name="int32"/>\r
+ <keyword name="int64"/>\r
+ <keyword name="float32"/>\r
+ <keyword name="float64"/>\r
+ <keyword name="error"/>\r
+ <keyword name="unsigned"/>\r
+ <keyword name="decimal"/>\r
+ <keyword name="date"/>\r
+ <keyword name="bstr"/>\r
+ <keyword name="lpstr"/>\r
+ <keyword name="lpwstr"/>\r
+ <keyword name="lptstr"/>\r
+ <keyword name="objectref"/>\r
+ <keyword name="iunknown"/>\r
+ <keyword name="idispatch"/>\r
+ <keyword name="struct"/>\r
+ <keyword name="safearray"/>\r
+ <keyword name="int"/>\r
+ <keyword name="byvalstr"/>\r
+ <keyword name="tbstr"/>\r
+ <keyword name="lpvoid"/>\r
+ <keyword name="any"/>\r
+ <keyword name="float"/>\r
+ <keyword name="lpstruct"/>\r
+ <keyword name="null"/>\r
+ <keyword name="ptr"/>\r
+ <keyword name="vector"/>\r
+ <keyword name="hresult"/>\r
+ <keyword name="carray"/>\r
+ <keyword name="userdefined"/>\r
+ <keyword name="record"/>\r
+ <keyword name="filetime"/>\r
+ <keyword name="blob"/>\r
+ <keyword name="stream"/>\r
+ <keyword name="storage"/>\r
+ <keyword name="streamed_object"/>\r
+ <keyword name="stored_object"/>\r
+ <keyword name="blob_object"/>\r
+ <keyword name="cf"/>\r
+ <keyword name="clsid"/>\r
+ <keyword name="method"/>\r
+ <keyword name="class"/>\r
+ <keyword name="pinned"/>\r
+ <keyword name="modreq"/>\r
+ <keyword name="modopt"/>\r
+ <keyword name="typedref"/>\r
+ <keyword name="wchar"/>\r
+ <keyword name="char"/>\r
+ <keyword name="fromunmanaged"/>\r
+ <keyword name="callmostderived"/>\r
+ <keyword name="bytearray"/>\r
+ <keyword name="with"/>\r
+ <keyword name="init"/>\r
+ <keyword name="to"/>\r
+ <keyword name="catch"/>\r
+ <keyword name="filter"/>\r
+ <keyword name="finally"/>\r
+ <keyword name="fault"/>\r
+ <keyword name="handler"/>\r
+ <keyword name="tls"/>\r
+ <keyword name="field"/>\r
+ <keyword name="request"/>\r
+ <keyword name="demand"/>\r
+ <keyword name="assert"/>\r
+ <keyword name="deny"/>\r
+ <keyword name="permitonly"/>\r
+ <keyword name="linkcheck"/>\r
+ <keyword name="inheritcheck"/>\r
+ <keyword name="reqmin"/>\r
+ <keyword name="reqopt"/>\r
+ <keyword name="reqrefuse"/>\r
+ <keyword name="prejitgrant"/>\r
+ <keyword name="prejitdeny"/>\r
+ <keyword name="noncasdemand"/>\r
+ <keyword name="noncaslinkdemand"/>\r
+ <keyword name="noncasinheritance"/>\r
+ <keyword name="readonly"/>\r
+ <keyword name="nometadata"/>\r
+ <keyword name="algorithm"/>\r
+ <keyword name="fullorigin"/>\r
+ <keyword name="nan"/>\r
+ <keyword name="inf"/>\r
+ <keyword name="publickey"/>\r
+ <keyword name="enablejittracking"/>\r
+ <keyword name="disablejitoptimizer"/>\r
+ <keyword name="preservesig"/>\r
+ <keyword name="beforefieldinit"/>\r
+\r
+ <keyword name="alignment"/>\r
+ <keyword name="nullref"/>\r
+ <keyword name="valuetype"/>\r
+ <keyword name="Compilercontrolled"/>\r
+ <keyword name="reqsecobj"/>\r
+\r
+ <keyword name="enum"/>\r
+ <keyword name="object"/>\r
+ <keyword name="string"/>\r
+ <keyword name="true"/>\r
+ <keyword name="false"/>\r
+\r
+ </keywords>\r
+\r
+</ilasm>\r
--- /dev/null
+<!-- updated according to final specs -->\r
+<md-schema version="1.0">\r
+\r
+<!-- see tables in 23.2.6 -->\r
+<coded-tokens>\r
+\r
+ <!-- NOTE: specs use token-type spelling (map/table/@token-type) rather than table id -->\r
+\r
+ <map name="TypeDefOrRef" bits="2">\r
+ <table name="TypeDef" tag="0"/>\r
+ <table name="TypeRef" tag="1"/>\r
+ <table name="TypeSpec" tag="2"/>\r
+ </map>\r
+\r
+ <map name="HasConstant" bits="2">\r
+ <table name="Field" tag="0" token-type="FieldDef"/>\r
+ <table name="Param" tag="1" token-type="ParamDef"/>\r
+ <table name="Property" tag="2"/>\r
+ </map>\r
+\r
+ <map name="HasCustomAttribute" bits="5"><!-- specs: HasCustomattribute -->\r
+ <table name="Method" tag="0" token-type="MethodDef"/>\r
+ <table name="Field" tag="1" token-type="FieldDef"/>\r
+ <table name="TypeRef" tag="2"/>\r
+ <table name="TypeDef" tag="3"/>\r
+ <table name="Param" tag="4" token-type="ParamDef"/>\r
+ <table name="InterfaceImpl" tag="5"/>\r
+ <table name="MemberRef" tag="6"/>\r
+ <table name="Module" tag="7"/>\r
+ <table name="DeclSecurity" tag="8" token-type="Permission"/>\r
+ <table name="Property" tag="9"/>\r
+ <table name="Event" tag="10"/>\r
+ <table name="StandAloneSig" tag="11" token-type="Signature"/>\r
+ <table name="ModuleRef" tag="12"/>\r
+ <table name="TypeSpec" tag="13"/>\r
+ <table name="Assembly" tag="14"/>\r
+ <table name="AssemblyRef" tag="15"/>\r
+ <table name="File" tag="16"/>\r
+ <table name="ExportedType" tag="17"/>\r
+ <table name="ManifestResource" tag="18"/>\r
+ </map>\r
+\r
+ <map name="HasFieldMarshal" bits="1"><!-- specs: HasFieldMarshall -->\r
+ <table name="Field" tag="0" token-type="FieldDef"/>\r
+ <table name="Param" tag="1" token-type="ParamDef"/>\r
+ </map>\r
+\r
+ <map name="HasDeclSecurity" bits="2">\r
+ <table name="TypeDef" tag="0"/>\r
+ <table name="Method" tag="1" token-type="MethodDef"/>\r
+ <table name="Assembly" tag="2"/>\r
+ </map>\r
+\r
+ <map name="MemberRefParent" bits="3">\r
+ <table name="TypeDef" tag="0"/><!-- specs: Not used -->\r
+ <table name="TypeRef" tag="1"/>\r
+ <table name="ModuleRef" tag="2"/>\r
+ <table name="Method" tag="3" token-type="MethodDef"/>\r
+ <table name="TypeSpec" tag="4"/>\r
+ </map>\r
+\r
+ <map name="HasSemantics" bits="1">\r
+ <table name="Event" tag="0"/>\r
+ <table name="Property" tag="1"/>\r
+ </map>\r
+\r
+ <map name="MethodDefOrRef" bits="1">\r
+ <table name="Method" tag="0" token-type="MethodDef"/>\r
+ <table name="MemberRef" tag="1"/>\r
+ </map>\r
+\r
+ <map name="MemberForwarded" bits="1">\r
+ <table name="Field" tag="0" token-type="FieldDef"/>\r
+ <table name="Method" tag="1" token-type="MethodDef"/>\r
+ </map>\r
+\r
+ <map name="Implementation" bits="2">\r
+ <table name="File" tag="0"/>\r
+ <table name="AssemblyRef" tag="1"/>\r
+ <table name="ExportedType" tag="2"/><!-- specs: tag value absent -->\r
+ </map>\r
+\r
+ <map name="CustomAttributeType" bits="3">\r
+ <table name="TypeRef" tag="0"/><!-- specs: not used -->\r
+ <table name="TypeDef" tag="1"/><!-- specs: not used -->\r
+ <table name="Method" tag="2" token-type="MethodDef"/>\r
+ <table name="MemberRef" tag="3"/>\r
+ <table name="String" tag="4"/><!-- specs: not used -->\r
+ </map>\r
+\r
+ <!-- LAMESPEC: 2 bits per tag, specs claims 3 -->\r
+ <map name="ResolutionScope" bits="2">\r
+ <table name="Module" tag="0"/>\r
+ <table name="ModuleRef" tag="1"/>\r
+ <table name="AssemblyRef" tag="2"/><!-- LAMESPEC: tag=3 -->\r
+ <table name="TypeRef" tag="3"/><!-- LAMESPEC: tag=4 -->\r
+ </map>\r
+\r
+</coded-tokens>\r
+\r
+\r
+<!-- 22.1.15 Element Types used in Signatures -->\r
+<element-types>\r
+ <type name="End" value="0x00" remarks="Marks end of a list."/>\r
+ <type name="Void" value="0x01"/>\r
+ <type name="Boolean" value="0x02"/>\r
+ <type name="Char" value="0x03"/>\r
+ <type name="I1" value="0x04"/>\r
+ <type name="U1" value="0x05"/>\r
+ <type name="I2" value="0x06"/>\r
+ <type name="U2" value="0x07"/>\r
+ <type name="I4" value="0x08"/>\r
+ <type name="U4" value="0x09"/>\r
+ <type name="I8" value="0x0a"/>\r
+ <type name="U8" value="0x0b"/>\r
+ <type name="R4" value="0x0c"/>\r
+ <type name="R8" value="0x0d"/>\r
+ <type name="String" value="0x0e"/>\r
+ <type name="Ptr" value="0x0f" remarks="Followed by <type> token."/>\r
+ <type name="ByRef" value="0x10" remarks="Followed by <type> token."/>\r
+ <type name="ValueType" value="0x11" remarks="Followed by <type> token."/>\r
+ <type name="Class" value="0x12" remarks="Followed by <type> token."/>\r
+ <type name="Array" value="0x14"/>\r
+ <type name="TypedByRef" value="0x16"/>\r
+ <type name="I" value="0x18" remarks="System.IntPtr"/>\r
+ <type name="U" value="0x19" remarks="System.UIntPtr"/>\r
+ <type name="FnPtr" value="0x1b" remarks="Followed by full method signature."/>\r
+ <type name="Object" value="0x1c" remarks="System.Object"/>\r
+ <type name="SzArray" value="0x1d" remarks="Single-dim array with 0 lower bound."/>\r
+ <type name="CModReqd" value="0x1f" remarks="Required modifier : followed by a TypeDef or TypeRef token."/>\r
+ <type name="CModOpt" value="0x20" remarks="Optional modifier : followed by a TypeDef or TypeRef token."/>\r
+ <type name="Internal" value="0x21" remarks="Implemented within the CLR."/>\r
+\r
+ <type name="Modifier" value="0x40" remarks="Or'd with following element types."/>\r
+ <type name="Sentinel" value="0x41" remarks="Sentinel for varargs method signature."/>\r
+ <type name="Pinned" value="0x45" remarks="Denotes a local variable that points at a pinned object."/>\r
+</element-types>\r
+\r
+\r
+\r
+\r
+<!--\r
+ Metadata tables.\r
+-->\r
+\r
+<tables>\r
+\r
+ <!-- -->\r
+ <table name="Module" id="0x00" section="21.27">\r
+ <schema>\r
+ <field name="Generation" type="ushort"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Mvid" type="index(#GUID)"/>\r
+ <field name="EncId" type="index(#GUID)"/>\r
+ <field name="EncBaseId" type="index(#GUID)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="TypeRef" id="0x01" section="21.35">\r
+ <schema>\r
+ <field name="ResolutionScope" type="coded-index(ResolutionScope)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Namespace" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="TypeDef" id="0x02" section="21.34">\r
+ <schema>\r
+ <field name="Flags" type="uint" cli-type="System.Reflection.TypeAttributes"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Namespace" type="index(#Strings)"/>\r
+ <field name="Extends" type="coded-index(TypeDefOrRef)"/>\r
+ <field name="FieldList" type="index(Field)"/>\r
+ <field name="MethodList" type="index(Method)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="FieldPtr" id="0x03" temporary="yes">\r
+ <schema>\r
+ <field name="Field" type="index(Field)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Field" id="0x04" section="21.15">\r
+ <schema>\r
+ <field name="Flags" type="ushort" cli-type="System.Reflection.FieldAttributes"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Signature" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="MethodPtr" id="0x05" temporary="yes">\r
+ <schema>\r
+ <field name="Method" type="index(Method)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Method" id="0x06" section="21.24">\r
+ <schema>\r
+ <field name="RVA" type="RVA" remarks="RVA of the COR_ILMETHOD structure for the body of the method."/>\r
+ <field name="ImplFlags" type="ushort" cli-type="System.Reflection.MethodImplAttributes"/>\r
+ <field name="Flags" type="ushort" cli-type="System.Reflection.MethodAttributes"/><!-- ??? MethodAttribute -->\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Signature" type="index(#Blob)"/>\r
+ <field name="ParamList" type="index(Param)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ParamPtr" id="0x07" temporary="yes">\r
+ <schema>\r
+ <field name="Param" type="index(Param)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Param" id="0x08" section="21.30">\r
+ <schema>\r
+ <field name="Flags" type="ushort" cli-type="System.Reflection.ParameterAttributes"/><!-- specs: ParamAttributes -->\r
+ <field name="Sequence" type="ushort"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="InterfaceImpl" id="0x09" section="21.21">\r
+ <schema>\r
+ <field name="Class" type="index(TypeDef)"/>\r
+ <field name="Interface" type="coded-index(TypeDefOrRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+\r
+ <!-- -->\r
+ <table name="MemberRef" id="0x0a" section="21.23">\r
+ <schema>\r
+ <field name="Class" type="coded-index(MemberRefParent)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Signature" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Constant" id="0x0b" section="21.9">\r
+ <schema>\r
+ <field name="Type" type="short" cli-type="ElementType" remarks="1 byte ElementType constant, followed by a 1-byte padding zero."/>\r
+ <field name="Parent" type="coded-index(HasConstant)"/>\r
+ <field name="Value" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="CustomAttribute" id="0x0c" section="21.10">\r
+ <schema>\r
+ <field name="Parent" type="coded-index(HasCustomAttribute)"/>\r
+ <field name="Type" type="coded-index(CustomAttributeType)"/>\r
+ <field name="Value" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="FieldMarshal" id="0x0d" section="21.17">\r
+ <schema>\r
+ <field name="Parent" type="coded-index(HasFieldMarshal)"/>\r
+ <field name="NativeType" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="DeclSecurity" id="0x0e" section="21.11">\r
+ <schema>\r
+ <field name="Action" type="short"/><!-- TODO: System.Security.SecurityAction -->\r
+ <field name="Parent" type="coded-index(HasDeclSecurity)"/>\r
+ <field name="PermissionSet" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ClassLayout" id="0x0f" section="21.8">\r
+ <schema>\r
+ <field name="PackingSize" type="short"/><!-- TODO: use enum? -->\r
+ <field name="ClassSize" type="int"/>\r
+ <field name="Parent" type="index(TypeDef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="FieldLayout" id="0x10" section="21.16">\r
+ <schema>\r
+ <field name="Offset" type="int"/>\r
+ <field name="Field" type="index(Field)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="StandAloneSig" id="0x11" section="21.33">\r
+ <schema>\r
+ <field name="Signature" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="EventMap" id="0x12" section="21.12">\r
+ <schema>\r
+ <field name="Parent" type="index(TypeDef)"/>\r
+ <field name="EventList" type="index(Event)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="EventPtr" id="0x13" temporary="yes">\r
+ <schema>\r
+ <field name="Event" type="index(Event)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Event" id="0x14" section="21.13">\r
+ <schema>\r
+ <field name="EventFlags" type="short" cli-type="System.Reflection.EventAttributes"/><!-- specs: EventAttribute -->\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="EventType" type="coded-index(TypeDefOrRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="PropertyMap" id="0x15" section="21.32">\r
+ <schema>\r
+ <field name="Parent" type="index(TypeDef)"/>\r
+ <field name="PropertyList" type="index(Property)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="PropertyPtr" id="0x16" temporary="yes">\r
+ <schema>\r
+ <field name="Property" type="index(Property)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Property" id="0x17" section="21.30"><!-- NOTE: previous name was "Properties" -->\r
+ <schema>\r
+ <field name="Flags" type="ushort" cli-type="System.Reflection.PropertyAttributes"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Type" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="MethodSemantics" id="0x18" section="21.26">\r
+ <schema>\r
+ <field name="Semantics" type="ushort" cli-type="MethodSemanticsAttributes"/>\r
+ <field name="Method" type="index(Method)"/>\r
+ <field name="Association" type="coded-index(HasSemantics)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="MethodImpl" id="0x19" section="21.25">\r
+ <schema>\r
+ <field name="Class" type="index(TypeDef)"/>\r
+ <field name="MethodBody" type="coded-index(MethodDefOrRef)"/>\r
+ <field name="MethodDeclaration" type="coded-index(MethodDefOrRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ModuleRef" id="0x1a" section="21.28">\r
+ <schema>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="TypeSpec" id="0x1b" section="21.36">\r
+ <schema>\r
+ <field name="Signature" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ImplMap" id="0x1c" section="21.20">\r
+ <schema>\r
+ <field name="MappingFlags" type="ushort" cli-type="PInvokeAttributes"/>\r
+ <field name="MemberForwarded" type="coded-index(MemberForwarded)"/>\r
+ <field name="ImportName" type="index(#Strings)"/>\r
+ <field name="ImportScope" type="index(ModuleRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="FieldRVA" id="0x1d" section="21.18">\r
+ <schema>\r
+ <field name="RVA" type="RVA"/>\r
+ <field name="Field" type="index(Field)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ENCLog" id="0x1e" temporary="yes">\r
+ <schema>\r
+ <field name="Token" type="uint"/>\r
+ <field name="FuncCode" type="uint"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ENCMap" id="0x1f" temporary="yes">\r
+ <schema>\r
+ <field name="Token" type="uint"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="Assembly" id="0x20" section="21.2">\r
+ <schema>\r
+ <field name="HashAlgId" type="int" cli-type="System.Configuration.Assemblies.AssemblyHashAlgorithm"/>\r
+ <field name="MajorVersion" type="short"/>\r
+ <field name="MinorVersion" type="short"/>\r
+ <field name="BuildNumber" type="short"/>\r
+ <field name="RevisionNumber" type="short"/>\r
+ <field name="Flags" type="uint" cli-type="AssemblyFlags"/>\r
+ <field name="PublicKey" type="index(#Blob)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Culture" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="AssemblyProcessor" id="0x21" section="21.4">\r
+ <schema>\r
+ <field name="Processor" type="int"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="AssemblyOS" id="0x22" section="21.3">\r
+ <schema>\r
+ <field name="OSPlatformID" type="int"/>\r
+ <field name="OSMajorVersion" type="int"/>\r
+ <field name="OSMinorVersion" type="int"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="AssemblyRef" id="0x23" section="21.5">\r
+ <schema>\r
+ <field name="MajorVersion" type="short"/>\r
+ <field name="MinorVersion" type="short"/>\r
+ <field name="BuildNumber" type="short"/>\r
+ <field name="RevisionNumber" type="short"/>\r
+ <field name="Flags" type="uint" cli-type="AssemblyFlags"/>\r
+ <field name="PublicKeyOrToken" type="index(#Blob)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Culture" type="index(#Strings)"/>\r
+ <field name="HashValue" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="AssemblyRefProcessor" id="0x24" section="21.7">\r
+ <schema>\r
+ <field name="Processor" type="int"/>\r
+ <field name="AssemblyRef" type="index(AssemblyRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="AssemblyRefOS" id="0x25" section="21.6">\r
+ <schema>\r
+ <field name="OSPlatformID" type="int"/>\r
+ <field name="OSMajorVersion" type="int"/>\r
+ <field name="OSMinorVersion" type="int"/>\r
+ <field name="AssemblyRef" type="index(AssemblyRef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="File" id="0x26" section="21.19">\r
+ <schema>\r
+ <field name="Flags" type="uint" cli-type="System.IO.FileAttributes"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="HashValue" type="index(#Blob)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ExportedType" id="0x27" section="21.14">\r
+ <schema>\r
+ <field name="Flags" type="uint" cli-type="System.Reflection.TypeAttributes"/>\r
+ <field name="TypeDefId" type="index(TypeDef)"/>\r
+ <field name="TypeName" type="index(#Strings)"/>\r
+ <field name="TypeNamespace" type="index(#Strings)"/>\r
+ <field name="Implementation" type="coded-index(Implementation)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="ManifestResource" id="0x28" section="21.22">\r
+ <schema>\r
+ <field name="Offset" type="int"/>\r
+ <field name="Flags" type="uint" cli-type="ManifestResourceAttributes"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ <field name="Implementation" type="coded-index(Implementation)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="NestedClass" id="0x29" section="21.29">\r
+ <schema>\r
+ <field name="NestedClass" type="index(TypeDef)"/>\r
+ <field name="EnclosingClass" type="index(TypeDef)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="TypeTyPar" id="0x2a" temporary="yes">\r
+ <schema>\r
+ <field name="Number" type="ushort"/>\r
+ <field name="Class" type="index(TypeDef)"/>\r
+ <field name="Bound" type="coded-index(TypeDefOrRef)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+ <!-- -->\r
+ <table name="MethodTyPar" id="0x2b" temporary="yes">\r
+ <schema>\r
+ <field name="Number" type="ushort"/>\r
+ <field name="Method" type="index(Method)"/>\r
+ <field name="Bound" type="coded-index(TypeDefOrRef)"/>\r
+ <field name="Name" type="index(#Strings)"/>\r
+ </schema>\r
+ </table>\r
+\r
+\r
+</tables>\r
+\r
+</md-schema>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or elem-type.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:text><![CDATA[\r
+ /// <summary>\r
+ /// Element types.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Partition II, 22.1.14 Element Types used in Signatures\r
+ /// </remarks>\r
+ public enum ElementType {\r
+\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/element-types/type">\r
+<xsl:text>		</xsl:text><xsl:value-of select="@name"/> = <xsl:value-of select="@value"/>,\r
+</xsl:for-each>\r
+ }\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+<!-- -->\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<!-- extracts arg x from expression of from 'f(x)' -->\r
+<xsl:template name="extract-arg">\r
+ <xsl:param name="expr" select="@type"/>\r
+ <xsl:value-of select="normalize-space(substring-after(substring-before($expr,')'),'('))"/>\r
+</xsl:template>\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template name="get-expanded-size">\r
+ <xsl:param name="fields" select="schema/field"/>\r
+\r
+ <xsl:for-each select="$fields">\r
+ <xsl:choose>\r
+ <!-- RVA special case, PE library type -->\r
+ <xsl:when test="@type = 'RVA'">\r
+ <xsl:text>RVA.Size</xsl:text>\r
+ </xsl:when>\r
+ <!-- table indices -->\r
+ <xsl:when test="starts-with(@type,'index') or starts-with(@type,'coded-index')">\r
+ <xsl:text>4</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="concat('sizeof (', @type, ')')"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text> + </xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template name="get-field-type">\r
+ <xsl:param name="field" select="."/>\r
+\r
+ <xsl:choose>\r
+ <!-- table indices -->\r
+ <xsl:when test="starts-with($field/@type,'index')">\r
+ <xsl:text>int</xsl:text>\r
+ </xsl:when>\r
+ <!-- coded token -->\r
+ <xsl:when test="starts-with($field/@type,'coded-index')">\r
+ <xsl:text>MDToken</xsl:text>\r
+ </xsl:when>\r
+ <!-- explicit library type -->\r
+ <xsl:when test="$field/@cli-type">\r
+ <xsl:value-of select="$field/@cli-type"/>\r
+ </xsl:when>\r
+ <!-- primitive type -->\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="$field/@type"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+</xsl:stylesheet>\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:import href="gen-utils.xsl"/>\r
+<xsl:output method="text"/>\r
+\r
+\r
+<!--\r
+-->\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or rows.xsl if you want to make changes.\r
+\r
+using System;\r
+using System.IO;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:for-each select="md-schema/tables/table">\r
+\r
+ /// <summary>\r
+ /// Represents row in <xsl:value-of select="@name"/> table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// <xsl:if test="@section">See Partition II, Metadata; section <xsl:value-of select="@section"/></xsl:if>\r
+ /// </remarks>\r
+ public class <xsl:value-of select="@name"/>Row : Row {\r
+\r
+ private MDTable table;\r
+\r
+ <xsl:for-each select="schema/field">\r
+ public <xsl:call-template name="get-field-type"/><xsl:value-of select="concat(' ',@name)"/>;</xsl:for-each>\r
+\r
+ public <xsl:value-of select="@name"/>Row()\r
+ {\r
+ }\r
+\r
+ public <xsl:value-of select="@name"/>Row(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in <xsl:value-of select="@name"/> table has <xsl:value-of select="count(schema/field)"/> columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return <xsl:value-of select="count(schema/field)"/>;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return <xsl:call-template name="get-expanded-size"/>;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ <xsl:for-each select="schema/field">\r
+ this.<xsl:value-of select="@name"/> = <xsl:call-template name="get-field-conversion-code"/>;\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text>offs += </xsl:text>\r
+ <xsl:call-template name="get-expanded-size">\r
+ <xsl:with-param name="fields" select="."/>\r
+ </xsl:call-template>\r
+ <xsl:text>;</xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+ }\r
+\r
+ <xsl:variable name="spaces" select="' '"/>\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ <xsl:text>string dump = String.Format(</xsl:text>\r
+ <xsl:for-each select="schema/field">\r
+ "<xsl:value-of select="concat(@name,substring($spaces,1,18 - string-length(@name)))"/>: {<xsl:value-of select="position () - 1"/>}" <xsl:text>+ Environment.NewLine</xsl:text>\r
+ <xsl:if test="position() != last()"><xsl:text> + </xsl:text></xsl:if>\r
+ <xsl:if test="position() = last()"><xsl:text>,</xsl:text></xsl:if>\r
+ </xsl:for-each>\r
+ <xsl:for-each select="schema/field">\r
+ <xsl:choose><!-- TODO: do something about ugly expression below -->\r
+ <xsl:when test="contains(@type,'#Strings')">\r
+ (<xsl:text>Table == null) ? </xsl:text>\r
+ <xsl:value-of select="concat(@name, '.ToString()')"/>\r
+ <xsl:text> : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [</xsl:text>\r
+ <xsl:value-of select="@name"/><xsl:text>] + "\" (#Strings[0x" + </xsl:text><xsl:value-of select="@name"/><xsl:text>.ToString("X") + "])"</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(@type,'index') and not(contains(@type,'coded-index'))">\r
+ "<xsl:call-template name="extract-arg"/>[" + <xsl:value-of select="@name"/><xsl:text>.ToString() + "]"</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ this.<xsl:value-of select="@name"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="position() != last()"><xsl:text>,</xsl:text></xsl:if>\r
+ </xsl:for-each>\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+</xsl:for-each>\r
+\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template name="get-field-conversion-code">\r
+ <xsl:param name="field" select="."/>\r
+ <xsl:variable name="type" select="$field/@type"/>\r
+\r
+ <xsl:choose>\r
+ <!-- RVA - library type -->\r
+ <xsl:when test="$type = 'RVA'">\r
+ <xsl:text>LEBitConverter.ToUInt32(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+\r
+ <!-- table indices -->\r
+ <xsl:when test="starts-with($type,'index')">\r
+ <xsl:text>LEBitConverter.ToInt32(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+\r
+ <!-- coded tokens -->\r
+ <xsl:when test="starts-with($type,'coded-index')">\r
+ <xsl:text>TabsDecoder.DecodeToken(CodedTokenId.</xsl:text>\r
+ <xsl:call-template name="extract-arg">\r
+ <xsl:with-param name="expr" select="$type"/>\r
+ </xsl:call-template>\r
+ <xsl:text>, LEBitConverter.ToInt32(buff, offs))</xsl:text>\r
+ </xsl:when>\r
+\r
+ <!-- primitive type -->\r
+ <xsl:otherwise>\r
+ <!-- explicitly mapped to library type -->\r
+ <xsl:if test="$field/@cli-type">\r
+ <xsl:value-of select="concat('(', $field/@cli-type, ') ')"/>\r
+ </xsl:if>\r
+ <xsl:choose>\r
+ <xsl:when test="$type = 'byte'">\r
+ <xsl:text>buff [offs]</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'short'">\r
+ <xsl:text>LEBitConverter.ToInt16(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'ushort'">\r
+ <xsl:text>LEBitConverter.ToUInt16(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'int'">\r
+ <xsl:text>LEBitConverter.ToInt32(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'uint'">\r
+ <xsl:text>LEBitConverter.ToUInt32(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'long'">\r
+ <xsl:text>LEBitConverter.ToInt64(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="$type = 'ulong'">\r
+ <xsl:text>LEBitConverter.ToUInt64(buff, offs)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>/* ERROR! */</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or table-id.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:text><![CDATA[\r
+ /// <summary>\r
+ /// Identifiers for tables in #~ heap.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Partition II, 21.x\r
+ /// </remarks>\r
+ public enum TableId {\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/tables/table">\r
+<xsl:text>		</xsl:text><xsl:value-of select="@name"/> = <xsl:value-of select="@id"/>,\r
+</xsl:for-each>\r
+\r
+ <!-- NOTE: bound values assigned explicitly based on XML definition,\r
+ so it's safe to add your own members below/above these lines.\r
+ -->\r
+ MAX = <xsl:value-of select="md-schema/tables/table[position()=last()]/@name"/>,\r
+ Count = MAX + 1\r
+ }\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs-base.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:text><![CDATA[\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public abstract class TablesHeapBase : MDHeap {\r
+\r
+ internal TablesHeapBase(MDStream stream) : base(stream)\r
+ {\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of valid tables (64-bit).\r
+ /// </summary>\r
+ public abstract long Valid {get; set;}\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of sorted tables (64-bit).\r
+ /// </summary>\r
+ public abstract long Sorted {get; set;}\r
+\r
+\r
+ //\r
+ // Accessors to decode Valid bitvector.\r
+ //\r
+\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/tables/table">\r
+ /// <summary>\r
+ /// True if heap has <xsl:value-of select="@name"/> table.\r
+ /// </summary>\r
+ public bool Has<xsl:value-of select="@name"/> {\r
+ get {\r
+ return (Valid & (1L << <xsl:value-of select="@id"/>)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << <xsl:value-of select="@id"/>);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+</xsl:for-each>\r
+\r
+ }\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:import href="gen-utils.xsl"/>\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs-decoder.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:text><![CDATA[\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public sealed class TabsDecoder {\r
+\r
+ private TabsDecoder()\r
+ {\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public static MDToken DecodeToken(CodedTokenId id, int data)\r
+ {\r
+ MDToken res = new MDToken();\r
+ int tag;\r
+ int rid;\r
+ TokenType tok;\r
+\r
+ switch (id) {\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/coded-tokens/map">\r
+ case CodedTokenId.<xsl:value-of select="@name"/> :\r
+ tag = data & 0x<xsl:value-of select="substring('000103070F1F3F7FFF',1 + (2 * @bits),2)"/>;\r
+ rid = (int) ((uint) data >> <xsl:value-of select="@bits"/>);\r
+ switch (tag) {\r
+<xsl:for-each select="table">\r
+ <xsl:variable name="tok-type">\r
+ <xsl:choose>\r
+ <xsl:when test="boolean(@token-type)">\r
+ <xsl:value-of select="@token-type"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="@name"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:variable>\r
+ case <xsl:value-of select="@tag"/> :\r
+ tok = TokenType.<xsl:value-of select="$tok-type"/>;\r
+ break;\r
+</xsl:for-each>\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for <xsl:value-of select="@name"/>, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+</xsl:for-each>\r
+\r
+\r
+<xsl:text><![CDATA[\r
+ default:\r
+ break;\r
+ }\r
+ return res;\r
+ }\r
+\r
+\r
+ private static int GetCodedIndexSize(TablesHeap heap, CodedTokenId id, int [] rows)\r
+ {\r
+ int res = 0;\r
+\r
+ switch (id) {\r
+]]></xsl:text>\r
+\r
+<xsl:for-each select="md-schema/coded-tokens/map">\r
+ case CodedTokenId.<xsl:value-of select="@name"/> :\r
+ res = MDUtils.Max(<xsl:call-template name="get-tables-list"/>);\r
+ res = res < (1 << (16 - <xsl:value-of select="@bits"/>)) ? 2 : 4;\r
+ break;\r
+</xsl:for-each>\r
+\r
+<xsl:text><![CDATA[\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return res;\r
+ }\r
+\r
+\r
+ private static int GetIndexSize(TableId tab, int [] rows)\r
+ {\r
+ // Index is 2 bytes wide if table has less than 2^16 rows\r
+ // otherwise it's 4 bytes wide.\r
+ return ((uint) rows [(int) tab]) < (1 << 16) ? 2 : 4;\r
+ }\r
+\r
+\r
+ private static void AllocBuff(ref byte [] buff, int size)\r
+ {\r
+ if (buff == null || buff.Length < size) {\r
+ buff = new byte [(size + 4) & ~3];\r
+ }\r
+ Array.Clear(buff, 0, size);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public static int DecodePhysicalTables(TablesHeap heap, byte [] data, int offs, int [] rows)\r
+ {\r
+ int rowSize; // expanded row size (all indices are dwords)\r
+ int fldSize; // physical field size\r
+ int dest;\r
+ int nRows;\r
+ byte [] buff = null;\r
+ int si = heap.StringsIndexSize;\r
+ int gi = heap.GUIDIndexSize;\r
+ int bi = heap.BlobIndexSize;\r
+]]></xsl:text>\r
+\r
+ <xsl:apply-templates select="md-schema/tables/table"/>\r
+\r
+<xsl:text><![CDATA[\r
+ return offs;\r
+ }\r
+\r
+ } // end class\r
+} // end namespace\r
+]]></xsl:text>\r
+\r
+</xsl:template>\r
+\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template name="get-tables-list">\r
+ <xsl:param name="map-node" select="."/>\r
+\r
+ <xsl:for-each select="$map-node/table">\r
+ <xsl:choose>\r
+ <xsl:when test="@name = 'String'"><!-- HACK -->\r
+ <xsl:text>(heap.StringsIndexSize > 2 ? 1 << 17 : 1)</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>rows [(int) TableId.</xsl:text><xsl:value-of select="@name"/><xsl:text>]</xsl:text>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ <xsl:if test="position() != last()">\r
+ <xsl:text>, </xsl:text>\r
+ </xsl:if>\r
+ </xsl:for-each>\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template name="get-field-size">\r
+ <xsl:param name="type" select="@type"/>\r
+\r
+ <xsl:choose>\r
+ <!-- RVA special case, PE library type -->\r
+ <xsl:when test="$type = 'RVA'">\r
+ <xsl:text>RVA.Size</xsl:text>\r
+ </xsl:when>\r
+ <!-- #Strings, #Blob or #GUID -->\r
+ <xsl:when test="contains($type,'#')">\r
+ <xsl:choose>\r
+ <xsl:when test="contains(substring-after($type, '#'), 'Strings')">\r
+ <xsl:text>si</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(substring-after($type, '#'), 'Blob')">\r
+ <xsl:text>bi</xsl:text>\r
+ </xsl:when>\r
+ <xsl:when test="contains(substring-after($type, '#'), 'GUID')">\r
+ <xsl:text>gi</xsl:text>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:text>ERROR: Unknown index - </xsl:text>\r
+ <xsl:value-of select="$type"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+ </xsl:when>\r
+ <!-- table indices -->\r
+ <xsl:when test="starts-with($type,'index')">\r
+ <xsl:variable name="tab">\r
+ <xsl:call-template name="extract-arg"/>\r
+ </xsl:variable>\r
+ <xsl:value-of select="concat('GetIndexSize(TableId.', $tab, ', rows)')"/>\r
+ </xsl:when>\r
+ <!-- coded tokens -->\r
+ <xsl:when test="starts-with($type,'coded-index')">\r
+ <xsl:variable name="tab">\r
+ <xsl:call-template name="extract-arg"/>\r
+ </xsl:variable>\r
+ <xsl:value-of select="concat('GetCodedIndexSize(heap, CodedTokenId.', $tab, ', rows)')"/>\r
+ </xsl:when>\r
+ <xsl:otherwise>\r
+ <xsl:value-of select="concat('sizeof (', $type, ')')"/>\r
+ </xsl:otherwise>\r
+ </xsl:choose>\r
+</xsl:template>\r
+\r
+\r
+\r
+\r
+<!-- ******************************************************************* -->\r
+<xsl:template match="md-schema/tables/table">\r
+ if (heap.Has<xsl:value-of select="@name"/>) {\r
+ rowSize = <xsl:call-template name="get-expanded-size"/>;\r
+ nRows = rows [(int) TableId.<xsl:value-of select="@name"/>];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new <xsl:value-of select="@name"/>Table(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ <xsl:for-each select="schema/field">\r
+ <xsl:variable name="fld-size">\r
+ <xsl:call-template name="get-field-size"/>\r
+ </xsl:variable>\r
+ <xsl:variable name="exp-fld-size">\r
+ <xsl:call-template name="get-expanded-size">\r
+ <xsl:with-param name="fields" select="."/>\r
+ </xsl:call-template>\r
+ </xsl:variable>\r
+ // <xsl:value-of select="@name"/>, <xsl:value-of select="@type"/>\r
+ fldSize = <xsl:value-of select="$fld-size"/>;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += <xsl:value-of select="$exp-fld-size"/>;\r
+ </xsl:for-each>\r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+</xsl:template>\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0" encoding="iso-8859-1"?>\r
+\r
+\r
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
+\r
+<xsl:output method="text"/>\r
+\r
+\r
+<xsl:template match="/">// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+<xsl:for-each select="md-schema/tables/table">\r
+ public class <xsl:value-of select="@name"/>Table : MDTableBase {\r
+\r
+ public <xsl:value-of select="@name"/>Table(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new <xsl:value-of select="@name"/>Row(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += <xsl:value-of select="@name"/>Row.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "<xsl:value-of select="@name"/>";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.<xsl:value-of select="@name"/>;\r
+ }\r
+ }\r
+ }\r
+</xsl:for-each>\r
+\r
+}\r
+</xsl:template>\r
+\r
+\r
+</xsl:stylesheet>\r
--- /dev/null
+<?xml version="1.0"?>\r
+\r
+<!--\r
+ | Author: Sergey Chaban <serge@wildwestsoftware.com>\r
+ -->\r
+\r
+<job id="xslt">\r
+\r
+ <runtime>\r
+\r
+ <description></description>\r
+\r
+ <named name="inFile"\r
+ type="string"\r
+ required="true"\r
+ helpstring=""\r
+ />\r
+\r
+ <named name="styleFile"\r
+ type="string"\r
+ required="true"\r
+ helpstring=""\r
+ />\r
+\r
+ <named name="outFile"\r
+ type="string"\r
+ required="false"\r
+ helpstring=""\r
+ />\r
+\r
+\r
+ <named name="unicode"\r
+ type="boolean"\r
+ required="false"\r
+ helpstring=""\r
+ />\r
+\r
+ <named name="timestamp"\r
+ type="boolean"\r
+ required="false"\r
+ helpstring=""\r
+ />\r
+\r
+\r
+ <named name="timing"\r
+ type="boolean"\r
+ required="false"\r
+ helpstring=""\r
+ />\r
+\r
+ <unnamed name="params"\r
+ type="string"\r
+ many="true"\r
+ required="false"\r
+ helpstring=""\r
+ />\r
+\r
+ </runtime>\r
+\r
+<script language="JScript"><![CDATA[\r
+\r
+ function Filter(str) {\r
+ this.data=str.split("\r\n");\r
+ this.namespaces=new Array();\r
+ this.pos=0;\r
+ this.numLines=0;\r
+ this.docComment=false;\r
+ this.indent="";\r
+ this.readLine=Filter_readLine;\r
+ }\r
+\r
+ function Filter_readLine() {\r
+\r
+ if (this.data==null\r
+ || this.data.length==0\r
+ || this.pos>=this.data.length)\r
+ return null;\r
+\r
+ var res=this.data[this.pos++];\r
+\r
+ if (res.charCodeAt(0)==127) {\r
+ this.docComment^=true;\r
+ if (this.docComment) {\r
+ var n=res.charCodeAt(1)-0x30;\r
+ this.indent="";\r
+ for (var i=0;i<n;i++,this.indent+="\t");\r
+ }\r
+ res=this.readLine();\r
+ } else if (this.docComment) {\r
+ res=this.indent+"/// "+res;\r
+ } else if (res.charCodeAt(0)==126) {\r
+ var ns=res.substr(1);\r
+ if (this.namespaces[ns]==null) {\r
+ this.namespaces[ns]=true;\r
+ res="using "+ns+";";\r
+ } else {\r
+ res=this.readLine();\r
+ }\r
+ }\r
+ ++this.numLines;\r
+ return res;\r
+ }\r
+\r
+\r
+\r
+ var isUnicode=false;\r
+ var timestamp=true;\r
+ var timing=false;\r
+\r
+ var start=0;\r
+ var ellapsed=0;\r
+\r
+\r
+ function writeFile(fileName,data) {\r
+ var res=0;\r
+ try {\r
+ var fso=WScript.CreateObject("Scripting.FileSystemObject");\r
+ var txtStream=fso.CreateTextFile(fileName,true,isUnicode);\r
+ if (false) {\r
+ txtStream.Write(data);\r
+ } else {\r
+ var filter=new Filter(data);\r
+ var str=filter.readLine();\r
+ while (str!=null) {\r
+ txtStream.WriteLine(str);\r
+ str=filter.readLine();\r
+ }\r
+ res=filter.numLines;\r
+ }\r
+ txtStream.Close();\r
+ } catch (e) {\r
+ WScript.Echo("writeFile() error: "+e);\r
+ }\r
+ return res;\r
+ }\r
+\r
+ var xmlFile=WScript.Arguments.Named.Item("inFile");\r
+ var xslFile=WScript.Arguments.Named.Item("styleFile");\r
+ var outFile=WScript.Arguments.Named.Item("outFile");\r
+\r
+ var unicodeFlag=WScript.Arguments.Named.Item("unicode");\r
+ isUnicode=(unicodeFlag!=null)?unicodeFlag:false;\r
+\r
+ var timestampFlag=WScript.Arguments.Named.Item("timestamp");\r
+ timestamp=(timestampFlag!=null)?timestampFlag:true;\r
+\r
+ var timingFlag=WScript.Arguments.Named.Item("timing");\r
+ timing=(timingFlag!=null)?timingFlag:false;\r
+\r
+ var writeToFile=(outFile!=null);\r
+\r
+ var params=new Array();\r
+\r
+\r
+ for (var i=0;i<WScript.Arguments.Unnamed.Count;i++) {\r
+ var prm=WScript.Arguments.Unnamed.Item(i);\r
+ var nv=prm.split("=");\r
+ if (nv.length==2) {\r
+ params[params.length]={name:nv[0],value:nv[1]};\r
+ }\r
+ }\r
+\r
+ if (timestamp) {\r
+ params[params.length]={name:"time-stamp",value:(new Date()).toGMTString()};\r
+ }\r
+\r
+ var res;\r
+ var xmlObj,xslObj;\r
+\r
+ var xmlVer="";\r
+\r
+ try {\r
+ xmlObj=WScript.CreateObject("Msxml2.FreeThreadedDOMDocument"+xmlVer);\r
+ xslObj=WScript.CreateObject("Msxml2.FreeThreadedDOMDocument"+xmlVer);\r
+ } catch (e) {\r
+ WScript.Echo("This script requires MSXML 3.0 (release) or better.")\r
+ WScript.Quit(-1);\r
+ }\r
+\r
+\r
+ xmlObj.async=false;\r
+ res=xmlObj.load(xmlFile);\r
+ if (!res) {\r
+ WScript.Echo("Unable to load source file.")\r
+ WScript.Quit(-1);\r
+ }\r
+\r
+ xslObj.async=false;\r
+ res=xslObj.load(xslFile);\r
+ if (!res) {\r
+ WScript.Echo("Unable to load stylesheet file.")\r
+ WScript.Quit(-1);\r
+ }\r
+\r
+ var template=WScript.CreateObject("Msxml2.XSLTemplate"+xmlVer);\r
+ template.stylesheet=xslObj;\r
+ var processor=template.createProcessor();\r
+ processor.input=xmlObj;\r
+ for (var i in params) {\r
+ processor.addParameter(params[i].name,params[i].value);\r
+ }\r
+\r
+ start=(new Date()).valueOf();\r
+ res=processor.transform();\r
+ ellapsed=(new Date()).valueOf()-start;\r
+\r
+ if (timing) {\r
+ WScript.Echo("Transform took "+ellapsed+" ms.")\r
+ }\r
+\r
+ var n=0;\r
+ var output=processor.output;\r
+\r
+ if (writeToFile) {\r
+ n=writeFile(outFile,output);\r
+ } else {\r
+ var filter=new Filter(output);\r
+ var str=filter.readLine();\r
+ while (str!=null) {\r
+ WScript.Echo(str);\r
+ str=filter.readLine();\r
+ }\r
+ n=filter.numLines;\r
+ }\r
+\r
+\r
+ WScript.Quit(0);\r
+\r
+]]></script>\r
+\r
+</job>\r
--- /dev/null
+topdir = ../..
+
+LIBRARY = $(topdir)/class/lib/Mono.PEToolkit.dll
+
+LIB_LIST = list.unix
+LIB_FLAGS = --unsafe -r corlib -r System.Xml -r mscorlib
+
+SOURCES_INCLUDE=
+SOURCES_EXCLUDE=
+
+export MONO_PATH_PREFIX = $(topdir)/class/lib:
+
+include $(topdir)/class/library.make
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Values for AssemblyFlags.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, 22.1.2\r
+ /// </remarks>\r
+ [Flags]\r
+ public enum AssemblyFlags {\r
+ /// <summary>\r
+ /// The assembly reference holds the full (unhashed) public key.\r
+ /// </summary>\r
+ PublicKey = 0x0001,\r
+\r
+ /// <summary>\r
+ /// The assembly is side by side compatible.\r
+ /// </summary>\r
+ SideBySideCompatible = 0x0000,\r
+\r
+ /// <summary>\r
+ /// The assembly cannot execute with other versions\r
+ /// if they are executing in the same application domain.\r
+ /// </summary>\r
+ NonSideBySideAppDomain = 0x0010,\r
+\r
+ /// <summary>\r
+ /// The assembly cannot execute with other versions\r
+ /// if they are executing in the same process.\r
+ /// </summary>\r
+ NonSideBySideProcess = 0x0020,\r
+\r
+ /// <summary>\r
+ /// The assembly cannot execute with other versions\r
+ /// if they are executing on the same machine.\r
+ /// </summary>\r
+ NonSideBySideMachine = 0x0030,\r
+\r
+ /// <summary>\r
+ /// JIT should generate CIL-to-native code map.\r
+ /// </summary>\r
+ EnableJITcompileTracking = 0x8000,\r
+\r
+ /// <summary>\r
+ /// JIT should not generate optimized code.\r
+ /// </summary>\r
+ DisableJITcompileOptimizer = 0x4000,\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ public class BadMetaDataException : Exception {\r
+\r
+ public BadMetaDataException() : base()\r
+ {\r
+ }\r
+\r
+ public BadMetaDataException(string msg) : base(msg)\r
+ {\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or coded-id.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public enum CodedTokenId {\r
+\r
+ TypeDefOrRef = 0,\r
+ HasConstant = 1,\r
+ HasCustomAttribute = 2,\r
+ HasFieldMarshal = 3,\r
+ HasDeclSecurity = 4,\r
+ MemberRefParent = 5,\r
+ HasSemantics = 6,\r
+ MethodDefOrRef = 7,\r
+ MemberForwarded = 8,\r
+ Implementation = 9,\r
+ CustomAttributeType = 10,\r
+ ResolutionScope = 11,\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or elem-type.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ /// <summary>\r
+ /// Element types.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Partition II, 22.1.14 Element Types used in Signatures\r
+ /// </remarks>\r
+ public enum ElementType {\r
+\r
+ End = 0x00,\r
+ Void = 0x01,\r
+ Boolean = 0x02,\r
+ Char = 0x03,\r
+ I1 = 0x04,\r
+ U1 = 0x05,\r
+ I2 = 0x06,\r
+ U2 = 0x07,\r
+ I4 = 0x08,\r
+ U4 = 0x09,\r
+ I8 = 0x0a,\r
+ U8 = 0x0b,\r
+ R4 = 0x0c,\r
+ R8 = 0x0d,\r
+ String = 0x0e,\r
+ Ptr = 0x0f,\r
+ ByRef = 0x10,\r
+ ValueType = 0x11,\r
+ Class = 0x12,\r
+ Array = 0x14,\r
+ TypedByRef = 0x16,\r
+ I = 0x18,\r
+ U = 0x19,\r
+ FnPtr = 0x1b,\r
+ Object = 0x1c,\r
+ SzArray = 0x1d,\r
+ CModReqd = 0x1f,\r
+ CModOpt = 0x20,\r
+ Internal = 0x21,\r
+ Modifier = 0x40,\r
+ Sentinel = 0x41,\r
+ Pinned = 0x45,\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// #GUID heap\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// 23.1.5\r
+ /// </remarks>\r
+ public class GUIDHeap : MDHeap {\r
+\r
+ private byte [] data;\r
+\r
+ internal GUIDHeap(MDStream stream) : base(stream)\r
+ {\r
+ }\r
+\r
+ unsafe override public void FromRawData(byte [] rawData)\r
+ {\r
+ data = rawData;\r
+ }\r
+\r
+ public Guid this [int index] {\r
+ get {\r
+ if (index + 16 > data.Length)\r
+ throw new IndexOutOfRangeException();\r
+ byte [] buff = new byte [16];\r
+ Buffer.BlockCopy(data, index, buff, 0, 16);\r
+ return new Guid(buff);\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}
\ No newline at end of file
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Base class for all metadata heaps.\r
+ /// </summary>\r
+ public abstract class MDHeap {\r
+\r
+\r
+ protected MDStream stream;\r
+\r
+ protected MDHeap(MDStream stream)\r
+ {\r
+ this.stream = stream;\r
+ if (stream.RawData != null) {\r
+ FromRawData(stream.RawData);\r
+ }\r
+ }\r
+\r
+ public MDStream Stream {\r
+ get {\r
+ return stream;\r
+ }\r
+ }\r
+\r
+ public abstract void FromRawData(byte [] rawData);\r
+\r
+\r
+ /// <summary>\r
+ /// Heap factory.\r
+ /// </summary>\r
+ /// <param name="stream">Base stream.</param>\r
+ /// <returns></returns>\r
+ public static MDHeap Create(MDStream stream)\r
+ {\r
+ MDHeap res = null;\r
+\r
+ switch (stream.Name) {\r
+ case "#~" :\r
+ case "#-" :\r
+ res = new TablesHeap(stream);\r
+ break;\r
+ case "#Strings" :\r
+ res = new StringsHeap(stream);\r
+ break;\r
+ case "#GUID" :\r
+ res = new GUIDHeap(stream);\r
+ break;\r
+ }\r
+\r
+ return res;\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Text;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Metadata stream.\r
+ /// </summary>\r
+ public class MDStream {\r
+\r
+ /// <summary>\r
+ /// MetaData stream header as described\r
+ /// in ECMA CLI specs, Partition II Metadata, 23.1.2\r
+ /// </summary>\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct Header {\r
+ internal uint offs;\r
+ internal uint size;\r
+ internal string name;\r
+\r
+\r
+ unsafe public void Read(BinaryReader reader, MDStream stream)\r
+ {\r
+ sbyte* pName = stackalloc sbyte [32];\r
+ sbyte* p = pName;\r
+\r
+ fixed (void* pThis = &this.offs) {\r
+ PEUtils.ReadStruct(reader, pThis, 2 * sizeof (uint));\r
+ }\r
+\r
+ while (true) {\r
+ sbyte c = reader.ReadSByte();\r
+ if (c == 0) break;\r
+ *p++ = c;\r
+ }\r
+\r
+ int len = (int) (p - pName);\r
+ if (len != 0) {\r
+ name = new string(pName, 0, len, Encoding.ASCII);\r
+ } else {\r
+ throw new BadImageException("Invalid stream name.");\r
+ }\r
+\r
+ // Round up to dword boundary.\r
+ long pos = reader.BaseStream.Position;\r
+ if (stream != null) pos -= stream.Root.filePos;\r
+ pos += 3;\r
+ pos &= ~3;\r
+ if (stream != null) pos += stream.Root.filePos;\r
+\r
+ // Advance file pointer.\r
+ reader.BaseStream.Position = pos;\r
+ }\r
+ } // header\r
+\r
+\r
+\r
+ private MetaDataRoot root;\r
+ private MDHeap heap;\r
+ internal Header hdr;\r
+ private byte [] data;\r
+\r
+\r
+ public MDStream(MetaDataRoot root)\r
+ {\r
+ this.root = root;\r
+ hdr = new Header();\r
+ data = null;\r
+ heap = null;\r
+ }\r
+\r
+\r
+ public uint Offset {\r
+ get {\r
+ return hdr.offs;\r
+ }\r
+ set {\r
+ hdr.offs = value;\r
+ }\r
+ }\r
+\r
+ public uint Size {\r
+ get {\r
+ return hdr.size;\r
+ }\r
+ set {\r
+ hdr.size = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Name of the stream.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Stored on-disk as a null-terminated ASCII string,\r
+ /// rounded up to 4-byte boundary.\r
+ /// </remarks>\r
+ public string Name {\r
+ get {\r
+ return hdr.name;\r
+ }\r
+ set {\r
+ hdr.name = value;\r
+ }\r
+ }\r
+\r
+ public byte [] RawData {\r
+ get {\r
+ return data;\r
+ }\r
+ }\r
+\r
+ public MetaDataRoot Root {\r
+ get {\r
+ return root;\r
+ }\r
+ }\r
+\r
+ public MDHeap Heap {\r
+ get {\r
+ lock (this) {\r
+ if (heap == null) InitHeap();\r
+ return heap;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Reads stream header and body from supplied BinaryReader.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Reader must be positioned at the first byte of metadata stream.\r
+ /// </remarks>\r
+ /// <param name="reader"></param>\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ hdr.Read(reader, this);\r
+ long oldPos = reader.BaseStream.Position;\r
+\r
+ // Offset field in the stream header is relataive to\r
+ // the start of metadata.\r
+ reader.BaseStream.Position = root.filePos + hdr.offs;\r
+ data = reader.ReadBytes((int) hdr.size);\r
+\r
+ // set reader's position to the first byte after\r
+ // stream header.\r
+ reader.BaseStream.Position = oldPos;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Initializes heap for this stream.\r
+ /// </summary>\r
+ protected void InitHeap()\r
+ {\r
+ heap = MDHeap.Create(this);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Name : {0}" + Environment.NewLine +\r
+ "Offset : 0x{1:x8}" + Environment.NewLine +\r
+ "Size : 0x{2:x8}" + Environment.NewLine,\r
+ hdr.name, hdr.offs, hdr.size\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter ();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Collections;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ public interface MDTable {\r
+ /// <summary>\r
+ /// Number of rows in the table.\r
+ /// </summary>\r
+ int NumberOfRows {get;}\r
+\r
+ /// <summary>\r
+ /// Gets ot sets a row in the metadata table.\r
+ /// </summary>\r
+ Row this [int rowNum] {get; set;}\r
+\r
+ void Add(Row row);\r
+\r
+ void FromRawData(byte [] buff, int offs, int numRows);\r
+\r
+ string Name {get;}\r
+\r
+ TableId Id {get;}\r
+\r
+ MDHeap Heap {get;}\r
+\r
+ void Dump(TextWriter writer);\r
+ }\r
+\r
+\r
+ public abstract class MDTableBase : MDTable {\r
+ protected ArrayList rows; // rows storage\r
+ protected MDHeap heap; // base heap\r
+\r
+ public MDTableBase(MDHeap heap)\r
+ {\r
+ rows = new ArrayList();\r
+ this.heap = heap;\r
+\r
+ if (heap is TablesHeap) {\r
+ (heap as TablesHeap).RegisterTable(this);\r
+ }\r
+ }\r
+\r
+ public virtual int NumberOfRows {\r
+ get {\r
+ return rows.Count;\r
+ }\r
+ }\r
+\r
+\r
+ public virtual Row this [int rowNum] {\r
+ get {\r
+ if (rowNum < 0) throw new IndexOutOfRangeException("Row[]");\r
+\r
+ // Zero row, special case\r
+ if (rowNum == 0) return NullRow.Instance;\r
+ return rows [rowNum - 1] as Row;\r
+ }\r
+ set {\r
+ rows.Insert(rowNum, value);\r
+ }\r
+ }\r
+\r
+ public virtual void Add(Row row)\r
+ {\r
+ rows.Add(row);\r
+ }\r
+\r
+ public abstract void FromRawData(byte [] buff, int offs, int numRows);\r
+\r
+ public abstract string Name {get;}\r
+\r
+ public abstract TableId Id {get;}\r
+\r
+ public virtual MDHeap Heap {\r
+ get {\r
+ return heap;\r
+ }\r
+ }\r
+\r
+ public virtual void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine("=========================================");\r
+ writer.WriteLine("Table '{0}', id = {1} (0x{2}), rows = {3}",\r
+ Name, Id, ((int) Id).ToString("X"), NumberOfRows);\r
+ int n = 1;\r
+ foreach (Row row in rows) {\r
+ writer.WriteLine();\r
+ writer.WriteLine("Row #{0}", n++);\r
+ writer.WriteLine("-------------");\r
+ row.Dump(writer);\r
+ writer.WriteLine();\r
+ }\r
+ }\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ [StructLayoutAttribute(LayoutKind.Sequential)]\r
+ public struct MDToken {\r
+\r
+ internal int token;\r
+\r
+ /// <summary>\r
+ /// Creates new token with specified token type and record id.\r
+ /// </summary>\r
+ /// <param name="type">Token type.</param>\r
+ /// <param name="rid">Record IDentifier.</param>\r
+ public MDToken(TokenType type, int rid)\r
+ {\r
+ token = (int)type | rid;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Creates new Nil token of a given type.\r
+ /// </summary>\r
+ /// <param name="type"></param>\r
+ public MDToken(TokenType type) : this(type, 0)\r
+ {\r
+ }\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <param name="tok"></param>\r
+ public MDToken(MDToken tok) : this(tok.Type, tok.RID)\r
+ {\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Gets or sets metadata token Record IDentifier (RID).\r
+ /// </summary>\r
+ public int RID {\r
+ get {\r
+ return token & (~(int)TokenType.__mask);\r
+ }\r
+ set {\r
+ token &= (int)TokenType.__mask;\r
+ token |= value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets metadata token type.\r
+ /// </summary>\r
+ public TokenType Type {\r
+ get {\r
+ return (TokenType) token & (TokenType.__mask);\r
+ }\r
+ set {\r
+ token &= ~(int)TokenType.__mask;\r
+ token |= (int)value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Returns true if this token is a Nil token (it's RID is 0).\r
+ /// </summary>\r
+ public bool IsNilToken {\r
+ get {\r
+ return (RID == 0);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Returns token value.\r
+ /// </summary>\r
+ /// <returns></returns>\r
+ public override int GetHashCode ()\r
+ {\r
+ return token;\r
+ }\r
+\r
+\r
+\r
+ // See Metadata Unmanaged API doc (10.8)\r
+ public int Compress(out int len)\r
+ {\r
+ int res = token;\r
+ len = 4;\r
+ int rid = this.RID;\r
+\r
+ // Make room for type bits.\r
+ rid <<= 2;\r
+\r
+ TokenType type = this.Type;\r
+\r
+ // Token type (table that this token indexes) is encoded\r
+ // in the least significant 2 bits:\r
+ // TypeDef = 0\r
+ // TypeRef = 1\r
+ // TypeSpec = 2\r
+ // BaseType = 3\r
+ switch (type) {\r
+ case TokenType.TypeDef:\r
+ break;\r
+ case TokenType.TypeRef:\r
+ rid |= 1;\r
+ break;\r
+ case TokenType.TypeSpec:\r
+ rid |= 2;\r
+ break;\r
+ case TokenType.BaseType:\r
+ rid |= 3;\r
+ break;\r
+ default:\r
+ // Invalid operation for this type of token.\r
+ return res;\r
+ }\r
+\r
+ len = MDUtils.CompressData(rid, out res);\r
+\r
+ return res;\r
+ }\r
+\r
+\r
+ unsafe public static int Size {\r
+ get {\r
+ return sizeof (int);\r
+ }\r
+ }\r
+\r
+ public static implicit operator MDToken (uint val) {\r
+ MDToken res = new MDToken();\r
+ res.token = (int) val;\r
+ return res;\r
+ }\r
+\r
+ public static implicit operator uint (MDToken tok) {\r
+ return (uint)tok.token;\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ if (this.token == 0) return "NULL";\r
+ return String.Format("{0}[{1}]",\r
+ ((int)Type >> (int)TokenType.__shift <= (int)TableId.MAX)\r
+ ? ((TableId)((int)Type >> (int)TokenType.__shift)).ToString()\r
+ : Type.ToString(), RID);\r
+ //String.Format ("type = {0}, RID = {1}", Type, RID);\r
+ }\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+//using System.Runtime.InteropServices;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ public sealed class MDUtils {\r
+\r
+ // Holds true if machine is little-endian.\r
+ private static bool isLE;\r
+\r
+ static MDUtils()\r
+ {\r
+ isLE = BitConverter.IsLittleEndian;\r
+ }\r
+\r
+ private MDUtils()\r
+ {\r
+ }\r
+\r
+\r
+ public static int CompressData(int data, out int res)\r
+ {\r
+ res = data;\r
+ int len = 4;\r
+\r
+ if (data < 0) {\r
+ // data is actually unsigned,\r
+ // that's why this empty clause is needed.\r
+ } else if (data < 0x80) {\r
+ res = data;\r
+ len = 1;\r
+ } else if (data < 0x4000) {\r
+ res = ((data >> 8) | 0x80) + ((data & 0xFF) << 8);\r
+ len = 2;\r
+ } else if (data < 0x1FFFFFFF) {\r
+ res = ((data >> 24) | 0xC0) |\r
+ (((data >> 16) & 0xFF) << 8) |\r
+ (((data >> 8) & 0xFF) << 16) |\r
+ ((data & 0xFF) << 24);\r
+ len = 4;\r
+ }\r
+\r
+ return len;\r
+ }\r
+\r
+ unsafe public static int CompressData(void* pData, void* pRes)\r
+ {\r
+ byte* p = (byte*) pData;\r
+\r
+ int data = (isLE)\r
+ ? *(int*)p\r
+ : p [0] + (p [1] << 8) + (p [2] << 16) + (p [3] << 24);\r
+\r
+ int res = 0;\r
+ int len = CompressData(data, out res);\r
+ p = (byte*) pRes;\r
+\r
+ if (isLE) {\r
+ *(int*)p = res;\r
+ } else {\r
+ *p++ = (byte) (res & 0xFF);\r
+ *p++ = (byte) (res >> 8);\r
+ *p++ = (byte) (res >> 16);\r
+ *p++ = (byte) (res >> 24);\r
+ }\r
+ return len;\r
+ }\r
+\r
+\r
+ public static int Max(params int [] list)\r
+ {\r
+ int len = (list != null) ? list.Length : 0;\r
+ if (len == 0) return 0;\r
+ int max = list [0];\r
+ for (int i = 1; i < len; i++) {\r
+ if (list [i] > max) max = list [i];\r
+ }\r
+ return max;\r
+ }\r
+\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Flags for ManifestResource.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, 22.1.8\r
+ /// </remarks>\r
+ [Flags]\r
+ public enum ManifestResourceAttributes {\r
+ VisibilityMask = 0x0007,\r
+\r
+ /// <summary>\r
+ /// The Resource is exported from the Assembly.\r
+ /// </summary>\r
+ Public = 0x0001,\r
+\r
+ /// <summary>\r
+ /// The Resource is private to the Assembly.\r
+ /// </summary>\r
+ Private = 0x0002,\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Text;\r
+using System.Collections;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ public class MetaDataRoot {\r
+\r
+ /// <summary>\r
+ /// "BSJB" signature.\r
+ /// </summary>\r
+ public static readonly uint Sig = 0x424A5342;\r
+\r
+ // Metadata Root header, see 23.1.1\r
+ internal uint sig;\r
+ internal short majVer; // currently 1\r
+ internal short minVer; // currently 1\r
+ internal uint reserved;\r
+ internal int len;\r
+ internal string verStr;\r
+ internal short flags;\r
+ internal short nStreams;\r
+\r
+\r
+ // Instance data\r
+\r
+ internal Hashtable streams;\r
+\r
+ // file position of the first byte of the header\r
+ internal long filePos;\r
+\r
+ private int strIdx;\r
+ private int guidIdx;\r
+ private int blobIdx;\r
+\r
+ internal Image img;\r
+\r
+\r
+ public MetaDataRoot(Image img)\r
+ {\r
+ this.img = img;\r
+ }\r
+\r
+ public Hashtable Streams {\r
+ get {\r
+ // never return null\r
+ if (streams == null) streams = new Hashtable();\r
+ return streams;\r
+ }\r
+ }\r
+\r
+\r
+ public uint Signature {\r
+ get {\r
+ return sig;\r
+ }\r
+ }\r
+\r
+ public string Version {\r
+ get {\r
+ return String.Format("{0}.{1}", majVer, minVer);\r
+ }\r
+ }\r
+\r
+ public string VersionString {\r
+ get {\r
+ return verStr;\r
+ }\r
+ set {\r
+ verStr = value;\r
+ len = value.Length;\r
+ }\r
+ }\r
+\r
+\r
+\r
+ public int StringsIndexSize {\r
+ get {\r
+ return strIdx;\r
+ }\r
+ }\r
+\r
+ public int GUIDIndexSize {\r
+ get {\r
+ return guidIdx;\r
+ }\r
+ }\r
+\r
+ public int BlobIndexSize {\r
+ get {\r
+ return blobIdx;\r
+ }\r
+ }\r
+\r
+\r
+ unsafe public void Read(BinaryReader reader)\r
+ {\r
+ filePos = reader.BaseStream.Position;\r
+\r
+ sig = reader.ReadUInt32();\r
+ if (sig != Sig) {\r
+ throw new BadImageException("Invalid MetaData Signature.");\r
+ }\r
+\r
+ majVer = reader.ReadInt16();\r
+ minVer = reader.ReadInt16();\r
+ reserved = reader.ReadUInt32();\r
+ \r
+ // Length of version string.\r
+ len = reader.ReadInt32();\r
+\r
+ // Read version string.\r
+ if (len != 0) {\r
+ sbyte* pVer = stackalloc sbyte [len];\r
+ sbyte* p = pVer;\r
+\r
+ long pos = reader.BaseStream.Position;\r
+ int i;\r
+ for (i = len; --i >= 0;) {\r
+ sbyte c = reader.ReadSByte();\r
+ if (c == 0) break;\r
+ *p++ = c;\r
+ }\r
+\r
+ verStr = new string(pVer, 0, len-i-1, Encoding.UTF8);\r
+\r
+ // Round up to dword boundary, relative to header start.\r
+ pos += len;\r
+ pos -= filePos;\r
+ pos += 3;\r
+ pos &= ~3;\r
+ pos += filePos;\r
+\r
+ // Advance file pointer.\r
+ reader.BaseStream.Position = pos;\r
+ } else {\r
+ VersionString = String.Empty;\r
+ }\r
+\r
+ flags = reader.ReadInt16();\r
+ nStreams = reader.ReadInt16();\r
+\r
+ streams = new Hashtable(nStreams);\r
+\r
+ // load all streams into memory\r
+ for (int i = nStreams; --i >=0;) {\r
+ MDStream s = new MDStream(this);\r
+ s.Read(reader);\r
+ // TODO: check for duplicated streams,\r
+ // use Add instead of indexer.\r
+ streams[s.Name] = s;\r
+ }\r
+\r
+ MDStream tabs = Streams["#~"] as MDStream;\r
+ // Try uncompressed stream.\r
+ if (tabs == null) tabs = Streams["#-"] as MDStream;\r
+ if (tabs == null) throw new BadMetaDataException("Missing #~ stream.");\r
+\r
+ TablesHeap tabsHeap = tabs.Heap as TablesHeap;\r
+ // cache index sizes\r
+ strIdx = tabsHeap.StringsIndexSize;\r
+ guidIdx = tabsHeap.GUIDIndexSize;\r
+ blobIdx = tabsHeap.BlobIndexSize;\r
+ }\r
+\r
+ public TablesHeap TablesHeap {\r
+ get {\r
+ MDStream tabs = Streams["#~"] as MDStream;\r
+ // Try uncompressed stream.\r
+ if (tabs == null) tabs = Streams["#-"] as MDStream;\r
+ return (tabs.Heap as TablesHeap);\r
+ }\r
+ }\r
+\r
+ public MethodIL GetMethodBody(int num)\r
+ {\r
+ MethodIL il = null;\r
+ if (img == null) return il;\r
+ MDStream tabs = Streams["#~"] as MDStream;\r
+ TablesHeap tabsHeap = tabs.Heap as TablesHeap;\r
+ if (tabsHeap.HasMethod) {\r
+ MDTable methods = tabsHeap[TableId.Method];\r
+ if (methods == null) return il;\r
+ MethodRow row = methods[num] as MethodRow;\r
+ if (row == null) return il;\r
+ BinaryReader reader = img.reader;\r
+ reader.BaseStream.Position = img.RVAToVA(row.RVA);\r
+ il = new MethodIL();\r
+ il.Read(reader);\r
+ }\r
+ return il;\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <remarks>\r
+ /// See Partition II\r
+ /// 24.4 Common Intermediate Language Physical Layout\r
+ /// </remarks>\r
+ public class MethodIL {\r
+\r
+ public enum Format {\r
+ // CorILMethod_TinyFormat, 24.4.2\r
+ Tiny = 2,\r
+ // CorILMethod_FatFormat, 24.4.3\r
+ Fat = 3,\r
+\r
+ // encoded in 3 bits\r
+ Shift = 3,\r
+ Mask = 0x7\r
+ }\r
+\r
+ public enum Flags {\r
+ TinyFormat = MethodIL.Format.Tiny,\r
+ FatFormat = MethodIL.Format.Fat,\r
+ MoreSections = 0x8,\r
+ InitLocals = 0x10\r
+ }\r
+\r
+ internal int fatFlags;\r
+ internal int maxStack;\r
+\r
+ internal byte[] bytecode;\r
+\r
+ public MethodIL()\r
+ {\r
+ fatFlags = 0;\r
+ maxStack = 0;\r
+ }\r
+\r
+ public byte [] ByteCode {\r
+ get {\r
+ return bytecode;\r
+ }\r
+ }\r
+\r
+ public int CodeSize {\r
+ get {\r
+ return (bytecode != null)\r
+ ? bytecode.Length : 0;\r
+ }\r
+ }\r
+\r
+ public int MaxStack {\r
+ get {\r
+ return maxStack;\r
+ }\r
+ set {\r
+ maxStack = value;\r
+ }\r
+ }\r
+\r
+ public bool InitLocals {\r
+ get {\r
+ return (fatFlags & (int)Flags.InitLocals) != 0;\r
+ }\r
+ }\r
+\r
+ public bool HasMoreSections {\r
+ get {\r
+ return (fatFlags & (int)Flags.MoreSections) != 0;\r
+ }\r
+ }\r
+\r
+ internal static bool IsMethodTiny(int flags)\r
+ {\r
+ return ((Format)(flags & ((int)Format.Mask >> 1)) == Format.Tiny);\r
+ }\r
+\r
+ public void Read(BinaryReader reader)\r
+ {\r
+ fatFlags = 0;\r
+ int codeSize;\r
+ bytecode = null;\r
+ int data = reader.ReadByte();\r
+ if (IsMethodTiny(data)) {\r
+ codeSize = data >> ((int)Format.Shift - 1);\r
+ maxStack = 0; // no locals\r
+ bytecode = reader.ReadBytes(codeSize);\r
+ } else {\r
+ long headPos = reader.BaseStream.Position - 1;\r
+ fatFlags = data | (reader.ReadByte() << 8);\r
+ // first 12 bits are flags\r
+ // next 4 bits is the\r
+ // "size of this header expressed as the count\r
+ // of 4-byte integers occupied"\r
+ int headSize = ((fatFlags >> 12) & 0xF) << 2;\r
+ fatFlags &= 0xFFF;\r
+ maxStack = reader.ReadInt16();\r
+ codeSize = reader.ReadInt32();\r
+ int localTok = reader.ReadInt32();\r
+ reader.BaseStream.Position = headPos + headSize;\r
+ bytecode = reader.ReadBytes(codeSize);\r
+ }\r
+ }\r
+\r
+ public virtual void Dump(TextWriter writer)\r
+ {\r
+ string dump = String.Format(\r
+ "Code size : {0:x4}" + Environment.NewLine + \r
+ "MaxStack : {1:x4}" + Environment.NewLine + \r
+ "InitLocals : {2}" + Environment.NewLine + \r
+ "MoreSections : {3}" + Environment.NewLine,\r
+ CodeSize, MaxStack, InitLocals, HasMoreSections\r
+ );\r
+ writer.Write(dump);\r
+ }\r
+\r
+ public void DumpHexBytecode(TextWriter w)\r
+ {\r
+ int n = CodeSize >> 3;\r
+ int i = 0;\r
+ for (int x = n; --x >= 0; i += 8) {\r
+ w.WriteLine(\r
+ String.Format("{0:x2} {1:x2} {2:x2} {3:x2} {4:x2} {5:x2} {6:x2} {7:x2}",\r
+ ByteCode[i], ByteCode[i + 1], ByteCode[i + 2], ByteCode[i + 3],\r
+ ByteCode[i + 4], ByteCode[i + 5], ByteCode[i + 6], ByteCode[i + 7]\r
+ )\r
+ );\r
+ }\r
+ for (;i < CodeSize; i++) {\r
+ w.Write("{0:x2} ", ByteCode[i]);\r
+ }\r
+ w.WriteLine();\r
+ }\r
+\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+ }\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Flags for MethodSemantics.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partiotion II, 22.1.10\r
+ /// </remarks>\r
+ [Flags]\r
+ public enum MethodSemanticsAttributes {\r
+ Setter = 0x0001,\r
+ Getter = 0x0002,\r
+ Other = 0x0004,\r
+ AddOn = 0x0008,\r
+ RemoveOn = 0x0010,\r
+ Fire = 0x0020,\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Flags for ImplMap.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, 22.1.7;\r
+ /// This is similar to PInvokeMap enum found\r
+ /// in older XML library spec (all.xml).\r
+ /// </remarks>\r
+ [Flags]\r
+ public enum PInvokeAttributes {\r
+ /// <summary>\r
+ /// PInvoke is to use the member name as specified.\r
+ /// </summary>\r
+ NoMangle = 0x0001,\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ CharSetMask = 0x0006,\r
+ /// <summary>\r
+ /// </summary>\r
+ CharSetNotSpec = 0x0000,\r
+ /// <summary>\r
+ /// </summary>\r
+ CharSetAnsi = 0x0002, // specs: CharSetAns\r
+ /// <summary>\r
+ /// </summary>\r
+ CharSetUnicode = 0x0004,\r
+ /// <summary>\r
+ /// </summary>\r
+ CharSetAuto = 0x0006,\r
+\r
+ CallConvMask = 0x0700,\r
+ CallConvWinapi = 0x0100,\r
+ CallConvCdecl = 0x0200,\r
+ CallConvStdcall = 0x0300,\r
+ CallConvThiscall = 0x0400,\r
+ CallConvFastcall = 0x0500,\r
+\r
+ PinvokeOLE = 0x0020, // as reported by verifier, not in specs\r
+ // also value from all.xml\r
+\r
+ SupportsLastError = 0x0040,\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Metadata row interface.\r
+ /// </summary>\r
+ public interface Row {\r
+\r
+ /// <summary>\r
+ /// Number of colums in a row.\r
+ /// </summary>\r
+ int NumberOfColumns {get;}\r
+\r
+ int Size {get;}\r
+\r
+ /// <summary>\r
+ /// Returns reference to parent table or null.\r
+ /// </summary>\r
+ MDTable Table {get;}\r
+\r
+ void FromRawData(byte [] buff, int offs);\r
+\r
+ void Dump(TextWriter writer);\r
+\r
+ }\r
+\r
+\r
+ public sealed class NullRow : Row {\r
+ public static readonly NullRow Instance;\r
+\r
+ static NullRow()\r
+ {\r
+ Instance = new NullRow();\r
+ }\r
+\r
+ private NullRow()\r
+ {\r
+ }\r
+\r
+ public int NumberOfColumns {\r
+ get {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ public int Size {\r
+ get {\r
+ return 0;\r
+ }\r
+ }\r
+\r
+ public MDTable Table {\r
+ get {\r
+ return null;\r
+ }\r
+ }\r
+\r
+ public void FromRawData(byte [] buff, int offs) \r
+ {\r
+ }\r
+\r
+ public void Dump(TextWriter writer)\r
+ {\r
+ writer.WriteLine("Null row.");\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or rows.xsl if you want to make changes.\r
+\r
+using System;\r
+using System.IO;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Module table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.27\r
+ /// </remarks>\r
+ public class ModuleRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public ushort Generation;\r
+ public int Name;\r
+ public int Mvid;\r
+ public int EncId;\r
+ public int EncBaseId;\r
+\r
+ public ModuleRow()\r
+ {\r
+ }\r
+\r
+ public ModuleRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Module table has 5 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 5;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Generation = LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Mvid = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.EncId = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.EncBaseId = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Generation : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Mvid : {2}" + Environment.NewLine + \r
+ "EncId : {3}" + Environment.NewLine + \r
+ "EncBaseId : {4}" + Environment.NewLine,\r
+ this.Generation,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#GUID[" + Mvid.ToString() + "]",\r
+ "#GUID[" + EncId.ToString() + "]",\r
+ "#GUID[" + EncBaseId.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in TypeRef table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.35\r
+ /// </remarks>\r
+ public class TypeRefRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public MDToken ResolutionScope;\r
+ public int Name;\r
+ public int Namespace;\r
+\r
+ public TypeRefRow()\r
+ {\r
+ }\r
+\r
+ public TypeRefRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in TypeRef table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.ResolutionScope = TabsDecoder.DecodeToken(CodedTokenId.ResolutionScope, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Namespace = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "ResolutionScope : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Namespace : {2}" + Environment.NewLine,\r
+ this.ResolutionScope,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ (Table == null) ? Namespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Namespace] + "\" (#Strings[0x" + Namespace.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in TypeDef table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.34\r
+ /// </remarks>\r
+ public class TypeDefRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.TypeAttributes Flags;\r
+ public int Name;\r
+ public int Namespace;\r
+ public MDToken Extends;\r
+ public int FieldList;\r
+ public int MethodList;\r
+\r
+ public TypeDefRow()\r
+ {\r
+ }\r
+\r
+ public TypeDefRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in TypeDef table has 6 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 6;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (uint) + 4 + 4 + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.Reflection.TypeAttributes) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Namespace = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Extends = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.FieldList = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.MethodList = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Namespace : {2}" + Environment.NewLine + \r
+ "Extends : {3}" + Environment.NewLine + \r
+ "FieldList : {4}" + Environment.NewLine + \r
+ "MethodList : {5}" + Environment.NewLine,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ (Table == null) ? Namespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Namespace] + "\" (#Strings[0x" + Namespace.ToString("X") + "])",\r
+ this.Extends,\r
+ "Field[" + FieldList.ToString() + "]",\r
+ "Method[" + MethodList.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in FieldPtr table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class FieldPtrRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Field;\r
+\r
+ public FieldPtrRow()\r
+ {\r
+ }\r
+\r
+ public FieldPtrRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in FieldPtr table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Field = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Field : {0}" + Environment.NewLine,\r
+ "Field[" + Field.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Field table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.15\r
+ /// </remarks>\r
+ public class FieldRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.FieldAttributes Flags;\r
+ public int Name;\r
+ public int Signature;\r
+\r
+ public FieldRow()\r
+ {\r
+ }\r
+\r
+ public FieldRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Field table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.Reflection.FieldAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Signature = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Signature : {2}" + Environment.NewLine,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#Blob[" + Signature.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in MethodPtr table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class MethodPtrRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Method;\r
+\r
+ public MethodPtrRow()\r
+ {\r
+ }\r
+\r
+ public MethodPtrRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in MethodPtr table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Method = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Method : {0}" + Environment.NewLine,\r
+ "Method[" + Method.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Method table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.24\r
+ /// </remarks>\r
+ public class MethodRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public RVA RVA;\r
+ public System.Reflection.MethodImplAttributes ImplFlags;\r
+ public System.Reflection.MethodAttributes Flags;\r
+ public int Name;\r
+ public int Signature;\r
+ public int ParamList;\r
+\r
+ public MethodRow()\r
+ {\r
+ }\r
+\r
+ public MethodRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Method table has 6 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 6;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return RVA.Size + sizeof (ushort) + sizeof (ushort) + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.RVA = LEBitConverter.ToUInt32(buff, offs);\r
+ offs += RVA.Size;\r
+ this.ImplFlags = (System.Reflection.MethodImplAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Flags = (System.Reflection.MethodAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Signature = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.ParamList = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "RVA : {0}" + Environment.NewLine + \r
+ "ImplFlags : {1}" + Environment.NewLine + \r
+ "Flags : {2}" + Environment.NewLine + \r
+ "Name : {3}" + Environment.NewLine + \r
+ "Signature : {4}" + Environment.NewLine + \r
+ "ParamList : {5}" + Environment.NewLine,\r
+ this.RVA,\r
+ this.ImplFlags,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#Blob[" + Signature.ToString() + "]",\r
+ "Param[" + ParamList.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ParamPtr table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class ParamPtrRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Param;\r
+\r
+ public ParamPtrRow()\r
+ {\r
+ }\r
+\r
+ public ParamPtrRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ParamPtr table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Param = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Param : {0}" + Environment.NewLine,\r
+ "Param[" + Param.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Param table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.30\r
+ /// </remarks>\r
+ public class ParamRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.ParameterAttributes Flags;\r
+ public ushort Sequence;\r
+ public int Name;\r
+\r
+ public ParamRow()\r
+ {\r
+ }\r
+\r
+ public ParamRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Param table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + sizeof (ushort) + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.Reflection.ParameterAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Sequence = LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "Sequence : {1}" + Environment.NewLine + \r
+ "Name : {2}" + Environment.NewLine,\r
+ this.Flags,\r
+ this.Sequence,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in InterfaceImpl table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.21\r
+ /// </remarks>\r
+ public class InterfaceImplRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Class;\r
+ public MDToken Interface;\r
+\r
+ public InterfaceImplRow()\r
+ {\r
+ }\r
+\r
+ public InterfaceImplRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in InterfaceImpl table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Class = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Interface = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Class : {0}" + Environment.NewLine + \r
+ "Interface : {1}" + Environment.NewLine,\r
+ "TypeDef[" + Class.ToString() + "]",\r
+ this.Interface\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in MemberRef table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.23\r
+ /// </remarks>\r
+ public class MemberRefRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public MDToken Class;\r
+ public int Name;\r
+ public int Signature;\r
+\r
+ public MemberRefRow()\r
+ {\r
+ }\r
+\r
+ public MemberRefRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in MemberRef table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Class = TabsDecoder.DecodeToken(CodedTokenId.MemberRefParent, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Signature = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Class : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Signature : {2}" + Environment.NewLine,\r
+ this.Class,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#Blob[" + Signature.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Constant table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.9\r
+ /// </remarks>\r
+ public class ConstantRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public ElementType Type;\r
+ public MDToken Parent;\r
+ public int Value;\r
+\r
+ public ConstantRow()\r
+ {\r
+ }\r
+\r
+ public ConstantRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Constant table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (short) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Type = (ElementType) LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasConstant, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Value = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Type : {0}" + Environment.NewLine + \r
+ "Parent : {1}" + Environment.NewLine + \r
+ "Value : {2}" + Environment.NewLine,\r
+ this.Type,\r
+ this.Parent,\r
+ "#Blob[" + Value.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in CustomAttribute table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.10\r
+ /// </remarks>\r
+ public class CustomAttributeRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public MDToken Parent;\r
+ public MDToken Type;\r
+ public int Value;\r
+\r
+ public CustomAttributeRow()\r
+ {\r
+ }\r
+\r
+ public CustomAttributeRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in CustomAttribute table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasCustomAttribute, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Type = TabsDecoder.DecodeToken(CodedTokenId.CustomAttributeType, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Value = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Parent : {0}" + Environment.NewLine + \r
+ "Type : {1}" + Environment.NewLine + \r
+ "Value : {2}" + Environment.NewLine,\r
+ this.Parent,\r
+ this.Type,\r
+ "#Blob[" + Value.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in FieldMarshal table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.17\r
+ /// </remarks>\r
+ public class FieldMarshalRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public MDToken Parent;\r
+ public int NativeType;\r
+\r
+ public FieldMarshalRow()\r
+ {\r
+ }\r
+\r
+ public FieldMarshalRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in FieldMarshal table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasFieldMarshal, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.NativeType = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Parent : {0}" + Environment.NewLine + \r
+ "NativeType : {1}" + Environment.NewLine,\r
+ this.Parent,\r
+ "#Blob[" + NativeType.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in DeclSecurity table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.11\r
+ /// </remarks>\r
+ public class DeclSecurityRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public short Action;\r
+ public MDToken Parent;\r
+ public int PermissionSet;\r
+\r
+ public DeclSecurityRow()\r
+ {\r
+ }\r
+\r
+ public DeclSecurityRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in DeclSecurity table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (short) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Action = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasDeclSecurity, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.PermissionSet = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Action : {0}" + Environment.NewLine + \r
+ "Parent : {1}" + Environment.NewLine + \r
+ "PermissionSet : {2}" + Environment.NewLine,\r
+ this.Action,\r
+ this.Parent,\r
+ "#Blob[" + PermissionSet.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ClassLayout table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.8\r
+ /// </remarks>\r
+ public class ClassLayoutRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public short PackingSize;\r
+ public int ClassSize;\r
+ public int Parent;\r
+\r
+ public ClassLayoutRow()\r
+ {\r
+ }\r
+\r
+ public ClassLayoutRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ClassLayout table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (short) + sizeof (int) + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.PackingSize = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.ClassSize = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.Parent = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "PackingSize : {0}" + Environment.NewLine + \r
+ "ClassSize : {1}" + Environment.NewLine + \r
+ "Parent : {2}" + Environment.NewLine,\r
+ this.PackingSize,\r
+ this.ClassSize,\r
+ "TypeDef[" + Parent.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in FieldLayout table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.16\r
+ /// </remarks>\r
+ public class FieldLayoutRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Offset;\r
+ public int Field;\r
+\r
+ public FieldLayoutRow()\r
+ {\r
+ }\r
+\r
+ public FieldLayoutRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in FieldLayout table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Offset = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.Field = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Offset : {0}" + Environment.NewLine + \r
+ "Field : {1}" + Environment.NewLine,\r
+ this.Offset,\r
+ "Field[" + Field.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in StandAloneSig table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.33\r
+ /// </remarks>\r
+ public class StandAloneSigRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Signature;\r
+\r
+ public StandAloneSigRow()\r
+ {\r
+ }\r
+\r
+ public StandAloneSigRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in StandAloneSig table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Signature = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Signature : {0}" + Environment.NewLine,\r
+ "#Blob[" + Signature.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in EventMap table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.12\r
+ /// </remarks>\r
+ public class EventMapRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Parent;\r
+ public int EventList;\r
+\r
+ public EventMapRow()\r
+ {\r
+ }\r
+\r
+ public EventMapRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in EventMap table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Parent = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.EventList = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Parent : {0}" + Environment.NewLine + \r
+ "EventList : {1}" + Environment.NewLine,\r
+ "TypeDef[" + Parent.ToString() + "]",\r
+ "Event[" + EventList.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in EventPtr table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class EventPtrRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Event;\r
+\r
+ public EventPtrRow()\r
+ {\r
+ }\r
+\r
+ public EventPtrRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in EventPtr table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Event = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Event : {0}" + Environment.NewLine,\r
+ "Event[" + Event.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Event table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.13\r
+ /// </remarks>\r
+ public class EventRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.EventAttributes EventFlags;\r
+ public int Name;\r
+ public MDToken EventType;\r
+\r
+ public EventRow()\r
+ {\r
+ }\r
+\r
+ public EventRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Event table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (short) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.EventFlags = (System.Reflection.EventAttributes) LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.EventType = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "EventFlags : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "EventType : {2}" + Environment.NewLine,\r
+ this.EventFlags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ this.EventType\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in PropertyMap table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.32\r
+ /// </remarks>\r
+ public class PropertyMapRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Parent;\r
+ public int PropertyList;\r
+\r
+ public PropertyMapRow()\r
+ {\r
+ }\r
+\r
+ public PropertyMapRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in PropertyMap table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Parent = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.PropertyList = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Parent : {0}" + Environment.NewLine + \r
+ "PropertyList : {1}" + Environment.NewLine,\r
+ "TypeDef[" + Parent.ToString() + "]",\r
+ "Property[" + PropertyList.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in PropertyPtr table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class PropertyPtrRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Property;\r
+\r
+ public PropertyPtrRow()\r
+ {\r
+ }\r
+\r
+ public PropertyPtrRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in PropertyPtr table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Property = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Property : {0}" + Environment.NewLine,\r
+ "Property[" + Property.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Property table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.30\r
+ /// </remarks>\r
+ public class PropertyRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.PropertyAttributes Flags;\r
+ public int Name;\r
+ public int Type;\r
+\r
+ public PropertyRow()\r
+ {\r
+ }\r
+\r
+ public PropertyRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Property table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.Reflection.PropertyAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Type = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "Type : {2}" + Environment.NewLine,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#Blob[" + Type.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in MethodSemantics table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.26\r
+ /// </remarks>\r
+ public class MethodSemanticsRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public MethodSemanticsAttributes Semantics;\r
+ public int Method;\r
+ public MDToken Association;\r
+\r
+ public MethodSemanticsRow()\r
+ {\r
+ }\r
+\r
+ public MethodSemanticsRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in MethodSemantics table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Semantics = (MethodSemanticsAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Method = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Association = TabsDecoder.DecodeToken(CodedTokenId.HasSemantics, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Semantics : {0}" + Environment.NewLine + \r
+ "Method : {1}" + Environment.NewLine + \r
+ "Association : {2}" + Environment.NewLine,\r
+ this.Semantics,\r
+ "Method[" + Method.ToString() + "]",\r
+ this.Association\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in MethodImpl table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.25\r
+ /// </remarks>\r
+ public class MethodImplRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Class;\r
+ public MDToken MethodBody;\r
+ public MDToken MethodDeclaration;\r
+\r
+ public MethodImplRow()\r
+ {\r
+ }\r
+\r
+ public MethodImplRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in MethodImpl table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Class = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.MethodBody = TabsDecoder.DecodeToken(CodedTokenId.MethodDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.MethodDeclaration = TabsDecoder.DecodeToken(CodedTokenId.MethodDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Class : {0}" + Environment.NewLine + \r
+ "MethodBody : {1}" + Environment.NewLine + \r
+ "MethodDeclaration : {2}" + Environment.NewLine,\r
+ "TypeDef[" + Class.ToString() + "]",\r
+ this.MethodBody,\r
+ this.MethodDeclaration\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ModuleRef table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.28\r
+ /// </remarks>\r
+ public class ModuleRefRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Name;\r
+\r
+ public ModuleRefRow()\r
+ {\r
+ }\r
+\r
+ public ModuleRefRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ModuleRef table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Name : {0}" + Environment.NewLine,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in TypeSpec table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.36\r
+ /// </remarks>\r
+ public class TypeSpecRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Signature;\r
+\r
+ public TypeSpecRow()\r
+ {\r
+ }\r
+\r
+ public TypeSpecRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in TypeSpec table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Signature = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Signature : {0}" + Environment.NewLine,\r
+ "#Blob[" + Signature.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ImplMap table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.20\r
+ /// </remarks>\r
+ public class ImplMapRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public PInvokeAttributes MappingFlags;\r
+ public MDToken MemberForwarded;\r
+ public int ImportName;\r
+ public int ImportScope;\r
+\r
+ public ImplMapRow()\r
+ {\r
+ }\r
+\r
+ public ImplMapRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ImplMap table has 4 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.MappingFlags = (PInvokeAttributes) LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.MemberForwarded = TabsDecoder.DecodeToken(CodedTokenId.MemberForwarded, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.ImportName = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.ImportScope = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "MappingFlags : {0}" + Environment.NewLine + \r
+ "MemberForwarded : {1}" + Environment.NewLine + \r
+ "ImportName : {2}" + Environment.NewLine + \r
+ "ImportScope : {3}" + Environment.NewLine,\r
+ this.MappingFlags,\r
+ this.MemberForwarded,\r
+ (Table == null) ? ImportName.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [ImportName] + "\" (#Strings[0x" + ImportName.ToString("X") + "])",\r
+ "ModuleRef[" + ImportScope.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in FieldRVA table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.18\r
+ /// </remarks>\r
+ public class FieldRVARow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public RVA RVA;\r
+ public int Field;\r
+\r
+ public FieldRVARow()\r
+ {\r
+ }\r
+\r
+ public FieldRVARow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in FieldRVA table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return RVA.Size + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.RVA = LEBitConverter.ToUInt32(buff, offs);\r
+ offs += RVA.Size;\r
+ this.Field = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "RVA : {0}" + Environment.NewLine + \r
+ "Field : {1}" + Environment.NewLine,\r
+ this.RVA,\r
+ "Field[" + Field.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ENCLog table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class ENCLogRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public uint Token;\r
+ public uint FuncCode;\r
+\r
+ public ENCLogRow()\r
+ {\r
+ }\r
+\r
+ public ENCLogRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ENCLog table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (uint) + sizeof (uint);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Token = LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.FuncCode = LEBitConverter.ToUInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Token : {0}" + Environment.NewLine + \r
+ "FuncCode : {1}" + Environment.NewLine,\r
+ this.Token,\r
+ this.FuncCode\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ENCMap table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class ENCMapRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public uint Token;\r
+\r
+ public ENCMapRow()\r
+ {\r
+ }\r
+\r
+ public ENCMapRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ENCMap table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (uint);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Token = LEBitConverter.ToUInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Token : {0}" + Environment.NewLine,\r
+ this.Token\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in Assembly table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.2\r
+ /// </remarks>\r
+ public class AssemblyRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Configuration.Assemblies.AssemblyHashAlgorithm HashAlgId;\r
+ public short MajorVersion;\r
+ public short MinorVersion;\r
+ public short BuildNumber;\r
+ public short RevisionNumber;\r
+ public AssemblyFlags Flags;\r
+ public int PublicKey;\r
+ public int Name;\r
+ public int Culture;\r
+\r
+ public AssemblyRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in Assembly table has 9 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 9;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.HashAlgId = (System.Configuration.Assemblies.AssemblyHashAlgorithm) LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.MajorVersion = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.MinorVersion = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.BuildNumber = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.RevisionNumber = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.Flags = (AssemblyFlags) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.PublicKey = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Culture = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "HashAlgId : {0}" + Environment.NewLine + \r
+ "MajorVersion : {1}" + Environment.NewLine + \r
+ "MinorVersion : {2}" + Environment.NewLine + \r
+ "BuildNumber : {3}" + Environment.NewLine + \r
+ "RevisionNumber : {4}" + Environment.NewLine + \r
+ "Flags : {5}" + Environment.NewLine + \r
+ "PublicKey : {6}" + Environment.NewLine + \r
+ "Name : {7}" + Environment.NewLine + \r
+ "Culture : {8}" + Environment.NewLine,\r
+ this.HashAlgId,\r
+ this.MajorVersion,\r
+ this.MinorVersion,\r
+ this.BuildNumber,\r
+ this.RevisionNumber,\r
+ this.Flags,\r
+ "#Blob[" + PublicKey.ToString() + "]",\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ (Table == null) ? Culture.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Culture] + "\" (#Strings[0x" + Culture.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in AssemblyProcessor table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.4\r
+ /// </remarks>\r
+ public class AssemblyProcessorRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Processor;\r
+\r
+ public AssemblyProcessorRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyProcessorRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in AssemblyProcessor table has 1 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 1;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Processor = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Processor : {0}" + Environment.NewLine,\r
+ this.Processor\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in AssemblyOS table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.3\r
+ /// </remarks>\r
+ public class AssemblyOSRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int OSPlatformID;\r
+ public int OSMajorVersion;\r
+ public int OSMinorVersion;\r
+\r
+ public AssemblyOSRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyOSRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in AssemblyOS table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + sizeof (int) + sizeof (int);\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.OSPlatformID = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.OSMajorVersion = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.OSMinorVersion = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "OSPlatformID : {0}" + Environment.NewLine + \r
+ "OSMajorVersion : {1}" + Environment.NewLine + \r
+ "OSMinorVersion : {2}" + Environment.NewLine,\r
+ this.OSPlatformID,\r
+ this.OSMajorVersion,\r
+ this.OSMinorVersion\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in AssemblyRef table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.5\r
+ /// </remarks>\r
+ public class AssemblyRefRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public short MajorVersion;\r
+ public short MinorVersion;\r
+ public short BuildNumber;\r
+ public short RevisionNumber;\r
+ public AssemblyFlags Flags;\r
+ public int PublicKeyOrToken;\r
+ public int Name;\r
+ public int Culture;\r
+ public int HashValue;\r
+\r
+ public AssemblyRefRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyRefRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in AssemblyRef table has 9 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 9;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.MajorVersion = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.MinorVersion = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.BuildNumber = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.RevisionNumber = LEBitConverter.ToInt16(buff, offs);\r
+ offs += sizeof (short);\r
+ this.Flags = (AssemblyFlags) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.PublicKeyOrToken = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Culture = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.HashValue = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "MajorVersion : {0}" + Environment.NewLine + \r
+ "MinorVersion : {1}" + Environment.NewLine + \r
+ "BuildNumber : {2}" + Environment.NewLine + \r
+ "RevisionNumber : {3}" + Environment.NewLine + \r
+ "Flags : {4}" + Environment.NewLine + \r
+ "PublicKeyOrToken : {5}" + Environment.NewLine + \r
+ "Name : {6}" + Environment.NewLine + \r
+ "Culture : {7}" + Environment.NewLine + \r
+ "HashValue : {8}" + Environment.NewLine,\r
+ this.MajorVersion,\r
+ this.MinorVersion,\r
+ this.BuildNumber,\r
+ this.RevisionNumber,\r
+ this.Flags,\r
+ "#Blob[" + PublicKeyOrToken.ToString() + "]",\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ (Table == null) ? Culture.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Culture] + "\" (#Strings[0x" + Culture.ToString("X") + "])",\r
+ "#Blob[" + HashValue.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in AssemblyRefProcessor table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.7\r
+ /// </remarks>\r
+ public class AssemblyRefProcessorRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Processor;\r
+ public int AssemblyRef;\r
+\r
+ public AssemblyRefProcessorRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyRefProcessorRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in AssemblyRefProcessor table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Processor = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.AssemblyRef = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Processor : {0}" + Environment.NewLine + \r
+ "AssemblyRef : {1}" + Environment.NewLine,\r
+ this.Processor,\r
+ "AssemblyRef[" + AssemblyRef.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in AssemblyRefOS table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.6\r
+ /// </remarks>\r
+ public class AssemblyRefOSRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int OSPlatformID;\r
+ public int OSMajorVersion;\r
+ public int OSMinorVersion;\r
+ public int AssemblyRef;\r
+\r
+ public AssemblyRefOSRow()\r
+ {\r
+ }\r
+\r
+ public AssemblyRefOSRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in AssemblyRefOS table has 4 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + sizeof (int) + sizeof (int) + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.OSPlatformID = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.OSMajorVersion = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.OSMinorVersion = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.AssemblyRef = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "OSPlatformID : {0}" + Environment.NewLine + \r
+ "OSMajorVersion : {1}" + Environment.NewLine + \r
+ "OSMinorVersion : {2}" + Environment.NewLine + \r
+ "AssemblyRef : {3}" + Environment.NewLine,\r
+ this.OSPlatformID,\r
+ this.OSMajorVersion,\r
+ this.OSMinorVersion,\r
+ "AssemblyRef[" + AssemblyRef.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in File table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.19\r
+ /// </remarks>\r
+ public class FileRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.IO.FileAttributes Flags;\r
+ public int Name;\r
+ public int HashValue;\r
+\r
+ public FileRow()\r
+ {\r
+ }\r
+\r
+ public FileRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in File table has 3 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 3;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (uint) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.IO.FileAttributes) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.HashValue = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "Name : {1}" + Environment.NewLine + \r
+ "HashValue : {2}" + Environment.NewLine,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ "#Blob[" + HashValue.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ExportedType table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.14\r
+ /// </remarks>\r
+ public class ExportedTypeRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public System.Reflection.TypeAttributes Flags;\r
+ public int TypeDefId;\r
+ public int TypeName;\r
+ public int TypeNamespace;\r
+ public MDToken Implementation;\r
+\r
+ public ExportedTypeRow()\r
+ {\r
+ }\r
+\r
+ public ExportedTypeRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ExportedType table has 5 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 5;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (uint) + 4 + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Flags = (System.Reflection.TypeAttributes) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.TypeDefId = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.TypeName = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.TypeNamespace = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Implementation = TabsDecoder.DecodeToken(CodedTokenId.Implementation, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Flags : {0}" + Environment.NewLine + \r
+ "TypeDefId : {1}" + Environment.NewLine + \r
+ "TypeName : {2}" + Environment.NewLine + \r
+ "TypeNamespace : {3}" + Environment.NewLine + \r
+ "Implementation : {4}" + Environment.NewLine,\r
+ this.Flags,\r
+ "TypeDef[" + TypeDefId.ToString() + "]",\r
+ (Table == null) ? TypeName.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [TypeName] + "\" (#Strings[0x" + TypeName.ToString("X") + "])",\r
+ (Table == null) ? TypeNamespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [TypeNamespace] + "\" (#Strings[0x" + TypeNamespace.ToString("X") + "])",\r
+ this.Implementation\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in ManifestResource table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.22\r
+ /// </remarks>\r
+ public class ManifestResourceRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int Offset;\r
+ public ManifestResourceAttributes Flags;\r
+ public int Name;\r
+ public MDToken Implementation;\r
+\r
+ public ManifestResourceRow()\r
+ {\r
+ }\r
+\r
+ public ManifestResourceRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in ManifestResource table has 4 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (int) + sizeof (uint) + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Offset = LEBitConverter.ToInt32(buff, offs);\r
+ offs += sizeof (int);\r
+ this.Flags = (ManifestResourceAttributes) LEBitConverter.ToUInt32(buff, offs);\r
+ offs += sizeof (uint);\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Implementation = TabsDecoder.DecodeToken(CodedTokenId.Implementation, LEBitConverter.ToInt32(buff, offs));\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Offset : {0}" + Environment.NewLine + \r
+ "Flags : {1}" + Environment.NewLine + \r
+ "Name : {2}" + Environment.NewLine + \r
+ "Implementation : {3}" + Environment.NewLine,\r
+ this.Offset,\r
+ this.Flags,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])",\r
+ this.Implementation\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in NestedClass table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Partition II, Metadata; section 21.29\r
+ /// </remarks>\r
+ public class NestedClassRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public int NestedClass;\r
+ public int EnclosingClass;\r
+\r
+ public NestedClassRow()\r
+ {\r
+ }\r
+\r
+ public NestedClassRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in NestedClass table has 2 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 2;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.NestedClass = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.EnclosingClass = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "NestedClass : {0}" + Environment.NewLine + \r
+ "EnclosingClass : {1}" + Environment.NewLine,\r
+ "TypeDef[" + NestedClass.ToString() + "]",\r
+ "TypeDef[" + EnclosingClass.ToString() + "]"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in TypeTyPar table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class TypeTyParRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public ushort Number;\r
+ public int Class;\r
+ public MDToken Bound;\r
+ public int Name;\r
+\r
+ public TypeTyParRow()\r
+ {\r
+ }\r
+\r
+ public TypeTyParRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in TypeTyPar table has 4 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Number = LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Class = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Bound = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Number : {0}" + Environment.NewLine + \r
+ "Class : {1}" + Environment.NewLine + \r
+ "Bound : {2}" + Environment.NewLine + \r
+ "Name : {3}" + Environment.NewLine,\r
+ this.Number,\r
+ "TypeDef[" + Class.ToString() + "]",\r
+ this.Bound,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+ /// <summary>\r
+ /// Represents row in MethodTyPar table.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// \r
+ /// </remarks>\r
+ public class MethodTyParRow : Row {\r
+\r
+ private MDTable table;\r
+\r
+ \r
+ public ushort Number;\r
+ public int Method;\r
+ public MDToken Bound;\r
+ public int Name;\r
+\r
+ public MethodTyParRow()\r
+ {\r
+ }\r
+\r
+ public MethodTyParRow(MDTable parent)\r
+ {\r
+ table = parent;\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Row in MethodTyPar table has 4 columns.\r
+ /// </summary>\r
+ public virtual int NumberOfColumns {\r
+ get {\r
+ return 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this instance in bytes.\r
+ /// </summary>\r
+ public virtual int Size {\r
+ get {\r
+ return LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public virtual MDTable Table {\r
+ get {\r
+ return table;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Logical size of this type of row in bytes.\r
+ /// </summary>\r
+ unsafe public static int LogicalSize {\r
+ get {\r
+ return sizeof (ushort) + 4 + 4 + 4;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Fills the row from the array of bytes.\r
+ /// </summary>\r
+ unsafe public void FromRawData(byte [] buff, int offs)\r
+ {\r
+ if (buff == null) throw new Exception("buff == null");\r
+ if (offs + Size > buff.Length) throw new Exception("bounds");\r
+\r
+ \r
+ this.Number = LEBitConverter.ToUInt16(buff, offs);\r
+ offs += sizeof (ushort);\r
+ this.Method = LEBitConverter.ToInt32(buff, offs);\r
+ offs += 4;\r
+ this.Bound = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs));\r
+ offs += 4;\r
+ this.Name = LEBitConverter.ToInt32(buff, offs);\r
+ \r
+ }\r
+\r
+ \r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public void Dump(TextWriter writer) {\r
+ string dump = String.Format(\r
+ "Number : {0}" + Environment.NewLine + \r
+ "Method : {1}" + Environment.NewLine + \r
+ "Bound : {2}" + Environment.NewLine + \r
+ "Name : {3}" + Environment.NewLine,\r
+ this.Number,\r
+ "Method[" + Method.ToString() + "]",\r
+ this.Bound,\r
+ (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])"\r
+ );\r
+ writer.WriteLine(dump);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ public override string ToString()\r
+ {\r
+ StringWriter sw = new StringWriter();\r
+ Dump(sw);\r
+ return sw.ToString();\r
+ }\r
+\r
+ }\r
+\r
+\r
+\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.Text;\r
+using System.Collections;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ // 23.1.3\r
+ public class StringsHeap : MDHeap {\r
+\r
+ private SortedList strings;\r
+ private int dataLen;\r
+\r
+ internal StringsHeap(MDStream stream) : base(stream)\r
+ {\r
+ }\r
+\r
+ unsafe override public void FromRawData(byte[] rawData)\r
+ {\r
+ strings = new SortedList();\r
+ strings.Add (0, String.Empty);\r
+ if (rawData == null) return;\r
+\r
+ int len = rawData.Length;\r
+ dataLen = len;\r
+ // the first entry in the string heap is always EmptyString\r
+ if (len < 1 || rawData [0] != 0) {\r
+ throw new BadMetaDataException("Invalid #Strings heap.");\r
+ }\r
+\r
+ int idx = 1;\r
+ for (int i = 1; i < len; i++) {\r
+ if (rawData [i] == 0) {\r
+ fixed (void* p = &rawData[idx]) {\r
+ string s = new string ((sbyte*)p, 0, i - idx, Encoding.UTF8);\r
+ strings.Add (idx, s);\r
+ }\r
+ idx = i + 1;\r
+ }\r
+ }\r
+ }\r
+\r
+ public string this [int index] {\r
+ get {\r
+ string res = null;\r
+ if (strings != null && index >= 0 && index < dataLen) {\r
+ res = strings[index] as string;\r
+ if (res == null) {\r
+ // cope with garbage/substrings\r
+ IList indices = strings.GetKeyList();\r
+ int i = FindNextIndex(indices, index);\r
+ if (i < 0) {\r
+ throw new Exception("Internal error (#Strings binary search).");\r
+ }\r
+ if (i != 0) {\r
+ // Position of the super-string in the heap.\r
+ int pos = (int) indices [i - 1];\r
+ res = strings[pos] as string;\r
+ // NOTE: Substring returns String.Empty if index\r
+ // is equal to the length.\r
+ res = res.Substring(index - pos);\r
+ }\r
+ }\r
+ }\r
+ return res;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Binary search.\r
+ /// </summary>\r
+ /// <param name="list">List of "edge" indices.</param>\r
+ /// <param name="index"></param>\r
+ /// <returns></returns>\r
+ private static int FindNextIndex(IList list, int index) {\r
+ int len = list.Count;\r
+\r
+ if (len == 0) return ~0;\r
+\r
+ int left = 0;\r
+ int right = len-1;\r
+\r
+ while (left <= right) {\r
+ int guess = (left + right) >> 1;\r
+ int cmp = index - (int) list [guess];\r
+ if (cmp == 0) return ~guess;\r
+ cmp &= ~Int32.MaxValue;\r
+ if (cmp == 0) left = guess+1;\r
+ else right = guess-1;\r
+ }\r
+\r
+ return left;\r
+ }\r
+\r
+ public int Count {\r
+ get {\r
+ return (strings == null) ? 0 : strings.Count;\r
+ }\r
+ }\r
+\r
+ }\r
+}\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or table-id.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ /// <summary>\r
+ /// Identifiers for tables in #~ heap.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Partition II, 21.x\r
+ /// </remarks>\r
+ public enum TableId {\r
+ Module = 0x00,\r
+ TypeRef = 0x01,\r
+ TypeDef = 0x02,\r
+ FieldPtr = 0x03,\r
+ Field = 0x04,\r
+ MethodPtr = 0x05,\r
+ Method = 0x06,\r
+ ParamPtr = 0x07,\r
+ Param = 0x08,\r
+ InterfaceImpl = 0x09,\r
+ MemberRef = 0x0a,\r
+ Constant = 0x0b,\r
+ CustomAttribute = 0x0c,\r
+ FieldMarshal = 0x0d,\r
+ DeclSecurity = 0x0e,\r
+ ClassLayout = 0x0f,\r
+ FieldLayout = 0x10,\r
+ StandAloneSig = 0x11,\r
+ EventMap = 0x12,\r
+ EventPtr = 0x13,\r
+ Event = 0x14,\r
+ PropertyMap = 0x15,\r
+ PropertyPtr = 0x16,\r
+ Property = 0x17,\r
+ MethodSemantics = 0x18,\r
+ MethodImpl = 0x19,\r
+ ModuleRef = 0x1a,\r
+ TypeSpec = 0x1b,\r
+ ImplMap = 0x1c,\r
+ FieldRVA = 0x1d,\r
+ ENCLog = 0x1e,\r
+ ENCMap = 0x1f,\r
+ Assembly = 0x20,\r
+ AssemblyProcessor = 0x21,\r
+ AssemblyOS = 0x22,\r
+ AssemblyRef = 0x23,\r
+ AssemblyRefProcessor = 0x24,\r
+ AssemblyRefOS = 0x25,\r
+ File = 0x26,\r
+ ExportedType = 0x27,\r
+ ManifestResource = 0x28,\r
+ NestedClass = 0x29,\r
+ TypeTyPar = 0x2a,\r
+ MethodTyPar = 0x2b,\r
+\r
+ MAX = MethodTyPar,\r
+ Count = MAX + 1\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ public class ModuleTable : MDTableBase {\r
+\r
+ public ModuleTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ModuleRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ModuleRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Module";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Module;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class TypeRefTable : MDTableBase {\r
+\r
+ public TypeRefTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new TypeRefRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += TypeRefRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "TypeRef";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.TypeRef;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class TypeDefTable : MDTableBase {\r
+\r
+ public TypeDefTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new TypeDefRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += TypeDefRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "TypeDef";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.TypeDef;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FieldPtrTable : MDTableBase {\r
+\r
+ public FieldPtrTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FieldPtrRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FieldPtrRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "FieldPtr";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.FieldPtr;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FieldTable : MDTableBase {\r
+\r
+ public FieldTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FieldRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FieldRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Field";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Field;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MethodPtrTable : MDTableBase {\r
+\r
+ public MethodPtrTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MethodPtrRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MethodPtrRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "MethodPtr";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.MethodPtr;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MethodTable : MDTableBase {\r
+\r
+ public MethodTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MethodRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MethodRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Method";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Method;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ParamPtrTable : MDTableBase {\r
+\r
+ public ParamPtrTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ParamPtrRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ParamPtrRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ParamPtr";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ParamPtr;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ParamTable : MDTableBase {\r
+\r
+ public ParamTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ParamRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ParamRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Param";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Param;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class InterfaceImplTable : MDTableBase {\r
+\r
+ public InterfaceImplTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new InterfaceImplRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += InterfaceImplRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "InterfaceImpl";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.InterfaceImpl;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MemberRefTable : MDTableBase {\r
+\r
+ public MemberRefTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MemberRefRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MemberRefRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "MemberRef";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.MemberRef;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ConstantTable : MDTableBase {\r
+\r
+ public ConstantTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ConstantRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ConstantRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Constant";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Constant;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class CustomAttributeTable : MDTableBase {\r
+\r
+ public CustomAttributeTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new CustomAttributeRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += CustomAttributeRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "CustomAttribute";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.CustomAttribute;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FieldMarshalTable : MDTableBase {\r
+\r
+ public FieldMarshalTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FieldMarshalRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FieldMarshalRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "FieldMarshal";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.FieldMarshal;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class DeclSecurityTable : MDTableBase {\r
+\r
+ public DeclSecurityTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new DeclSecurityRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += DeclSecurityRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "DeclSecurity";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.DeclSecurity;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ClassLayoutTable : MDTableBase {\r
+\r
+ public ClassLayoutTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ClassLayoutRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ClassLayoutRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ClassLayout";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ClassLayout;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FieldLayoutTable : MDTableBase {\r
+\r
+ public FieldLayoutTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FieldLayoutRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FieldLayoutRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "FieldLayout";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.FieldLayout;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class StandAloneSigTable : MDTableBase {\r
+\r
+ public StandAloneSigTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new StandAloneSigRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += StandAloneSigRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "StandAloneSig";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.StandAloneSig;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class EventMapTable : MDTableBase {\r
+\r
+ public EventMapTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new EventMapRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += EventMapRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "EventMap";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.EventMap;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class EventPtrTable : MDTableBase {\r
+\r
+ public EventPtrTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new EventPtrRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += EventPtrRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "EventPtr";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.EventPtr;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class EventTable : MDTableBase {\r
+\r
+ public EventTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new EventRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += EventRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Event";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Event;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class PropertyMapTable : MDTableBase {\r
+\r
+ public PropertyMapTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new PropertyMapRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += PropertyMapRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "PropertyMap";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.PropertyMap;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class PropertyPtrTable : MDTableBase {\r
+\r
+ public PropertyPtrTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new PropertyPtrRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += PropertyPtrRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "PropertyPtr";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.PropertyPtr;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class PropertyTable : MDTableBase {\r
+\r
+ public PropertyTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new PropertyRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += PropertyRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Property";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Property;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MethodSemanticsTable : MDTableBase {\r
+\r
+ public MethodSemanticsTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MethodSemanticsRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MethodSemanticsRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "MethodSemantics";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.MethodSemantics;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MethodImplTable : MDTableBase {\r
+\r
+ public MethodImplTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MethodImplRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MethodImplRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "MethodImpl";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.MethodImpl;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ModuleRefTable : MDTableBase {\r
+\r
+ public ModuleRefTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ModuleRefRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ModuleRefRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ModuleRef";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ModuleRef;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class TypeSpecTable : MDTableBase {\r
+\r
+ public TypeSpecTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new TypeSpecRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += TypeSpecRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "TypeSpec";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.TypeSpec;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ImplMapTable : MDTableBase {\r
+\r
+ public ImplMapTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ImplMapRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ImplMapRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ImplMap";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ImplMap;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FieldRVATable : MDTableBase {\r
+\r
+ public FieldRVATable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FieldRVARow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FieldRVARow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "FieldRVA";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.FieldRVA;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ENCLogTable : MDTableBase {\r
+\r
+ public ENCLogTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ENCLogRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ENCLogRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ENCLog";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ENCLog;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ENCMapTable : MDTableBase {\r
+\r
+ public ENCMapTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ENCMapRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ENCMapRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ENCMap";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ENCMap;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyTable : MDTableBase {\r
+\r
+ public AssemblyTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "Assembly";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.Assembly;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyProcessorTable : MDTableBase {\r
+\r
+ public AssemblyProcessorTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyProcessorRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyProcessorRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "AssemblyProcessor";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.AssemblyProcessor;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyOSTable : MDTableBase {\r
+\r
+ public AssemblyOSTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyOSRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyOSRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "AssemblyOS";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.AssemblyOS;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyRefTable : MDTableBase {\r
+\r
+ public AssemblyRefTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyRefRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyRefRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "AssemblyRef";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.AssemblyRef;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyRefProcessorTable : MDTableBase {\r
+\r
+ public AssemblyRefProcessorTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyRefProcessorRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyRefProcessorRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "AssemblyRefProcessor";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.AssemblyRefProcessor;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class AssemblyRefOSTable : MDTableBase {\r
+\r
+ public AssemblyRefOSTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new AssemblyRefOSRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += AssemblyRefOSRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "AssemblyRefOS";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.AssemblyRefOS;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class FileTable : MDTableBase {\r
+\r
+ public FileTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new FileRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += FileRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "File";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.File;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ExportedTypeTable : MDTableBase {\r
+\r
+ public ExportedTypeTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ExportedTypeRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ExportedTypeRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ExportedType";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ExportedType;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class ManifestResourceTable : MDTableBase {\r
+\r
+ public ManifestResourceTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new ManifestResourceRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += ManifestResourceRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "ManifestResource";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.ManifestResource;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class NestedClassTable : MDTableBase {\r
+\r
+ public NestedClassTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new NestedClassRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += NestedClassRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "NestedClass";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.NestedClass;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class TypeTyParTable : MDTableBase {\r
+\r
+ public TypeTyParTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new TypeTyParRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += TypeTyParRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "TypeTyPar";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.TypeTyPar;\r
+ }\r
+ }\r
+ }\r
+\r
+ public class MethodTyParTable : MDTableBase {\r
+\r
+ public MethodTyParTable(MDHeap heap)\r
+ : base(heap)\r
+ {\r
+ }\r
+\r
+\r
+ public override void FromRawData(byte [] buff, int offs, int numRows) {\r
+ for (int i = numRows; --i >= 0;) {\r
+ Row row = new MethodTyParRow(this);\r
+ row.FromRawData(buff, offs);\r
+ Add(row);\r
+ offs += MethodTyParRow.LogicalSize;\r
+ }\r
+ }\r
+\r
+\r
+ public override string Name {\r
+ get {\r
+ return "MethodTyPar";\r
+ }\r
+ }\r
+\r
+ public override TableId Id {\r
+ get {\r
+ return TableId.MethodTyPar;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+}\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+using System.IO;\r
+using System.Collections;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// Metadata tables heap (#~).\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// Partition II; Chapter 21 & 23.1.6\r
+ /// </remarks>\r
+ public class TablesHeap : TablesHeapBase {\r
+\r
+ private long valid; // bitvector of valid tables\r
+ //(64-bit, max index = TableId.MAX)\r
+ private int numTabs; // number of tables (calculated from valid)\r
+\r
+ private long sorted; // bitvector of sorted tables (64-bit)\r
+\r
+ // schema version (currently 1.0)\r
+ private byte verMaj;\r
+ private byte verMin;\r
+\r
+ // bitvector for heap-size flags:\r
+ // bit 1 - if set #Strings heap uses wide indices (dword)\r
+ // bit 2 - if set #GUID heap uses wide indices\r
+ // bit 3 - if set #Blob heap uses wide indices\r
+ // otherwise (particular bit is not set) index size is word.\r
+ private byte heapSizes;\r
+\r
+\r
+ private Hashtable tables;\r
+\r
+\r
+ internal TablesHeap (MDStream stream) : base (stream)\r
+ {\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of valid tables (64-bit).\r
+ /// </summary>\r
+ public override long Valid {\r
+ get {\r
+ return valid;\r
+ }\r
+ set {\r
+ valid = value;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of sorted tables (64-bit).\r
+ /// </summary>\r
+ public override long Sorted {\r
+ get {\r
+ return sorted;\r
+ }\r
+ set {\r
+ sorted = value;\r
+ }\r
+ }\r
+\r
+\r
+ //\r
+ // "Universal" accessors for Valid and Sorted bitvectors.\r
+ //\r
+\r
+\r
+ public bool IsValid (TableId tab)\r
+ {\r
+ return (valid & (1L << (int) tab)) != 0;\r
+ }\r
+\r
+ public void SetValid (TableId tab, bool b)\r
+ {\r
+ long mask = 1L << (int) tab;\r
+ if (b) {\r
+ valid |= mask;\r
+ } else {\r
+ valid &= ~mask;\r
+ }\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// True if the given table in this heap is sorted.\r
+ /// </summary>\r
+ /// <param name="tab"></param>\r
+ /// <returns></returns>\r
+ public bool IsSorted (TableId tab)\r
+ {\r
+ return (sorted & (1L << (int) tab)) != 0;\r
+ }\r
+\r
+ /// <summary>\r
+ /// Marks specified table in this heap as sorted or unsorted.\r
+ /// </summary>\r
+ /// <param name="tab"></param>\r
+ /// <param name="b"></param>\r
+ public void SetSorted (TableId tab, bool b)\r
+ {\r
+ long mask = 1L << (int) tab;\r
+ if (b) {\r
+ sorted |= mask;\r
+ } else {\r
+ sorted &= ~mask;\r
+ }\r
+ }\r
+\r
+\r
+\r
+ public byte HeapSizes {\r
+ get {\r
+ return heapSizes;\r
+ }\r
+ set {\r
+ heapSizes = value;\r
+ }\r
+ }\r
+\r
+ public int StringsIndexSize {\r
+ get {\r
+ return 2 + ((heapSizes & 1) << 1);\r
+ }\r
+ }\r
+\r
+ public int GUIDIndexSize {\r
+ get {\r
+ return 2 + (heapSizes & 2);\r
+ }\r
+ }\r
+\r
+ public int BlobIndexSize {\r
+ get {\r
+ return 2 + ((heapSizes & 4) >> 1);\r
+ }\r
+ }\r
+\r
+\r
+\r
+ unsafe override public void FromRawData (byte [] rawData)\r
+ {\r
+ valid = 0;\r
+ sorted = 0;\r
+\r
+ if (rawData == null || rawData.Length < 24) {\r
+ throw new BadMetaDataException ("Invalid header for #~ heap.");\r
+ }\r
+\r
+ verMaj = rawData [4];\r
+ verMin = rawData [5];\r
+ heapSizes = rawData [6];\r
+\r
+ valid = LEBitConverter.ToInt64 (rawData, 8);\r
+ sorted = LEBitConverter.ToInt64 (rawData, 16);\r
+\r
+ // Calc number of tables from valid bitvector.\r
+ numTabs = 0;\r
+ for (int i = (int) TableId.Count; --i >= 0;) {\r
+ numTabs += (int) (valid >> i) & 1;\r
+ }\r
+\r
+ int [] rows = new int [(int) TableId.Count];\r
+ Array.Clear (rows, 0, rows.Length);\r
+ int offs = 24; // offset to #~::Rows\r
+ for (int i = 0; i < numTabs; i++) {\r
+ int n = -1;\r
+ int vpos = -1;\r
+ long v = valid;\r
+ while (n < i && v != 0) {\r
+ n += (int) (v & 1L);\r
+ v >>= 1;\r
+ vpos++;\r
+ }\r
+ if (vpos != -1) {\r
+ rows [vpos] = LEBitConverter.ToInt32 (rawData, offs);\r
+ offs += sizeof (int);\r
+ }\r
+ }\r
+\r
+ // TODO: this could be called from constructor\r
+ // This sequence: MDHeap::.ctor -> FromRawData -> RegisterTable\r
+ // and we are making "this" available here, before the object\r
+ // is fully constructed. This is bad, fix it somehow.\r
+ TabsDecoder.DecodePhysicalTables (this, rawData, offs, rows);\r
+\r
+ }\r
+\r
+\r
+ public void RegisterTable (MDTable tab)\r
+ {\r
+ if (tables == null) tables = new Hashtable (64);\r
+ tables [tab.Id] = tab;\r
+ }\r
+\r
+ public MDTable this [TableId id] {\r
+ get {\r
+ return tables [id] as MDTable;\r
+ }\r
+ }\r
+\r
+ public ICollection Tables {\r
+ get {\r
+ return tables.Values;\r
+ }\r
+ }\r
+\r
+\r
+ }\r
+\r
+}\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs-base.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public abstract class TablesHeapBase : MDHeap {\r
+\r
+ internal TablesHeapBase(MDStream stream) : base(stream)\r
+ {\r
+ }\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of valid tables (64-bit).\r
+ /// </summary>\r
+ public abstract long Valid {get; set;}\r
+\r
+ /// <summary>\r
+ /// Gets or sets bitvector of sorted tables (64-bit).\r
+ /// </summary>\r
+ public abstract long Sorted {get; set;}\r
+\r
+\r
+ //\r
+ // Accessors to decode Valid bitvector.\r
+ //\r
+\r
+\r
+ /// <summary>\r
+ /// True if heap has Module table.\r
+ /// </summary>\r
+ public bool HasModule {\r
+ get {\r
+ return (Valid & (1L << 0x00)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x00);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has TypeRef table.\r
+ /// </summary>\r
+ public bool HasTypeRef {\r
+ get {\r
+ return (Valid & (1L << 0x01)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x01);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has TypeDef table.\r
+ /// </summary>\r
+ public bool HasTypeDef {\r
+ get {\r
+ return (Valid & (1L << 0x02)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x02);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has FieldPtr table.\r
+ /// </summary>\r
+ public bool HasFieldPtr {\r
+ get {\r
+ return (Valid & (1L << 0x03)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x03);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Field table.\r
+ /// </summary>\r
+ public bool HasField {\r
+ get {\r
+ return (Valid & (1L << 0x04)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x04);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has MethodPtr table.\r
+ /// </summary>\r
+ public bool HasMethodPtr {\r
+ get {\r
+ return (Valid & (1L << 0x05)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x05);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Method table.\r
+ /// </summary>\r
+ public bool HasMethod {\r
+ get {\r
+ return (Valid & (1L << 0x06)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x06);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ParamPtr table.\r
+ /// </summary>\r
+ public bool HasParamPtr {\r
+ get {\r
+ return (Valid & (1L << 0x07)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x07);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Param table.\r
+ /// </summary>\r
+ public bool HasParam {\r
+ get {\r
+ return (Valid & (1L << 0x08)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x08);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has InterfaceImpl table.\r
+ /// </summary>\r
+ public bool HasInterfaceImpl {\r
+ get {\r
+ return (Valid & (1L << 0x09)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x09);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has MemberRef table.\r
+ /// </summary>\r
+ public bool HasMemberRef {\r
+ get {\r
+ return (Valid & (1L << 0x0a)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0a);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Constant table.\r
+ /// </summary>\r
+ public bool HasConstant {\r
+ get {\r
+ return (Valid & (1L << 0x0b)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0b);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has CustomAttribute table.\r
+ /// </summary>\r
+ public bool HasCustomAttribute {\r
+ get {\r
+ return (Valid & (1L << 0x0c)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0c);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has FieldMarshal table.\r
+ /// </summary>\r
+ public bool HasFieldMarshal {\r
+ get {\r
+ return (Valid & (1L << 0x0d)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0d);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has DeclSecurity table.\r
+ /// </summary>\r
+ public bool HasDeclSecurity {\r
+ get {\r
+ return (Valid & (1L << 0x0e)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0e);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ClassLayout table.\r
+ /// </summary>\r
+ public bool HasClassLayout {\r
+ get {\r
+ return (Valid & (1L << 0x0f)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x0f);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has FieldLayout table.\r
+ /// </summary>\r
+ public bool HasFieldLayout {\r
+ get {\r
+ return (Valid & (1L << 0x10)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x10);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has StandAloneSig table.\r
+ /// </summary>\r
+ public bool HasStandAloneSig {\r
+ get {\r
+ return (Valid & (1L << 0x11)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x11);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has EventMap table.\r
+ /// </summary>\r
+ public bool HasEventMap {\r
+ get {\r
+ return (Valid & (1L << 0x12)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x12);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has EventPtr table.\r
+ /// </summary>\r
+ public bool HasEventPtr {\r
+ get {\r
+ return (Valid & (1L << 0x13)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x13);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Event table.\r
+ /// </summary>\r
+ public bool HasEvent {\r
+ get {\r
+ return (Valid & (1L << 0x14)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x14);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has PropertyMap table.\r
+ /// </summary>\r
+ public bool HasPropertyMap {\r
+ get {\r
+ return (Valid & (1L << 0x15)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x15);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has PropertyPtr table.\r
+ /// </summary>\r
+ public bool HasPropertyPtr {\r
+ get {\r
+ return (Valid & (1L << 0x16)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x16);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Property table.\r
+ /// </summary>\r
+ public bool HasProperty {\r
+ get {\r
+ return (Valid & (1L << 0x17)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x17);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has MethodSemantics table.\r
+ /// </summary>\r
+ public bool HasMethodSemantics {\r
+ get {\r
+ return (Valid & (1L << 0x18)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x18);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has MethodImpl table.\r
+ /// </summary>\r
+ public bool HasMethodImpl {\r
+ get {\r
+ return (Valid & (1L << 0x19)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x19);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ModuleRef table.\r
+ /// </summary>\r
+ public bool HasModuleRef {\r
+ get {\r
+ return (Valid & (1L << 0x1a)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1a);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has TypeSpec table.\r
+ /// </summary>\r
+ public bool HasTypeSpec {\r
+ get {\r
+ return (Valid & (1L << 0x1b)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1b);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ImplMap table.\r
+ /// </summary>\r
+ public bool HasImplMap {\r
+ get {\r
+ return (Valid & (1L << 0x1c)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1c);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has FieldRVA table.\r
+ /// </summary>\r
+ public bool HasFieldRVA {\r
+ get {\r
+ return (Valid & (1L << 0x1d)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1d);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ENCLog table.\r
+ /// </summary>\r
+ public bool HasENCLog {\r
+ get {\r
+ return (Valid & (1L << 0x1e)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1e);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ENCMap table.\r
+ /// </summary>\r
+ public bool HasENCMap {\r
+ get {\r
+ return (Valid & (1L << 0x1f)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x1f);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has Assembly table.\r
+ /// </summary>\r
+ public bool HasAssembly {\r
+ get {\r
+ return (Valid & (1L << 0x20)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x20);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has AssemblyProcessor table.\r
+ /// </summary>\r
+ public bool HasAssemblyProcessor {\r
+ get {\r
+ return (Valid & (1L << 0x21)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x21);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has AssemblyOS table.\r
+ /// </summary>\r
+ public bool HasAssemblyOS {\r
+ get {\r
+ return (Valid & (1L << 0x22)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x22);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has AssemblyRef table.\r
+ /// </summary>\r
+ public bool HasAssemblyRef {\r
+ get {\r
+ return (Valid & (1L << 0x23)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x23);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has AssemblyRefProcessor table.\r
+ /// </summary>\r
+ public bool HasAssemblyRefProcessor {\r
+ get {\r
+ return (Valid & (1L << 0x24)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x24);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has AssemblyRefOS table.\r
+ /// </summary>\r
+ public bool HasAssemblyRefOS {\r
+ get {\r
+ return (Valid & (1L << 0x25)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x25);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has File table.\r
+ /// </summary>\r
+ public bool HasFile {\r
+ get {\r
+ return (Valid & (1L << 0x26)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x26);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ExportedType table.\r
+ /// </summary>\r
+ public bool HasExportedType {\r
+ get {\r
+ return (Valid & (1L << 0x27)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x27);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has ManifestResource table.\r
+ /// </summary>\r
+ public bool HasManifestResource {\r
+ get {\r
+ return (Valid & (1L << 0x28)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x28);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has NestedClass table.\r
+ /// </summary>\r
+ public bool HasNestedClass {\r
+ get {\r
+ return (Valid & (1L << 0x29)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x29);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has TypeTyPar table.\r
+ /// </summary>\r
+ public bool HasTypeTyPar {\r
+ get {\r
+ return (Valid & (1L << 0x2a)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x2a);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
+ /// True if heap has MethodTyPar table.\r
+ /// </summary>\r
+ public bool HasMethodTyPar {\r
+ get {\r
+ return (Valid & (1L << 0x2b)) != 0;\r
+ }\r
+ set {\r
+ long mask = (1L << 0x2b);\r
+ if (value) {\r
+ Valid |= mask;\r
+ } else {\r
+ Valid &= ~mask;\r
+ }\r
+ }\r
+ }\r
+\r
+\r
+ }\r
+\r
+}\r
+\r
--- /dev/null
+// Auto-generated file - DO NOT EDIT!\r
+// Please edit md-schema.xml or tabs-decoder.xsl if you want to make changes.\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public sealed class TabsDecoder {\r
+\r
+ private TabsDecoder()\r
+ {\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// </remarks>\r
+ public static MDToken DecodeToken(CodedTokenId id, int data)\r
+ {\r
+ MDToken res = new MDToken();\r
+ int tag;\r
+ int rid;\r
+ TokenType tok;\r
+\r
+ switch (id) {\r
+\r
+ case CodedTokenId.TypeDefOrRef :\r
+ tag = data & 0x03;\r
+ rid = (int) ((uint) data >> 2);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.TypeDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.TypeRef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.TypeSpec;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for TypeDefOrRef, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.HasConstant :\r
+ tag = data & 0x03;\r
+ rid = (int) ((uint) data >> 2);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.FieldDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.ParamDef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.Property;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for HasConstant, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.HasCustomAttribute :\r
+ tag = data & 0x1F;\r
+ rid = (int) ((uint) data >> 5);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.FieldDef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.TypeRef;\r
+ break;\r
+\r
+ case 3 :\r
+ tok = TokenType.TypeDef;\r
+ break;\r
+\r
+ case 4 :\r
+ tok = TokenType.ParamDef;\r
+ break;\r
+\r
+ case 5 :\r
+ tok = TokenType.InterfaceImpl;\r
+ break;\r
+\r
+ case 6 :\r
+ tok = TokenType.MemberRef;\r
+ break;\r
+\r
+ case 7 :\r
+ tok = TokenType.Module;\r
+ break;\r
+\r
+ case 8 :\r
+ tok = TokenType.Permission;\r
+ break;\r
+\r
+ case 9 :\r
+ tok = TokenType.Property;\r
+ break;\r
+\r
+ case 10 :\r
+ tok = TokenType.Event;\r
+ break;\r
+\r
+ case 11 :\r
+ tok = TokenType.Signature;\r
+ break;\r
+\r
+ case 12 :\r
+ tok = TokenType.ModuleRef;\r
+ break;\r
+\r
+ case 13 :\r
+ tok = TokenType.TypeSpec;\r
+ break;\r
+\r
+ case 14 :\r
+ tok = TokenType.Assembly;\r
+ break;\r
+\r
+ case 15 :\r
+ tok = TokenType.AssemblyRef;\r
+ break;\r
+\r
+ case 16 :\r
+ tok = TokenType.File;\r
+ break;\r
+\r
+ case 17 :\r
+ tok = TokenType.ExportedType;\r
+ break;\r
+\r
+ case 18 :\r
+ tok = TokenType.ManifestResource;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for HasCustomAttribute, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.HasFieldMarshal :\r
+ tag = data & 0x01;\r
+ rid = (int) ((uint) data >> 1);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.FieldDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.ParamDef;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for HasFieldMarshal, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.HasDeclSecurity :\r
+ tag = data & 0x03;\r
+ rid = (int) ((uint) data >> 2);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.TypeDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.Assembly;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for HasDeclSecurity, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.MemberRefParent :\r
+ tag = data & 0x07;\r
+ rid = (int) ((uint) data >> 3);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.TypeDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.TypeRef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.ModuleRef;\r
+ break;\r
+\r
+ case 3 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ case 4 :\r
+ tok = TokenType.TypeSpec;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for MemberRefParent, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.HasSemantics :\r
+ tag = data & 0x01;\r
+ rid = (int) ((uint) data >> 1);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.Event;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.Property;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for HasSemantics, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.MethodDefOrRef :\r
+ tag = data & 0x01;\r
+ rid = (int) ((uint) data >> 1);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.MemberRef;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for MethodDefOrRef, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.MemberForwarded :\r
+ tag = data & 0x01;\r
+ rid = (int) ((uint) data >> 1);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.FieldDef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for MemberForwarded, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.Implementation :\r
+ tag = data & 0x03;\r
+ rid = (int) ((uint) data >> 2);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.File;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.AssemblyRef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.ExportedType;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for Implementation, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.CustomAttributeType :\r
+ tag = data & 0x07;\r
+ rid = (int) ((uint) data >> 3);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.TypeRef;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.TypeDef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.MethodDef;\r
+ break;\r
+\r
+ case 3 :\r
+ tok = TokenType.MemberRef;\r
+ break;\r
+\r
+ case 4 :\r
+ tok = TokenType.String;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for CustomAttributeType, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ case CodedTokenId.ResolutionScope :\r
+ tag = data & 0x03;\r
+ rid = (int) ((uint) data >> 2);\r
+ switch (tag) {\r
+\r
+ case 0 :\r
+ tok = TokenType.Module;\r
+ break;\r
+\r
+ case 1 :\r
+ tok = TokenType.ModuleRef;\r
+ break;\r
+\r
+ case 2 :\r
+ tok = TokenType.AssemblyRef;\r
+ break;\r
+\r
+ case 3 :\r
+ tok = TokenType.TypeRef;\r
+ break;\r
+\r
+ default :\r
+ throw new BadMetaDataException("Invalid coded token for ResolutionScope, unknown table tag - " + tag);\r
+ }\r
+ res = new MDToken(tok, rid);\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+ return res;\r
+ }\r
+\r
+\r
+ private static int GetCodedIndexSize(TablesHeap heap, CodedTokenId id, int [] rows)\r
+ {\r
+ int res = 0;\r
+\r
+ switch (id) {\r
+\r
+ case CodedTokenId.TypeDefOrRef :\r
+ res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.TypeRef], rows [(int) TableId.TypeSpec]);\r
+ res = res < (1 << (16 - 2)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.HasConstant :\r
+ res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Param], rows [(int) TableId.Property]);\r
+ res = res < (1 << (16 - 2)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.HasCustomAttribute :\r
+ res = MDUtils.Max(rows [(int) TableId.Method], rows [(int) TableId.Field], rows [(int) TableId.TypeRef], rows [(int) TableId.TypeDef], rows [(int) TableId.Param], rows [(int) TableId.InterfaceImpl], rows [(int) TableId.MemberRef], rows [(int) TableId.Module], rows [(int) TableId.DeclSecurity], rows [(int) TableId.Property], rows [(int) TableId.Event], rows [(int) TableId.StandAloneSig], rows [(int) TableId.ModuleRef], rows [(int) TableId.TypeSpec], rows [(int) TableId.Assembly], rows [(int) TableId.AssemblyRef], rows [(int) TableId.File], rows [(int) TableId.ExportedType], rows [(int) TableId.ManifestResource]);\r
+ res = res < (1 << (16 - 5)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.HasFieldMarshal :\r
+ res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Param]);\r
+ res = res < (1 << (16 - 1)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.HasDeclSecurity :\r
+ res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.Method], rows [(int) TableId.Assembly]);\r
+ res = res < (1 << (16 - 2)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.MemberRefParent :\r
+ res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.TypeRef], rows [(int) TableId.ModuleRef], rows [(int) TableId.Method], rows [(int) TableId.TypeSpec]);\r
+ res = res < (1 << (16 - 3)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.HasSemantics :\r
+ res = MDUtils.Max(rows [(int) TableId.Event], rows [(int) TableId.Property]);\r
+ res = res < (1 << (16 - 1)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.MethodDefOrRef :\r
+ res = MDUtils.Max(rows [(int) TableId.Method], rows [(int) TableId.MemberRef]);\r
+ res = res < (1 << (16 - 1)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.MemberForwarded :\r
+ res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Method]);\r
+ res = res < (1 << (16 - 1)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.Implementation :\r
+ res = MDUtils.Max(rows [(int) TableId.File], rows [(int) TableId.AssemblyRef], rows [(int) TableId.ExportedType]);\r
+ res = res < (1 << (16 - 2)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.CustomAttributeType :\r
+ res = MDUtils.Max(rows [(int) TableId.TypeRef], rows [(int) TableId.TypeDef], rows [(int) TableId.Method], rows [(int) TableId.MemberRef], (heap.StringsIndexSize > 2 ? 1 << 17 : 1));\r
+ res = res < (1 << (16 - 3)) ? 2 : 4;\r
+ break;\r
+\r
+ case CodedTokenId.ResolutionScope :\r
+ res = MDUtils.Max(rows [(int) TableId.Module], rows [(int) TableId.ModuleRef], rows [(int) TableId.AssemblyRef], rows [(int) TableId.TypeRef]);\r
+ res = res < (1 << (16 - 2)) ? 2 : 4;\r
+ break;\r
+\r
+ default:\r
+ break;\r
+ }\r
+\r
+ return res;\r
+ }\r
+\r
+\r
+ private static int GetIndexSize(TableId tab, int [] rows)\r
+ {\r
+ // Index is 2 bytes wide if table has less than 2^16 rows\r
+ // otherwise it's 4 bytes wide.\r
+ return ((uint) rows [(int) tab]) < (1 << 16) ? 2 : 4;\r
+ }\r
+\r
+\r
+ private static void AllocBuff(ref byte [] buff, int size)\r
+ {\r
+ if (buff == null || buff.Length < size) {\r
+ buff = new byte [(size + 4) & ~3];\r
+ }\r
+ Array.Clear(buff, 0, size);\r
+ }\r
+\r
+\r
+ /// <summary>\r
+ /// </summary>\r
+ unsafe public static int DecodePhysicalTables(TablesHeap heap, byte [] data, int offs, int [] rows)\r
+ {\r
+ int rowSize; // expanded row size (all indices are dwords)\r
+ int fldSize; // physical field size\r
+ int dest;\r
+ int nRows;\r
+ byte [] buff = null;\r
+ int si = heap.StringsIndexSize;\r
+ int gi = heap.GUIDIndexSize;\r
+ int bi = heap.BlobIndexSize;\r
+\r
+ if (heap.HasModule) {\r
+ rowSize = sizeof (ushort) + 4 + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.Module];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ModuleTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Generation, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Mvid, index(#GUID)\r
+ fldSize = gi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // EncId, index(#GUID)\r
+ fldSize = gi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // EncBaseId, index(#GUID)\r
+ fldSize = gi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasTypeRef) {\r
+ rowSize = 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.TypeRef];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new TypeRefTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // ResolutionScope, coded-index(ResolutionScope)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.ResolutionScope, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Namespace, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasTypeDef) {\r
+ rowSize = sizeof (uint) + 4 + 4 + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.TypeDef];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new TypeDefTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Namespace, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Extends, coded-index(TypeDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // FieldList, index(Field)\r
+ fldSize = GetIndexSize(TableId.Field, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // MethodList, index(Method)\r
+ fldSize = GetIndexSize(TableId.Method, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasFieldPtr) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.FieldPtr];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FieldPtrTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Field, index(Field)\r
+ fldSize = GetIndexSize(TableId.Field, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasField) {\r
+ rowSize = sizeof (ushort) + 4 + 4;\r
+ nRows = rows [(int) TableId.Field];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FieldTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Signature, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMethodPtr) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.MethodPtr];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MethodPtrTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Method, index(Method)\r
+ fldSize = GetIndexSize(TableId.Method, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMethod) {\r
+ rowSize = RVA.Size + sizeof (ushort) + sizeof (ushort) + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.Method];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MethodTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // RVA, RVA\r
+ fldSize = RVA.Size;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += RVA.Size;\r
+ \r
+ // ImplFlags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Flags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Signature, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // ParamList, index(Param)\r
+ fldSize = GetIndexSize(TableId.Param, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasParamPtr) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.ParamPtr];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ParamPtrTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Param, index(Param)\r
+ fldSize = GetIndexSize(TableId.Param, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasParam) {\r
+ rowSize = sizeof (ushort) + sizeof (ushort) + 4;\r
+ nRows = rows [(int) TableId.Param];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ParamTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Sequence, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasInterfaceImpl) {\r
+ rowSize = 4 + 4;\r
+ nRows = rows [(int) TableId.InterfaceImpl];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new InterfaceImplTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Class, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Interface, coded-index(TypeDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMemberRef) {\r
+ rowSize = 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.MemberRef];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MemberRefTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Class, coded-index(MemberRefParent)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.MemberRefParent, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Signature, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasConstant) {\r
+ rowSize = sizeof (short) + 4 + 4;\r
+ nRows = rows [(int) TableId.Constant];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ConstantTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Type, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // Parent, coded-index(HasConstant)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.HasConstant, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Value, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasCustomAttribute) {\r
+ rowSize = 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.CustomAttribute];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new CustomAttributeTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Parent, coded-index(HasCustomAttribute)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.HasCustomAttribute, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Type, coded-index(CustomAttributeType)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.CustomAttributeType, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Value, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasFieldMarshal) {\r
+ rowSize = 4 + 4;\r
+ nRows = rows [(int) TableId.FieldMarshal];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FieldMarshalTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Parent, coded-index(HasFieldMarshal)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.HasFieldMarshal, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // NativeType, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasDeclSecurity) {\r
+ rowSize = sizeof (short) + 4 + 4;\r
+ nRows = rows [(int) TableId.DeclSecurity];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new DeclSecurityTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Action, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // Parent, coded-index(HasDeclSecurity)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.HasDeclSecurity, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // PermissionSet, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasClassLayout) {\r
+ rowSize = sizeof (short) + sizeof (int) + 4;\r
+ nRows = rows [(int) TableId.ClassLayout];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ClassLayoutTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // PackingSize, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // ClassSize, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // Parent, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasFieldLayout) {\r
+ rowSize = sizeof (int) + 4;\r
+ nRows = rows [(int) TableId.FieldLayout];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FieldLayoutTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Offset, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // Field, index(Field)\r
+ fldSize = GetIndexSize(TableId.Field, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasStandAloneSig) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.StandAloneSig];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new StandAloneSigTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Signature, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasEventMap) {\r
+ rowSize = 4 + 4;\r
+ nRows = rows [(int) TableId.EventMap];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new EventMapTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Parent, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // EventList, index(Event)\r
+ fldSize = GetIndexSize(TableId.Event, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasEventPtr) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.EventPtr];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new EventPtrTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Event, index(Event)\r
+ fldSize = GetIndexSize(TableId.Event, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasEvent) {\r
+ rowSize = sizeof (short) + 4 + 4;\r
+ nRows = rows [(int) TableId.Event];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new EventTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // EventFlags, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // EventType, coded-index(TypeDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasPropertyMap) {\r
+ rowSize = 4 + 4;\r
+ nRows = rows [(int) TableId.PropertyMap];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new PropertyMapTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Parent, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // PropertyList, index(Property)\r
+ fldSize = GetIndexSize(TableId.Property, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasPropertyPtr) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.PropertyPtr];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new PropertyPtrTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Property, index(Property)\r
+ fldSize = GetIndexSize(TableId.Property, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasProperty) {\r
+ rowSize = sizeof (ushort) + 4 + 4;\r
+ nRows = rows [(int) TableId.Property];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new PropertyTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Type, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMethodSemantics) {\r
+ rowSize = sizeof (ushort) + 4 + 4;\r
+ nRows = rows [(int) TableId.MethodSemantics];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MethodSemanticsTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Semantics, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Method, index(Method)\r
+ fldSize = GetIndexSize(TableId.Method, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Association, coded-index(HasSemantics)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.HasSemantics, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMethodImpl) {\r
+ rowSize = 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.MethodImpl];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MethodImplTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Class, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // MethodBody, coded-index(MethodDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.MethodDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // MethodDeclaration, coded-index(MethodDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.MethodDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasModuleRef) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.ModuleRef];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ModuleRefTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasTypeSpec) {\r
+ rowSize = 4;\r
+ nRows = rows [(int) TableId.TypeSpec];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new TypeSpecTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Signature, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasImplMap) {\r
+ rowSize = sizeof (ushort) + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.ImplMap];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ImplMapTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // MappingFlags, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // MemberForwarded, coded-index(MemberForwarded)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.MemberForwarded, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // ImportName, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // ImportScope, index(ModuleRef)\r
+ fldSize = GetIndexSize(TableId.ModuleRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasFieldRVA) {\r
+ rowSize = RVA.Size + 4;\r
+ nRows = rows [(int) TableId.FieldRVA];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FieldRVATable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // RVA, RVA\r
+ fldSize = RVA.Size;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += RVA.Size;\r
+ \r
+ // Field, index(Field)\r
+ fldSize = GetIndexSize(TableId.Field, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasENCLog) {\r
+ rowSize = sizeof (uint) + sizeof (uint);\r
+ nRows = rows [(int) TableId.ENCLog];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ENCLogTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Token, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // FuncCode, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasENCMap) {\r
+ rowSize = sizeof (uint);\r
+ nRows = rows [(int) TableId.ENCMap];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ENCMapTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Token, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssembly) {\r
+ rowSize = sizeof (int) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.Assembly];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // HashAlgId, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // MajorVersion, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // MinorVersion, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // BuildNumber, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // RevisionNumber, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // PublicKey, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Culture, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssemblyProcessor) {\r
+ rowSize = sizeof (int);\r
+ nRows = rows [(int) TableId.AssemblyProcessor];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyProcessorTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Processor, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssemblyOS) {\r
+ rowSize = sizeof (int) + sizeof (int) + sizeof (int);\r
+ nRows = rows [(int) TableId.AssemblyOS];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyOSTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // OSPlatformID, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // OSMajorVersion, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // OSMinorVersion, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssemblyRef) {\r
+ rowSize = sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.AssemblyRef];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyRefTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // MajorVersion, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // MinorVersion, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // BuildNumber, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // RevisionNumber, short\r
+ fldSize = sizeof (short);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (short);\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // PublicKeyOrToken, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Culture, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // HashValue, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssemblyRefProcessor) {\r
+ rowSize = sizeof (int) + 4;\r
+ nRows = rows [(int) TableId.AssemblyRefProcessor];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyRefProcessorTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Processor, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // AssemblyRef, index(AssemblyRef)\r
+ fldSize = GetIndexSize(TableId.AssemblyRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasAssemblyRefOS) {\r
+ rowSize = sizeof (int) + sizeof (int) + sizeof (int) + 4;\r
+ nRows = rows [(int) TableId.AssemblyRefOS];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new AssemblyRefOSTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // OSPlatformID, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // OSMajorVersion, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // OSMinorVersion, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // AssemblyRef, index(AssemblyRef)\r
+ fldSize = GetIndexSize(TableId.AssemblyRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasFile) {\r
+ rowSize = sizeof (uint) + 4 + 4;\r
+ nRows = rows [(int) TableId.File];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new FileTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // HashValue, index(#Blob)\r
+ fldSize = bi;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasExportedType) {\r
+ rowSize = sizeof (uint) + 4 + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.ExportedType];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ExportedTypeTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // TypeDefId, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // TypeName, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // TypeNamespace, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Implementation, coded-index(Implementation)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.Implementation, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasManifestResource) {\r
+ rowSize = sizeof (int) + sizeof (uint) + 4 + 4;\r
+ nRows = rows [(int) TableId.ManifestResource];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new ManifestResourceTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Offset, int\r
+ fldSize = sizeof (int);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (int);\r
+ \r
+ // Flags, uint\r
+ fldSize = sizeof (uint);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (uint);\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Implementation, coded-index(Implementation)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.Implementation, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasNestedClass) {\r
+ rowSize = 4 + 4;\r
+ nRows = rows [(int) TableId.NestedClass];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new NestedClassTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // NestedClass, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // EnclosingClass, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasTypeTyPar) {\r
+ rowSize = sizeof (ushort) + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.TypeTyPar];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new TypeTyParTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Number, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Class, index(TypeDef)\r
+ fldSize = GetIndexSize(TableId.TypeDef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Bound, coded-index(TypeDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ if (heap.HasMethodTyPar) {\r
+ rowSize = sizeof (ushort) + 4 + 4 + 4;\r
+ nRows = rows [(int) TableId.MethodTyPar];\r
+ AllocBuff(ref buff, rowSize * nRows);\r
+ dest = 0;\r
+\r
+ MDTable tab = new MethodTyParTable(heap);\r
+\r
+ for (int i = nRows; --i >= 0;) {\r
+ \r
+ // Number, ushort\r
+ fldSize = sizeof (ushort);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += sizeof (ushort);\r
+ \r
+ // Method, index(Method)\r
+ fldSize = GetIndexSize(TableId.Method, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Bound, coded-index(TypeDefOrRef)\r
+ fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows);\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ // Name, index(#Strings)\r
+ fldSize = si;\r
+ Array.Copy(data, offs, buff, dest, fldSize);\r
+ offs += fldSize;\r
+ dest += 4;\r
+ \r
+ }\r
+\r
+ tab.FromRawData(buff, 0, nRows);\r
+ }\r
+\r
+ return offs;\r
+ }\r
+\r
+ } // end class\r
+} // end namespace\r
+\r
--- /dev/null
+/*\r
+ * Copyright (c) 2002 Sergey Chaban <serge@wildwestsoftware.com>\r
+ */\r
+\r
+using System;\r
+\r
+namespace Mono.PEToolkit.Metadata {\r
+\r
+ /// <summary>\r
+ /// TokenType enum.\r
+ /// See mdt* constants in CorHdr.\r
+ /// </summary>\r
+ /// <remarks>\r
+ /// See Metadata Unmanaged API, 9.1 Token Types\r
+ /// </remarks>\r
+ public enum TokenType : int {\r
+ __shift = 24,\r
+ __mask = 0xFF << __shift,\r
+\r
+ Module = 0x00 << __shift,\r
+ TypeRef = 0x01 << __shift,\r
+ TypeDef = 0x02 << __shift,\r
+ FieldDef = 0x04 << __shift,\r
+ MethodDef = 0x06 << __shift,\r
+ ParamDef = 0x08 << __shift,\r
+ InterfaceImpl = 0x09 << __shift,\r
+ MemberRef = 0x0a << __shift,\r
+ CustomAttribute = 0x0c << __shift,\r
+ Permission = 0x0e << __shift,\r
+ Signature = 0x11 << __shift,\r
+ Event = 0x14 << __shift,\r
+ Property = 0x17 << __shift,\r
+ ModuleRef = 0x1a << __shift,\r
+ TypeSpec = 0x1b << __shift,\r
+ Assembly = 0x20 << __shift,\r
+ AssemblyRef = 0x23 << __shift,\r
+ File = 0x26 << __shift,\r
+ ExportedType = 0x27 << __shift,\r
+ ManifestResource = 0x28 << __shift,\r
+\r
+ String = 0x70 << __shift,\r
+ Name = 0x71 << __shift,\r
+ BaseType = 0x72 << __shift,\r
+ }\r
+\r
+}\r