From 3bff76f0df53e29def802e04a34289dc8cba4549 Mon Sep 17 00:00:00 2001 From: Miguel de Icaza Date: Sat, 2 May 2009 05:30:59 +0000 Subject: [PATCH] Move dead code svn path=/trunk/mcs/; revision=133369 --- mcs/class/Mono.PEToolkit/BadImageException.cs | 41 - mcs/class/Mono.PEToolkit/COFFHeader.cs | 127 - mcs/class/Mono.PEToolkit/ChangeLog | 49 - mcs/class/Mono.PEToolkit/Characteristics.cs | 186 - mcs/class/Mono.PEToolkit/CheckSum.cs | 117 - mcs/class/Mono.PEToolkit/CorHeader.cs | 409 -- mcs/class/Mono.PEToolkit/DEPRECATED | 1 - mcs/class/Mono.PEToolkit/DOSHeader.cs | 117 - mcs/class/Mono.PEToolkit/DataDir.cs | 132 - mcs/class/Mono.PEToolkit/ExeSignature.cs | 79 - mcs/class/Mono.PEToolkit/Image.cs | 297 - mcs/class/Mono.PEToolkit/LEBitConverter.cs | 272 - mcs/class/Mono.PEToolkit/MachineId.cs | 278 - mcs/class/Mono.PEToolkit/Makefile | 15 - .../Mono.PEToolkit/Mono.PEToolkit.dll.sources | 41 - mcs/class/Mono.PEToolkit/PEHeader.cs | 698 --- mcs/class/Mono.PEToolkit/PEUtils.cs | 192 - mcs/class/Mono.PEToolkit/README | 1 - mcs/class/Mono.PEToolkit/RVA.cs | 143 - mcs/class/Mono.PEToolkit/Section.cs | 234 - .../Mono.PEToolkit/SectionCharacteristics.cs | 213 - mcs/class/Mono.PEToolkit/Subsystem.cs | 132 - mcs/class/Mono.PEToolkit/build/ChangeLog | 3 - mcs/class/Mono.PEToolkit/build/Makefile | 23 - mcs/class/Mono.PEToolkit/build/mddump.cs | 64 - .../Mono.PEToolkit/build/mddump.exe.sources | 42 - mcs/class/Mono.PEToolkit/build/srcgen/a.bat | 14 - .../build/srcgen/bitconv-types.xml | 10 - .../build/srcgen/bitconverter.xsl | 149 - .../Mono.PEToolkit/build/srcgen/coded-id.xsl | 34 - .../build/srcgen/data/ilasm.xml | 549 -- .../build/srcgen/data/md-schema.xml | 589 -- .../Mono.PEToolkit/build/srcgen/elem-type.xsl | 36 - .../Mono.PEToolkit/build/srcgen/gen-utils.xsl | 72 - .../Mono.PEToolkit/build/srcgen/rows.xsl | 225 - .../Mono.PEToolkit/build/srcgen/table-id.xsl | 41 - .../Mono.PEToolkit/build/srcgen/tabs-base.xsl | 69 - .../build/srcgen/tabs-decoder.xsl | 255 - .../Mono.PEToolkit/build/srcgen/tabs.xsl | 53 - .../Mono.PEToolkit/build/srcgen/xslt.wsf | 231 - .../Mono.PEToolkit/metadata/AssemblyFlags.cs | 56 - .../metadata/BadMetaDataException.cs | 20 - mcs/class/Mono.PEToolkit/metadata/ChangeLog | 20 - .../Mono.PEToolkit/metadata/CodedTokenId.cs | 31 - .../Mono.PEToolkit/metadata/ElementType.cs | 53 - mcs/class/Mono.PEToolkit/metadata/GUIDHeap.cs | 40 - mcs/class/Mono.PEToolkit/metadata/MDHeap.cs | 60 - mcs/class/Mono.PEToolkit/metadata/MDStream.cs | 219 - mcs/class/Mono.PEToolkit/metadata/MDTable.cs | 105 - mcs/class/Mono.PEToolkit/metadata/MDToken.cs | 158 - mcs/class/Mono.PEToolkit/metadata/MDUtils.cs | 89 - .../metadata/ManifestResourceAttributes.cs | 29 - .../Mono.PEToolkit/metadata/MetaDataRoot.cs | 237 - mcs/class/Mono.PEToolkit/metadata/MethodIL.cs | 149 - .../metadata/MethodSemanticsAttributes.cs | 26 - .../metadata/PInvokeAttributes.cs | 54 - mcs/class/Mono.PEToolkit/metadata/Row.cs | 74 - mcs/class/Mono.PEToolkit/metadata/Rows.cs | 4887 ----------------- .../Mono.PEToolkit/metadata/StringsHeap.cs | 105 - mcs/class/Mono.PEToolkit/metadata/TableId.cs | 66 - mcs/class/Mono.PEToolkit/metadata/Tables.cs | 1375 ----- .../Mono.PEToolkit/metadata/TablesHeap.cs | 217 - .../Mono.PEToolkit/metadata/TablesHeapBase.cs | 787 --- .../Mono.PEToolkit/metadata/TabsDecoder.cs | 1933 ------- .../Mono.PEToolkit/metadata/TokenType.cs | 46 - 65 files changed, 17069 deletions(-) delete mode 100644 mcs/class/Mono.PEToolkit/BadImageException.cs delete mode 100644 mcs/class/Mono.PEToolkit/COFFHeader.cs delete mode 100644 mcs/class/Mono.PEToolkit/ChangeLog delete mode 100644 mcs/class/Mono.PEToolkit/Characteristics.cs delete mode 100644 mcs/class/Mono.PEToolkit/CheckSum.cs delete mode 100644 mcs/class/Mono.PEToolkit/CorHeader.cs delete mode 100644 mcs/class/Mono.PEToolkit/DEPRECATED delete mode 100644 mcs/class/Mono.PEToolkit/DOSHeader.cs delete mode 100644 mcs/class/Mono.PEToolkit/DataDir.cs delete mode 100644 mcs/class/Mono.PEToolkit/ExeSignature.cs delete mode 100644 mcs/class/Mono.PEToolkit/Image.cs delete mode 100644 mcs/class/Mono.PEToolkit/LEBitConverter.cs delete mode 100644 mcs/class/Mono.PEToolkit/MachineId.cs delete mode 100644 mcs/class/Mono.PEToolkit/Makefile delete mode 100644 mcs/class/Mono.PEToolkit/Mono.PEToolkit.dll.sources delete mode 100644 mcs/class/Mono.PEToolkit/PEHeader.cs delete mode 100644 mcs/class/Mono.PEToolkit/PEUtils.cs delete mode 100644 mcs/class/Mono.PEToolkit/README delete mode 100644 mcs/class/Mono.PEToolkit/RVA.cs delete mode 100644 mcs/class/Mono.PEToolkit/Section.cs delete mode 100644 mcs/class/Mono.PEToolkit/SectionCharacteristics.cs delete mode 100644 mcs/class/Mono.PEToolkit/Subsystem.cs delete mode 100644 mcs/class/Mono.PEToolkit/build/ChangeLog delete mode 100644 mcs/class/Mono.PEToolkit/build/Makefile delete mode 100644 mcs/class/Mono.PEToolkit/build/mddump.cs delete mode 100644 mcs/class/Mono.PEToolkit/build/mddump.exe.sources delete mode 100755 mcs/class/Mono.PEToolkit/build/srcgen/a.bat delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/bitconv-types.xml delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/bitconverter.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/coded-id.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/data/ilasm.xml delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/data/md-schema.xml delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/elem-type.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/gen-utils.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/rows.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/table-id.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/tabs-base.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/tabs-decoder.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/tabs.xsl delete mode 100644 mcs/class/Mono.PEToolkit/build/srcgen/xslt.wsf delete mode 100644 mcs/class/Mono.PEToolkit/metadata/AssemblyFlags.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/BadMetaDataException.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/ChangeLog delete mode 100644 mcs/class/Mono.PEToolkit/metadata/CodedTokenId.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/ElementType.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/GUIDHeap.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MDHeap.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MDStream.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MDTable.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MDToken.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MDUtils.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/ManifestResourceAttributes.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MetaDataRoot.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MethodIL.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/MethodSemanticsAttributes.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/PInvokeAttributes.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/Row.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/Rows.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/StringsHeap.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/TableId.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/Tables.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/TablesHeap.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/TablesHeapBase.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/TabsDecoder.cs delete mode 100644 mcs/class/Mono.PEToolkit/metadata/TokenType.cs diff --git a/mcs/class/Mono.PEToolkit/BadImageException.cs b/mcs/class/Mono.PEToolkit/BadImageException.cs deleted file mode 100644 index 48a85d5b24681..0000000000000 --- a/mcs/class/Mono.PEToolkit/BadImageException.cs +++ /dev/null @@ -1,41 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit { - - public class BadImageException : Exception { - - public BadImageException() : base() - { - } - - public BadImageException(string msg) : base(msg) - { - } - } - -} diff --git a/mcs/class/Mono.PEToolkit/COFFHeader.cs b/mcs/class/Mono.PEToolkit/COFFHeader.cs deleted file mode 100644 index 8f8ef9223020e..0000000000000 --- a/mcs/class/Mono.PEToolkit/COFFHeader.cs +++ /dev/null @@ -1,127 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - public class COFFHeader { - - private MachineId machine; - private short sections; - private uint tdStampRaw; - private uint symTabPtr; - private uint numSymbols; - private short optHeaderSize; - private Characteristics characteristics; - - public MachineId Machine { - get { return machine; } - set { machine = value; } - } - - public short NumberOfSections { - get { return sections; } - set { sections = value; } - } - - public uint TimeDateStamp { - get { return tdStampRaw; } - set { tdStampRaw = value; } - } - - public DateTime TimeStamp { - get { - return (new DateTime(1970, 1, 1) + - TimeSpan.FromSeconds(tdStampRaw)).ToLocalTime(); - } - } - - public uint PointerToSymbolTable { - get { return symTabPtr; } - set { symTabPtr = value; } - } - - public uint NumberOfSymbols { - get { return numSymbols; } - set { numSymbols = value; } - } - - public short SizeOfOptionalHeader { - get { return optHeaderSize; } - set { optHeaderSize = value; } - } - - public Characteristics Characteristics { - get { return characteristics; } - set { characteristics = value; } - } - - public void Read (BinaryReader reader) - { - machine = (MachineId) reader.ReadUInt16 (); - sections = reader.ReadInt16 (); - tdStampRaw = reader.ReadUInt32 (); - symTabPtr = reader.ReadUInt32 (); - numSymbols = reader.ReadUInt32 (); - optHeaderSize = reader.ReadInt16 (); - characteristics = (Characteristics) reader.ReadUInt16 (); - } - - public void Write (BinaryWriter writer) - { - writer.Write ((ushort)machine); - writer.Write (sections); - writer.Write (tdStampRaw); - writer.Write (symTabPtr); - writer.Write (numSymbols); - writer.Write (optHeaderSize); - writer.Write ((ushort)characteristics); - } - - public void Dump(TextWriter writer) - { - writer.WriteLine( - "Machine ID : {0}" + Environment.NewLine + - "Sections : {1}" + Environment.NewLine + - "Characteristics : {2}" + Environment.NewLine + - "timestamp : {3} ({4})" + Environment.NewLine - ,machine, sections, (ushort)characteristics, - TimeStamp, tdStampRaw.ToString("X") - ); - } - - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } -} - diff --git a/mcs/class/Mono.PEToolkit/ChangeLog b/mcs/class/Mono.PEToolkit/ChangeLog deleted file mode 100644 index d715e06345644..0000000000000 --- a/mcs/class/Mono.PEToolkit/ChangeLog +++ /dev/null @@ -1,49 +0,0 @@ -2003-03-01 Jackson Harper - - * Image.cs: Write Metadata root - -2003-02-23 Peter Williams - - * makefile.gnu (all): Give this dependencies - so that we don't rebuild every time. - (all): Take two. - -2003-02-22 Jackson Harper - - * Image.cs: Write CorHeader - -2003-02-22 Jackson Harper - - * Image.cs: Write Sections - -2003-02-22 Jackson Harper - - * Section.cs: Add method for writing Sections - -2003-02-21 Jackson Harper - - * Section.cs: Add Method to write Headers - -2003-02-21 Jackson Harper - - * Section.cs: Make Read method safe - -2003-02-21 Jackson Harper - - * Section.cs: Convert Header to a class and lowers it accesability. - -2003-02-17 Jackson Harper - - * COFFHeader.cs: Convert to class, use Read and Write methods. Compress some code - * CheckSum.cs: Access Lfanew through property not field. - * CorHeader.cs: Convert to class, use Read and Write methods. - * DOSHeader.cs: Convert to class, use Read and Write methods, and Init method for creating - new DOSHeaders - * DataDir.cs: Convert to class, use Read and Write methods. - * Image.cs: Access lfanew through property, add Write method. - * PEHeader.cs: Convert to class, use Read and Write methods. - * PEUtils.cs: Add GetString method for converting byte pointers to strings. - * RVA.cs: Add Write method - * Section.cs: Use PEUtils.GetString method instead of new string (byte*) - * makefuile.gnu: Compile all the files I want compiled ;-) - diff --git a/mcs/class/Mono.PEToolkit/Characteristics.cs b/mcs/class/Mono.PEToolkit/Characteristics.cs deleted file mode 100644 index b2865724b8d07..0000000000000 --- a/mcs/class/Mono.PEToolkit/Characteristics.cs +++ /dev/null @@ -1,186 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit { - - [Flags] - public enum Characteristics : ushort { - - - /// - /// Relocation info stripped from file. - /// - /// - /// IMAGE_FILE_RELOCS_STRIPPED - /// - RELOCS_STRIPPED = 0x0001, - - - - /// - /// File is executable - /// (i.e. file is neither object file nor library file, - /// so there are no unresolved externel references). - /// - /// - /// IMAGE_FILE_EXECUTABLE_IMAGE - /// - EXECUTABLE_IMAGE = 0x0002, - - - /// - /// Line nunbers stripped from file. - /// - /// - /// IMAGE_FILE_LINE_NUMS_STRIPPED - /// - LINE_NUMS_STRIPPED = 0x0004, - - - /// - /// Local symbols stripped from file. - /// - /// - /// IMAGE_FILE_LOCAL_SYMS_STRIPPED - /// - LOCAL_SYMS_STRIPPED = 0x0008, - - - /// - /// Agressively trim working set - /// - /// - /// IMAGE_FILE_AGGRESIVE_WS_TRIM - /// - AGGRESIVE_WS_TRIM = 0x0010, - - - /// - /// App can handle >2gb addresses - /// - /// - /// IMAGE_FILE_LARGE_ADDRESS_AWARE - /// - LARGE_ADDRESS_AWARE = 0x0020, - - - /// - /// Bytes of machine word are reversed. - /// - /// - /// IMAGE_FILE_BYTES_REVERSED_LO - /// - BYTES_REVERSED_LO = 0x0080, - - - /// - /// 32 bit word machine. - /// - /// - /// IMAGE_FILE_32BIT_MACHINE - /// - MACHINE_32BIT = 0x0100, - - - /// - /// Debugging info stripped from file in .DBG file - /// - /// - /// IMAGE_FILE_DEBUG_STRIPPED - /// - DEBUG_STRIPPED = 0x0200, - - - /// - /// If Image is on removable media, copy and run from the swap file. - /// - /// - /// IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP - /// - REMOVABLE_RUN_FROM_SWAP = 0x0400, - - - /// - /// If Image is on Net, copy and run from the swap file. - /// - /// - /// IMAGE_FILE_NET_RUN_FROM_SWAP - /// - NET_RUN_FROM_SWAP = 0x0800, - - - /// - /// This flag is used to indicate that the file - /// is a system sile, such as device driver. - /// - /// - /// IMAGE_FILE_SYSTEM - /// - SYSTEM = 0x1000, - - - /// - /// This flag indicates that the file - /// is a dynamic library (DLL). - /// - /// - /// IMAGE_FILE_DLL - /// - DLL = 0x2000, - - - /// - /// File should only be run on a uni-processor (UP) machine. - /// - /// - /// IMAGE_FILE_UP_SYSTEM_ONLY - /// - UP_SYSTEM_ONLY = 0x4000, - - - /// - /// Bytes of machine word are reversed. - /// - /// - /// IMAGE_FILE_BYTES_REVERSED_HI - /// - BYTES_REVERSED_HI = 0x8000, - - - - /// - /// Default flags that must be set in CIL-only image. - /// - /// - /// See Partition II, 24.2.2.1 - /// - CIL_DEFAULT = LINE_NUMS_STRIPPED | - LOCAL_SYMS_STRIPPED | - DEBUG_STRIPPED - } - -} diff --git a/mcs/class/Mono.PEToolkit/CheckSum.cs b/mcs/class/Mono.PEToolkit/CheckSum.cs deleted file mode 100644 index b842eaa63f170..0000000000000 --- a/mcs/class/Mono.PEToolkit/CheckSum.cs +++ /dev/null @@ -1,117 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -// see http://cvs.winehq.com/cvsweb/wine/dlls/imagehlp/modify.c -// starting from Revision 1.8 - -using System; -using System.IO; - -namespace Mono.PEToolkit { - - public sealed class CheckSum { - - private CheckSum() - { - // Never instantiated. - } - - - public static uint Calc(string peFile) - { - uint res = 0; - - FileInfo pe = new FileInfo(peFile); - if (!pe.Exists) { - throw new Exception("CheckSum : Invalid file path."); - } - - using (BinaryReader reader = new BinaryReader(pe.OpenRead())) { - if (!reader.BaseStream.CanSeek) { - throw new Exception("Can't seek."); - } - - DOSHeader dosHdr = new DOSHeader(); - COFFHeader coffHdr = new COFFHeader(); - PEHeader peHdr = new PEHeader(); - - dosHdr.Read (reader); - reader.BaseStream.Position = dosHdr.Lfanew; - ExeSignature peSig = (ExeSignature) reader.ReadUInt16(); - if (peSig != ExeSignature.NT) { - throw new BadImageException("Checksum : Invalid image format, cannot find PE signature."); - } - - peSig = (ExeSignature) reader.ReadUInt16(); - if (peSig != ExeSignature.NT2) { - throw new BadImageException("Checksum : Invalid image format, cannot find PE signature."); - } - - coffHdr.Read(reader); - peHdr.Read(reader); - - uint oldSum = peHdr.CheckSum; - reader.BaseStream.Position = 0; - long len = pe.Length; - long whole = len >> 1; - uint sum = 0; - uint hi, lo; - for (long i = whole; --i >= 0;) { - sum += reader.ReadUInt16(); - hi = sum >> 16; - if (hi != 0) { - sum = hi + (sum & 0xFFFF); - } - } - if ((len & 1L) != 0) { - sum += (uint) reader.ReadByte(); - hi = sum >> 16; - if (hi != 0) { - sum = hi + (sum & 0xFFFF); - } - } - - // fix low word of checksum - lo = oldSum & 0xFFFF; - if ((sum & 0xFFFF) >= lo) { - sum -= lo; - } else { - sum = (((sum & 0xFFFF) - lo) & 0xFFFF) - 1; - } - - // fix high word of checksum - hi = oldSum >> 16; - if ((sum & 0xFFFF) >= hi) { - sum -= hi; - } else { - sum = (((sum & 0xFFFF) - hi) & 0xFFFF) - 1; - } - } - - return res; - } - } - -} diff --git a/mcs/class/Mono.PEToolkit/CorHeader.cs b/mcs/class/Mono.PEToolkit/CorHeader.cs deleted file mode 100644 index 2f76368b6f28a..0000000000000 --- a/mcs/class/Mono.PEToolkit/CorHeader.cs +++ /dev/null @@ -1,409 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -using Mono.PEToolkit.Metadata; - -namespace Mono.PEToolkit { - - [Flags] - public enum CorFlags : uint { - /// - /// COMIMAGE_FLAGS_ILONLY - /// - ILONLY = 0x00000001, - - /// - /// COMIMAGE_FLAGS_32BITREQUIRED - /// - REQUIRED_32BIT = 0x00000002, - - /// - /// COMIMAGE_FLAGS_IL_LIBRARY - /// - IL_LIBRARY = 0x00000004, - - /// - /// COMIMAGE_FLAGS_TRACKDEBUGDATA - /// - TRACKDEBUGDATA = 0x00010000, - } - - - /// - /// CLR 2.0 header structure. - /// IMAGE_COR20_HEADER - /// - public class CorHeader { - // Header versioning - internal uint cb; - internal short runtimeMaj; - internal short runtimeMin; - - // Symbol table and startup information. - internal DataDir meta; - internal CorFlags flags; - internal uint entryTok; - - // Binding information. - internal DataDir rsrc; - internal DataDir strongSig; - - // Regular fixup and binding information. - internal DataDir codeManTab; - internal DataDir vtab; - internal DataDir jumps; - - // Managed Native Code. - internal DataDir eeInfo; - internal DataDir helper; - internal DataDir dynInfo; - internal DataDir delayInfo; - internal DataDir modImg; - internal DataDir extFixups; - internal DataDir ridMap; - internal DataDir dbgMap; - - // obsolete? - internal DataDir ipMap; - - - // - // Accessors - // - - public uint Size { - get { - return cb; - } - set { - cb = value; - } - } - - public short MajorRuntimeVersion { - get { - return runtimeMaj; - } - set { - runtimeMaj = value; - } - } - - public short MinorRuntimeVersion { - get { - return runtimeMin; - } - set { - runtimeMin = value; - } - } - - public string RuntimeVersion { - get { - return String.Format("{0}.{1}", runtimeMaj, runtimeMin); - } - } - - public DataDir MetaData { - get { - return meta; - } - set { - meta = value; - } - } - - public CorFlags Flags { - get { - return flags; - } - set { - flags = value; - } - } - - public MDToken EntryPointToken { - get { - return entryTok; - } - set { - entryTok = value; - } - } - - public DataDir Resources { - get { - return rsrc; - } - set { - rsrc = value; - } - } - - public DataDir StrongNameSignature { - get { - return strongSig; - } - set { - strongSig = value; - } - } - - public DataDir CodeManagerTable { - get { - return codeManTab; - } - set { - codeManTab = value; - } - } - - public DataDir VTableFixups { - get { - return vtab; - } - set { - vtab = value; - } - } - - public DataDir ExportAddressTableJumps { - get { - return jumps; - } - set { - jumps = value; - } - } - - - public DataDir EEInfoTable { - get { - return eeInfo; - } - set { - eeInfo = value; - } - } - - public DataDir HelperTable { - get { - return helper; - } - set { - helper = value; - } - } - - public DataDir DynamicInfo { - get { - return dynInfo; - } - set { - dynInfo = value; - } - } - - public DataDir DelayLoadInfo { - get { - return delayInfo; - } - set { - delayInfo = value; - } - } - - public DataDir ModuleImage { - get { - return modImg; - } - set { - modImg = value; - } - } - - public DataDir ExternalFixups { - get { - return extFixups; - } - set { - extFixups = value; - } - } - - public DataDir RidMap { - get { - return ridMap; - } - set { - ridMap = value; - } - } - - public DataDir DebugMap { - get { - return dbgMap; - } - set { - dbgMap = value; - } - } - - - public DataDir IPMap { - get { - return ipMap; - } - set { - ipMap = value; - } - } - - - public void Read(BinaryReader reader) - { - // Header versioning - cb = reader.ReadUInt32 (); - - runtimeMaj = reader.ReadInt16 (); - runtimeMin = reader.ReadInt16 (); - - - // Symbol table and startup information. - meta = new DataDir (reader); - flags = (CorFlags) reader.ReadUInt32 (); - entryTok = reader.ReadUInt32 (); - - // Binding information. - rsrc = new DataDir (reader); - strongSig = new DataDir (reader); - - // Regular fixup and binding information. - codeManTab = new DataDir (reader); - vtab = new DataDir (reader); - jumps = new DataDir (reader); - - // Managed Native Code. - eeInfo = new DataDir (reader); - helper = new DataDir (reader); - dynInfo = new DataDir (reader); - delayInfo = new DataDir (reader); - modImg = new DataDir (reader); - extFixups = new DataDir (reader); - ridMap = new DataDir (reader); - dbgMap = new DataDir (reader); - - // obsolete? - ipMap = new DataDir (reader); - } - - public void Write (BinaryWriter writer) - { - // Header versioning - writer.Write (cb); - - writer.Write (runtimeMaj); - writer.Write (runtimeMin); - - // Symbol table and startup information. - meta.Write (writer); - writer.Write ((uint)flags); - writer.Write (entryTok); - - // Binding information. - rsrc.Write (writer); - strongSig.Write (writer); - - // Regular fixup and binding information. - codeManTab.Write (writer); - vtab.Write (writer); - jumps.Write (writer); - - // Managed Native Code. - eeInfo.Write (writer); - helper.Write (writer); - dynInfo.Write (writer); - delayInfo.Write (writer); - modImg.Write (writer); - extFixups.Write (writer); - ridMap.Write (writer); - dbgMap.Write (writer); - - // obsolete? - ipMap.Write (writer); - } - - - public void Dump(TextWriter writer) - { - writer.WriteLine(String.Format ( - "Header Size : {0}" + Environment.NewLine + - "Runtime Version : {1}" + Environment.NewLine + - "MetaData Root : {2}" + Environment.NewLine + - "Flags : {3}" + Environment.NewLine + - "Entry Point Token : {4}" + Environment.NewLine + - "Resources : {5}" + Environment.NewLine + - "Strong Name Signature : {6}" + Environment.NewLine + - "Code Manager Table : {7}" + Environment.NewLine + - "VTable Fixups : {8}" + Environment.NewLine + - "Export Address Table Jumps : {9}" + Environment.NewLine + - "EE Info Table : {10}" + Environment.NewLine + - "Helper Table : {11}" + Environment.NewLine + - "Dynamic Info : {12}" + Environment.NewLine + - "Delay Load Info : {13}" + Environment.NewLine + - "Module Image : {14}" + Environment.NewLine + - "External Fixups : {15}" + Environment.NewLine + - "Rid Map : {16}" + Environment.NewLine + - "Debug Map : {17}" + Environment.NewLine + - "IP Map : {18}" + Environment.NewLine + - "Runtime Major : {19}" + Environment.NewLine + - "Runtime Minor : {20}" + Environment.NewLine, - cb, - RuntimeVersion, - meta, null, EntryPointToken, - rsrc, strongSig, - codeManTab, vtab, jumps, - eeInfo, helper, dynInfo, delayInfo, modImg, extFixups, - ridMap, dbgMap, ipMap, MajorRuntimeVersion, MinorRuntimeVersion - )); - - } - - /// - /// - /// - public override string ToString() { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - - } -} diff --git a/mcs/class/Mono.PEToolkit/DEPRECATED b/mcs/class/Mono.PEToolkit/DEPRECATED deleted file mode 100644 index 469f7999817e5..0000000000000 --- a/mcs/class/Mono.PEToolkit/DEPRECATED +++ /dev/null @@ -1 +0,0 @@ -This module has not been maintained diff --git a/mcs/class/Mono.PEToolkit/DOSHeader.cs b/mcs/class/Mono.PEToolkit/DOSHeader.cs deleted file mode 100644 index 6c57bdab6729d..0000000000000 --- a/mcs/class/Mono.PEToolkit/DOSHeader.cs +++ /dev/null @@ -1,117 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - public class DOSHeader { - - private readonly int OpenSize = 60; - private readonly int CloseSize = 64; - - private byte[] open_data; // First 60 bytes of data - private byte[] close_data; // Last 64 bytes of data - - // File address of new exe header. - private uint lfanew; - - public DOSHeader () - { - Init (); - } - - public DOSHeader (BinaryReader reader) - { - Read (reader); - } - - public uint Lfanew { - get { return lfanew; } - } - - public void Read (BinaryReader reader) - { - open_data = reader.ReadBytes (OpenSize); - lfanew = reader.ReadUInt32 (); - close_data = reader.ReadBytes (CloseSize); - } - - public void Write (BinaryWriter writer) - { - writer.Write (open_data); - writer.Write (lfanew); - writer.Write (close_data); - } - - public void Init () - { - open_data = new byte[] { 0x4D, 0x5A, 0x0, 0x0, 0xE7, 0x0, 0x0, 0x0, - 0x4, 0x0, 0x0, 0x0, 0xFF, 0xFF, 0x0, 0x0, - 0xB8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, - 0x0, 0x0, 0x0, 0x0 }; - - close_data = new byte[] { 0xE, 0x1F, 0xBA, 0xE, 0x0, 0xB4, 0x9, 0xCD, - 0x21, 0xB8, 0x1, 0x4C, 0xCD, 0x21,0x54, 0x68, - 0x69, 0x73, 0x20, 0x70, 0x72, 0x6F, 0x67, 0x72, - 0x61, 0x6D, 0x20, 0x63, 0x61, 0x6E, 0x6E, 0x6F, - 0x74, 0x20, 0x62, 0x65, 0x20, 0x72, 0x75, 0x6E, - 0x20, 0x69, 0x6E, 0x20, 0x44, 0x4F, 0x53, 0x20, - 0x6D, 0x6F, 0x64, 0x65, 0x2E, 0xD, 0xD, 0xA, - 0x24, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0 }; - - } - - /// - /// - /// - public void Dump(TextWriter writer) - { - writer.WriteLine( - "New header offset : {0}", - lfanew + " (0x" + lfanew.ToString("X") + ")" - ); - } - - /// - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/DataDir.cs b/mcs/class/Mono.PEToolkit/DataDir.cs deleted file mode 100644 index 7c0b8b6922e5d..0000000000000 --- a/mcs/class/Mono.PEToolkit/DataDir.cs +++ /dev/null @@ -1,132 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - /// - /// IMAGE_DATA_DIRECTORY. - /// - public class DataDir { - - public static readonly DataDir Null; - - public RVA virtAddr; - public uint size; - - static DataDir () - { - Null = new DataDir (); - Null.virtAddr = 0; - Null.size = 0; - } - - public DataDir () { - - } - - public DataDir (BinaryReader reader) - { - Read (reader); - } - - public void Read (BinaryReader reader) - { - virtAddr = new RVA (reader.ReadUInt32 ()); - size = reader.ReadUInt32 (); - } - - public void Write (BinaryWriter writer) - { - virtAddr.Write (writer); - writer.Write (size); - } - - public RVA VirtualAddress { - get { - return virtAddr; - } - set { - virtAddr = value; - } - } - - public uint Size { - get { - return size; - } - set { - size = value; - } - } - - public bool IsNull { - get { - return (this == Null); - } - } - - public override int GetHashCode() - { - return (virtAddr.GetHashCode() ^ (int)(size << 1)); - } - - public override bool Equals(object obj) - { - bool res = (obj is DataDir); - if (res) { - DataDir that = (DataDir) obj; - res = (this.virtAddr == that.virtAddr) && - (this.size == that.size); - } - return res; - } - - public static bool operator == (DataDir d1, DataDir d2) - { - return d1.Equals(d2); - } - - public static bool operator != (DataDir d1, DataDir d2) - { - return !d1.Equals(d2); - } - - /// - /// - /// - public override string ToString() - { - if (this.IsNull) return "NULL"; - return String.Format("RVA = {0}, size = 0x{1}", virtAddr, size.ToString("X")); - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/ExeSignature.cs b/mcs/class/Mono.PEToolkit/ExeSignature.cs deleted file mode 100644 index 8b9401920e55f..0000000000000 --- a/mcs/class/Mono.PEToolkit/ExeSignature.cs +++ /dev/null @@ -1,79 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -namespace Mono.PEToolkit { - - public enum ExeSignature : ushort { - - UNKNOWN = 0, - - /// - /// "MZ" - /// - /// - /// IMAGE_DOS_SIGNATURE - /// - DOS = 0x5A4D, - - - /// - /// "NE" - /// - /// - /// IMAGE_OS2_SIGNATURE - /// - OS2 = 0x454E, - - - /// - /// "LE" - /// - /// - /// IMAGE_OS2_SIGNATURE_LE - /// - OS2_LE = 0x454C, - - - /// - /// "LE" - /// - /// - /// IMAGE_VXD_SIGNATURE - /// - VXD = OS2_LE, - - - /// - /// "PE", the complete signature is "PE\0\0" - /// (that is, NT followed by NT2). - /// - /// - /// IMAGE_NT_SIGNATURE - /// - NT = 0x4550, - NT2 = 0 - } - -} diff --git a/mcs/class/Mono.PEToolkit/Image.cs b/mcs/class/Mono.PEToolkit/Image.cs deleted file mode 100644 index f909b2b6b7bf4..0000000000000 --- a/mcs/class/Mono.PEToolkit/Image.cs +++ /dev/null @@ -1,297 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Collections; -using System.Runtime.InteropServices; - -using Mono.PEToolkit.Metadata; - -namespace Mono.PEToolkit { - - public class Image : IDisposable { - - internal DOSHeader dosHdr; - internal COFFHeader coffHdr; - internal PEHeader peHdr; - - internal CorHeader corHdr; - - internal Hashtable sections; - // File position right after PEHeader (NT Optional Header). - protected long sectionsPos; - - private MetaDataRoot mdRoot; - - private string name; - private bool open; - internal BinaryReader reader; - - public Image(string name) - { - this.name = name; - open = false; - reader = null; - - mdRoot = null; - - dosHdr = new DOSHeader(); - coffHdr = new COFFHeader(); - peHdr = new PEHeader(); - corHdr = new CorHeader(); - - sections = new Hashtable(); - sectionsPos = -1; - } - - ~Image() - { - Close(); - } - - - public Hashtable Sections { - get { - return sections; - } - } - - public void Open() - { - lock (this) if (!open) { - FileInfo pe = new FileInfo(name); - if (!pe.Exists) { - throw new Exception("Invalid file path."); - } - - reader = new BinaryReader(new BufferedStream(pe.OpenRead())); - if (!reader.BaseStream.CanSeek) { - throw new Exception("Can't seek."); - } - - open = true; - } - } - - public void Close() - { - lock (this) if (open) { - reader.Close(); - open = false; - } - } - - // IDisposable - public void Dispose() - { - Close(); - } - - - public bool IsCLI { - get { - return peHdr.IsCLIImage; - } - } - - public MetaDataRoot MetadataRoot { - get { - return mdRoot; - } - } - - /// - /// - public void ReadHeaders() - { - if (!open) { - throw new Exception("You must open image before trying to read it."); - } - - dosHdr.Read(reader); - reader.BaseStream.Position = dosHdr.Lfanew; - ExeSignature peSig = (ExeSignature) reader.ReadUInt16(); - if (peSig != ExeSignature.NT) { - throw new Exception ("Invalid image format: cannot find PE signature."); - } - peSig = (ExeSignature) reader.ReadUInt16(); - if (peSig != ExeSignature.NT2) { - throw new Exception ("Invalid image format: cannot find PE signature."); - } - - coffHdr.Read(reader); - peHdr.Read(reader); - - sectionsPos = reader.BaseStream.Position; - ReadSections(); - - if (this.IsCLI) { - - reader.BaseStream.Position = RVAToVA(peHdr.CLIHdrDir.virtAddr); - corHdr.Read (reader); - - mdRoot = new MetaDataRoot(this); - reader.BaseStream.Position = RVAToVA(corHdr.MetaData.virtAddr); - mdRoot.Read(reader); - } - - } - - public void WriteHeaders (BinaryWriter writer) - { - dosHdr.Write (writer); - writer.BaseStream.Position = dosHdr.Lfanew; - writer.Write ((ushort)ExeSignature.NT); - writer.Write ((ushort)ExeSignature.NT2); - - coffHdr.Write (writer); - peHdr.Write (writer); - - WriteSections (writer); - - if (this.IsCLI) { - - writer.BaseStream.Position = RVAToVA (peHdr.CLIHdrDir.virtAddr); - corHdr.Write (writer); - - long pos = RVAToVA (corHdr.MetaData.virtAddr); - writer.BaseStream.Position = pos; - mdRoot.Write (writer); - - } - - } - - /// - /// - protected void ReadSections() - { - if (sectionsPos < 0) { - throw new Exception("Read headers first."); - } - reader.BaseStream.Position = sectionsPos; - - int n = coffHdr.NumberOfSections; - for (int i = n; --i >=0;) { - Section sect = new Section(); - sect.Read(reader); - sections [sect.Name] = sect; - } - } - - protected void WriteSections (BinaryWriter writer) - { - foreach (Section section in sections.Values) { - section.Write (writer); - } - } - - - /// - /// - /// - public void Dump(TextWriter writer) - { - writer.WriteLine ( - "COFF Header:" + Environment.NewLine + - coffHdr.ToString() + Environment.NewLine + - "PE Header:" + Environment.NewLine + - peHdr.ToString() + Environment.NewLine + - "Core Header:" + Environment.NewLine + - corHdr.ToString() - ); - } - - - /// - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - - /// - /// Returns name of the section for the given RVA. - /// - /// - /// - public string RVAToSectionName(RVA rva) - { - string res = null; - foreach (Section s in Sections.Values) { - RVA sva = s.VirtualAddress; - if (rva >= sva && rva < sva + s.SizeOfRawData) { - res = s.Name; - break; - } - } - return res; - } - - public long RVAToVA(RVA rva) - { - string sectName = RVAToSectionName(rva); - long res = 0; - if (sectName != null) { - Section s = (Section) Sections [sectName]; - res = rva + (s.PointerToRawData - s.VirtualAddress); - } - return res; - } - - public MetaDataRoot MetaDataRoot { - get { - return mdRoot; - } - } - - public void DumpStreamHeader(TextWriter writer, string name) - { - if (mdRoot == null || name == null || name == String.Empty || writer == null) return; - writer.Write(name + " header: "); - MDStream s = MetaDataRoot.Streams[name] as MDStream; - if (s != null) { - writer.WriteLine(); - writer.WriteLine(s); - } else { - writer.WriteLine("not present."); - writer.WriteLine(); - } - } - - public void DumpStreamHeader(string name) - { - DumpStreamHeader(Console.Out, name); - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/LEBitConverter.cs b/mcs/class/Mono.PEToolkit/LEBitConverter.cs deleted file mode 100644 index 5efbe4e38935a..0000000000000 --- a/mcs/class/Mono.PEToolkit/LEBitConverter.cs +++ /dev/null @@ -1,272 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -// Auto-generated file - DO NOT EDIT! -// Please edit bitconverter.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit { - - /// - /// Little-endian bit converter. - /// - public sealed class LEBitConverter { - - internal interface IConverter { - - short ToInt16(byte [] val, int idx); - ushort ToUInt16(byte [] val, int idx); - int ToInt32(byte [] val, int idx); - uint ToUInt32(byte [] val, int idx); - long ToInt64(byte [] val, int idx); - ulong ToUInt64(byte [] val, int idx); - - } - - public static readonly bool Native = System.BitConverter.IsLittleEndian; - - private static readonly IConverter impl = System.BitConverter.IsLittleEndian - ? new LEConverter() as IConverter - : new BEConverter() as IConverter; - - - - - private LEBitConverter() - { - // Never instantiated. - } - - /// - unsafe public static short SwapInt16(short x) - { - short* p = stackalloc short [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [1]; - bp [1] = b; - return *p; - } - - /// - unsafe public static ushort SwapUInt16(ushort x) - { - ushort* p = stackalloc ushort [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [1]; - bp [1] = b; - return *p; - } - - /// - unsafe public static int SwapInt32(int x) - { - int* p = stackalloc int [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [3]; - bp [3] = b; - b = bp [1]; - bp [1] = bp [2]; - bp [2] = b; - return *p; - } - - /// - unsafe public static uint SwapUInt32(uint x) - { - uint* p = stackalloc uint [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [3]; - bp [3] = b; - b = bp [1]; - bp [1] = bp [2]; - bp [2] = b; - return *p; - } - - /// - unsafe public static long SwapInt64(long x) - { - long* p = stackalloc long [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [7]; - bp [7] = b; - b = bp [1]; - bp [1] = bp [6]; - bp [6] = b; - b = bp [2]; - bp [2] = bp [5]; - bp [5] = b; - b = bp [3]; - bp [3] = bp [4]; - bp [4] = b; - return *p; - } - - /// - unsafe public static ulong SwapUInt64(ulong x) - { - ulong* p = stackalloc ulong [1]; - *p = x; - byte* bp = (byte*) p; - byte b = bp [0]; - bp [0] = bp [7]; - bp [7] = b; - b = bp [1]; - bp [1] = bp [6]; - bp [6] = b; - b = bp [2]; - bp [2] = bp [5]; - bp [5] = b; - b = bp [3]; - bp [3] = bp [4]; - bp [4] = b; - return *p; - } - - - - - - internal sealed class LEConverter : IConverter { - /// - public short ToInt16(byte [] val, int idx) - { - return BitConverter.ToInt16(val, idx); - } - /// - public ushort ToUInt16(byte [] val, int idx) - { - return BitConverter.ToUInt16(val, idx); - } - /// - public int ToInt32(byte [] val, int idx) - { - return BitConverter.ToInt32(val, idx); - } - /// - public uint ToUInt32(byte [] val, int idx) - { - return BitConverter.ToUInt32(val, idx); - } - /// - public long ToInt64(byte [] val, int idx) - { - return BitConverter.ToInt64(val, idx); - } - /// - public ulong ToUInt64(byte [] val, int idx) - { - return BitConverter.ToUInt64(val, idx); - } - - } - - internal sealed class BEConverter : IConverter { - /// - public short ToInt16(byte [] val, int idx) - { - return SwapInt16(BitConverter.ToInt16(val, idx)); - } - /// - public ushort ToUInt16(byte [] val, int idx) - { - return SwapUInt16(BitConverter.ToUInt16(val, idx)); - } - /// - public int ToInt32(byte [] val, int idx) - { - return SwapInt32(BitConverter.ToInt32(val, idx)); - } - /// - public uint ToUInt32(byte [] val, int idx) - { - return SwapUInt32(BitConverter.ToUInt32(val, idx)); - } - /// - public long ToInt64(byte [] val, int idx) - { - return SwapInt64(BitConverter.ToInt64(val, idx)); - } - /// - public ulong ToUInt64(byte [] val, int idx) - { - return SwapUInt64(BitConverter.ToUInt64(val, idx)); - } - - } - - - - - /// - public static short ToInt16(byte [] val, int idx) - { - return impl.ToInt16(val, idx); - } - - /// - public static ushort ToUInt16(byte [] val, int idx) - { - return impl.ToUInt16(val, idx); - } - - /// - public static int ToInt32(byte [] val, int idx) - { - return impl.ToInt32(val, idx); - } - - /// - public static uint ToUInt32(byte [] val, int idx) - { - return impl.ToUInt32(val, idx); - } - - /// - public static long ToInt64(byte [] val, int idx) - { - return impl.ToInt64(val, idx); - } - - /// - public static ulong ToUInt64(byte [] val, int idx) - { - return impl.ToUInt64(val, idx); - } - - - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/MachineId.cs b/mcs/class/Mono.PEToolkit/MachineId.cs deleted file mode 100644 index 8768aefe5de25..0000000000000 --- a/mcs/class/Mono.PEToolkit/MachineId.cs +++ /dev/null @@ -1,278 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -namespace Mono.PEToolkit { - - public enum MachineId : ushort { - - /// - /// - /// - /// IMAGE_FILE_MACHINE_UNKNOWN - /// - UNKNOWN = 0, - - /// - /// Intel 386. - /// - /// - /// IMAGE_FILE_MACHINE_I386 - /// - I386 = 0x014c, - - /// - /// Intel 486. - /// - /// - /// - I486 = 0x014d, - - /// - /// Intel Pentium. - /// - /// - /// - PENTIUM = 0x014e, - - /// - /// MIPS 3K big-endian - /// - /// - /// IMAGE_FILE_MACHINE_R3000 - /// - R3000_BE = 0x0160, - - /// - /// MIPS 3K little-endian, 0x160 big-endian - /// - /// - /// IMAGE_FILE_MACHINE_R3000 - /// - R3000 = 0x0162, - - /// - /// MIPS 4K little-endian - /// - /// - /// IMAGE_FILE_MACHINE_R4000 - /// - R4000 = 0x0166, - - /// - /// MIPS little-endian - /// - /// - /// IMAGE_FILE_MACHINE_R10000 - /// - R10000 = 0x0168, - - /// - /// MIPS little-endian WCE v2 - /// - /// - /// IMAGE_FILE_MACHINE_WCEMIPSV2 - /// - WCEMIPSV2 = 0x0169, - - /// - /// Alpha_AXP - /// - /// - /// IMAGE_FILE_MACHINE_ALPHA - /// - ALPHA = 0x0184, - - /// - /// SH3 little-endian - /// - /// - /// IMAGE_FILE_MACHINE_SH3 - /// - SH3 = 0x01a2, - - /// - /// - /// - /// IMAGE_FILE_MACHINE_SH3DSP - /// - SH3DSP = 0x01a3, - - /// - /// SH3E little-endian - /// - /// - /// IMAGE_FILE_MACHINE_SH3E - /// - SH3E = 0x01a4, - - /// - /// SH4 little-endian - /// - /// - /// IMAGE_FILE_MACHINE_SH4 - /// - SH4 = 0x01a6, - - /// - /// SH5 - /// - /// - /// IMAGE_FILE_MACHINE_SH5 - /// - SH5 = 0x01a8, - - /// - /// ARM Little-Endian - /// - /// - /// IMAGE_FILE_MACHINE_ARM - /// - ARM = 0x01c0, - - /// - /// ARM 10 Thumb family CPU. - /// - /// - /// IMAGE_FILE_MACHINE_THUMB - /// http://www.arm.com/armtech/ARM10_Thumb?OpenDocument&ExpandSection=2 - /// - THUMB = 0x01c2, - - /// - /// - /// - /// IMAGE_FILE_MACHINE_AM33 - /// - AM33 = 0x01d3, - - /// - /// IBM PowerPC Little-Endian - /// - /// - /// IMAGE_FILE_MACHINE_POWERPC - /// - POWERPC = 0x01F0, - - /// - /// - /// - /// IMAGE_FILE_MACHINE_POWERPCFP - /// - POWERPCFP = 0x01f1, - - /// - /// Intel 64 - /// - /// - /// IMAGE_FILE_MACHINE_IA64 - /// - IA64 = 0x0200, - - /// - /// MIPS - /// - /// - /// IMAGE_FILE_MACHINE_MIPS16 - /// - MIPS16 = 0x0266, - - /// - /// ALPHA64 - /// - /// - /// IMAGE_FILE_MACHINE_ALPHA64 - /// - ALPHA64 = 0x0284, - - /// - /// MIPS - /// - /// - /// IMAGE_FILE_MACHINE_MIPSFPU - /// - MIPSFPU = 0x0366, - - /// - /// MIPS - /// - /// - /// IMAGE_FILE_MACHINE_MIPSFPU16 - /// - MIPSFPU16 = 0x0466, - - /// - /// - /// - /// IMAGE_FILE_MACHINE_AXP64 - /// - AXP64 = ALPHA64, - - /// - /// Infineon - /// - /// - /// IMAGE_FILE_MACHINE_TRICORE - /// http://www.infineon.com/tricore - /// - TRICORE = 0x0520, - - /// - /// Common Executable Format (Windows CE). - /// - /// - /// IMAGE_FILE_MACHINE_CEF - /// - CEF = 0x0CEF, - - /// - /// EFI Byte Code - /// - EBC = 0x0EBC, - - /// - /// AMD64 (K8) - /// - /// - /// IMAGE_FILE_MACHINE_AMD64 - /// - AMD64 = 0x8664, - - /// - /// M32R little-endian - /// - /// - /// IMAGE_FILE_MACHINE_M32R - /// - M32R = 0x9104, - - /// - /// - /// - /// IMAGE_FILE_MACHINE_CEE - /// - CEE = 0xC0EE, - } - -} diff --git a/mcs/class/Mono.PEToolkit/Makefile b/mcs/class/Mono.PEToolkit/Makefile deleted file mode 100644 index 824d6d8c2ba56..0000000000000 --- a/mcs/class/Mono.PEToolkit/Makefile +++ /dev/null @@ -1,15 +0,0 @@ -thisdir = class/Mono.PEToolkit -SUBDIRS = build -include ../../build/rules.make - -LIBRARY = Mono.PEToolkit.dll -LIB_MCS_FLAGS = /unsafe /r:$(corlib) /r:System.Xml.dll -NO_TEST = yes - -EXTRA_DISTFILES = README - -mddump.exe: - @echo $@ now lives in build/. Email 'peter@newton.cx' - @echo if this change is a problem. - -include ../../build/library.make diff --git a/mcs/class/Mono.PEToolkit/Mono.PEToolkit.dll.sources b/mcs/class/Mono.PEToolkit/Mono.PEToolkit.dll.sources deleted file mode 100644 index 58b64d9ef77e7..0000000000000 --- a/mcs/class/Mono.PEToolkit/Mono.PEToolkit.dll.sources +++ /dev/null @@ -1,41 +0,0 @@ -BadImageException.cs -COFFHeader.cs -Characteristics.cs -CheckSum.cs -CorHeader.cs -DOSHeader.cs -DataDir.cs -ExeSignature.cs -Image.cs -LEBitConverter.cs -MachineId.cs -PEHeader.cs -PEUtils.cs -RVA.cs -Section.cs -SectionCharacteristics.cs -Subsystem.cs -metadata/AssemblyFlags.cs -metadata/BadMetaDataException.cs -metadata/CodedTokenId.cs -metadata/ElementType.cs -metadata/GUIDHeap.cs -metadata/MDHeap.cs -metadata/MDStream.cs -metadata/MDTable.cs -metadata/MDToken.cs -metadata/MDUtils.cs -metadata/ManifestResourceAttributes.cs -metadata/MetaDataRoot.cs -metadata/MethodIL.cs -metadata/MethodSemanticsAttributes.cs -metadata/PInvokeAttributes.cs -metadata/Row.cs -metadata/Rows.cs -metadata/StringsHeap.cs -metadata/TableId.cs -metadata/Tables.cs -metadata/TablesHeap.cs -metadata/TablesHeapBase.cs -metadata/TabsDecoder.cs -metadata/TokenType.cs diff --git a/mcs/class/Mono.PEToolkit/PEHeader.cs b/mcs/class/Mono.PEToolkit/PEHeader.cs deleted file mode 100644 index 3ff1e9becbc70..0000000000000 --- a/mcs/class/Mono.PEToolkit/PEHeader.cs +++ /dev/null @@ -1,698 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - // IMAGE_OPTIONAL_HEADER - public class PEHeader { - - /// - /// Standard PE/COFF fields. - /// - public class StdFields { - internal short magic; // always 0x10B? - internal byte lMajor; - internal byte lMinor; - internal uint codeSize; - internal uint initDataSize; - internal uint uninitDataSize; - internal RVA entryRVA; - internal RVA codeBase; - internal RVA dataBase; - - public StdFields () - { - - } - - public StdFields (BinaryReader reader) - { - Read (reader); - } - - public void Read (BinaryReader reader) - { - magic = reader.ReadInt16 (); - lMajor = reader.ReadByte (); - lMinor = reader.ReadByte (); - codeSize = reader.ReadUInt32 (); - initDataSize = reader.ReadUInt32 (); - uninitDataSize = reader.ReadUInt32 (); - entryRVA = new RVA (reader.ReadUInt32 ()); - codeBase = new RVA (reader.ReadUInt32 ()); - dataBase = new RVA (reader.ReadUInt32 ()); - } - - public void Write (BinaryWriter writer) - { - writer.Write (magic); - writer.Write (lMajor); - writer.Write (lMinor); - writer.Write (codeSize); - writer.Write (initDataSize); - writer.Write (uninitDataSize); - entryRVA.Write (writer); - codeBase.Write (writer); - dataBase.Write (writer); - } - - public string LinkerVersion { - get { - return String.Format("{0}.{1}", lMajor, lMinor); - } - } - - public override string ToString() { - return String.Format( - "Magic : 0x{0}" + Environment.NewLine + - "Linker ver. : {1}" + Environment.NewLine + - "Size of code : {2}" + Environment.NewLine + - "Size of initialized data : {3}" + Environment.NewLine + - "Size of uinitialized data (BSS) : {4}" + Environment.NewLine, - magic.ToString("X"), LinkerVersion, - codeSize, initDataSize, uninitDataSize - ); - } - } - - - /// - /// Windows-specific fields. - /// - /// - /// See Partition II, 24.2.3.2 - /// - public class NTFields { - internal uint imgBase; - internal uint sectAlign; - internal uint fileAlign; - internal short osMaj; - internal short osMin; - internal short imgMaj; - internal short imgMin; - internal short subSysMaj; - internal short subSysMin; - internal int reserved_win32ver; - internal uint imgSize; - internal uint hdrSize; - internal uint chksum; - internal Subsystem subSys; - internal short dllFlags; - internal uint stackRes; - internal uint stackCommit; - internal uint heapRes; - internal uint heapCommit; - internal uint ldrFlags; - internal uint numDirs; - - public NTFields () - { - - } - - public NTFields (BinaryReader reader) - { - Read (reader); - } - - public void Read (BinaryReader reader) - { - imgBase = reader.ReadUInt32 (); - sectAlign = reader.ReadUInt32 (); - fileAlign = reader.ReadUInt32 (); - osMaj = reader.ReadInt16 (); - osMin = reader.ReadInt16 (); - imgMaj = reader.ReadInt16 (); - imgMin = reader.ReadInt16 (); - subSysMaj = reader.ReadInt16 (); - subSysMin = reader.ReadInt16 (); - reserved_win32ver = reader.ReadInt32 (); - imgSize = reader.ReadUInt32 (); - hdrSize = reader.ReadUInt32 (); - chksum = reader.ReadUInt32 (); - subSys = (Subsystem) reader.ReadInt16 (); - dllFlags = reader.ReadInt16 (); - stackRes = reader.ReadUInt32 (); - stackCommit = reader.ReadUInt32 (); - heapRes = reader.ReadUInt32 (); - heapCommit = reader.ReadUInt32 (); - ldrFlags = reader.ReadUInt32 (); - numDirs = reader.ReadUInt32 (); - } - - public void Write (BinaryWriter writer) - { - writer.Write (imgBase); - writer.Write (sectAlign); - writer.Write (fileAlign); - writer.Write (osMaj); - writer.Write (osMin); - writer.Write (imgMaj); - writer.Write (imgMin); - writer.Write (subSysMaj); - writer.Write (subSysMin); - writer.Write (reserved_win32ver); - writer.Write (imgSize); - writer.Write (hdrSize); - writer.Write (chksum); - writer.Write ((short)subSys); - writer.Write (dllFlags); - writer.Write (stackRes); - writer.Write (stackCommit); - writer.Write (heapRes); - writer.Write (heapCommit); - writer.Write (ldrFlags); - writer.Write (numDirs); - } - - public string OSVersion { - get { - return String.Format("{0}.{1}", osMaj, osMin); - } - } - - public string ImageVersion { - get { - return String.Format("{0}.{1}", imgMaj, imgMin); - } - } - - public string SubsysVersion { - get { - return String.Format("{0}.{1}", subSysMaj, subSysMin); - } - } - - - /// - /// - /// - public override string ToString() { - return String.Format( - "Image Base : 0x{0}" + Environment.NewLine + - "Section Alignment : 0x{1}" + Environment.NewLine + - "File Alignment : 0x{2}" + Environment.NewLine + - "OS Version : {3}" + Environment.NewLine + - "Image Version : {4}" + Environment.NewLine + - "Subsystem Version : {5}" + Environment.NewLine + - "Reserved/Win32Ver : {6}" + Environment.NewLine + - "Image Size : {7}" + Environment.NewLine + - "Header Size : {8}" + Environment.NewLine + - "Checksum : 0x{9}" + Environment.NewLine + - "Subsystem : {10}" + Environment.NewLine + - "DLL Flags : {11}" + Environment.NewLine + - "Stack Reserve Size : 0x{12}" + Environment.NewLine + - "Stack Commit Size : 0x{13}" + Environment.NewLine + - "Heap Reserve Size : 0x{14}" + Environment.NewLine + - "Heap Commit Size : 0x{15}" + Environment.NewLine + - "Loader Flags : {16}" + Environment.NewLine + - "Number of Directories : {17}" + Environment.NewLine, - imgBase.ToString("X"), sectAlign.ToString("X"), fileAlign.ToString("X"), - OSVersion, ImageVersion, SubsysVersion, - reserved_win32ver, - imgSize, hdrSize, chksum.ToString("X"), subSys, dllFlags, - stackRes.ToString("X"), stackCommit.ToString("X"), heapRes.ToString("X"), heapCommit.ToString ("X"), - ldrFlags, numDirs - ); - } - } - - - internal StdFields stdFlds; - internal NTFields ntFlds; - - internal DataDir exportDir; - internal DataDir importDir; - internal DataDir resourceDir; - internal DataDir exceptionDir; - internal DataDir securityDir; - internal DataDir baseRelocDir; - internal DataDir debugDir; - internal DataDir copyrightDir; - internal DataDir GPDir; - internal DataDir TLSDir; - internal DataDir loadCfgDir; - internal DataDir boundImpDir; - internal DataDir IATDir; - internal DataDir delayImpDir; - internal DataDir CLIHdrDir; - internal DataDir reservedDir; - - - public bool IsCLIImage { - get { - return (CLIHdrDir.virtAddr.Value != 0); - } - } - - - // - // Accessors for standard COFF fields. - // - - public short Magic { - get { - return stdFlds.magic; - } - set { - stdFlds.magic = value; - } - } - - public byte MajorLinkerVersion { - get { - return stdFlds.lMajor; - } - set { - stdFlds.lMajor = value; - } - } - - public byte MinorLinkerVersion { - get { - return stdFlds.lMinor; - } - set { - stdFlds.lMinor = value; - } - } - - public uint SizeOfCode { - get { - return stdFlds.codeSize; - } - set { - stdFlds.codeSize = value; - } - } - - public uint SizeOfInitializedData { - get { - return stdFlds.initDataSize; - } - set { - stdFlds.initDataSize = value; - } - } - - public uint SizeOfUninitializedData { - get { - return stdFlds.uninitDataSize; - } - set { - stdFlds.uninitDataSize = value; - } - } - - public RVA AddressOfEntryPoint { - get { - return stdFlds.entryRVA; - } - set { - stdFlds.entryRVA.value = value.value; - } - } - - public RVA BaseOfCode { - get { - return stdFlds.codeBase; - } - set { - stdFlds.codeBase.value = value.value; - } - } - - public RVA BaseOfData { - get { - return stdFlds.dataBase; - } - set { - stdFlds.dataBase.value = value.value; - } - } - - - // - // Accessors for Windows-specific fields. - // - - - /// - /// Preferred address of image when loaded into memory. - /// - /// - /// - /// This is a linear address and not RVA, - /// and must be a multiple of 64K. - /// - /// - /// Table in the Partition II states that for CIL images - /// it must be 0x400000. - /// - /// - public uint ImageBase { - get { - return ntFlds.imgBase; - } - set { - ntFlds.imgBase = value; - } - } - - /// - /// Alignment of section when loaded into memory. - /// - /// - /// Must be greater or equal to FileAlignment. - /// Default is the native page size. - /// According to specs for CIL images it must be set to 8K. - /// - public uint SectionAlignment { - get { - return ntFlds.sectAlign; - } - set { - ntFlds.sectAlign = value; - } - } - - /// - /// Byte alignment of pages in image file. - /// - /// - /// Valid values are powers of 2 between 512 and 64K. - /// For CIL images it must be either 512 or 4K. - /// - public uint FileAlignment { - get { - return ntFlds.fileAlign; - } - set { - ntFlds.fileAlign = value; - } - } - - - public short MajorOperatingSystemVersion { - get { - return ntFlds.osMaj; - } - set { - ntFlds.osMaj = value; - } - } - - public short MinorOperatingSystemVersion { - get { - return ntFlds.osMin; - } - set { - ntFlds.osMin = value; - } - } - - public short MajorImageVersion { - get { - return ntFlds.imgMaj; - } - set { - ntFlds.imgMaj = value; - } - } - - public short MinorImageVersion { - get { - return ntFlds.imgMin; - } - set { - ntFlds.imgMin = value; - } - } - - public short MajorSubsystemVersion { - get { - return ntFlds.subSysMaj; - } - set { - ntFlds.subSysMaj = value; - } - } - - public short MinorSubsystemVersion { - get { - return ntFlds.subSysMin; - } - set { - ntFlds.subSysMin = value; - } - } - - public int Win32VersionValue { - get { - return ntFlds.reserved_win32ver; - } - set { - ntFlds.reserved_win32ver = value; - } - } - - public int Reserved { - get { - return ntFlds.reserved_win32ver; - } - set { - ntFlds.reserved_win32ver = value; - } - } - - public uint SizeOfImage { - get { - return ntFlds.imgSize; - } - set { - ntFlds.imgSize = value; - } - } - - public uint SizeOfHeaders { - get { - return ntFlds.hdrSize; - } - set { - ntFlds.hdrSize = value; - } - } - - public uint CheckSum { - get { - return ntFlds.chksum; - } - set { - ntFlds.chksum = value; - } - } - - public Subsystem Subsystem { - get { - return ntFlds.subSys; - } - set { - ntFlds.subSys = value; - } - } - - public short DllCharacteristics { - get { - return ntFlds.dllFlags; - } - set { - ntFlds.dllFlags = value; - } - } - - - public uint SizeOfStackReserve { - get { - return ntFlds.stackRes; - } - set { - ntFlds.stackRes = value; - } - } - - public uint SizeOfStackCommit { - get { - return ntFlds.stackCommit; - } - set { - ntFlds.stackCommit = value; - } - } - - public uint SizeOfHeapReserve { - get { - return ntFlds.heapRes; - } - set { - ntFlds.heapRes = value; - } - } - - public uint SizeOfHeapCommit { - get { - return ntFlds.heapCommit; - } - set { - ntFlds.heapCommit = value; - } - } - - public uint LoaderFlags { - get { - return ntFlds.ldrFlags; - } - set { - ntFlds.ldrFlags = value; - } - } - - public uint NumberOfRvaAndSizes { - get { - return ntFlds.numDirs; - } - set { - ntFlds.numDirs = value; - } - } - - - - - - /// - /// - public void Read(BinaryReader reader) - { - stdFlds = new StdFields (reader); - ntFlds = new NTFields (reader); - - exportDir = new DataDir (reader); - importDir = new DataDir (reader); - resourceDir = new DataDir (reader); - exceptionDir = new DataDir (reader); - securityDir = new DataDir (reader); - baseRelocDir = new DataDir (reader); - debugDir = new DataDir (reader); - copyrightDir = new DataDir (reader); - GPDir = new DataDir (reader); - TLSDir = new DataDir (reader); - loadCfgDir = new DataDir (reader); - boundImpDir = new DataDir (reader); - IATDir = new DataDir (reader); - delayImpDir = new DataDir (reader); - CLIHdrDir = new DataDir (reader); - reservedDir = new DataDir (reader); - - } - - public void Write (BinaryWriter writer) - { - stdFlds.Write (writer); - ntFlds.Write (writer); - - exportDir.Write (writer); - importDir.Write (writer); - resourceDir.Write (writer); - exceptionDir.Write (writer); - securityDir.Write (writer); - baseRelocDir.Write (writer); - debugDir.Write (writer); - copyrightDir.Write (writer); - GPDir.Write (writer); - TLSDir.Write (writer); - loadCfgDir.Write (writer); - boundImpDir.Write (writer); - IATDir.Write (writer); - delayImpDir.Write (writer); - CLIHdrDir.Write (writer); - reservedDir.Write (writer); - } - - /// - /// - public void Dump(TextWriter writer) - { - string dirs = String.Format( - "Export Table : {0}" + Environment.NewLine + - "Import Table : {1}" + Environment.NewLine + - "Win32 Resource Table : {2}" + Environment.NewLine + - "Exception Table : {3}" + Environment.NewLine + - "Certificate Table : {4}" + Environment.NewLine + - "Base Relocation Table : {5}" + Environment.NewLine + - "Debug Table : {6}" + Environment.NewLine + - "Copyright : {7}" + Environment.NewLine + - "MIPS Global Ptr : {8}" + Environment.NewLine + - "TLS Table : {9}" + Environment.NewLine + - "Load Config Table : {10}" + Environment.NewLine + - "Bound Import : {11}" + Environment.NewLine + - "IAT : {12}" + Environment.NewLine + - "Delay Import Descriptor : {13}" + Environment.NewLine + - "CLI Header : {14}" + Environment.NewLine + - "Reserved : {15}" + Environment.NewLine, - exportDir, importDir, resourceDir, exceptionDir, - securityDir, baseRelocDir, debugDir, copyrightDir, - GPDir, TLSDir, loadCfgDir, boundImpDir, IATDir, delayImpDir, - CLIHdrDir, reservedDir - ); - - writer.WriteLine( - "Standard Fields:" + Environment.NewLine + - stdFlds.ToString() + Environment.NewLine + - "NT Fields:" + Environment.NewLine + - ntFlds.ToString() + Environment.NewLine + - "Directories: "+ Environment.NewLine + - dirs - ); - } - - - /// - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/PEUtils.cs b/mcs/class/Mono.PEToolkit/PEUtils.cs deleted file mode 100644 index a3673e0c72b50..0000000000000 --- a/mcs/class/Mono.PEToolkit/PEUtils.cs +++ /dev/null @@ -1,192 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Text; -using System.Reflection; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - public sealed class PEUtils { - - private PEUtils() - { - } - - - unsafe internal static string GetString (sbyte* data, int start, int len, Encoding encoding) - { - byte[] data_array = new byte[len-start]; - - for (int i=start; i - /// Reads structure from the input stream preserving its endianess. - /// - /// - /// - /// - unsafe internal static void ReadStruct(BinaryReader reader, void* pStruct, int len) - { - byte* p = (byte*) pStruct; - - if (System.BitConverter.IsLittleEndian) { - // On a little-endian machine read data in 64-bit chunks, - // this won't work on big-endian machine because - // BinaryReader APIs are little-endian while - // memory writes are platform-native. - // This seems faster than ReadBytes/Copy method - // in the "else" clause, especially if used often - // (no extra memory allocation for byte[]?). - int whole = len >> 3; - int rem = len & 7; - - for (int i = whole; --i >= 0;) { - long qw = reader.ReadInt64(); - Marshal.WriteInt64((IntPtr) p, qw); - p += sizeof (long); - } - for (int i = rem; --i >= 0;) { - *p++ = (byte) reader.ReadByte(); - } - } else { - byte [] buff = reader.ReadBytes(len); - Marshal.Copy(buff, 0, (IntPtr) p, len); - } - } - - /// - /// Reads structure from the input stream - /// changing its endianess if required - /// (if running on big-endian hardware). - /// - /// - /// - /// - /// - unsafe internal static void ReadStruct(BinaryReader reader, void* pStruct, int len, Type type) - { - ReadStruct(reader, pStruct, len); - if (!System.BitConverter.IsLittleEndian) { - ChangeStructEndianess(pStruct, type); - } - } - - - unsafe private static int SwapByTypeCode(byte* p, TypeCode tcode) - { - int inc = 0; - switch (tcode) { - case TypeCode.Int16 : - short* sp = (short*) p; - short sx = *sp; - sx = LEBitConverter.SwapInt16(sx); - *sp = sx; - inc = sizeof (short); - break; - case TypeCode.UInt16 : - ushort* usp = (ushort*) p; - ushort usx = *usp; - usx = LEBitConverter.SwapUInt16(usx); - *usp = usx; - inc = sizeof (ushort); - break; - case TypeCode.Int32 : - int* ip = (int*) p; - int ix = *ip; - ix = LEBitConverter.SwapInt32(ix); - *ip = ix; - inc = sizeof (int); - break; - case TypeCode.UInt32 : - uint* uip = (uint*) p; - uint uix = *uip; - uix = LEBitConverter.SwapUInt32(uix); - *uip = uix; - inc = sizeof (uint); - break; - case TypeCode.Int64 : - long* lp = (long*) p; - long lx = *lp; - lx = LEBitConverter.SwapInt64(lx); - *lp = lx; - inc = sizeof (long); - break; - case TypeCode.UInt64 : - ulong* ulp = (ulong*) p; - ulong ulx = *ulp; - ulx = LEBitConverter.SwapUInt64(ulx); - *ulp = ulx; - inc = sizeof (ulong); - break; - case TypeCode.Byte : - case TypeCode.SByte : - inc = sizeof (byte); - break; - default : - break; - } - return inc; - } - - unsafe internal static int ChangeStructEndianess(void* pStruct, Type type) - { - if (type == null || !type.IsValueType) return 0; - if (!type.IsLayoutSequential && !type.IsExplicitLayout) { - throw new Exception("Internal error: struct must have explicit or sequential layout."); - } - - bool seq = type.IsLayoutSequential; - byte* p = (byte*) pStruct; - int offs = 0; - int inc; - FieldInfo [] fields = type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public); - - foreach (FieldInfo fi in fields) { - if (!seq) offs = Marshal.OffsetOf(type, fi.Name).ToInt32 (); - Type ft = fi.FieldType; - TypeCode tcode = Type.GetTypeCode(ft); - if (tcode == TypeCode.Object) { - // not a primitive type, process recursively. - inc = ChangeStructEndianess(p + offs, ft); - } else { - inc = SwapByTypeCode(p + offs, tcode); - } - if (seq) offs += inc; - } - - return offs; - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/README b/mcs/class/Mono.PEToolkit/README deleted file mode 100644 index 9229f3fffc90a..0000000000000 --- a/mcs/class/Mono.PEToolkit/README +++ /dev/null @@ -1 +0,0 @@ -The PEToolkit was authored by Sergey Chaban (serge@wildwestsoftware.com) diff --git a/mcs/class/Mono.PEToolkit/RVA.cs b/mcs/class/Mono.PEToolkit/RVA.cs deleted file mode 100644 index c6960761c42eb..0000000000000 --- a/mcs/class/Mono.PEToolkit/RVA.cs +++ /dev/null @@ -1,143 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; - -namespace Mono.PEToolkit { - - /// - /// Relative Virtual Address. - /// - public struct RVA { - - public static readonly RVA Null; - - public uint value; - - static RVA() - { - Null = new RVA(0); - } - - - public RVA(uint val) - { - value = val; - } - - - public uint Value { - get { - return value; - } - set { - this.value = value; - } - } - - public void Write (BinaryWriter writer) - { - writer.Write (value); - } - - public static implicit operator RVA (uint val) - { - return new RVA(val); - } - - public static implicit operator uint (RVA rva) - { - return rva.value; - } - - public override int GetHashCode() - { - return (int) value; - } - - public override bool Equals(object o) - { - bool res = o is RVA; - if (res) res = (this.value == ((RVA)o).value); - return res; - } - - public static bool operator == (RVA rva1, RVA rva2) - { - return rva1.Equals(rva2); - } - - public static bool operator != (RVA rva1, RVA rva2) - { - return !rva1.Equals(rva2); - } - - public static bool operator < (RVA rva1, RVA rva2) - { - return (rva1.value < rva2.value); - } - - public static bool operator > (RVA rva1, RVA rva2) { - return (rva1.value > rva2.value); - } - - public static bool operator <= (RVA rva1, RVA rva2) - { - return (rva1.value <= rva2.value); - } - - public static bool operator >= (RVA rva1, RVA rva2) - { - return (rva1.value >= rva2.value); - } - - public static RVA operator + (RVA rva, uint x) - { - return new RVA (rva.value + x); - } - - public static RVA operator - (RVA rva, uint x) - { - return new RVA (rva.value - x); - } - - - public override string ToString() - { - if (this == Null) return "NULL"; - return ("0x" + value.ToString("X")); - } - - unsafe public static int Size { - get { - return sizeof (uint); - } - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/Section.cs b/mcs/class/Mono.PEToolkit/Section.cs deleted file mode 100644 index 46ecf8ba4355e..0000000000000 --- a/mcs/class/Mono.PEToolkit/Section.cs +++ /dev/null @@ -1,234 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Text; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit { - - public class Section { - - // IMAGE_SECTION_HEADER - protected class Header { - internal uint phAddr_virtSize; - internal RVA virtAddr; - internal uint rawSize; - internal RVA rawDataPtr; - internal RVA relocPtr; - internal RVA lineNumPtr; - internal short relocNum; - internal short linenumNum; - internal SectionCharacteristics flags; - - public Header (BinaryReader reader) - { - Read (reader); - } - - public void Read (BinaryReader reader) - { - phAddr_virtSize = reader.ReadUInt32 (); - virtAddr = new RVA (reader.ReadUInt32 ()); - rawSize = reader.ReadUInt32 (); - rawDataPtr = new RVA (reader.ReadUInt32 ()); - relocPtr = new RVA (reader.ReadUInt32 ()); - lineNumPtr = new RVA (reader.ReadUInt32 ()); - relocNum = reader.ReadInt16 (); - linenumNum = reader.ReadInt16 (); - flags = (SectionCharacteristics) reader.ReadUInt32 (); - } - - public void Write (BinaryWriter writer) - { - writer.Write (phAddr_virtSize); - virtAddr.Write (writer); - writer.Write (rawSize); - rawDataPtr.Write (writer); - relocPtr.Write (writer); - lineNumPtr.Write (writer); - writer.Write (relocNum); - writer.Write (linenumNum); - writer.Write ((uint) flags); - } - } - - private string name; - private Header hdr; - - public readonly static Section Invalid; - - static Section() - { - Invalid = new Section(); - } - - public Section() - { - } - - - public string Name { - get { - return name; - } - set { - name = value; - } - } - - - public uint PhysicalAddress { - get { - return hdr.phAddr_virtSize; - } - set { - hdr.phAddr_virtSize = value; - } - } - - public uint VirtualSize { - get { - return hdr.phAddr_virtSize; - } - set { - hdr.phAddr_virtSize = value; - } - } - - public RVA VirtualAddress { - get { - return hdr.virtAddr; - } - set { - hdr.virtAddr = value; - } - } - - public uint SizeOfRawData { - get { - return hdr.rawSize; - } - set { - hdr.rawSize = value; - } - } - - public RVA PointerToRawData { - get { - return hdr.rawDataPtr; - } - set { - hdr.rawDataPtr = value; - } - } - - public RVA PointerToRelocations { - get { - return hdr.relocPtr; - } - set { - hdr.relocPtr = value; - } - } - - public RVA PointerToLinenumbers { - get { - return hdr.lineNumPtr; - } - set { - hdr.lineNumPtr = value; - } - } - - public short NumberOfRelocations { - get { - return hdr.relocNum; - } - set { - hdr.relocNum = value; - } - } - - public short NumberOfLinenumbers { - get { - return hdr.linenumNum; - } - set { - hdr.linenumNum = value; - } - } - - public SectionCharacteristics Characteristics { - get { - return hdr.flags; - } - set { - hdr.flags = value; - } - } - - /// - /// - public void Read(BinaryReader reader) - { - char[] pName = new char[8]; - int len = 0; - - for (len = 0; len<8; len++) { - sbyte c = reader.ReadSByte(); - if (c == 0) - break; - pName[len] = (char) c; - } - - if (len == 0) - name = String.Empty; - else - name = new String (pName); - - reader.BaseStream.Position += 8 - len - 1; - - hdr = new Header (reader); - } - - public void Write (BinaryWriter writer) - { - sbyte[] name_bytes = new sbyte[8]; - - for (int i=0; i - */ - -using System; - -namespace Mono.PEToolkit { - - [Flags] - public enum SectionCharacteristics : uint { - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_REG = 0x00000000, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_DSECT = 0x00000001, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_NOLOAD = 0x00000002, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_GROUP = 0x00000004, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_NO_PAD = 0x00000008, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_COPY = 0x00000010, - - /// - /// Section contains code. - /// - IMAGE_SCN_CNT_CODE = 0x00000020, - - /// - /// Section contains initialized data. - /// - IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040, - - /// - /// Section contains uninitialized data. - /// - IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080, - - /// - /// Reserved. - /// - IMAGE_SCN_LNK_OTHER = 0x00000100, - - /// - /// Section contains comments or some other type of information. - /// - IMAGE_SCN_LNK_INFO = 0x00000200, - - /// - /// Reserved. - /// - IMAGE_SCN_TYPE_OVER = 0x00000400, - - /// - /// Section contents will not become part of image. - /// - IMAGE_SCN_LNK_REMOVE = 0x00000800, - - /// - /// Section contents comdat. - /// - IMAGE_SCN_LNK_COMDAT = 0x00001000, - - - /// - /// Reset speculative exceptions handling bits in the TLB entries for this section. - /// - /// - /// IMAGE_SCN_MEM_PROTECTED - Obsolete. - /// - IMAGE_SCN_NO_DEFER_SPEC_EXC = 0x00004000, - - /// - /// Section content can be accessed relative to GP (MIPS). - /// - IMAGE_SCN_GPREL = 0x00008000, - - /// - /// - IMAGE_SCN_MEM_FARDATA = 0x00008000, - - /// - /// Obsolete. - /// - IMAGE_SCN_MEM_PURGEABLE = 0x00020000, - - /// - /// Obsolete. - /// - IMAGE_SCN_MEM_16BIT = 0x00020000, - - /// - /// Obsolete. - /// - IMAGE_SCN_MEM_LOCKED = 0x00040000, - - /// - /// Obsolete. - /// - IMAGE_SCN_MEM_PRELOAD = 0x00080000, - - /// - /// - /// - /// IMAGE_SCN_MEM_SYSHEAP - Obsolete 0x00010000 - /// - IMAGE_SCN_ALIGN_1BYTES = 0x00100000, - - IMAGE_SCN_ALIGN_2BYTES = 0x00200000, - IMAGE_SCN_ALIGN_4BYTES = 0x00300000, - IMAGE_SCN_ALIGN_8BYTES = 0x00400000, - - // default alignment - IMAGE_SCN_ALIGN_16BYTES = 0x00500000, - - IMAGE_SCN_ALIGN_32BYTES = 0x00600000, - IMAGE_SCN_ALIGN_64BYTES = 0x00700000, - IMAGE_SCN_ALIGN_128BYTES = 0x00800000, - IMAGE_SCN_ALIGN_256BYTES = 0x00900000, - IMAGE_SCN_ALIGN_512BYTES = 0x00A00000, - IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000, - IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000, - IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000, - IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000, - - IMAGE_SCN_ALIGN_MASK = 0x00F00000, - - /// - /// Section contains extended relocations. - /// - IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000, - - /// - /// Section can be discarded. - /// - IMAGE_SCN_MEM_DISCARDABLE = 0x02000000, - - /// - /// Section is not cachable. - /// - IMAGE_SCN_MEM_NOT_CACHED = 0x04000000, - - /// - /// Section is not pageable. - /// - IMAGE_SCN_MEM_NOT_PAGED = 0x08000000, - - /// - /// Section is shareable. - /// - IMAGE_SCN_MEM_SHARED = 0x10000000, - - /// - /// Section is executable. - /// - IMAGE_SCN_MEM_EXECUTE = 0x20000000, - - /// - /// Section is readable. - /// - IMAGE_SCN_MEM_READ = 0x40000000, - - /// - /// Section is writeable. - /// - IMAGE_SCN_MEM_WRITE = 0x80000000, - - - /// - /// TLS index is scaled. - /// - IMAGE_SCN_SCALE_INDEX = 0x00000001, - } - -} diff --git a/mcs/class/Mono.PEToolkit/Subsystem.cs b/mcs/class/Mono.PEToolkit/Subsystem.cs deleted file mode 100644 index ea9505249cd76..0000000000000 --- a/mcs/class/Mono.PEToolkit/Subsystem.cs +++ /dev/null @@ -1,132 +0,0 @@ - -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// -/* - * Copyright (c) 2002 Sergey Chaban - */ - -namespace Mono.PEToolkit { - - /// - /// - public enum Subsystem : short { - - /// - /// Unknown subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_UNKNOWN - /// - UNKNOWN = 0, - - /// - /// Image doesn't require a subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_NATIVE - /// - NATIVE = 1, - - /// - /// Image runs in the Windows GUI subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_WINDOWS_GUI - /// - WINDOWS_GUI = 2, - - /// - /// Image runs in the Windows character subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_WINDOWS_CUI - /// - WINDOWS_CUI = 3, - - /// - /// Image runs in the OS/2 character subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_OS2_CUI - /// - OS2_CUI = 5, - - /// - /// Image runs in the Posix character subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_POSIX_CUI - /// - POSIX_CUI = 7, - - /// - /// Image is a native Win9x driver. - /// - /// - /// IMAGE_SUBSYSTEM_NATIVE_WINDOWS - /// - NATIVE_WINDOWS = 8, - - /// - /// Image runs in the Windows CE subsystem. - /// - /// - /// IMAGE_SUBSYSTEM_WINDOWS_CE_GUI - /// - WINDOWS_CE_GUI = 9, - - /// - /// - /// - /// IMAGE_SUBSYSTEM_EFI_APPLICATION - /// - EFI_APPLICATION = 10, - - /// - /// - /// - /// IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER - /// - EFI_BOOT_SERVICE_DRIVER = 11, - - /// - /// - /// - /// IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER - /// - EFI_RUNTIME_DRIVER = 12, - - /// - /// - /// - /// IMAGE_SUBSYSTEM_EFI_ROM - /// - EFI_ROM = 13, - - /// - /// - /// - /// IMAGE_SUBSYSTEM_XBOX - /// - XBOX = 14, - } - -} diff --git a/mcs/class/Mono.PEToolkit/build/ChangeLog b/mcs/class/Mono.PEToolkit/build/ChangeLog deleted file mode 100644 index 2b555b5e2f717..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/ChangeLog +++ /dev/null @@ -1,3 +0,0 @@ -2003-02-17 Jackson Harper - - * mddump.cs: Comment out some stuff that does not need to be seen. diff --git a/mcs/class/Mono.PEToolkit/build/Makefile b/mcs/class/Mono.PEToolkit/build/Makefile deleted file mode 100644 index ac5a05295659e..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -thisdir = class/Mono.PEToolkit/build -SUBDIRS = -include ../../../build/rules.make - -# ok this duplication of the source lists is just wrong. But we can't -# include both library and build/executable.make in one makefile at the -# moment, so... -# -# someday there will be a better way. - -PROGRAM = mddump.exe -LOCAL_MCS_FLAGS = /unsafe - -EXTRA_DISTFILES = \ - ChangeLog \ - srcgen/a.bat \ - srcgen/bitconv-types.xml \ - srcgen/xslt.wsf \ - $(wildcard srcgen/*.xsl) \ - srcgen/data/ilasm.xml \ - srcgen/data/md-schema.xml - -include ../../../build/executable.make diff --git a/mcs/class/Mono.PEToolkit/build/mddump.cs b/mcs/class/Mono.PEToolkit/build/mddump.cs deleted file mode 100644 index 04a4942c9abf3..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/mddump.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.IO; - -using Mono.PEToolkit; -using Mono.PEToolkit.Metadata; - - -public sealed class MDDump { - - private MDDump() {} - - - public static uint Dump (string peFile) - { - using (Image pe = new Image (peFile)) { - pe.Open (); - pe.ReadHeaders (); - - Console.WriteLine (pe); - - if (pe.IsCLI) { - pe.DumpStreamHeader("#~"); - pe.DumpStreamHeader("#-"); - pe.DumpStreamHeader("#Strings"); - pe.DumpStreamHeader("#US"); - pe.DumpStreamHeader("#GUID"); - pe.DumpStreamHeader("#Blob"); - - Console.WriteLine("CLI image detected, dumping metadata tables."); - TablesHeap tabs = pe.MetaDataRoot.TablesHeap; - - foreach (MDTable t in tabs.Tables) { - t.Dump (Console.Out); - } - - /* - MethodIL il = pe.MetaDataRoot.GetMethodBody(1); - Console.WriteLine(il); - il.DumpHexBytecode(Console.Out); - */ - } - - FileStream out_file = new FileStream ("out.dll", FileMode.Create); - BinaryWriter binary_writer = new BinaryWriter (out_file); - pe.WriteHeaders (binary_writer); - out_file.Close (); - } - - return 0; - } - - - - - - public static void Main (string [] args) { - if (args.Length == 0) { - Console.WriteLine ("mddump "); - } else { - Dump (args [0]); - } - } - -} diff --git a/mcs/class/Mono.PEToolkit/build/mddump.exe.sources b/mcs/class/Mono.PEToolkit/build/mddump.exe.sources deleted file mode 100644 index 4fa6cc3a16330..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/mddump.exe.sources +++ /dev/null @@ -1,42 +0,0 @@ -mddump.cs -../BadImageException.cs -../COFFHeader.cs -../Characteristics.cs -../CheckSum.cs -../CorHeader.cs -../DOSHeader.cs -../DataDir.cs -../ExeSignature.cs -../Image.cs -../LEBitConverter.cs -../MachineId.cs -../PEHeader.cs -../PEUtils.cs -../RVA.cs -../Section.cs -../SectionCharacteristics.cs -../Subsystem.cs -../metadata/AssemblyFlags.cs -../metadata/BadMetaDataException.cs -../metadata/CodedTokenId.cs -../metadata/ElementType.cs -../metadata/GUIDHeap.cs -../metadata/MDHeap.cs -../metadata/MDStream.cs -../metadata/MDTable.cs -../metadata/MDToken.cs -../metadata/MDUtils.cs -../metadata/ManifestResourceAttributes.cs -../metadata/MetaDataRoot.cs -../metadata/MethodIL.cs -../metadata/MethodSemanticsAttributes.cs -../metadata/PInvokeAttributes.cs -../metadata/Row.cs -../metadata/Rows.cs -../metadata/StringsHeap.cs -../metadata/TableId.cs -../metadata/Tables.cs -../metadata/TablesHeap.cs -../metadata/TablesHeapBase.cs -../metadata/TabsDecoder.cs -../metadata/TokenType.cs diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/a.bat b/mcs/class/Mono.PEToolkit/build/srcgen/a.bat deleted file mode 100755 index 4a541189bd9fd..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/a.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -set X=cscript //nologo xslt.wsf /inFile:data\md-schema.xml - -: dir /b /on *.cs > common.src -:cscript //nologo xslt.wsf /inFile:bitconv-types.xml /styleFile:bitconverter.xsl - - -%X% /styleFile:table-id.xsl > code\TableId.cs -%X% /styleFile:coded-id.xsl > code\CodedTokenId.cs -%X% /styleFile:elem-type.xsl > code\ElementType.cs -%X% /styleFile:tabs-decoder.xsl > code\TabsDecoder.cs -%X% /styleFile:tabs-base.xsl > code\TablesHeapBase.cs -%X% /styleFile:rows.xsl > code\Rows.cs -%X% /styleFile:tabs.xsl > code\Tables.cs diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/bitconv-types.xml b/mcs/class/Mono.PEToolkit/build/srcgen/bitconv-types.xml deleted file mode 100644 index f8550b38239bb..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/bitconv-types.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/bitconverter.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/bitconverter.xsl deleted file mode 100644 index 5a25e3be717ac..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/bitconverter.xsl +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit bitconverter.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit { - - /// <summary> - /// Little-endian bit converter. - /// </summary> - public sealed class LEBitConverter { - - internal interface IConverter { - - - } - - public static readonly bool Native = System.BitConverter.IsLittleEndian; - - private static readonly IConverter impl = System.BitConverter.IsLittleEndian - ? new LEConverter() as IConverter - : new BEConverter() as IConverter; - - - - - private LEBitConverter() - { - // Never instantiated. - } - - - - - - internal sealed class LEConverter : IConverter { - - } - - internal sealed class BEConverter : IConverter { - - } - - - - - - - } - -} - - - - - - - - - - - ///<summary></summary> - - { - return impl.To - - (val, idx); - } - - - - - ///<summary></summary> - - { - return BitConverter.To - - (val, idx); - } - - - - - ///<summary></summary> - - { - return Swap - - (BitConverter.To - - (val, idx)); - } - - - - - ///<summary></summary> - - { - - *p = x; - byte* bp = (byte*) p; - - - byte b = bp [0]; - bp [0] = bp [1]; - bp [1] = b; - - - byte b = bp [0]; - bp [0] = bp [3]; - bp [3] = b; - b = bp [1]; - bp [1] = bp [2]; - bp [2] = b; - - - byte b = bp [0]; - bp [0] = bp [7]; - bp [7] = b; - b = bp [1]; - bp [1] = bp [6]; - bp [6] = b; - b = bp [2]; - bp [2] = bp [5]; - bp [5] = b; - b = bp [3]; - bp [3] = bp [4]; - bp [4] = b; - - - // Not implemented - - - return *p; - } - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/coded-id.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/coded-id.xsl deleted file mode 100644 index 3f3b3aee5426a..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/coded-id.xsl +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or coded-id.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - public enum CodedTokenId { - -]]> - - - = , - - } - -} - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/data/ilasm.xml b/mcs/class/Mono.PEToolkit/build/srcgen/data/ilasm.xml deleted file mode 100644 index 877ac5540ad71..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/data/ilasm.xml +++ /dev/null @@ -1,549 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/data/md-schema.xml b/mcs/class/Mono.PEToolkit/build/srcgen/data/md-schema.xml deleted file mode 100644 index b36af43ab081e..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/data/md-schema.xml +++ /dev/null @@ -1,589 +0,0 @@ - - - - - - - - - - -
-
- - - -
-
-
- - - -
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - -
-
- - - -
-
-
- - - -
-
-
-
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
-
- - - -
-
-
-
-
- - - - -
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - -
- - - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - - -
- - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - -
- - - - - - - -
- - - - - - - -
- - - - - - - - - - -
- - - - - - - - -
- - - - - - - - -
- - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - -
- - - - - - - - - - - -
- - - - - - - - - - -
- - - - - - - - -
- - - - - - - - - - -
- - - - - - - - - - -
- - - - -
diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/elem-type.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/elem-type.xsl deleted file mode 100644 index 48493493b7973..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/elem-type.xsl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or elem-type.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// Element types. - /// - /// - /// Partition II, 22.1.14 Element Types used in Signatures - /// - public enum ElementType { - -]]> - - - = , - - } - -} - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/gen-utils.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/gen-utils.xsl deleted file mode 100644 index f80f75a322fd7..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/gen-utils.xsl +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - RVA.Size - - - - 4 - - - - - - - + - - - - - - - - - - - - - - - int - - - - MDToken - - - - - - - - - - - - - - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/rows.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/rows.xsl deleted file mode 100644 index 26c9178fedca4..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/rows.xsl +++ /dev/null @@ -1,225 +0,0 @@ - - - - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or rows.xsl if you want to make changes. - -using System; -using System.IO; - -namespace Mono.PEToolkit.Metadata { - - - - /// <summary> - /// Represents row in table. - /// </summary> - /// <remarks> - /// See Partition II, Metadata; section - /// </remarks> - public class Row : Row { - - private MDTable table; - - - public ; - - public Row() - { - } - - public Row(MDTable parent) - { - table = parent; - } - - - /// <summary> - /// Row in table has columns. - /// </summary> - public virtual int NumberOfColumns { - get { - return ; - } - } - - - /// <summary> - /// Logical size of this instance in bytes. - /// </summary> - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// <summary> - /// </summary> - public virtual MDTable Table { - get { - return table; - } - } - - - /// <summary> - /// Logical size of this type of row in bytes. - /// </summary> - unsafe public static int LogicalSize { - get { - return ; - } - } - - - /// <summary> - /// Fills the row from the array of bytes. - /// </summary> - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this. = ; - - offs += - - - - ; - - - } - - - - /// <summary> - /// </summary> - public void Dump(TextWriter writer) { - string dump = String.Format( - - ": {}" + Environment.NewLine - + - , - - - - - (Table == null) ? - - : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [ - ] + "\" (#Strings[0x" + .ToString("X") + "])" - - - "[" + .ToString() + "]" - - - this. - - - , - - ); - writer.WriteLine(dump); - } - - - /// <summary> - /// </summary> - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - -} - - - - - - - - - - - - - - - - LEBitConverter.ToUInt32(buff, offs) - - - - - LEBitConverter.ToInt32(buff, offs) - - - - - TabsDecoder.DecodeToken(CodedTokenId. - - - - , LEBitConverter.ToInt32(buff, offs)) - - - - - - - - - - - buff [offs] - - - LEBitConverter.ToInt16(buff, offs) - - - LEBitConverter.ToUInt16(buff, offs) - - - LEBitConverter.ToInt32(buff, offs) - - - LEBitConverter.ToUInt32(buff, offs) - - - LEBitConverter.ToInt64(buff, offs) - - - LEBitConverter.ToUInt64(buff, offs) - - - /* ERROR! */ - - - - - - - - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/table-id.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/table-id.xsl deleted file mode 100644 index 9d9cdb5e0a823..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/table-id.xsl +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or table-id.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// Identifiers for tables in #~ heap. - /// - /// - /// Partition II, 21.x - /// - public enum TableId { -]]> - - - = , - - - - MAX = , - Count = MAX + 1 - } - -} - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/tabs-base.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/tabs-base.xsl deleted file mode 100644 index e3fa441e8ea05..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/tabs-base.xsl +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs-base.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - public abstract class TablesHeapBase : MDHeap { - - internal TablesHeapBase(MDStream stream) : base(stream) - { - } - - /// - /// Gets or sets bitvector of valid tables (64-bit). - /// - public abstract long Valid {get; set;} - - /// - /// Gets or sets bitvector of sorted tables (64-bit). - /// - public abstract long Sorted {get; set;} - - - // - // Accessors to decode Valid bitvector. - // - -]]> - - - /// <summary> - /// True if heap has table. - /// </summary> - public bool Has { - get { - return (Valid & (1L << )) != 0; - } - set { - long mask = (1L << ); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - - } - -} - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/tabs-decoder.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/tabs-decoder.xsl deleted file mode 100644 index e6c71d4ce589e..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/tabs-decoder.xsl +++ /dev/null @@ -1,255 +0,0 @@ - - - - - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs-decoder.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - public sealed class TabsDecoder { - - private TabsDecoder() - { - } - - - /// - /// - /// - /// - public static MDToken DecodeToken(CodedTokenId id, int data) - { - MDToken res = new MDToken(); - int tag; - int rid; - TokenType tok; - - switch (id) { -]]> - - - case CodedTokenId. : - tag = data & 0x; - rid = (int) ((uint) data >> ); - switch (tag) { - - - - - - - - - - - - case : - tok = TokenType.; - break; - - default : - throw new BadMetaDataException("Invalid coded token for , unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - - - - - - case CodedTokenId. : - res = MDUtils.Max(); - res = res < (1 << (16 - )) ? 2 : 4; - break; - - - - /// - unsafe public static int DecodePhysicalTables(TablesHeap heap, byte [] data, int offs, int [] rows) - { - int rowSize; // expanded row size (all indices are dwords) - int fldSize; // physical field size - int dest; - int nRows; - byte [] buff = null; - int si = heap.StringsIndexSize; - int gi = heap.GUIDIndexSize; - int bi = heap.BlobIndexSize; -]]> - - - - - - - - - - - - - - - - - (heap.StringsIndexSize > 2 ? 1 << 17 : 1) - - - rows [(int) TableId.] - - - - , - - - - - - - - - - - - - - - - RVA.Size - - - - - - si - - - bi - - - gi - - - ERROR: Unknown index - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - if (heap.Has) { - rowSize = ; - nRows = rows [(int) TableId.]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new Table(heap); - - for (int i = nRows; --i >= 0;) { - - - - - - - - - - // , - fldSize = ; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += ; - - } - - tab.FromRawData(buff, 0, nRows); - } - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/tabs.xsl b/mcs/class/Mono.PEToolkit/build/srcgen/tabs.xsl deleted file mode 100644 index 7845be66a486d..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/tabs.xsl +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - public class Table : MDTableBase { - - public Table(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new Row(this); - row.FromRawData(buff, offs); - Add(row); - offs += Row.LogicalSize; - } - } - - - public override string Name { - get { - return ""; - } - } - - public override TableId Id { - get { - return TableId.; - } - } - } - - -} - - - - diff --git a/mcs/class/Mono.PEToolkit/build/srcgen/xslt.wsf b/mcs/class/Mono.PEToolkit/build/srcgen/xslt.wsf deleted file mode 100644 index ea99a085bb937..0000000000000 --- a/mcs/class/Mono.PEToolkit/build/srcgen/xslt.wsf +++ /dev/null @@ -1,231 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/mcs/class/Mono.PEToolkit/metadata/AssemblyFlags.cs b/mcs/class/Mono.PEToolkit/metadata/AssemblyFlags.cs deleted file mode 100644 index 8b0b00d2c0667..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/AssemblyFlags.cs +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Values for AssemblyFlags. - /// - /// - /// See Partition II, 22.1.2 - /// - [Flags] - public enum AssemblyFlags { - /// - /// The assembly reference holds the full (unhashed) public key. - /// - PublicKey = 0x0001, - - /// - /// The assembly is side by side compatible. - /// - SideBySideCompatible = 0x0000, - - /// - /// The assembly cannot execute with other versions - /// if they are executing in the same application domain. - /// - NonSideBySideAppDomain = 0x0010, - - /// - /// The assembly cannot execute with other versions - /// if they are executing in the same process. - /// - NonSideBySideProcess = 0x0020, - - /// - /// The assembly cannot execute with other versions - /// if they are executing on the same machine. - /// - NonSideBySideMachine = 0x0030, - - /// - /// JIT should generate CIL-to-native code map. - /// - EnableJITcompileTracking = 0x8000, - - /// - /// JIT should not generate optimized code. - /// - DisableJITcompileOptimizer = 0x4000, - } - -} diff --git a/mcs/class/Mono.PEToolkit/metadata/BadMetaDataException.cs b/mcs/class/Mono.PEToolkit/metadata/BadMetaDataException.cs deleted file mode 100644 index 16e321f5b7328..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/BadMetaDataException.cs +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - public class BadMetaDataException : Exception { - - public BadMetaDataException() : base() - { - } - - public BadMetaDataException(string msg) : base(msg) - { - } - } - -} diff --git a/mcs/class/Mono.PEToolkit/metadata/ChangeLog b/mcs/class/Mono.PEToolkit/metadata/ChangeLog deleted file mode 100644 index 2d5fc6e4faf4a..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/ChangeLog +++ /dev/null @@ -1,20 +0,0 @@ -2003-03-01 Jackson Harper - - * MDStream.cs: Add methods to write metadata streams - -2003-03-01 Jackson Harper - - * MetaDataRoot.cs: Add method to write Metadata - -2003-02-20 Jackson Harper - - * MDStream.cs: Make Header a class and use a Read method to load it. Because it is no longer - being loaded by a utility method I can lower some accesibility levels. - -2003-02-17 Jackson Harper - - * MDStream.cs: Use PEUtils.GetString instead of new string (byte*) - * Rows.cs: Cast a bunch of enums to int when displaying them otherwise an Exception is thrown., - this is probably a bug but I haven't had time to track it down yet. - * StringHeap.cs: Use PEUtils.GetString instead of new string (byte*) - diff --git a/mcs/class/Mono.PEToolkit/metadata/CodedTokenId.cs b/mcs/class/Mono.PEToolkit/metadata/CodedTokenId.cs deleted file mode 100644 index 381a1ccad0098..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/CodedTokenId.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or coded-id.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - /// - public enum CodedTokenId { - - TypeDefOrRef = 0, - HasConstant = 1, - HasCustomAttribute = 2, - HasFieldMarshal = 3, - HasDeclSecurity = 4, - MemberRefParent = 5, - HasSemantics = 6, - MethodDefOrRef = 7, - MemberForwarded = 8, - Implementation = 9, - CustomAttributeType = 10, - ResolutionScope = 11, - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/ElementType.cs b/mcs/class/Mono.PEToolkit/metadata/ElementType.cs deleted file mode 100644 index c8ac9f6c57adb..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/ElementType.cs +++ /dev/null @@ -1,53 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or elem-type.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// Element types. - /// - /// - /// Partition II, 22.1.14 Element Types used in Signatures - /// - public enum ElementType { - - End = 0x00, - Void = 0x01, - Boolean = 0x02, - Char = 0x03, - I1 = 0x04, - U1 = 0x05, - I2 = 0x06, - U2 = 0x07, - I4 = 0x08, - U4 = 0x09, - I8 = 0x0a, - U8 = 0x0b, - R4 = 0x0c, - R8 = 0x0d, - String = 0x0e, - Ptr = 0x0f, - ByRef = 0x10, - ValueType = 0x11, - Class = 0x12, - Array = 0x14, - TypedByRef = 0x16, - I = 0x18, - U = 0x19, - FnPtr = 0x1b, - Object = 0x1c, - SzArray = 0x1d, - CModReqd = 0x1f, - CModOpt = 0x20, - Internal = 0x21, - Modifier = 0x40, - Sentinel = 0x41, - Pinned = 0x45, - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/GUIDHeap.cs b/mcs/class/Mono.PEToolkit/metadata/GUIDHeap.cs deleted file mode 100644 index d396a740fa706..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/GUIDHeap.cs +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// #GUID heap - /// - /// - /// 23.1.5 - /// - public class GUIDHeap : MDHeap { - - private byte [] data; - - internal GUIDHeap(MDStream stream) : base(stream) - { - } - - unsafe override public void FromRawData(byte [] rawData) - { - data = rawData; - } - - public Guid this [int index] { - get { - if (index + 16 > data.Length) - throw new IndexOutOfRangeException(); - byte [] buff = new byte [16]; - Buffer.BlockCopy(data, index, buff, 0, 16); - return new Guid(buff); - } - } - - } - -} \ No newline at end of file diff --git a/mcs/class/Mono.PEToolkit/metadata/MDHeap.cs b/mcs/class/Mono.PEToolkit/metadata/MDHeap.cs deleted file mode 100644 index 2f25cb51ccb95..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MDHeap.cs +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Base class for all metadata heaps. - /// - public abstract class MDHeap { - - - protected MDStream stream; - - protected MDHeap(MDStream stream) - { - this.stream = stream; - if (stream.RawData != null) { - FromRawData(stream.RawData); - } - } - - public MDStream Stream { - get { - return stream; - } - } - - public abstract void FromRawData(byte [] rawData); - - - /// - /// Heap factory. - /// - /// Base stream. - /// - public static MDHeap Create(MDStream stream) - { - MDHeap res = null; - - switch (stream.Name) { - case "#~" : - case "#-" : - res = new TablesHeap(stream); - break; - case "#Strings" : - res = new StringsHeap(stream); - break; - case "#GUID" : - res = new GUIDHeap(stream); - break; - } - - return res; - } - - } -} diff --git a/mcs/class/Mono.PEToolkit/metadata/MDStream.cs b/mcs/class/Mono.PEToolkit/metadata/MDStream.cs deleted file mode 100644 index 4e4518fa96c0d..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MDStream.cs +++ /dev/null @@ -1,219 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Text; -using System.Collections; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Metadata stream. - /// - public class MDStream { - - /// - /// MetaData stream header as described - /// in ECMA CLI specs, Partition II Metadata, 23.1.2 - /// - protected class Header { - internal uint offs; - internal uint size; - internal string name; - - - public void Read(BinaryReader reader, MDStream stream) - { - offs = reader.ReadUInt32 (); - size = reader.ReadUInt32 (); - - StringBuilder name_builder = new StringBuilder (); - while (true) { - sbyte c = reader.ReadSByte(); - if (c == 0) - break; - name_builder.Append ((char) c); - } - - name = name_builder.ToString (); - if (name.Length == 0) - throw new BadImageException("Invalid stream name."); - - // Round up to dword boundary. - long pos = reader.BaseStream.Position; - if (stream != null) - pos -= stream.Root.filePos; - pos += 3; - pos &= ~3; - if (stream != null) - pos += stream.Root.filePos; - - // Advance file pointer. - reader.BaseStream.Position = pos; - } - - public void Write (BinaryWriter writer, MDStream stream) - { - writer.Write (offs); - writer.Write (size); - - for (int i=0; i - /// Name of the stream. - /// - /// - /// Stored on-disk as a null-terminated ASCII string, - /// rounded up to 4-byte boundary. - /// - public string Name { - get { - return hdr.name; - } - set { - hdr.name = value; - } - } - - public byte [] RawData { - get { - return data; - } - } - - public MetaDataRoot Root { - get { - return root; - } - } - - public MDHeap Heap { - get { - lock (this) { - if (heap == null) InitHeap(); - return heap; - } - } - } - - - /// - /// Reads stream header and body from supplied BinaryReader. - /// - /// - /// Reader must be positioned at the first byte of metadata stream. - /// - /// - unsafe public void Read(BinaryReader reader) - { - hdr.Read(reader, this); - long oldPos = reader.BaseStream.Position; - - // Offset field in the stream header is relataive to - // the start of metadata. - reader.BaseStream.Position = root.filePos + hdr.offs; - data = reader.ReadBytes((int) hdr.size); - - // set reader's position to the first byte after - // stream header. - reader.BaseStream.Position = oldPos; - } - - - public void Write (BinaryWriter writer) - { - hdr.Write (writer, this); - long old_pos = writer.BaseStream.Position; - writer.BaseStream.Position = root.filePos + hdr.offs; - writer.Write (data); - writer.BaseStream.Position = old_pos; - } - - /// - /// Initializes heap for this stream. - /// - protected void InitHeap() - { - heap = MDHeap.Create(this); - } - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Name : {0}" + Environment.NewLine + - "Offset : 0x{1:x8}" + Environment.NewLine + - "Size : 0x{2:x8}" + Environment.NewLine, - hdr.name, hdr.offs, hdr.size - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter (); - Dump(sw); - return sw.ToString(); - } - - } -} diff --git a/mcs/class/Mono.PEToolkit/metadata/MDTable.cs b/mcs/class/Mono.PEToolkit/metadata/MDTable.cs deleted file mode 100644 index 418fcd219b5e9..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MDTable.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Collections; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit.Metadata { - - public interface MDTable { - /// - /// Number of rows in the table. - /// - int NumberOfRows {get;} - - /// - /// Gets ot sets a row in the metadata table. - /// - Row this [int rowNum] {get; set;} - - void Add(Row row); - - void FromRawData(byte [] buff, int offs, int numRows); - - string Name {get;} - - TableId Id {get;} - - MDHeap Heap {get;} - - void Dump(TextWriter writer); - } - - - public abstract class MDTableBase : MDTable { - protected ArrayList rows; // rows storage - protected MDHeap heap; // base heap - - public MDTableBase(MDHeap heap) - { - rows = new ArrayList(); - this.heap = heap; - - if (heap is TablesHeap) { - (heap as TablesHeap).RegisterTable(this); - } - } - - public virtual int NumberOfRows { - get { - return rows.Count; - } - } - - - public virtual Row this [int rowNum] { - get { - if (rowNum < 0) throw new IndexOutOfRangeException("Row[]"); - - // Zero row, special case - if (rowNum == 0) return NullRow.Instance; - return rows [rowNum - 1] as Row; - } - set { - rows.Insert(rowNum, value); - } - } - - public virtual void Add(Row row) - { - rows.Add(row); - } - - public abstract void FromRawData(byte [] buff, int offs, int numRows); - - public abstract string Name {get;} - - public abstract TableId Id {get;} - - public virtual MDHeap Heap { - get { - return heap; - } - } - - public virtual void Dump(TextWriter writer) - { - writer.WriteLine("========================================="); - writer.WriteLine("Table '{0}', id = {1} (0x{2}), rows = {3}", - Name, Id, ((int) Id).ToString("X"), NumberOfRows); - int n = 1; - foreach (Row row in rows) { - writer.WriteLine(); - writer.WriteLine("Row #{0}", n++); - writer.WriteLine("-------------"); - row.Dump(writer); - writer.WriteLine(); - } - } - - } - -} diff --git a/mcs/class/Mono.PEToolkit/metadata/MDToken.cs b/mcs/class/Mono.PEToolkit/metadata/MDToken.cs deleted file mode 100644 index ba4bec4a95463..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MDToken.cs +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.Runtime.InteropServices; - -namespace Mono.PEToolkit.Metadata { - - [StructLayoutAttribute(LayoutKind.Sequential)] - public struct MDToken { - - internal int token; - - /// - /// Creates new token with specified token type and record id. - /// - /// Token type. - /// Record IDentifier. - public MDToken(TokenType type, int rid) - { - token = (int)type | rid; - } - - /// - /// Creates new Nil token of a given type. - /// - /// - public MDToken(TokenType type) : this(type, 0) - { - } - - /// - /// - /// - public MDToken(MDToken tok) : this(tok.Type, tok.RID) - { - } - - - /// - /// Gets or sets metadata token Record IDentifier (RID). - /// - public int RID { - get { - return token & (~(int)TokenType.__mask); - } - set { - token &= (int)TokenType.__mask; - token |= value; - } - } - - /// - /// Gets or sets metadata token type. - /// - public TokenType Type { - get { - return (TokenType) token & (TokenType.__mask); - } - set { - token &= ~(int)TokenType.__mask; - token |= (int)value; - } - } - - /// - /// Returns true if this token is a Nil token (it's RID is 0). - /// - public bool IsNilToken { - get { - return (RID == 0); - } - } - - - /// - /// Returns token value. - /// - /// - public override int GetHashCode () - { - return token; - } - - - - // See Metadata Unmanaged API doc (10.8) - public int Compress(out int len) - { - int res = token; - len = 4; - int rid = this.RID; - - // Make room for type bits. - rid <<= 2; - - TokenType type = this.Type; - - // Token type (table that this token indexes) is encoded - // in the least significant 2 bits: - // TypeDef = 0 - // TypeRef = 1 - // TypeSpec = 2 - // BaseType = 3 - switch (type) { - case TokenType.TypeDef: - break; - case TokenType.TypeRef: - rid |= 1; - break; - case TokenType.TypeSpec: - rid |= 2; - break; - case TokenType.BaseType: - rid |= 3; - break; - default: - // Invalid operation for this type of token. - return res; - } - - len = MDUtils.CompressData(rid, out res); - - return res; - } - - - unsafe public static int Size { - get { - return sizeof (int); - } - } - - public static implicit operator MDToken (uint val) { - MDToken res = new MDToken(); - res.token = (int) val; - return res; - } - - public static implicit operator uint (MDToken tok) { - return (uint)tok.token; - } - - public override string ToString() - { - if (this.token == 0) return "NULL"; - return String.Format("{0}[{1}]", - ((int)Type >> (int)TokenType.__shift <= (int)TableId.MAX) - ? ((TableId)((int)Type >> (int)TokenType.__shift)).ToString() - : Type.ToString(), RID); - //String.Format ("type = {0}, RID = {1}", Type, RID); - } - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/MDUtils.cs b/mcs/class/Mono.PEToolkit/metadata/MDUtils.cs deleted file mode 100644 index 6f11aa551a1f0..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MDUtils.cs +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -//using System.Runtime.InteropServices; - -namespace Mono.PEToolkit.Metadata { - - public sealed class MDUtils { - - // Holds true if machine is little-endian. - private static bool isLE; - - static MDUtils() - { - isLE = BitConverter.IsLittleEndian; - } - - private MDUtils() - { - } - - - public static int CompressData(int data, out int res) - { - res = data; - int len = 4; - - if (data < 0) { - // data is actually unsigned, - // that's why this empty clause is needed. - } else if (data < 0x80) { - res = data; - len = 1; - } else if (data < 0x4000) { - res = ((data >> 8) | 0x80) + ((data & 0xFF) << 8); - len = 2; - } else if (data < 0x1FFFFFFF) { - res = ((data >> 24) | 0xC0) | - (((data >> 16) & 0xFF) << 8) | - (((data >> 8) & 0xFF) << 16) | - ((data & 0xFF) << 24); - len = 4; - } - - return len; - } - - unsafe public static int CompressData(void* pData, void* pRes) - { - byte* p = (byte*) pData; - - int data = (isLE) - ? *(int*)p - : p [0] + (p [1] << 8) + (p [2] << 16) + (p [3] << 24); - - int res = 0; - int len = CompressData(data, out res); - p = (byte*) pRes; - - if (isLE) { - *(int*)p = res; - } else { - *p++ = (byte) (res & 0xFF); - *p++ = (byte) (res >> 8); - *p++ = (byte) (res >> 16); - *p++ = (byte) (res >> 24); - } - return len; - } - - - public static int Max(params int [] list) - { - int len = (list != null) ? list.Length : 0; - if (len == 0) return 0; - int max = list [0]; - for (int i = 1; i < len; i++) { - if (list [i] > max) max = list [i]; - } - return max; - } - - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/ManifestResourceAttributes.cs b/mcs/class/Mono.PEToolkit/metadata/ManifestResourceAttributes.cs deleted file mode 100644 index 3e6a099e416b8..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/ManifestResourceAttributes.cs +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Flags for ManifestResource. - /// - /// - /// See Partition II, 22.1.8 - /// - [Flags] - public enum ManifestResourceAttributes { - VisibilityMask = 0x0007, - - /// - /// The Resource is exported from the Assembly. - /// - Public = 0x0001, - - /// - /// The Resource is private to the Assembly. - /// - Private = 0x0002, - } -} diff --git a/mcs/class/Mono.PEToolkit/metadata/MetaDataRoot.cs b/mcs/class/Mono.PEToolkit/metadata/MetaDataRoot.cs deleted file mode 100644 index a0fd69d165d46..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MetaDataRoot.cs +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Text; -using System.Collections; - -namespace Mono.PEToolkit.Metadata { - - public class MetaDataRoot { - - /// - /// "BSJB" signature. - /// - public static readonly uint Sig = 0x424A5342; - - // Metadata Root header, see 23.1.1 - internal uint sig; - internal short majVer; // currently 1 - internal short minVer; // currently 1 - internal uint reserved; - internal int len; - internal string verStr; - internal short flags; - internal short nStreams; - - - // Instance data - - internal Hashtable streams; - - // file position of the first byte of the header - internal long filePos; - - private int strIdx; - private int guidIdx; - private int blobIdx; - - internal Image img; - - - public MetaDataRoot(Image img) - { - this.img = img; - } - - public Hashtable Streams { - get { - // never return null - if (streams == null) streams = new Hashtable(); - return streams; - } - } - - - public uint Signature { - get { - return sig; - } - } - - public string Version { - get { - return String.Format("{0}.{1}", majVer, minVer); - } - } - - public string VersionString { - get { - return verStr; - } - set { - verStr = value; - len = value.Length; - } - } - - - - public int StringsIndexSize { - get { - return strIdx; - } - } - - public int GUIDIndexSize { - get { - return guidIdx; - } - } - - public int BlobIndexSize { - get { - return blobIdx; - } - } - - - unsafe public void Read(BinaryReader reader) - { - filePos = reader.BaseStream.Position; - - sig = reader.ReadUInt32(); - if (sig != Sig) { - throw new BadImageException("Invalid MetaData Signature."); - } - - majVer = reader.ReadInt16(); - minVer = reader.ReadInt16(); - reserved = reader.ReadUInt32(); - - // Length of version string. - len = reader.ReadInt32(); - - // Read version string. - if (len != 0) { - sbyte* pVer = stackalloc sbyte [len]; - sbyte* p = pVer; - - long pos = reader.BaseStream.Position; - int i; - for (i = len; --i >= 0;) { - sbyte c = reader.ReadSByte(); - if (c == 0) break; - *p++ = c; - } - - verStr = PEUtils.GetString (pVer, 0, len-i-1, Encoding.UTF8); - - // Round up to dword boundary, relative to header start. - pos += len; - pos -= filePos; - pos += 3; - pos &= ~3; - pos += filePos; - - // Advance file pointer. - reader.BaseStream.Position = pos; - } else { - VersionString = String.Empty; - } - - flags = reader.ReadInt16(); - nStreams = reader.ReadInt16(); - streams = new Hashtable(nStreams); - - // load all streams into memory - for (int i = nStreams; --i >=0;) { - MDStream s = new MDStream(this); - s.Read(reader); - // TODO: check for duplicated streams, - // use Add instead of indexer. - streams[s.Name] = s; - } - - MDStream tabs = Streams["#~"] as MDStream; - // Try uncompressed stream. - if (tabs == null) tabs = Streams["#-"] as MDStream; - if (tabs == null) throw new BadMetaDataException("Missing #~ stream."); - - TablesHeap tabsHeap = tabs.Heap as TablesHeap; - // cache index sizes - strIdx = tabsHeap.StringsIndexSize; - guidIdx = tabsHeap.GUIDIndexSize; - blobIdx = tabsHeap.BlobIndexSize; - } - - public void Write (BinaryWriter writer) - { - filePos = writer.BaseStream.Position; - - writer.Write (Sig); - - writer.Write (majVer); - writer.Write (minVer); - writer.Write (reserved); - - // Length of version string - writer.Write (verStr.Length); - - if (verStr.Length > 0) { - long pos = writer.BaseStream.Position; - for (int i=0; i - */ - -using System; -using System.IO; - -namespace Mono.PEToolkit.Metadata { - - /// - /// See Partition II - /// 24.4 Common Intermediate Language Physical Layout - /// - public class MethodIL { - - public enum Format { - // CorILMethod_TinyFormat, 24.4.2 - Tiny = 2, - // CorILMethod_FatFormat, 24.4.3 - Fat = 3, - - // encoded in 3 bits - Shift = 3, - Mask = 0x7 - } - - public enum Flags { - TinyFormat = MethodIL.Format.Tiny, - FatFormat = MethodIL.Format.Fat, - MoreSections = 0x8, - InitLocals = 0x10 - } - - internal int fatFlags; - internal int maxStack; - - internal byte[] bytecode; - - public MethodIL() - { - fatFlags = 0; - maxStack = 0; - } - - public byte [] ByteCode { - get { - return bytecode; - } - } - - public int CodeSize { - get { - return (bytecode != null) - ? bytecode.Length : 0; - } - } - - public int MaxStack { - get { - return maxStack; - } - set { - maxStack = value; - } - } - - public bool InitLocals { - get { - return (fatFlags & (int)Flags.InitLocals) != 0; - } - } - - public bool HasMoreSections { - get { - return (fatFlags & (int)Flags.MoreSections) != 0; - } - } - - internal static bool IsMethodTiny(int flags) - { - return ((Format)(flags & ((int)Format.Mask >> 1)) == Format.Tiny); - } - - public void Read(BinaryReader reader) - { - fatFlags = 0; - int codeSize; - bytecode = null; - int data = reader.ReadByte(); - if (IsMethodTiny(data)) { - codeSize = data >> ((int)Format.Shift - 1); - maxStack = 0; // no locals - bytecode = reader.ReadBytes(codeSize); - } else { - long headPos = reader.BaseStream.Position - 1; - fatFlags = data | (reader.ReadByte() << 8); - // first 12 bits are flags - // next 4 bits is the - // "size of this header expressed as the count - // of 4-byte integers occupied" - int headSize = ((fatFlags >> 12) & 0xF) << 2; - fatFlags &= 0xFFF; - maxStack = reader.ReadInt16(); - codeSize = reader.ReadInt32(); - int localTok = reader.ReadInt32(); - reader.BaseStream.Position = headPos + headSize; - bytecode = reader.ReadBytes(codeSize); - } - } - - public virtual void Dump(TextWriter writer) - { - string dump = String.Format( - "Code size : {0:x4}" + Environment.NewLine + - "MaxStack : {1:x4}" + Environment.NewLine + - "InitLocals : {2}" + Environment.NewLine + - "MoreSections : {3}" + Environment.NewLine, - CodeSize, MaxStack, InitLocals, HasMoreSections - ); - writer.Write(dump); - } - - public void DumpHexBytecode(TextWriter w) - { - int n = CodeSize >> 3; - int i = 0; - for (int x = n; --x >= 0; i += 8) { - w.WriteLine( - String.Format("{0:x2} {1:x2} {2:x2} {3:x2} {4:x2} {5:x2} {6:x2} {7:x2}", - ByteCode[i], ByteCode[i + 1], ByteCode[i + 2], ByteCode[i + 3], - ByteCode[i + 4], ByteCode[i + 5], ByteCode[i + 6], ByteCode[i + 7] - ) - ); - } - for (;i < CodeSize; i++) { - w.Write("{0:x2} ", ByteCode[i]); - } - w.WriteLine(); - } - - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - } -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/MethodSemanticsAttributes.cs b/mcs/class/Mono.PEToolkit/metadata/MethodSemanticsAttributes.cs deleted file mode 100644 index 95b2d033add76..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/MethodSemanticsAttributes.cs +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Flags for MethodSemantics. - /// - /// - /// See Partiotion II, 22.1.10 - /// - [Flags] - public enum MethodSemanticsAttributes { - Setter = 0x0001, - Getter = 0x0002, - Other = 0x0004, - AddOn = 0x0008, - RemoveOn = 0x0010, - Fire = 0x0020, - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/PInvokeAttributes.cs b/mcs/class/Mono.PEToolkit/metadata/PInvokeAttributes.cs deleted file mode 100644 index eff8a6f808b7d..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/PInvokeAttributes.cs +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Flags for ImplMap. - /// - /// - /// See Partition II, 22.1.7; - /// This is similar to PInvokeMap enum found - /// in older XML library spec (all.xml). - /// - [Flags] - public enum PInvokeAttributes { - /// - /// PInvoke is to use the member name as specified. - /// - NoMangle = 0x0001, - - /// - /// - CharSetMask = 0x0006, - /// - /// - CharSetNotSpec = 0x0000, - /// - /// - CharSetAnsi = 0x0002, // specs: CharSetAns - /// - /// - CharSetUnicode = 0x0004, - /// - /// - CharSetAuto = 0x0006, - - CallConvMask = 0x0700, - CallConvWinapi = 0x0100, - CallConvCdecl = 0x0200, - CallConvStdcall = 0x0300, - CallConvThiscall = 0x0400, - CallConvFastcall = 0x0500, - - PinvokeOLE = 0x0020, // as reported by verifier, not in specs - // also value from all.xml - - SupportsLastError = 0x0040, - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/Row.cs b/mcs/class/Mono.PEToolkit/metadata/Row.cs deleted file mode 100644 index 4716cbfd080dd..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/Row.cs +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Metadata row interface. - /// - public interface Row { - - /// - /// Number of colums in a row. - /// - int NumberOfColumns {get;} - - int Size {get;} - - /// - /// Returns reference to parent table or null. - /// - MDTable Table {get;} - - void FromRawData(byte [] buff, int offs); - - void Dump(TextWriter writer); - - } - - - public sealed class NullRow : Row { - public static readonly NullRow Instance; - - static NullRow() - { - Instance = new NullRow(); - } - - private NullRow() - { - } - - public int NumberOfColumns { - get { - return 0; - } - } - - public int Size { - get { - return 0; - } - } - - public MDTable Table { - get { - return null; - } - } - - public void FromRawData(byte [] buff, int offs) - { - } - - public void Dump(TextWriter writer) - { - writer.WriteLine("Null row."); - } - } - -} diff --git a/mcs/class/Mono.PEToolkit/metadata/Rows.cs b/mcs/class/Mono.PEToolkit/metadata/Rows.cs deleted file mode 100644 index 7853f118f7c13..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/Rows.cs +++ /dev/null @@ -1,4887 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or rows.xsl if you want to make changes. - -using System; -using System.IO; - -namespace Mono.PEToolkit.Metadata { - - - - /// - /// Represents row in Module table. - /// - /// - /// See Partition II, Metadata; section 21.27 - /// - public class ModuleRow : Row { - - private MDTable table; - - - public ushort Generation; - public int Name; - public int Mvid; - public int EncId; - public int EncBaseId; - - public ModuleRow() - { - } - - public ModuleRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Module table has 5 columns. - /// - public virtual int NumberOfColumns { - get { - return 5; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Generation = LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Mvid = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.EncId = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.EncBaseId = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Generation : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Mvid : {2}" + Environment.NewLine + - "EncId : {3}" + Environment.NewLine + - "EncBaseId : {4}" + Environment.NewLine, - this.Generation, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#GUID[" + Mvid.ToString() + "]", - "#GUID[" + EncId.ToString() + "]", - "#GUID[" + EncBaseId.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in TypeRef table. - /// - /// - /// See Partition II, Metadata; section 21.35 - /// - public class TypeRefRow : Row { - - private MDTable table; - - - public MDToken ResolutionScope; - public int Name; - public int Namespace; - - public TypeRefRow() - { - } - - public TypeRefRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in TypeRef table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.ResolutionScope = TabsDecoder.DecodeToken(CodedTokenId.ResolutionScope, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Namespace = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "ResolutionScope : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Namespace : {2}" + Environment.NewLine, - this.ResolutionScope, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - (Table == null) ? Namespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Namespace] + "\" (#Strings[0x" + Namespace.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in TypeDef table. - /// - /// - /// See Partition II, Metadata; section 21.34 - /// - public class TypeDefRow : Row { - - private MDTable table; - - - public System.Reflection.TypeAttributes Flags; - public int Name; - public int Namespace; - public MDToken Extends; - public int FieldList; - public int MethodList; - - public TypeDefRow() - { - } - - public TypeDefRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in TypeDef table has 6 columns. - /// - public virtual int NumberOfColumns { - get { - return 6; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (uint) + 4 + 4 + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.Reflection.TypeAttributes) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Namespace = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Extends = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.FieldList = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.MethodList = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Namespace : {2}" + Environment.NewLine + - "Extends : {3}" + Environment.NewLine + - "FieldList : {4}" + Environment.NewLine + - "MethodList : {5}" + Environment.NewLine, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - (Table == null) ? Namespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Namespace] + "\" (#Strings[0x" + Namespace.ToString("X") + "])", - this.Extends, - "Field[" + FieldList.ToString() + "]", - "Method[" + MethodList.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in FieldPtr table. - /// - /// - /// - /// - public class FieldPtrRow : Row { - - private MDTable table; - - - public int Field; - - public FieldPtrRow() - { - } - - public FieldPtrRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in FieldPtr table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Field = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Field : {0}" + Environment.NewLine, - "Field[" + Field.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Field table. - /// - /// - /// See Partition II, Metadata; section 21.15 - /// - public class FieldRow : Row { - - private MDTable table; - - - public System.Reflection.FieldAttributes Flags; - public int Name; - public int Signature; - - public FieldRow() - { - } - - public FieldRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Field table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.Reflection.FieldAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Signature = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Signature : {2}" + Environment.NewLine, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#Blob[" + Signature.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in MethodPtr table. - /// - /// - /// - /// - public class MethodPtrRow : Row { - - private MDTable table; - - - public int Method; - - public MethodPtrRow() - { - } - - public MethodPtrRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in MethodPtr table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Method = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Method : {0}" + Environment.NewLine, - "Method[" + Method.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Method table. - /// - /// - /// See Partition II, Metadata; section 21.24 - /// - public class MethodRow : Row { - - private MDTable table; - - - public RVA RVA; - public System.Reflection.MethodImplAttributes ImplFlags; - public System.Reflection.MethodAttributes Flags; - public int Name; - public int Signature; - public int ParamList; - - public MethodRow() - { - } - - public MethodRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Method table has 6 columns. - /// - public virtual int NumberOfColumns { - get { - return 6; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return RVA.Size + sizeof (ushort) + sizeof (ushort) + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.RVA = LEBitConverter.ToUInt32(buff, offs); - offs += RVA.Size; - this.ImplFlags = (System.Reflection.MethodImplAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Flags = (System.Reflection.MethodAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Signature = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.ParamList = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "RVA : {0}" + Environment.NewLine + - "ImplFlags : {1}" + Environment.NewLine + - "Flags : {2}" + Environment.NewLine + - "Name : {3}" + Environment.NewLine + - "Signature : {4}" + Environment.NewLine + - "ParamList : {5}" + Environment.NewLine, - this.RVA, - this.ImplFlags, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#Blob[" + Signature.ToString() + "]", - "Param[" + ParamList.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ParamPtr table. - /// - /// - /// - /// - public class ParamPtrRow : Row { - - private MDTable table; - - - public int Param; - - public ParamPtrRow() - { - } - - public ParamPtrRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ParamPtr table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Param = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Param : {0}" + Environment.NewLine, - "Param[" + Param.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Param table. - /// - /// - /// See Partition II, Metadata; section 21.30 - /// - public class ParamRow : Row { - - private MDTable table; - - - public System.Reflection.ParameterAttributes Flags; - public ushort Sequence; - public int Name; - - public ParamRow() - { - } - - public ParamRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Param table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + sizeof (ushort) + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.Reflection.ParameterAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Sequence = LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Name = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "Sequence : {1}" + Environment.NewLine + - "Name : {2}" + Environment.NewLine, - (int)this.Flags, - this.Sequence, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in InterfaceImpl table. - /// - /// - /// See Partition II, Metadata; section 21.21 - /// - public class InterfaceImplRow : Row { - - private MDTable table; - - - public int Class; - public MDToken Interface; - - public InterfaceImplRow() - { - } - - public InterfaceImplRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in InterfaceImpl table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Class = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Interface = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Class : {0}" + Environment.NewLine + - "Interface : {1}" + Environment.NewLine, - "TypeDef[" + Class.ToString() + "]", - this.Interface - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in MemberRef table. - /// - /// - /// See Partition II, Metadata; section 21.23 - /// - public class MemberRefRow : Row { - - private MDTable table; - - - public MDToken Class; - public int Name; - public int Signature; - - public MemberRefRow() - { - } - - public MemberRefRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in MemberRef table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Class = TabsDecoder.DecodeToken(CodedTokenId.MemberRefParent, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Signature = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Class : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Signature : {2}" + Environment.NewLine, - this.Class, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#Blob[" + Signature.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Constant table. - /// - /// - /// See Partition II, Metadata; section 21.9 - /// - public class ConstantRow : Row { - - private MDTable table; - - - public ElementType Type; - public MDToken Parent; - public int Value; - - public ConstantRow() - { - } - - public ConstantRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Constant table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (short) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Type = (ElementType) LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasConstant, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Value = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Type : {0}" + Environment.NewLine + - "Parent : {1}" + Environment.NewLine + - "Value : {2}" + Environment.NewLine, - this.Type, - this.Parent, - "#Blob[" + Value.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in CustomAttribute table. - /// - /// - /// See Partition II, Metadata; section 21.10 - /// - public class CustomAttributeRow : Row { - - private MDTable table; - - - public MDToken Parent; - public MDToken Type; - public int Value; - - public CustomAttributeRow() - { - } - - public CustomAttributeRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in CustomAttribute table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasCustomAttribute, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Type = TabsDecoder.DecodeToken(CodedTokenId.CustomAttributeType, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Value = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Parent : {0}" + Environment.NewLine + - "Type : {1}" + Environment.NewLine + - "Value : {2}" + Environment.NewLine, - this.Parent, - this.Type, - "#Blob[" + Value.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in FieldMarshal table. - /// - /// - /// See Partition II, Metadata; section 21.17 - /// - public class FieldMarshalRow : Row { - - private MDTable table; - - - public MDToken Parent; - public int NativeType; - - public FieldMarshalRow() - { - } - - public FieldMarshalRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in FieldMarshal table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasFieldMarshal, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.NativeType = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Parent : {0}" + Environment.NewLine + - "NativeType : {1}" + Environment.NewLine, - this.Parent, - "#Blob[" + NativeType.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in DeclSecurity table. - /// - /// - /// See Partition II, Metadata; section 21.11 - /// - public class DeclSecurityRow : Row { - - private MDTable table; - - - public short Action; - public MDToken Parent; - public int PermissionSet; - - public DeclSecurityRow() - { - } - - public DeclSecurityRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in DeclSecurity table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (short) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Action = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.Parent = TabsDecoder.DecodeToken(CodedTokenId.HasDeclSecurity, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.PermissionSet = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Action : {0}" + Environment.NewLine + - "Parent : {1}" + Environment.NewLine + - "PermissionSet : {2}" + Environment.NewLine, - this.Action, - this.Parent, - "#Blob[" + PermissionSet.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ClassLayout table. - /// - /// - /// See Partition II, Metadata; section 21.8 - /// - public class ClassLayoutRow : Row { - - private MDTable table; - - - public short PackingSize; - public int ClassSize; - public int Parent; - - public ClassLayoutRow() - { - } - - public ClassLayoutRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ClassLayout table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (short) + sizeof (int) + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.PackingSize = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.ClassSize = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.Parent = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "PackingSize : {0}" + Environment.NewLine + - "ClassSize : {1}" + Environment.NewLine + - "Parent : {2}" + Environment.NewLine, - this.PackingSize, - this.ClassSize, - "TypeDef[" + Parent.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in FieldLayout table. - /// - /// - /// See Partition II, Metadata; section 21.16 - /// - public class FieldLayoutRow : Row { - - private MDTable table; - - - public int Offset; - public int Field; - - public FieldLayoutRow() - { - } - - public FieldLayoutRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in FieldLayout table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Offset = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.Field = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Offset : {0}" + Environment.NewLine + - "Field : {1}" + Environment.NewLine, - this.Offset, - "Field[" + Field.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in StandAloneSig table. - /// - /// - /// See Partition II, Metadata; section 21.33 - /// - public class StandAloneSigRow : Row { - - private MDTable table; - - - public int Signature; - - public StandAloneSigRow() - { - } - - public StandAloneSigRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in StandAloneSig table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Signature = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Signature : {0}" + Environment.NewLine, - "#Blob[" + Signature.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in EventMap table. - /// - /// - /// See Partition II, Metadata; section 21.12 - /// - public class EventMapRow : Row { - - private MDTable table; - - - public int Parent; - public int EventList; - - public EventMapRow() - { - } - - public EventMapRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in EventMap table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Parent = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.EventList = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Parent : {0}" + Environment.NewLine + - "EventList : {1}" + Environment.NewLine, - "TypeDef[" + Parent.ToString() + "]", - "Event[" + EventList.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in EventPtr table. - /// - /// - /// - /// - public class EventPtrRow : Row { - - private MDTable table; - - - public int Event; - - public EventPtrRow() - { - } - - public EventPtrRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in EventPtr table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Event = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Event : {0}" + Environment.NewLine, - "Event[" + Event.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Event table. - /// - /// - /// See Partition II, Metadata; section 21.13 - /// - public class EventRow : Row { - - private MDTable table; - - - public System.Reflection.EventAttributes EventFlags; - public int Name; - public MDToken EventType; - - public EventRow() - { - } - - public EventRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Event table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (short) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.EventFlags = (System.Reflection.EventAttributes) LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.EventType = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "EventFlags : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "EventType : {2}" + Environment.NewLine, - this.EventFlags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - this.EventType - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in PropertyMap table. - /// - /// - /// See Partition II, Metadata; section 21.32 - /// - public class PropertyMapRow : Row { - - private MDTable table; - - - public int Parent; - public int PropertyList; - - public PropertyMapRow() - { - } - - public PropertyMapRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in PropertyMap table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Parent = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.PropertyList = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Parent : {0}" + Environment.NewLine + - "PropertyList : {1}" + Environment.NewLine, - "TypeDef[" + Parent.ToString() + "]", - "Property[" + PropertyList.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in PropertyPtr table. - /// - /// - /// - /// - public class PropertyPtrRow : Row { - - private MDTable table; - - - public int Property; - - public PropertyPtrRow() - { - } - - public PropertyPtrRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in PropertyPtr table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Property = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Property : {0}" + Environment.NewLine, - "Property[" + Property.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Property table. - /// - /// - /// See Partition II, Metadata; section 21.30 - /// - public class PropertyRow : Row { - - private MDTable table; - - - public System.Reflection.PropertyAttributes Flags; - public int Name; - public int Type; - - public PropertyRow() - { - } - - public PropertyRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Property table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.Reflection.PropertyAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Type = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "Type : {2}" + Environment.NewLine, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#Blob[" + Type.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in MethodSemantics table. - /// - /// - /// See Partition II, Metadata; section 21.26 - /// - public class MethodSemanticsRow : Row { - - private MDTable table; - - - public MethodSemanticsAttributes Semantics; - public int Method; - public MDToken Association; - - public MethodSemanticsRow() - { - } - - public MethodSemanticsRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in MethodSemantics table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Semantics = (MethodSemanticsAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Method = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Association = TabsDecoder.DecodeToken(CodedTokenId.HasSemantics, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Semantics : {0}" + Environment.NewLine + - "Method : {1}" + Environment.NewLine + - "Association : {2}" + Environment.NewLine, - (int)this.Semantics, - "Method[" + Method.ToString() + "]", - this.Association - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in MethodImpl table. - /// - /// - /// See Partition II, Metadata; section 21.25 - /// - public class MethodImplRow : Row { - - private MDTable table; - - - public int Class; - public MDToken MethodBody; - public MDToken MethodDeclaration; - - public MethodImplRow() - { - } - - public MethodImplRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in MethodImpl table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Class = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.MethodBody = TabsDecoder.DecodeToken(CodedTokenId.MethodDefOrRef, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.MethodDeclaration = TabsDecoder.DecodeToken(CodedTokenId.MethodDefOrRef, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Class : {0}" + Environment.NewLine + - "MethodBody : {1}" + Environment.NewLine + - "MethodDeclaration : {2}" + Environment.NewLine, - "TypeDef[" + Class.ToString() + "]", - this.MethodBody, - this.MethodDeclaration - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ModuleRef table. - /// - /// - /// See Partition II, Metadata; section 21.28 - /// - public class ModuleRefRow : Row { - - private MDTable table; - - - public int Name; - - public ModuleRefRow() - { - } - - public ModuleRefRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ModuleRef table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Name = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Name : {0}" + Environment.NewLine, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in TypeSpec table. - /// - /// - /// See Partition II, Metadata; section 21.36 - /// - public class TypeSpecRow : Row { - - private MDTable table; - - - public int Signature; - - public TypeSpecRow() - { - } - - public TypeSpecRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in TypeSpec table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Signature = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Signature : {0}" + Environment.NewLine, - "#Blob[" + Signature.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ImplMap table. - /// - /// - /// See Partition II, Metadata; section 21.20 - /// - public class ImplMapRow : Row { - - private MDTable table; - - - public PInvokeAttributes MappingFlags; - public MDToken MemberForwarded; - public int ImportName; - public int ImportScope; - - public ImplMapRow() - { - } - - public ImplMapRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ImplMap table has 4 columns. - /// - public virtual int NumberOfColumns { - get { - return 4; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.MappingFlags = (PInvokeAttributes) LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.MemberForwarded = TabsDecoder.DecodeToken(CodedTokenId.MemberForwarded, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.ImportName = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.ImportScope = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "MappingFlags : {0}" + Environment.NewLine + - "MemberForwarded : {1}" + Environment.NewLine + - "ImportName : {2}" + Environment.NewLine + - "ImportScope : {3}" + Environment.NewLine, - this.MappingFlags, - this.MemberForwarded, - (Table == null) ? ImportName.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [ImportName] + "\" (#Strings[0x" + ImportName.ToString("X") + "])", - "ModuleRef[" + ImportScope.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in FieldRVA table. - /// - /// - /// See Partition II, Metadata; section 21.18 - /// - public class FieldRVARow : Row { - - private MDTable table; - - - public RVA RVA; - public int Field; - - public FieldRVARow() - { - } - - public FieldRVARow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in FieldRVA table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return RVA.Size + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.RVA = LEBitConverter.ToUInt32(buff, offs); - offs += RVA.Size; - this.Field = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "RVA : {0}" + Environment.NewLine + - "Field : {1}" + Environment.NewLine, - this.RVA, - "Field[" + Field.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ENCLog table. - /// - /// - /// - /// - public class ENCLogRow : Row { - - private MDTable table; - - - public uint Token; - public uint FuncCode; - - public ENCLogRow() - { - } - - public ENCLogRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ENCLog table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (uint) + sizeof (uint); - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Token = LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.FuncCode = LEBitConverter.ToUInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Token : {0}" + Environment.NewLine + - "FuncCode : {1}" + Environment.NewLine, - this.Token, - this.FuncCode - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ENCMap table. - /// - /// - /// - /// - public class ENCMapRow : Row { - - private MDTable table; - - - public uint Token; - - public ENCMapRow() - { - } - - public ENCMapRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ENCMap table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (uint); - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Token = LEBitConverter.ToUInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Token : {0}" + Environment.NewLine, - this.Token - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in Assembly table. - /// - /// - /// See Partition II, Metadata; section 21.2 - /// - public class AssemblyRow : Row { - - private MDTable table; - - - public System.Configuration.Assemblies.AssemblyHashAlgorithm HashAlgId; - public short MajorVersion; - public short MinorVersion; - public short BuildNumber; - public short RevisionNumber; - public AssemblyFlags Flags; - public int PublicKey; - public int Name; - public int Culture; - - public AssemblyRow() - { - } - - public AssemblyRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in Assembly table has 9 columns. - /// - public virtual int NumberOfColumns { - get { - return 9; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.HashAlgId = (System.Configuration.Assemblies.AssemblyHashAlgorithm) LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.MajorVersion = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.MinorVersion = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.BuildNumber = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.RevisionNumber = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.Flags = (AssemblyFlags) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.PublicKey = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Culture = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "HashAlgId : {0}" + Environment.NewLine + - "MajorVersion : {1}" + Environment.NewLine + - "MinorVersion : {2}" + Environment.NewLine + - "BuildNumber : {3}" + Environment.NewLine + - "RevisionNumber : {4}" + Environment.NewLine + - "Flags : {5}" + Environment.NewLine + - "PublicKey : {6}" + Environment.NewLine + - "Name : {7}" + Environment.NewLine + - "Culture : {8}" + Environment.NewLine, - this.HashAlgId, - this.MajorVersion, - this.MinorVersion, - this.BuildNumber, - this.RevisionNumber, - (int)this.Flags, - "#Blob[" + PublicKey.ToString() + "]", - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - (Table == null) ? Culture.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Culture] + "\" (#Strings[0x" + Culture.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in AssemblyProcessor table. - /// - /// - /// See Partition II, Metadata; section 21.4 - /// - public class AssemblyProcessorRow : Row { - - private MDTable table; - - - public int Processor; - - public AssemblyProcessorRow() - { - } - - public AssemblyProcessorRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in AssemblyProcessor table has 1 columns. - /// - public virtual int NumberOfColumns { - get { - return 1; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int); - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Processor = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Processor : {0}" + Environment.NewLine, - this.Processor - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in AssemblyOS table. - /// - /// - /// See Partition II, Metadata; section 21.3 - /// - public class AssemblyOSRow : Row { - - private MDTable table; - - - public int OSPlatformID; - public int OSMajorVersion; - public int OSMinorVersion; - - public AssemblyOSRow() - { - } - - public AssemblyOSRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in AssemblyOS table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + sizeof (int) + sizeof (int); - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.OSPlatformID = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.OSMajorVersion = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.OSMinorVersion = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "OSPlatformID : {0}" + Environment.NewLine + - "OSMajorVersion : {1}" + Environment.NewLine + - "OSMinorVersion : {2}" + Environment.NewLine, - this.OSPlatformID, - this.OSMajorVersion, - this.OSMinorVersion - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in AssemblyRef table. - /// - /// - /// See Partition II, Metadata; section 21.5 - /// - public class AssemblyRefRow : Row { - - private MDTable table; - - - public short MajorVersion; - public short MinorVersion; - public short BuildNumber; - public short RevisionNumber; - public AssemblyFlags Flags; - public int PublicKeyOrToken; - public int Name; - public int Culture; - public int HashValue; - - public AssemblyRefRow() - { - } - - public AssemblyRefRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in AssemblyRef table has 9 columns. - /// - public virtual int NumberOfColumns { - get { - return 9; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.MajorVersion = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.MinorVersion = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.BuildNumber = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.RevisionNumber = LEBitConverter.ToInt16(buff, offs); - offs += sizeof (short); - this.Flags = (AssemblyFlags) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.PublicKeyOrToken = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Culture = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.HashValue = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "MajorVersion : {0}" + Environment.NewLine + - "MinorVersion : {1}" + Environment.NewLine + - "BuildNumber : {2}" + Environment.NewLine + - "RevisionNumber : {3}" + Environment.NewLine + - "Flags : {4}" + Environment.NewLine + - "PublicKeyOrToken : {5}" + Environment.NewLine + - "Name : {6}" + Environment.NewLine + - "Culture : {7}" + Environment.NewLine + - "HashValue : {8}" + Environment.NewLine, - this.MajorVersion, - this.MinorVersion, - this.BuildNumber, - this.RevisionNumber, - (int)this.Flags, - "#Blob[" + PublicKeyOrToken.ToString() + "]", - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - (Table == null) ? Culture.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Culture] + "\" (#Strings[0x" + Culture.ToString("X") + "])", - "#Blob[" + HashValue.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in AssemblyRefProcessor table. - /// - /// - /// See Partition II, Metadata; section 21.7 - /// - public class AssemblyRefProcessorRow : Row { - - private MDTable table; - - - public int Processor; - public int AssemblyRef; - - public AssemblyRefProcessorRow() - { - } - - public AssemblyRefProcessorRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in AssemblyRefProcessor table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Processor = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.AssemblyRef = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Processor : {0}" + Environment.NewLine + - "AssemblyRef : {1}" + Environment.NewLine, - this.Processor, - "AssemblyRef[" + AssemblyRef.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in AssemblyRefOS table. - /// - /// - /// See Partition II, Metadata; section 21.6 - /// - public class AssemblyRefOSRow : Row { - - private MDTable table; - - - public int OSPlatformID; - public int OSMajorVersion; - public int OSMinorVersion; - public int AssemblyRef; - - public AssemblyRefOSRow() - { - } - - public AssemblyRefOSRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in AssemblyRefOS table has 4 columns. - /// - public virtual int NumberOfColumns { - get { - return 4; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + sizeof (int) + sizeof (int) + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.OSPlatformID = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.OSMajorVersion = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.OSMinorVersion = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.AssemblyRef = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "OSPlatformID : {0}" + Environment.NewLine + - "OSMajorVersion : {1}" + Environment.NewLine + - "OSMinorVersion : {2}" + Environment.NewLine + - "AssemblyRef : {3}" + Environment.NewLine, - this.OSPlatformID, - this.OSMajorVersion, - this.OSMinorVersion, - "AssemblyRef[" + AssemblyRef.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in File table. - /// - /// - /// See Partition II, Metadata; section 21.19 - /// - public class FileRow : Row { - - private MDTable table; - - - public System.IO.FileAttributes Flags; - public int Name; - public int HashValue; - - public FileRow() - { - } - - public FileRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in File table has 3 columns. - /// - public virtual int NumberOfColumns { - get { - return 3; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (uint) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.IO.FileAttributes) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.HashValue = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "Name : {1}" + Environment.NewLine + - "HashValue : {2}" + Environment.NewLine, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - "#Blob[" + HashValue.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ExportedType table. - /// - /// - /// See Partition II, Metadata; section 21.14 - /// - public class ExportedTypeRow : Row { - - private MDTable table; - - - public System.Reflection.TypeAttributes Flags; - public int TypeDefId; - public int TypeName; - public int TypeNamespace; - public MDToken Implementation; - - public ExportedTypeRow() - { - } - - public ExportedTypeRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ExportedType table has 5 columns. - /// - public virtual int NumberOfColumns { - get { - return 5; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (uint) + 4 + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Flags = (System.Reflection.TypeAttributes) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.TypeDefId = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.TypeName = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.TypeNamespace = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Implementation = TabsDecoder.DecodeToken(CodedTokenId.Implementation, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Flags : {0}" + Environment.NewLine + - "TypeDefId : {1}" + Environment.NewLine + - "TypeName : {2}" + Environment.NewLine + - "TypeNamespace : {3}" + Environment.NewLine + - "Implementation : {4}" + Environment.NewLine, - (int)this.Flags, - "TypeDef[" + TypeDefId.ToString() + "]", - (Table == null) ? TypeName.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [TypeName] + "\" (#Strings[0x" + TypeName.ToString("X") + "])", - (Table == null) ? TypeNamespace.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [TypeNamespace] + "\" (#Strings[0x" + TypeNamespace.ToString("X") + "])", - this.Implementation - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in ManifestResource table. - /// - /// - /// See Partition II, Metadata; section 21.22 - /// - public class ManifestResourceRow : Row { - - private MDTable table; - - - public int Offset; - public ManifestResourceAttributes Flags; - public int Name; - public MDToken Implementation; - - public ManifestResourceRow() - { - } - - public ManifestResourceRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in ManifestResource table has 4 columns. - /// - public virtual int NumberOfColumns { - get { - return 4; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (int) + sizeof (uint) + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Offset = LEBitConverter.ToInt32(buff, offs); - offs += sizeof (int); - this.Flags = (ManifestResourceAttributes) LEBitConverter.ToUInt32(buff, offs); - offs += sizeof (uint); - this.Name = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Implementation = TabsDecoder.DecodeToken(CodedTokenId.Implementation, LEBitConverter.ToInt32(buff, offs)); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Offset : {0}" + Environment.NewLine + - "Flags : {1}" + Environment.NewLine + - "Name : {2}" + Environment.NewLine + - "Implementation : {3}" + Environment.NewLine, - this.Offset, - (int)this.Flags, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])", - this.Implementation - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in NestedClass table. - /// - /// - /// See Partition II, Metadata; section 21.29 - /// - public class NestedClassRow : Row { - - private MDTable table; - - - public int NestedClass; - public int EnclosingClass; - - public NestedClassRow() - { - } - - public NestedClassRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in NestedClass table has 2 columns. - /// - public virtual int NumberOfColumns { - get { - return 2; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.NestedClass = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.EnclosingClass = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "NestedClass : {0}" + Environment.NewLine + - "EnclosingClass : {1}" + Environment.NewLine, - "TypeDef[" + NestedClass.ToString() + "]", - "TypeDef[" + EnclosingClass.ToString() + "]" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in TypeTyPar table. - /// - /// - /// - /// - public class TypeTyParRow : Row { - - private MDTable table; - - - public ushort Number; - public int Class; - public MDToken Bound; - public int Name; - - public TypeTyParRow() - { - } - - public TypeTyParRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in TypeTyPar table has 4 columns. - /// - public virtual int NumberOfColumns { - get { - return 4; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Number = LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Class = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Bound = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Number : {0}" + Environment.NewLine + - "Class : {1}" + Environment.NewLine + - "Bound : {2}" + Environment.NewLine + - "Name : {3}" + Environment.NewLine, - this.Number, - "TypeDef[" + Class.ToString() + "]", - this.Bound, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - /// - /// Represents row in MethodTyPar table. - /// - /// - /// - /// - public class MethodTyParRow : Row { - - private MDTable table; - - - public ushort Number; - public int Method; - public MDToken Bound; - public int Name; - - public MethodTyParRow() - { - } - - public MethodTyParRow(MDTable parent) - { - table = parent; - } - - - /// - /// Row in MethodTyPar table has 4 columns. - /// - public virtual int NumberOfColumns { - get { - return 4; - } - } - - - /// - /// Logical size of this instance in bytes. - /// - public virtual int Size { - get { - return LogicalSize; - } - } - - - /// - /// - public virtual MDTable Table { - get { - return table; - } - } - - - /// - /// Logical size of this type of row in bytes. - /// - unsafe public static int LogicalSize { - get { - return sizeof (ushort) + 4 + 4 + 4; - } - } - - - /// - /// Fills the row from the array of bytes. - /// - unsafe public void FromRawData(byte [] buff, int offs) - { - if (buff == null) throw new Exception("buff == null"); - if (offs + Size > buff.Length) throw new Exception("bounds"); - - - this.Number = LEBitConverter.ToUInt16(buff, offs); - offs += sizeof (ushort); - this.Method = LEBitConverter.ToInt32(buff, offs); - offs += 4; - this.Bound = TabsDecoder.DecodeToken(CodedTokenId.TypeDefOrRef, LEBitConverter.ToInt32(buff, offs)); - offs += 4; - this.Name = LEBitConverter.ToInt32(buff, offs); - - } - - - - /// - /// - public void Dump(TextWriter writer) { - string dump = String.Format( - "Number : {0}" + Environment.NewLine + - "Method : {1}" + Environment.NewLine + - "Bound : {2}" + Environment.NewLine + - "Name : {3}" + Environment.NewLine, - this.Number, - "Method[" + Method.ToString() + "]", - this.Bound, - (Table == null) ? Name.ToString() : "\"" + ((Table.Heap.Stream.Root.Streams["#Strings"] as MDStream).Heap as StringsHeap) [Name] + "\" (#Strings[0x" + Name.ToString("X") + "])" - ); - writer.WriteLine(dump); - } - - - /// - /// - public override string ToString() - { - StringWriter sw = new StringWriter(); - Dump(sw); - return sw.ToString(); - } - - } - - - - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/StringsHeap.cs b/mcs/class/Mono.PEToolkit/metadata/StringsHeap.cs deleted file mode 100644 index 788a1b32befd9..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/StringsHeap.cs +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.Text; -using System.Collections; - -namespace Mono.PEToolkit.Metadata { - - // 23.1.3 - public class StringsHeap : MDHeap { - - private SortedList strings; - private int dataLen; - - internal StringsHeap(MDStream stream) : base(stream) - { - } - - unsafe override public void FromRawData(byte[] rawData) - { - strings = new SortedList(); - strings.Add (0, String.Empty); - if (rawData == null) return; - - int len = rawData.Length; - dataLen = len; - // the first entry in the string heap is always EmptyString - if (len < 1 || rawData [0] != 0) { - throw new BadMetaDataException("Invalid #Strings heap."); - } - - int idx = 1; - for (int i = 1; i < len; i++) { - if (rawData [i] == 0) { - fixed (void* p = &rawData[idx]) { - string s = PEUtils.GetString ((sbyte*)p, 0, i - idx, Encoding.UTF8); - strings.Add (idx, s); - } - idx = i + 1; - } - } - } - - public string this [int index] { - get { - string res = null; - if (strings != null && index >= 0 && index < dataLen) { - res = strings[index] as string; - if (res == null) { - // cope with garbage/substrings - IList indices = strings.GetKeyList(); - int i = FindNextIndex(indices, index); - if (i < 0) { - throw new Exception("Internal error (#Strings binary search)."); - } - if (i != 0) { - // Position of the super-string in the heap. - int pos = (int) indices [i - 1]; - res = strings[pos] as string; - // NOTE: Substring returns String.Empty if index - // is equal to the length. - res = res.Substring(index - pos); - } - } - } - return res; - } - } - - /// - /// Binary search. - /// - /// List of "edge" indices. - /// - /// - private static int FindNextIndex(IList list, int index) { - int len = list.Count; - - if (len == 0) return ~0; - - int left = 0; - int right = len-1; - - while (left <= right) { - int guess = (left + right) >> 1; - int cmp = index - (int) list [guess]; - if (cmp == 0) return ~guess; - cmp &= ~Int32.MaxValue; - if (cmp == 0) left = guess+1; - else right = guess-1; - } - - return left; - } - - public int Count { - get { - return (strings == null) ? 0 : strings.Count; - } - } - - } -} diff --git a/mcs/class/Mono.PEToolkit/metadata/TableId.cs b/mcs/class/Mono.PEToolkit/metadata/TableId.cs deleted file mode 100644 index bd0b1d06abec7..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/TableId.cs +++ /dev/null @@ -1,66 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or table-id.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// Identifiers for tables in #~ heap. - /// - /// - /// Partition II, 21.x - /// - public enum TableId { - Module = 0x00, - TypeRef = 0x01, - TypeDef = 0x02, - FieldPtr = 0x03, - Field = 0x04, - MethodPtr = 0x05, - Method = 0x06, - ParamPtr = 0x07, - Param = 0x08, - InterfaceImpl = 0x09, - MemberRef = 0x0a, - Constant = 0x0b, - CustomAttribute = 0x0c, - FieldMarshal = 0x0d, - DeclSecurity = 0x0e, - ClassLayout = 0x0f, - FieldLayout = 0x10, - StandAloneSig = 0x11, - EventMap = 0x12, - EventPtr = 0x13, - Event = 0x14, - PropertyMap = 0x15, - PropertyPtr = 0x16, - Property = 0x17, - MethodSemantics = 0x18, - MethodImpl = 0x19, - ModuleRef = 0x1a, - TypeSpec = 0x1b, - ImplMap = 0x1c, - FieldRVA = 0x1d, - ENCLog = 0x1e, - ENCMap = 0x1f, - Assembly = 0x20, - AssemblyProcessor = 0x21, - AssemblyOS = 0x22, - AssemblyRef = 0x23, - AssemblyRefProcessor = 0x24, - AssemblyRefOS = 0x25, - File = 0x26, - ExportedType = 0x27, - ManifestResource = 0x28, - NestedClass = 0x29, - TypeTyPar = 0x2a, - MethodTyPar = 0x2b, - - MAX = MethodTyPar, - Count = MAX + 1 - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/Tables.cs b/mcs/class/Mono.PEToolkit/metadata/Tables.cs deleted file mode 100644 index ed858f6d202a7..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/Tables.cs +++ /dev/null @@ -1,1375 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - public class ModuleTable : MDTableBase { - - public ModuleTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ModuleRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ModuleRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Module"; - } - } - - public override TableId Id { - get { - return TableId.Module; - } - } - } - - public class TypeRefTable : MDTableBase { - - public TypeRefTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new TypeRefRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += TypeRefRow.LogicalSize; - } - } - - - public override string Name { - get { - return "TypeRef"; - } - } - - public override TableId Id { - get { - return TableId.TypeRef; - } - } - } - - public class TypeDefTable : MDTableBase { - - public TypeDefTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new TypeDefRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += TypeDefRow.LogicalSize; - } - } - - - public override string Name { - get { - return "TypeDef"; - } - } - - public override TableId Id { - get { - return TableId.TypeDef; - } - } - } - - public class FieldPtrTable : MDTableBase { - - public FieldPtrTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FieldPtrRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FieldPtrRow.LogicalSize; - } - } - - - public override string Name { - get { - return "FieldPtr"; - } - } - - public override TableId Id { - get { - return TableId.FieldPtr; - } - } - } - - public class FieldTable : MDTableBase { - - public FieldTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FieldRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FieldRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Field"; - } - } - - public override TableId Id { - get { - return TableId.Field; - } - } - } - - public class MethodPtrTable : MDTableBase { - - public MethodPtrTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MethodPtrRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MethodPtrRow.LogicalSize; - } - } - - - public override string Name { - get { - return "MethodPtr"; - } - } - - public override TableId Id { - get { - return TableId.MethodPtr; - } - } - } - - public class MethodTable : MDTableBase { - - public MethodTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MethodRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MethodRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Method"; - } - } - - public override TableId Id { - get { - return TableId.Method; - } - } - } - - public class ParamPtrTable : MDTableBase { - - public ParamPtrTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ParamPtrRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ParamPtrRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ParamPtr"; - } - } - - public override TableId Id { - get { - return TableId.ParamPtr; - } - } - } - - public class ParamTable : MDTableBase { - - public ParamTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ParamRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ParamRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Param"; - } - } - - public override TableId Id { - get { - return TableId.Param; - } - } - } - - public class InterfaceImplTable : MDTableBase { - - public InterfaceImplTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new InterfaceImplRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += InterfaceImplRow.LogicalSize; - } - } - - - public override string Name { - get { - return "InterfaceImpl"; - } - } - - public override TableId Id { - get { - return TableId.InterfaceImpl; - } - } - } - - public class MemberRefTable : MDTableBase { - - public MemberRefTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MemberRefRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MemberRefRow.LogicalSize; - } - } - - - public override string Name { - get { - return "MemberRef"; - } - } - - public override TableId Id { - get { - return TableId.MemberRef; - } - } - } - - public class ConstantTable : MDTableBase { - - public ConstantTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ConstantRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ConstantRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Constant"; - } - } - - public override TableId Id { - get { - return TableId.Constant; - } - } - } - - public class CustomAttributeTable : MDTableBase { - - public CustomAttributeTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new CustomAttributeRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += CustomAttributeRow.LogicalSize; - } - } - - - public override string Name { - get { - return "CustomAttribute"; - } - } - - public override TableId Id { - get { - return TableId.CustomAttribute; - } - } - } - - public class FieldMarshalTable : MDTableBase { - - public FieldMarshalTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FieldMarshalRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FieldMarshalRow.LogicalSize; - } - } - - - public override string Name { - get { - return "FieldMarshal"; - } - } - - public override TableId Id { - get { - return TableId.FieldMarshal; - } - } - } - - public class DeclSecurityTable : MDTableBase { - - public DeclSecurityTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new DeclSecurityRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += DeclSecurityRow.LogicalSize; - } - } - - - public override string Name { - get { - return "DeclSecurity"; - } - } - - public override TableId Id { - get { - return TableId.DeclSecurity; - } - } - } - - public class ClassLayoutTable : MDTableBase { - - public ClassLayoutTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ClassLayoutRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ClassLayoutRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ClassLayout"; - } - } - - public override TableId Id { - get { - return TableId.ClassLayout; - } - } - } - - public class FieldLayoutTable : MDTableBase { - - public FieldLayoutTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FieldLayoutRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FieldLayoutRow.LogicalSize; - } - } - - - public override string Name { - get { - return "FieldLayout"; - } - } - - public override TableId Id { - get { - return TableId.FieldLayout; - } - } - } - - public class StandAloneSigTable : MDTableBase { - - public StandAloneSigTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new StandAloneSigRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += StandAloneSigRow.LogicalSize; - } - } - - - public override string Name { - get { - return "StandAloneSig"; - } - } - - public override TableId Id { - get { - return TableId.StandAloneSig; - } - } - } - - public class EventMapTable : MDTableBase { - - public EventMapTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new EventMapRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += EventMapRow.LogicalSize; - } - } - - - public override string Name { - get { - return "EventMap"; - } - } - - public override TableId Id { - get { - return TableId.EventMap; - } - } - } - - public class EventPtrTable : MDTableBase { - - public EventPtrTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new EventPtrRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += EventPtrRow.LogicalSize; - } - } - - - public override string Name { - get { - return "EventPtr"; - } - } - - public override TableId Id { - get { - return TableId.EventPtr; - } - } - } - - public class EventTable : MDTableBase { - - public EventTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new EventRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += EventRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Event"; - } - } - - public override TableId Id { - get { - return TableId.Event; - } - } - } - - public class PropertyMapTable : MDTableBase { - - public PropertyMapTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new PropertyMapRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += PropertyMapRow.LogicalSize; - } - } - - - public override string Name { - get { - return "PropertyMap"; - } - } - - public override TableId Id { - get { - return TableId.PropertyMap; - } - } - } - - public class PropertyPtrTable : MDTableBase { - - public PropertyPtrTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new PropertyPtrRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += PropertyPtrRow.LogicalSize; - } - } - - - public override string Name { - get { - return "PropertyPtr"; - } - } - - public override TableId Id { - get { - return TableId.PropertyPtr; - } - } - } - - public class PropertyTable : MDTableBase { - - public PropertyTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new PropertyRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += PropertyRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Property"; - } - } - - public override TableId Id { - get { - return TableId.Property; - } - } - } - - public class MethodSemanticsTable : MDTableBase { - - public MethodSemanticsTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MethodSemanticsRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MethodSemanticsRow.LogicalSize; - } - } - - - public override string Name { - get { - return "MethodSemantics"; - } - } - - public override TableId Id { - get { - return TableId.MethodSemantics; - } - } - } - - public class MethodImplTable : MDTableBase { - - public MethodImplTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MethodImplRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MethodImplRow.LogicalSize; - } - } - - - public override string Name { - get { - return "MethodImpl"; - } - } - - public override TableId Id { - get { - return TableId.MethodImpl; - } - } - } - - public class ModuleRefTable : MDTableBase { - - public ModuleRefTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ModuleRefRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ModuleRefRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ModuleRef"; - } - } - - public override TableId Id { - get { - return TableId.ModuleRef; - } - } - } - - public class TypeSpecTable : MDTableBase { - - public TypeSpecTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new TypeSpecRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += TypeSpecRow.LogicalSize; - } - } - - - public override string Name { - get { - return "TypeSpec"; - } - } - - public override TableId Id { - get { - return TableId.TypeSpec; - } - } - } - - public class ImplMapTable : MDTableBase { - - public ImplMapTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ImplMapRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ImplMapRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ImplMap"; - } - } - - public override TableId Id { - get { - return TableId.ImplMap; - } - } - } - - public class FieldRVATable : MDTableBase { - - public FieldRVATable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FieldRVARow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FieldRVARow.LogicalSize; - } - } - - - public override string Name { - get { - return "FieldRVA"; - } - } - - public override TableId Id { - get { - return TableId.FieldRVA; - } - } - } - - public class ENCLogTable : MDTableBase { - - public ENCLogTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ENCLogRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ENCLogRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ENCLog"; - } - } - - public override TableId Id { - get { - return TableId.ENCLog; - } - } - } - - public class ENCMapTable : MDTableBase { - - public ENCMapTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ENCMapRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ENCMapRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ENCMap"; - } - } - - public override TableId Id { - get { - return TableId.ENCMap; - } - } - } - - public class AssemblyTable : MDTableBase { - - public AssemblyTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyRow.LogicalSize; - } - } - - - public override string Name { - get { - return "Assembly"; - } - } - - public override TableId Id { - get { - return TableId.Assembly; - } - } - } - - public class AssemblyProcessorTable : MDTableBase { - - public AssemblyProcessorTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyProcessorRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyProcessorRow.LogicalSize; - } - } - - - public override string Name { - get { - return "AssemblyProcessor"; - } - } - - public override TableId Id { - get { - return TableId.AssemblyProcessor; - } - } - } - - public class AssemblyOSTable : MDTableBase { - - public AssemblyOSTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyOSRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyOSRow.LogicalSize; - } - } - - - public override string Name { - get { - return "AssemblyOS"; - } - } - - public override TableId Id { - get { - return TableId.AssemblyOS; - } - } - } - - public class AssemblyRefTable : MDTableBase { - - public AssemblyRefTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyRefRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyRefRow.LogicalSize; - } - } - - - public override string Name { - get { - return "AssemblyRef"; - } - } - - public override TableId Id { - get { - return TableId.AssemblyRef; - } - } - } - - public class AssemblyRefProcessorTable : MDTableBase { - - public AssemblyRefProcessorTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyRefProcessorRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyRefProcessorRow.LogicalSize; - } - } - - - public override string Name { - get { - return "AssemblyRefProcessor"; - } - } - - public override TableId Id { - get { - return TableId.AssemblyRefProcessor; - } - } - } - - public class AssemblyRefOSTable : MDTableBase { - - public AssemblyRefOSTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new AssemblyRefOSRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += AssemblyRefOSRow.LogicalSize; - } - } - - - public override string Name { - get { - return "AssemblyRefOS"; - } - } - - public override TableId Id { - get { - return TableId.AssemblyRefOS; - } - } - } - - public class FileTable : MDTableBase { - - public FileTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new FileRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += FileRow.LogicalSize; - } - } - - - public override string Name { - get { - return "File"; - } - } - - public override TableId Id { - get { - return TableId.File; - } - } - } - - public class ExportedTypeTable : MDTableBase { - - public ExportedTypeTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ExportedTypeRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ExportedTypeRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ExportedType"; - } - } - - public override TableId Id { - get { - return TableId.ExportedType; - } - } - } - - public class ManifestResourceTable : MDTableBase { - - public ManifestResourceTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new ManifestResourceRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += ManifestResourceRow.LogicalSize; - } - } - - - public override string Name { - get { - return "ManifestResource"; - } - } - - public override TableId Id { - get { - return TableId.ManifestResource; - } - } - } - - public class NestedClassTable : MDTableBase { - - public NestedClassTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new NestedClassRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += NestedClassRow.LogicalSize; - } - } - - - public override string Name { - get { - return "NestedClass"; - } - } - - public override TableId Id { - get { - return TableId.NestedClass; - } - } - } - - public class TypeTyParTable : MDTableBase { - - public TypeTyParTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new TypeTyParRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += TypeTyParRow.LogicalSize; - } - } - - - public override string Name { - get { - return "TypeTyPar"; - } - } - - public override TableId Id { - get { - return TableId.TypeTyPar; - } - } - } - - public class MethodTyParTable : MDTableBase { - - public MethodTyParTable(MDHeap heap) - : base(heap) - { - } - - - public override void FromRawData(byte [] buff, int offs, int numRows) { - for (int i = numRows; --i >= 0;) { - Row row = new MethodTyParRow(this); - row.FromRawData(buff, offs); - Add(row); - offs += MethodTyParRow.LogicalSize; - } - } - - - public override string Name { - get { - return "MethodTyPar"; - } - } - - public override TableId Id { - get { - return TableId.MethodTyPar; - } - } - } - - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/TablesHeap.cs b/mcs/class/Mono.PEToolkit/metadata/TablesHeap.cs deleted file mode 100644 index 5ae11b60df110..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/TablesHeap.cs +++ /dev/null @@ -1,217 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; -using System.IO; -using System.Collections; - -namespace Mono.PEToolkit.Metadata { - - /// - /// Metadata tables heap (#~). - /// - /// - /// Partition II; Chapter 21 & 23.1.6 - /// - public class TablesHeap : TablesHeapBase { - - private long valid; // bitvector of valid tables - //(64-bit, max index = TableId.MAX) - private int numTabs; // number of tables (calculated from valid) - - private long sorted; // bitvector of sorted tables (64-bit) - - // schema version (currently 1.0) - private byte verMaj; - private byte verMin; - - // bitvector for heap-size flags: - // bit 1 - if set #Strings heap uses wide indices (dword) - // bit 2 - if set #GUID heap uses wide indices - // bit 3 - if set #Blob heap uses wide indices - // otherwise (particular bit is not set) index size is word. - private byte heapSizes; - - - private Hashtable tables; - - - internal TablesHeap (MDStream stream) : base (stream) - { - } - - - /// - /// Gets or sets bitvector of valid tables (64-bit). - /// - public override long Valid { - get { - return valid; - } - set { - valid = value; - } - } - - /// - /// Gets or sets bitvector of sorted tables (64-bit). - /// - public override long Sorted { - get { - return sorted; - } - set { - sorted = value; - } - } - - - // - // "Universal" accessors for Valid and Sorted bitvectors. - // - - - public bool IsValid (TableId tab) - { - return (valid & (1L << (int) tab)) != 0; - } - - public void SetValid (TableId tab, bool b) - { - long mask = 1L << (int) tab; - if (b) { - valid |= mask; - } else { - valid &= ~mask; - } - } - - - /// - /// True if the given table in this heap is sorted. - /// - /// - /// - public bool IsSorted (TableId tab) - { - return (sorted & (1L << (int) tab)) != 0; - } - - /// - /// Marks specified table in this heap as sorted or unsorted. - /// - /// - /// - public void SetSorted (TableId tab, bool b) - { - long mask = 1L << (int) tab; - if (b) { - sorted |= mask; - } else { - sorted &= ~mask; - } - } - - - - public byte HeapSizes { - get { - return heapSizes; - } - set { - heapSizes = value; - } - } - - public int StringsIndexSize { - get { - return 2 + ((heapSizes & 1) << 1); - } - } - - public int GUIDIndexSize { - get { - return 2 + (heapSizes & 2); - } - } - - public int BlobIndexSize { - get { - return 2 + ((heapSizes & 4) >> 1); - } - } - - - - unsafe override public void FromRawData (byte [] rawData) - { - valid = 0; - sorted = 0; - - if (rawData == null || rawData.Length < 24) { - throw new BadMetaDataException ("Invalid header for #~ heap."); - } - - verMaj = rawData [4]; - verMin = rawData [5]; - heapSizes = rawData [6]; - - valid = LEBitConverter.ToInt64 (rawData, 8); - sorted = LEBitConverter.ToInt64 (rawData, 16); - - // Calc number of tables from valid bitvector. - numTabs = 0; - for (int i = (int) TableId.Count; --i >= 0;) { - numTabs += (int) (valid >> i) & 1; - } - - int [] rows = new int [(int) TableId.Count]; - Array.Clear (rows, 0, rows.Length); - int offs = 24; // offset to #~::Rows - for (int i = 0; i < numTabs; i++) { - int n = -1; - int vpos = -1; - long v = valid; - while (n < i && v != 0) { - n += (int) (v & 1L); - v >>= 1; - vpos++; - } - if (vpos != -1) { - rows [vpos] = LEBitConverter.ToInt32 (rawData, offs); - offs += sizeof (int); - } - } - - // TODO: this could be called from constructor - // This sequence: MDHeap::.ctor -> FromRawData -> RegisterTable - // and we are making "this" available here, before the object - // is fully constructed. This is bad, fix it somehow. - TabsDecoder.DecodePhysicalTables (this, rawData, offs, rows); - - } - - - public void RegisterTable (MDTable tab) - { - if (tables == null) tables = new Hashtable (64); - tables [tab.Id] = tab; - } - - public MDTable this [TableId id] { - get { - return tables [id] as MDTable; - } - } - - public ICollection Tables { - get { - return tables.Values; - } - } - - - } - -} diff --git a/mcs/class/Mono.PEToolkit/metadata/TablesHeapBase.cs b/mcs/class/Mono.PEToolkit/metadata/TablesHeapBase.cs deleted file mode 100644 index 8606ae176dc3b..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/TablesHeapBase.cs +++ /dev/null @@ -1,787 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs-base.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - /// - public abstract class TablesHeapBase : MDHeap { - - internal TablesHeapBase(MDStream stream) : base(stream) - { - } - - /// - /// Gets or sets bitvector of valid tables (64-bit). - /// - public abstract long Valid {get; set;} - - /// - /// Gets or sets bitvector of sorted tables (64-bit). - /// - public abstract long Sorted {get; set;} - - - // - // Accessors to decode Valid bitvector. - // - - - /// - /// True if heap has Module table. - /// - public bool HasModule { - get { - return (Valid & (1L << 0x00)) != 0; - } - set { - long mask = (1L << 0x00); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has TypeRef table. - /// - public bool HasTypeRef { - get { - return (Valid & (1L << 0x01)) != 0; - } - set { - long mask = (1L << 0x01); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has TypeDef table. - /// - public bool HasTypeDef { - get { - return (Valid & (1L << 0x02)) != 0; - } - set { - long mask = (1L << 0x02); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has FieldPtr table. - /// - public bool HasFieldPtr { - get { - return (Valid & (1L << 0x03)) != 0; - } - set { - long mask = (1L << 0x03); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Field table. - /// - public bool HasField { - get { - return (Valid & (1L << 0x04)) != 0; - } - set { - long mask = (1L << 0x04); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has MethodPtr table. - /// - public bool HasMethodPtr { - get { - return (Valid & (1L << 0x05)) != 0; - } - set { - long mask = (1L << 0x05); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Method table. - /// - public bool HasMethod { - get { - return (Valid & (1L << 0x06)) != 0; - } - set { - long mask = (1L << 0x06); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ParamPtr table. - /// - public bool HasParamPtr { - get { - return (Valid & (1L << 0x07)) != 0; - } - set { - long mask = (1L << 0x07); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Param table. - /// - public bool HasParam { - get { - return (Valid & (1L << 0x08)) != 0; - } - set { - long mask = (1L << 0x08); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has InterfaceImpl table. - /// - public bool HasInterfaceImpl { - get { - return (Valid & (1L << 0x09)) != 0; - } - set { - long mask = (1L << 0x09); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has MemberRef table. - /// - public bool HasMemberRef { - get { - return (Valid & (1L << 0x0a)) != 0; - } - set { - long mask = (1L << 0x0a); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Constant table. - /// - public bool HasConstant { - get { - return (Valid & (1L << 0x0b)) != 0; - } - set { - long mask = (1L << 0x0b); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has CustomAttribute table. - /// - public bool HasCustomAttribute { - get { - return (Valid & (1L << 0x0c)) != 0; - } - set { - long mask = (1L << 0x0c); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has FieldMarshal table. - /// - public bool HasFieldMarshal { - get { - return (Valid & (1L << 0x0d)) != 0; - } - set { - long mask = (1L << 0x0d); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has DeclSecurity table. - /// - public bool HasDeclSecurity { - get { - return (Valid & (1L << 0x0e)) != 0; - } - set { - long mask = (1L << 0x0e); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ClassLayout table. - /// - public bool HasClassLayout { - get { - return (Valid & (1L << 0x0f)) != 0; - } - set { - long mask = (1L << 0x0f); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has FieldLayout table. - /// - public bool HasFieldLayout { - get { - return (Valid & (1L << 0x10)) != 0; - } - set { - long mask = (1L << 0x10); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has StandAloneSig table. - /// - public bool HasStandAloneSig { - get { - return (Valid & (1L << 0x11)) != 0; - } - set { - long mask = (1L << 0x11); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has EventMap table. - /// - public bool HasEventMap { - get { - return (Valid & (1L << 0x12)) != 0; - } - set { - long mask = (1L << 0x12); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has EventPtr table. - /// - public bool HasEventPtr { - get { - return (Valid & (1L << 0x13)) != 0; - } - set { - long mask = (1L << 0x13); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Event table. - /// - public bool HasEvent { - get { - return (Valid & (1L << 0x14)) != 0; - } - set { - long mask = (1L << 0x14); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has PropertyMap table. - /// - public bool HasPropertyMap { - get { - return (Valid & (1L << 0x15)) != 0; - } - set { - long mask = (1L << 0x15); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has PropertyPtr table. - /// - public bool HasPropertyPtr { - get { - return (Valid & (1L << 0x16)) != 0; - } - set { - long mask = (1L << 0x16); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Property table. - /// - public bool HasProperty { - get { - return (Valid & (1L << 0x17)) != 0; - } - set { - long mask = (1L << 0x17); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has MethodSemantics table. - /// - public bool HasMethodSemantics { - get { - return (Valid & (1L << 0x18)) != 0; - } - set { - long mask = (1L << 0x18); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has MethodImpl table. - /// - public bool HasMethodImpl { - get { - return (Valid & (1L << 0x19)) != 0; - } - set { - long mask = (1L << 0x19); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ModuleRef table. - /// - public bool HasModuleRef { - get { - return (Valid & (1L << 0x1a)) != 0; - } - set { - long mask = (1L << 0x1a); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has TypeSpec table. - /// - public bool HasTypeSpec { - get { - return (Valid & (1L << 0x1b)) != 0; - } - set { - long mask = (1L << 0x1b); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ImplMap table. - /// - public bool HasImplMap { - get { - return (Valid & (1L << 0x1c)) != 0; - } - set { - long mask = (1L << 0x1c); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has FieldRVA table. - /// - public bool HasFieldRVA { - get { - return (Valid & (1L << 0x1d)) != 0; - } - set { - long mask = (1L << 0x1d); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ENCLog table. - /// - public bool HasENCLog { - get { - return (Valid & (1L << 0x1e)) != 0; - } - set { - long mask = (1L << 0x1e); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ENCMap table. - /// - public bool HasENCMap { - get { - return (Valid & (1L << 0x1f)) != 0; - } - set { - long mask = (1L << 0x1f); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has Assembly table. - /// - public bool HasAssembly { - get { - return (Valid & (1L << 0x20)) != 0; - } - set { - long mask = (1L << 0x20); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has AssemblyProcessor table. - /// - public bool HasAssemblyProcessor { - get { - return (Valid & (1L << 0x21)) != 0; - } - set { - long mask = (1L << 0x21); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has AssemblyOS table. - /// - public bool HasAssemblyOS { - get { - return (Valid & (1L << 0x22)) != 0; - } - set { - long mask = (1L << 0x22); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has AssemblyRef table. - /// - public bool HasAssemblyRef { - get { - return (Valid & (1L << 0x23)) != 0; - } - set { - long mask = (1L << 0x23); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has AssemblyRefProcessor table. - /// - public bool HasAssemblyRefProcessor { - get { - return (Valid & (1L << 0x24)) != 0; - } - set { - long mask = (1L << 0x24); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has AssemblyRefOS table. - /// - public bool HasAssemblyRefOS { - get { - return (Valid & (1L << 0x25)) != 0; - } - set { - long mask = (1L << 0x25); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has File table. - /// - public bool HasFile { - get { - return (Valid & (1L << 0x26)) != 0; - } - set { - long mask = (1L << 0x26); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ExportedType table. - /// - public bool HasExportedType { - get { - return (Valid & (1L << 0x27)) != 0; - } - set { - long mask = (1L << 0x27); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has ManifestResource table. - /// - public bool HasManifestResource { - get { - return (Valid & (1L << 0x28)) != 0; - } - set { - long mask = (1L << 0x28); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has NestedClass table. - /// - public bool HasNestedClass { - get { - return (Valid & (1L << 0x29)) != 0; - } - set { - long mask = (1L << 0x29); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has TypeTyPar table. - /// - public bool HasTypeTyPar { - get { - return (Valid & (1L << 0x2a)) != 0; - } - set { - long mask = (1L << 0x2a); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - /// - /// True if heap has MethodTyPar table. - /// - public bool HasMethodTyPar { - get { - return (Valid & (1L << 0x2b)) != 0; - } - set { - long mask = (1L << 0x2b); - if (value) { - Valid |= mask; - } else { - Valid &= ~mask; - } - } - } - - - } - -} - diff --git a/mcs/class/Mono.PEToolkit/metadata/TabsDecoder.cs b/mcs/class/Mono.PEToolkit/metadata/TabsDecoder.cs deleted file mode 100644 index cc6436a7c98ee..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/TabsDecoder.cs +++ /dev/null @@ -1,1933 +0,0 @@ -// Auto-generated file - DO NOT EDIT! -// Please edit md-schema.xml or tabs-decoder.xsl if you want to make changes. - -using System; - -namespace Mono.PEToolkit.Metadata { - - - /// - /// - /// - /// - public sealed class TabsDecoder { - - private TabsDecoder() - { - } - - - /// - /// - /// - /// - public static MDToken DecodeToken(CodedTokenId id, int data) - { - MDToken res = new MDToken(); - int tag; - int rid; - TokenType tok; - - switch (id) { - - case CodedTokenId.TypeDefOrRef : - tag = data & 0x03; - rid = (int) ((uint) data >> 2); - switch (tag) { - - case 0 : - tok = TokenType.TypeDef; - break; - - case 1 : - tok = TokenType.TypeRef; - break; - - case 2 : - tok = TokenType.TypeSpec; - break; - - default : - throw new BadMetaDataException("Invalid coded token for TypeDefOrRef, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.HasConstant : - tag = data & 0x03; - rid = (int) ((uint) data >> 2); - switch (tag) { - - case 0 : - tok = TokenType.FieldDef; - break; - - case 1 : - tok = TokenType.ParamDef; - break; - - case 2 : - tok = TokenType.Property; - break; - - default : - throw new BadMetaDataException("Invalid coded token for HasConstant, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.HasCustomAttribute : - tag = data & 0x1F; - rid = (int) ((uint) data >> 5); - switch (tag) { - - case 0 : - tok = TokenType.MethodDef; - break; - - case 1 : - tok = TokenType.FieldDef; - break; - - case 2 : - tok = TokenType.TypeRef; - break; - - case 3 : - tok = TokenType.TypeDef; - break; - - case 4 : - tok = TokenType.ParamDef; - break; - - case 5 : - tok = TokenType.InterfaceImpl; - break; - - case 6 : - tok = TokenType.MemberRef; - break; - - case 7 : - tok = TokenType.Module; - break; - - case 8 : - tok = TokenType.Permission; - break; - - case 9 : - tok = TokenType.Property; - break; - - case 10 : - tok = TokenType.Event; - break; - - case 11 : - tok = TokenType.Signature; - break; - - case 12 : - tok = TokenType.ModuleRef; - break; - - case 13 : - tok = TokenType.TypeSpec; - break; - - case 14 : - tok = TokenType.Assembly; - break; - - case 15 : - tok = TokenType.AssemblyRef; - break; - - case 16 : - tok = TokenType.File; - break; - - case 17 : - tok = TokenType.ExportedType; - break; - - case 18 : - tok = TokenType.ManifestResource; - break; - - default : - throw new BadMetaDataException("Invalid coded token for HasCustomAttribute, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.HasFieldMarshal : - tag = data & 0x01; - rid = (int) ((uint) data >> 1); - switch (tag) { - - case 0 : - tok = TokenType.FieldDef; - break; - - case 1 : - tok = TokenType.ParamDef; - break; - - default : - throw new BadMetaDataException("Invalid coded token for HasFieldMarshal, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.HasDeclSecurity : - tag = data & 0x03; - rid = (int) ((uint) data >> 2); - switch (tag) { - - case 0 : - tok = TokenType.TypeDef; - break; - - case 1 : - tok = TokenType.MethodDef; - break; - - case 2 : - tok = TokenType.Assembly; - break; - - default : - throw new BadMetaDataException("Invalid coded token for HasDeclSecurity, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.MemberRefParent : - tag = data & 0x07; - rid = (int) ((uint) data >> 3); - switch (tag) { - - case 0 : - tok = TokenType.TypeDef; - break; - - case 1 : - tok = TokenType.TypeRef; - break; - - case 2 : - tok = TokenType.ModuleRef; - break; - - case 3 : - tok = TokenType.MethodDef; - break; - - case 4 : - tok = TokenType.TypeSpec; - break; - - default : - throw new BadMetaDataException("Invalid coded token for MemberRefParent, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.HasSemantics : - tag = data & 0x01; - rid = (int) ((uint) data >> 1); - switch (tag) { - - case 0 : - tok = TokenType.Event; - break; - - case 1 : - tok = TokenType.Property; - break; - - default : - throw new BadMetaDataException("Invalid coded token for HasSemantics, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.MethodDefOrRef : - tag = data & 0x01; - rid = (int) ((uint) data >> 1); - switch (tag) { - - case 0 : - tok = TokenType.MethodDef; - break; - - case 1 : - tok = TokenType.MemberRef; - break; - - default : - throw new BadMetaDataException("Invalid coded token for MethodDefOrRef, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.MemberForwarded : - tag = data & 0x01; - rid = (int) ((uint) data >> 1); - switch (tag) { - - case 0 : - tok = TokenType.FieldDef; - break; - - case 1 : - tok = TokenType.MethodDef; - break; - - default : - throw new BadMetaDataException("Invalid coded token for MemberForwarded, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.Implementation : - tag = data & 0x03; - rid = (int) ((uint) data >> 2); - switch (tag) { - - case 0 : - tok = TokenType.File; - break; - - case 1 : - tok = TokenType.AssemblyRef; - break; - - case 2 : - tok = TokenType.ExportedType; - break; - - default : - throw new BadMetaDataException("Invalid coded token for Implementation, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.CustomAttributeType : - tag = data & 0x07; - rid = (int) ((uint) data >> 3); - switch (tag) { - - case 0 : - tok = TokenType.TypeRef; - break; - - case 1 : - tok = TokenType.TypeDef; - break; - - case 2 : - tok = TokenType.MethodDef; - break; - - case 3 : - tok = TokenType.MemberRef; - break; - - case 4 : - tok = TokenType.String; - break; - - default : - throw new BadMetaDataException("Invalid coded token for CustomAttributeType, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - case CodedTokenId.ResolutionScope : - tag = data & 0x03; - rid = (int) ((uint) data >> 2); - switch (tag) { - - case 0 : - tok = TokenType.Module; - break; - - case 1 : - tok = TokenType.ModuleRef; - break; - - case 2 : - tok = TokenType.AssemblyRef; - break; - - case 3 : - tok = TokenType.TypeRef; - break; - - default : - throw new BadMetaDataException("Invalid coded token for ResolutionScope, unknown table tag - " + tag); - } - res = new MDToken(tok, rid); - break; - - default: - break; - } - return res; - } - - - private static int GetCodedIndexSize(TablesHeap heap, CodedTokenId id, int [] rows) - { - int res = 0; - - switch (id) { - - case CodedTokenId.TypeDefOrRef : - res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.TypeRef], rows [(int) TableId.TypeSpec]); - res = res < (1 << (16 - 2)) ? 2 : 4; - break; - - case CodedTokenId.HasConstant : - res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Param], rows [(int) TableId.Property]); - res = res < (1 << (16 - 2)) ? 2 : 4; - break; - - case CodedTokenId.HasCustomAttribute : - 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]); - res = res < (1 << (16 - 5)) ? 2 : 4; - break; - - case CodedTokenId.HasFieldMarshal : - res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Param]); - res = res < (1 << (16 - 1)) ? 2 : 4; - break; - - case CodedTokenId.HasDeclSecurity : - res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.Method], rows [(int) TableId.Assembly]); - res = res < (1 << (16 - 2)) ? 2 : 4; - break; - - case CodedTokenId.MemberRefParent : - res = MDUtils.Max(rows [(int) TableId.TypeDef], rows [(int) TableId.TypeRef], rows [(int) TableId.ModuleRef], rows [(int) TableId.Method], rows [(int) TableId.TypeSpec]); - res = res < (1 << (16 - 3)) ? 2 : 4; - break; - - case CodedTokenId.HasSemantics : - res = MDUtils.Max(rows [(int) TableId.Event], rows [(int) TableId.Property]); - res = res < (1 << (16 - 1)) ? 2 : 4; - break; - - case CodedTokenId.MethodDefOrRef : - res = MDUtils.Max(rows [(int) TableId.Method], rows [(int) TableId.MemberRef]); - res = res < (1 << (16 - 1)) ? 2 : 4; - break; - - case CodedTokenId.MemberForwarded : - res = MDUtils.Max(rows [(int) TableId.Field], rows [(int) TableId.Method]); - res = res < (1 << (16 - 1)) ? 2 : 4; - break; - - case CodedTokenId.Implementation : - res = MDUtils.Max(rows [(int) TableId.File], rows [(int) TableId.AssemblyRef], rows [(int) TableId.ExportedType]); - res = res < (1 << (16 - 2)) ? 2 : 4; - break; - - case CodedTokenId.CustomAttributeType : - 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)); - res = res < (1 << (16 - 3)) ? 2 : 4; - break; - - case CodedTokenId.ResolutionScope : - res = MDUtils.Max(rows [(int) TableId.Module], rows [(int) TableId.ModuleRef], rows [(int) TableId.AssemblyRef], rows [(int) TableId.TypeRef]); - res = res < (1 << (16 - 2)) ? 2 : 4; - break; - - default: - break; - } - - return res; - } - - - private static int GetIndexSize(TableId tab, int [] rows) - { - // Index is 2 bytes wide if table has less than 2^16 rows - // otherwise it's 4 bytes wide. - return ((uint) rows [(int) tab]) < (1 << 16) ? 2 : 4; - } - - - private static void AllocBuff(ref byte [] buff, int size) - { - if (buff == null || buff.Length < size) { - buff = new byte [(size + 4) & ~3]; - } - Array.Clear(buff, 0, size); - } - - - /// - /// - unsafe public static int DecodePhysicalTables(TablesHeap heap, byte [] data, int offs, int [] rows) - { - int rowSize; // expanded row size (all indices are dwords) - int fldSize; // physical field size - int dest; - int nRows; - byte [] buff = null; - int si = heap.StringsIndexSize; - int gi = heap.GUIDIndexSize; - int bi = heap.BlobIndexSize; - - if (heap.HasModule) { - rowSize = sizeof (ushort) + 4 + 4 + 4 + 4; - nRows = rows [(int) TableId.Module]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ModuleTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Generation, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Mvid, index(#GUID) - fldSize = gi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // EncId, index(#GUID) - fldSize = gi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // EncBaseId, index(#GUID) - fldSize = gi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasTypeRef) { - rowSize = 4 + 4 + 4; - nRows = rows [(int) TableId.TypeRef]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new TypeRefTable(heap); - - for (int i = nRows; --i >= 0;) { - - // ResolutionScope, coded-index(ResolutionScope) - fldSize = GetCodedIndexSize(heap, CodedTokenId.ResolutionScope, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Namespace, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasTypeDef) { - rowSize = sizeof (uint) + 4 + 4 + 4 + 4 + 4; - nRows = rows [(int) TableId.TypeDef]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new TypeDefTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Namespace, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Extends, coded-index(TypeDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // FieldList, index(Field) - fldSize = GetIndexSize(TableId.Field, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // MethodList, index(Method) - fldSize = GetIndexSize(TableId.Method, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasFieldPtr) { - rowSize = 4; - nRows = rows [(int) TableId.FieldPtr]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FieldPtrTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Field, index(Field) - fldSize = GetIndexSize(TableId.Field, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasField) { - rowSize = sizeof (ushort) + 4 + 4; - nRows = rows [(int) TableId.Field]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FieldTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Signature, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMethodPtr) { - rowSize = 4; - nRows = rows [(int) TableId.MethodPtr]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MethodPtrTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Method, index(Method) - fldSize = GetIndexSize(TableId.Method, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMethod) { - rowSize = RVA.Size + sizeof (ushort) + sizeof (ushort) + 4 + 4 + 4; - nRows = rows [(int) TableId.Method]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MethodTable(heap); - - for (int i = nRows; --i >= 0;) { - - // RVA, RVA - fldSize = RVA.Size; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += RVA.Size; - - // ImplFlags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Flags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Signature, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // ParamList, index(Param) - fldSize = GetIndexSize(TableId.Param, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasParamPtr) { - rowSize = 4; - nRows = rows [(int) TableId.ParamPtr]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ParamPtrTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Param, index(Param) - fldSize = GetIndexSize(TableId.Param, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasParam) { - rowSize = sizeof (ushort) + sizeof (ushort) + 4; - nRows = rows [(int) TableId.Param]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ParamTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Sequence, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasInterfaceImpl) { - rowSize = 4 + 4; - nRows = rows [(int) TableId.InterfaceImpl]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new InterfaceImplTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Class, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Interface, coded-index(TypeDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMemberRef) { - rowSize = 4 + 4 + 4; - nRows = rows [(int) TableId.MemberRef]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MemberRefTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Class, coded-index(MemberRefParent) - fldSize = GetCodedIndexSize(heap, CodedTokenId.MemberRefParent, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Signature, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasConstant) { - rowSize = sizeof (short) + 4 + 4; - nRows = rows [(int) TableId.Constant]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ConstantTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Type, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // Parent, coded-index(HasConstant) - fldSize = GetCodedIndexSize(heap, CodedTokenId.HasConstant, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Value, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasCustomAttribute) { - rowSize = 4 + 4 + 4; - nRows = rows [(int) TableId.CustomAttribute]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new CustomAttributeTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Parent, coded-index(HasCustomAttribute) - fldSize = GetCodedIndexSize(heap, CodedTokenId.HasCustomAttribute, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Type, coded-index(CustomAttributeType) - fldSize = GetCodedIndexSize(heap, CodedTokenId.CustomAttributeType, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Value, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasFieldMarshal) { - rowSize = 4 + 4; - nRows = rows [(int) TableId.FieldMarshal]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FieldMarshalTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Parent, coded-index(HasFieldMarshal) - fldSize = GetCodedIndexSize(heap, CodedTokenId.HasFieldMarshal, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // NativeType, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasDeclSecurity) { - rowSize = sizeof (short) + 4 + 4; - nRows = rows [(int) TableId.DeclSecurity]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new DeclSecurityTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Action, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // Parent, coded-index(HasDeclSecurity) - fldSize = GetCodedIndexSize(heap, CodedTokenId.HasDeclSecurity, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // PermissionSet, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasClassLayout) { - rowSize = sizeof (short) + sizeof (int) + 4; - nRows = rows [(int) TableId.ClassLayout]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ClassLayoutTable(heap); - - for (int i = nRows; --i >= 0;) { - - // PackingSize, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // ClassSize, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // Parent, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasFieldLayout) { - rowSize = sizeof (int) + 4; - nRows = rows [(int) TableId.FieldLayout]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FieldLayoutTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Offset, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // Field, index(Field) - fldSize = GetIndexSize(TableId.Field, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasStandAloneSig) { - rowSize = 4; - nRows = rows [(int) TableId.StandAloneSig]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new StandAloneSigTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Signature, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasEventMap) { - rowSize = 4 + 4; - nRows = rows [(int) TableId.EventMap]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new EventMapTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Parent, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // EventList, index(Event) - fldSize = GetIndexSize(TableId.Event, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasEventPtr) { - rowSize = 4; - nRows = rows [(int) TableId.EventPtr]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new EventPtrTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Event, index(Event) - fldSize = GetIndexSize(TableId.Event, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasEvent) { - rowSize = sizeof (short) + 4 + 4; - nRows = rows [(int) TableId.Event]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new EventTable(heap); - - for (int i = nRows; --i >= 0;) { - - // EventFlags, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // EventType, coded-index(TypeDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasPropertyMap) { - rowSize = 4 + 4; - nRows = rows [(int) TableId.PropertyMap]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new PropertyMapTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Parent, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // PropertyList, index(Property) - fldSize = GetIndexSize(TableId.Property, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasPropertyPtr) { - rowSize = 4; - nRows = rows [(int) TableId.PropertyPtr]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new PropertyPtrTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Property, index(Property) - fldSize = GetIndexSize(TableId.Property, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasProperty) { - rowSize = sizeof (ushort) + 4 + 4; - nRows = rows [(int) TableId.Property]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new PropertyTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Type, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMethodSemantics) { - rowSize = sizeof (ushort) + 4 + 4; - nRows = rows [(int) TableId.MethodSemantics]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MethodSemanticsTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Semantics, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Method, index(Method) - fldSize = GetIndexSize(TableId.Method, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Association, coded-index(HasSemantics) - fldSize = GetCodedIndexSize(heap, CodedTokenId.HasSemantics, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMethodImpl) { - rowSize = 4 + 4 + 4; - nRows = rows [(int) TableId.MethodImpl]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MethodImplTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Class, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // MethodBody, coded-index(MethodDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.MethodDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // MethodDeclaration, coded-index(MethodDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.MethodDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasModuleRef) { - rowSize = 4; - nRows = rows [(int) TableId.ModuleRef]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ModuleRefTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasTypeSpec) { - rowSize = 4; - nRows = rows [(int) TableId.TypeSpec]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new TypeSpecTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Signature, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasImplMap) { - rowSize = sizeof (ushort) + 4 + 4 + 4; - nRows = rows [(int) TableId.ImplMap]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ImplMapTable(heap); - - for (int i = nRows; --i >= 0;) { - - // MappingFlags, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // MemberForwarded, coded-index(MemberForwarded) - fldSize = GetCodedIndexSize(heap, CodedTokenId.MemberForwarded, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // ImportName, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // ImportScope, index(ModuleRef) - fldSize = GetIndexSize(TableId.ModuleRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasFieldRVA) { - rowSize = RVA.Size + 4; - nRows = rows [(int) TableId.FieldRVA]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FieldRVATable(heap); - - for (int i = nRows; --i >= 0;) { - - // RVA, RVA - fldSize = RVA.Size; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += RVA.Size; - - // Field, index(Field) - fldSize = GetIndexSize(TableId.Field, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasENCLog) { - rowSize = sizeof (uint) + sizeof (uint); - nRows = rows [(int) TableId.ENCLog]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ENCLogTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Token, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // FuncCode, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasENCMap) { - rowSize = sizeof (uint); - nRows = rows [(int) TableId.ENCMap]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ENCMapTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Token, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssembly) { - rowSize = sizeof (int) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4; - nRows = rows [(int) TableId.Assembly]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyTable(heap); - - for (int i = nRows; --i >= 0;) { - - // HashAlgId, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // MajorVersion, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // MinorVersion, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // BuildNumber, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // RevisionNumber, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // PublicKey, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Culture, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssemblyProcessor) { - rowSize = sizeof (int); - nRows = rows [(int) TableId.AssemblyProcessor]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyProcessorTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Processor, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssemblyOS) { - rowSize = sizeof (int) + sizeof (int) + sizeof (int); - nRows = rows [(int) TableId.AssemblyOS]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyOSTable(heap); - - for (int i = nRows; --i >= 0;) { - - // OSPlatformID, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // OSMajorVersion, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // OSMinorVersion, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssemblyRef) { - rowSize = sizeof (short) + sizeof (short) + sizeof (short) + sizeof (short) + sizeof (uint) + 4 + 4 + 4 + 4; - nRows = rows [(int) TableId.AssemblyRef]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyRefTable(heap); - - for (int i = nRows; --i >= 0;) { - - // MajorVersion, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // MinorVersion, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // BuildNumber, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // RevisionNumber, short - fldSize = sizeof (short); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (short); - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // PublicKeyOrToken, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Culture, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // HashValue, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssemblyRefProcessor) { - rowSize = sizeof (int) + 4; - nRows = rows [(int) TableId.AssemblyRefProcessor]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyRefProcessorTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Processor, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // AssemblyRef, index(AssemblyRef) - fldSize = GetIndexSize(TableId.AssemblyRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasAssemblyRefOS) { - rowSize = sizeof (int) + sizeof (int) + sizeof (int) + 4; - nRows = rows [(int) TableId.AssemblyRefOS]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new AssemblyRefOSTable(heap); - - for (int i = nRows; --i >= 0;) { - - // OSPlatformID, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // OSMajorVersion, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // OSMinorVersion, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // AssemblyRef, index(AssemblyRef) - fldSize = GetIndexSize(TableId.AssemblyRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasFile) { - rowSize = sizeof (uint) + 4 + 4; - nRows = rows [(int) TableId.File]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new FileTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // HashValue, index(#Blob) - fldSize = bi; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasExportedType) { - rowSize = sizeof (uint) + 4 + 4 + 4 + 4; - nRows = rows [(int) TableId.ExportedType]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ExportedTypeTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // TypeDefId, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // TypeName, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // TypeNamespace, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Implementation, coded-index(Implementation) - fldSize = GetCodedIndexSize(heap, CodedTokenId.Implementation, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasManifestResource) { - rowSize = sizeof (int) + sizeof (uint) + 4 + 4; - nRows = rows [(int) TableId.ManifestResource]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new ManifestResourceTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Offset, int - fldSize = sizeof (int); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (int); - - // Flags, uint - fldSize = sizeof (uint); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (uint); - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Implementation, coded-index(Implementation) - fldSize = GetCodedIndexSize(heap, CodedTokenId.Implementation, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasNestedClass) { - rowSize = 4 + 4; - nRows = rows [(int) TableId.NestedClass]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new NestedClassTable(heap); - - for (int i = nRows; --i >= 0;) { - - // NestedClass, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // EnclosingClass, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasTypeTyPar) { - rowSize = sizeof (ushort) + 4 + 4 + 4; - nRows = rows [(int) TableId.TypeTyPar]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new TypeTyParTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Number, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Class, index(TypeDef) - fldSize = GetIndexSize(TableId.TypeDef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Bound, coded-index(TypeDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - if (heap.HasMethodTyPar) { - rowSize = sizeof (ushort) + 4 + 4 + 4; - nRows = rows [(int) TableId.MethodTyPar]; - AllocBuff(ref buff, rowSize * nRows); - dest = 0; - - MDTable tab = new MethodTyParTable(heap); - - for (int i = nRows; --i >= 0;) { - - // Number, ushort - fldSize = sizeof (ushort); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += sizeof (ushort); - - // Method, index(Method) - fldSize = GetIndexSize(TableId.Method, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Bound, coded-index(TypeDefOrRef) - fldSize = GetCodedIndexSize(heap, CodedTokenId.TypeDefOrRef, rows); - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - // Name, index(#Strings) - fldSize = si; - Array.Copy(data, offs, buff, dest, fldSize); - offs += fldSize; - dest += 4; - - } - - tab.FromRawData(buff, 0, nRows); - } - - return offs; - } - - } // end class -} // end namespace - diff --git a/mcs/class/Mono.PEToolkit/metadata/TokenType.cs b/mcs/class/Mono.PEToolkit/metadata/TokenType.cs deleted file mode 100644 index dd4b9a49e8fba..0000000000000 --- a/mcs/class/Mono.PEToolkit/metadata/TokenType.cs +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2002 Sergey Chaban - */ - -using System; - -namespace Mono.PEToolkit.Metadata { - - /// - /// TokenType enum. - /// See mdt* constants in CorHdr. - /// - /// - /// See Metadata Unmanaged API, 9.1 Token Types - /// - public enum TokenType : int { - __shift = 24, - __mask = 0xFF << __shift, - - Module = 0x00 << __shift, - TypeRef = 0x01 << __shift, - TypeDef = 0x02 << __shift, - FieldDef = 0x04 << __shift, - MethodDef = 0x06 << __shift, - ParamDef = 0x08 << __shift, - InterfaceImpl = 0x09 << __shift, - MemberRef = 0x0a << __shift, - CustomAttribute = 0x0c << __shift, - Permission = 0x0e << __shift, - Signature = 0x11 << __shift, - Event = 0x14 << __shift, - Property = 0x17 << __shift, - ModuleRef = 0x1a << __shift, - TypeSpec = 0x1b << __shift, - Assembly = 0x20 << __shift, - AssemblyRef = 0x23 << __shift, - File = 0x26 << __shift, - ExportedType = 0x27 << __shift, - ManifestResource = 0x28 << __shift, - - String = 0x70 << __shift, - Name = 0x71 << __shift, - BaseType = 0x72 << __shift, - } - -}