зеркало из https://github.com/mono/ikvm-fork.git
Added Module.__ReadDataFromRVA() to make it more convenient to read data based on rva.
This commit is contained in:
Родитель
87c2970ea8
Коммит
dbfb677b7b
|
@ -207,6 +207,11 @@ namespace IKVM.Reflection
|
|||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public virtual int __ReadDataFromRVA(int rva, byte[] data, int offset, int length)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public virtual void GetPEKind(out PortableExecutableKinds peKind, out ImageFileMachine machine)
|
||||
{
|
||||
throw new NotSupportedException();
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
Загрузка…
Ссылка в новой задаче