Reading Pe (DLL) from a Stream

Topics: PE reader, Source Model
Aug 20, 2010 at 1:41 AM

I would like to read meta-data from a Pe stream, which ISNT on the FileSystem.

How do I create a BinaryDocument from a MemoryStream? All the samples are centered around reading from the Filesystem....

 

Thanks.

 

P.s. - i do not have write access to the FileSystem, so please dont suggest "write the stream to the filesystem then use BinaryDocument.GetBinaryDocumentForFile

 

Coordinator
Aug 20, 2010 at 10:54 PM

You can use the public constructor for BinaryDocument to get an instance of IBinaryDocument without involving the file system.

The next hurdle is to get an instance of IBinaryMemoryBlock. You can now get an instance of UnmangedBinaryMemoryBlock via a factory method that takes a Stream, rather than a file name.

Finally, you need a host that will create the above mentioned objects for you, given just "file names". You'll need to subclass MetadataReaderHost and override OpenBinaryDocument.