diff options
author | jfrijters <jfrijters> | 2011-03-18 08:49:05 +0300 |
---|---|---|
committer | jfrijters <jfrijters> | 2011-03-18 08:49:05 +0300 |
commit | dbfb677b7b97d5aa95ff7910567d6461608a5f7c (patch) | |
tree | 85ac8ffe272ad87d12544cc7ff84a2617aff1a26 /reflect/Reader | |
parent | 87c2970ea87fe2f43224fb0d3be1093e458701d5 (diff) |
Added Module.__ReadDataFromRVA() to make it more convenient to read data based on rva.
Diffstat (limited to 'reflect/Reader')
-rw-r--r-- | reflect/Reader/Field.cs | 13 | ||||
-rw-r--r-- | reflect/Reader/ModuleReader.cs | 19 |
2 files changed, 20 insertions, 12 deletions
diff --git a/reflect/Reader/Field.cs b/reflect/Reader/Field.cs index 5784ebce..6f25dfb2 100644 --- a/reflect/Reader/Field.cs +++ b/reflect/Reader/Field.cs @@ -87,18 +87,7 @@ namespace IKVM.Reflection.Reader Array.Clear(data, offset, length); return; } - module.SeekRVA(rva); - while (length > 0) - { - int read = module.stream.Read(data, offset, length); - if (read == 0) - { - // C++ assemblies can have fields that have an RVA that lies outside of the file - break; - } - offset += read; - length -= read; - } + module.__ReadDataFromRVA(rva, data, offset, length); } public override int __FieldRVA diff --git a/reflect/Reader/ModuleReader.cs b/reflect/Reader/ModuleReader.cs index dad37326..5ac9928e 100644 --- a/reflect/Reader/ModuleReader.cs +++ b/reflect/Reader/ModuleReader.cs @@ -1044,6 +1044,25 @@ namespace IKVM.Reflection.Reader return peFile.GetSectionInfo(rva, out name, out characteristics); } + public override int __ReadDataFromRVA(int rva, byte[] data, int offset, int length) + { + SeekRVA(rva); + int totalBytesRead = 0; + while (length > 0) + { + int read = stream.Read(data, offset, length); + if (read == 0) + { + // C++ assemblies can have fields that have an RVA that lies outside of the file + break; + } + offset += read; + length -= read; + totalBytesRead += read; + } + return totalBytesRead; + } + public override void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine) { peKind = 0; |