TableHeap.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //
  2. // TableHeap.cs
  3. //
  4. // Author:
  5. // Jb Evain (jbevain@gmail.com)
  6. //
  7. // Copyright (c) 2008 - 2011 Jb Evain
  8. //
  9. // Permission is hereby granted, free of charge, to any person obtaining
  10. // a copy of this software and associated documentation files (the
  11. // "Software"), to deal in the Software without restriction, including
  12. // without limitation the rights to use, copy, modify, merge, publish,
  13. // distribute, sublicense, and/or sell copies of the Software, and to
  14. // permit persons to whom the Software is furnished to do so, subject to
  15. // the following conditions:
  16. //
  17. // The above copyright notice and this permission notice shall be
  18. // included in all copies or substantial portions of the Software.
  19. //
  20. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  21. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  22. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  23. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  24. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  25. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  26. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  27. //
  28. using System;
  29. using Mono.Cecil.PE;
  30. namespace Mono.Cecil.Metadata {
  31. enum Table : byte {
  32. Module = 0x00,
  33. TypeRef = 0x01,
  34. TypeDef = 0x02,
  35. FieldPtr = 0x03,
  36. Field = 0x04,
  37. MethodPtr = 0x05,
  38. Method = 0x06,
  39. ParamPtr = 0x07,
  40. Param = 0x08,
  41. InterfaceImpl = 0x09,
  42. MemberRef = 0x0a,
  43. Constant = 0x0b,
  44. CustomAttribute = 0x0c,
  45. FieldMarshal = 0x0d,
  46. DeclSecurity = 0x0e,
  47. ClassLayout = 0x0f,
  48. FieldLayout = 0x10,
  49. StandAloneSig = 0x11,
  50. EventMap = 0x12,
  51. EventPtr = 0x13,
  52. Event = 0x14,
  53. PropertyMap = 0x15,
  54. PropertyPtr = 0x16,
  55. Property = 0x17,
  56. MethodSemantics = 0x18,
  57. MethodImpl = 0x19,
  58. ModuleRef = 0x1a,
  59. TypeSpec = 0x1b,
  60. ImplMap = 0x1c,
  61. FieldRVA = 0x1d,
  62. EncLog = 0x1e,
  63. EncMap = 0x1f,
  64. Assembly = 0x20,
  65. AssemblyProcessor = 0x21,
  66. AssemblyOS = 0x22,
  67. AssemblyRef = 0x23,
  68. AssemblyRefProcessor = 0x24,
  69. AssemblyRefOS = 0x25,
  70. File = 0x26,
  71. ExportedType = 0x27,
  72. ManifestResource = 0x28,
  73. NestedClass = 0x29,
  74. GenericParam = 0x2a,
  75. MethodSpec = 0x2b,
  76. GenericParamConstraint = 0x2c,
  77. }
  78. struct TableInformation {
  79. public uint Offset;
  80. public uint Length;
  81. public uint RowSize;
  82. }
  83. sealed class TableHeap : Heap {
  84. public long Valid;
  85. public long Sorted;
  86. public const int TableCount = 45;
  87. public readonly TableInformation [] Tables = new TableInformation [TableCount];
  88. public TableInformation this [Table table] {
  89. get { return Tables [(int) table]; }
  90. }
  91. public TableHeap (Section section, uint start, uint size)
  92. : base (section, start, size)
  93. {
  94. }
  95. public bool HasTable (Table table)
  96. {
  97. return (Valid & (1L << (int) table)) != 0;
  98. }
  99. }
  100. }