diff options
author | jfrijters <jfrijters> | 2011-03-03 11:34:58 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-03-03 11:34:58 +0300 |
commit | 084c8c0a5bd50f9765bfe681485d7783ad6bd708 (patch) | |
tree | 26f60d2f22238dd9a2a91b85f2f2d956bb9d0540 /reflect/Reader | |
parent | dd91949b8165f91699014c027b33a6b0581b6398 (diff) |
Added limited support for #- metadata stream ("uncompressed" table heap). ParamPtr table is not yet implemented.
Diffstat (limited to 'reflect/Reader')
-rw-r--r-- | reflect/Reader/ModuleReader.cs | 5 | ||||
-rw-r--r-- | reflect/Reader/TypeDefImpl.cs | 56 |
2 files changed, 53 insertions, 8 deletions
diff --git a/reflect/Reader/ModuleReader.cs b/reflect/Reader/ModuleReader.cs index 5b2ec44b..8349b58d 100644 --- a/reflect/Reader/ModuleReader.cs +++ b/reflect/Reader/ModuleReader.cs @@ -139,6 +139,7 @@ namespace IKVM.Reflection.Reader guidHeap = ReadHeap(stream, sh); break; case "#~": + case "#-": stream.Seek(peFile.RvaToFileOffset(cliHeader.MetaDataRVA + sh.Offset), SeekOrigin.Begin); ReadTables(br); break; @@ -207,6 +208,10 @@ namespace IKVM.Reflection.Reader tables[i].Read(mr); } } + if (ParamPtr.RowCount != 0) + { + throw new NotImplementedException("ParamPtr table support has not yet been implemented."); + } } private byte[] ReadHeap(Stream stream, StreamHeader sh) diff --git a/reflect/Reader/TypeDefImpl.cs b/reflect/Reader/TypeDefImpl.cs index 707d803b..1a2f0171 100644 --- a/reflect/Reader/TypeDefImpl.cs +++ b/reflect/Reader/TypeDefImpl.cs @@ -74,9 +74,19 @@ namespace IKVM.Reflection.Reader int evt = module.EventMap.records[i].EventList - 1; int end = module.EventMap.records.Length > i + 1 ? module.EventMap.records[i + 1].EventList - 1 : module.Event.records.Length; EventInfo[] events = new EventInfo[end - evt]; - for (int j = 0; evt < end; evt++, j++) + if (module.EventPtr.RowCount == 0) { - events[j] = new EventInfoImpl(module, this, evt); + for (int j = 0; evt < end; evt++, j++) + { + events[j] = new EventInfoImpl(module, this, evt); + } + } + else + { + for (int j = 0; evt < end; evt++, j++) + { + events[j] = new EventInfoImpl(module, this, module.EventPtr.records[evt] - 1); + } } return events; } @@ -89,9 +99,19 @@ namespace IKVM.Reflection.Reader int field = module.TypeDef.records[index].FieldList - 1; int end = module.TypeDef.records.Length > index + 1 ? module.TypeDef.records[index + 1].FieldList - 1 : module.Field.records.Length; FieldInfo[] fields = new FieldInfo[end - field]; - for (int i = 0; field < end; i++, field++) + if (module.FieldPtr.RowCount == 0) { - fields[i] = module.GetFieldAt(this, field); + for (int i = 0; field < end; i++, field++) + { + fields[i] = module.GetFieldAt(this, field); + } + } + else + { + for (int i = 0; field < end; i++, field++) + { + fields[i] = module.GetFieldAt(this, module.FieldPtr.records[field] - 1); + } } return fields; } @@ -120,9 +140,19 @@ namespace IKVM.Reflection.Reader int method = module.TypeDef.records[index].MethodList - 1; int end = module.TypeDef.records.Length > index + 1 ? module.TypeDef.records[index + 1].MethodList - 1 : module.MethodDef.records.Length; MethodBase[] methods = new MethodBase[end - method]; - for (int i = 0; method < end; method++, i++) + if (module.MethodPtr.RowCount == 0) { - methods[i] = module.GetMethodAt(this, method); + for (int i = 0; method < end; method++, i++) + { + methods[i] = module.GetMethodAt(this, method); + } + } + else + { + for (int i = 0; method < end; method++, i++) + { + methods[i] = module.GetMethodAt(this, module.MethodPtr.records[method] - 1); + } } return methods; } @@ -186,9 +216,19 @@ namespace IKVM.Reflection.Reader int property = module.PropertyMap.records[i].PropertyList - 1; int end = module.PropertyMap.records.Length > i + 1 ? module.PropertyMap.records[i + 1].PropertyList - 1 : module.Property.records.Length; PropertyInfo[] properties = new PropertyInfo[end - property]; - for (int j = 0; property < end; property++, j++) + if (module.PropertyPtr.RowCount == 0) { - properties[j] = new PropertyInfoImpl(module, this, property); + for (int j = 0; property < end; property++, j++) + { + properties[j] = new PropertyInfoImpl(module, this, property); + } + } + else + { + for (int j = 0; property < end; property++, j++) + { + properties[j] = new PropertyInfoImpl(module, this, module.PropertyPtr.records[property] - 1); + } } return properties; } |