PE size calculation
Posted: Thu Aug 12, 2010 8:10 am
Hi there all. I have a somewhat non-standard problem I’m trying to work through. Any help will get you free drinks of your choice at whatever conference we’re both at next! (Heck, at this point, I might even drop some in the mail, but shhhhh... Don’t tell the post master general.)
Anyways...
I have long streams of bytes I’m working with. In those streams, PE files are embedded inside. I can identify the PE file and am parsing/validating headers etc... So far, I'm only’ up to the optional headers, which might be the problem leading to this question, but...
Question is:
How can I calculate where the end of the PE file is in the stream of bytes?
The SizeOfImage characteristic rarely seems to match the actual size of the file in bytes, so I’m guessing there’s some kind of trickery and magic I need to do with other values to find the actual end of file.
Thank you in advance for any help!!!
Anyways...
I have long streams of bytes I’m working with. In those streams, PE files are embedded inside. I can identify the PE file and am parsing/validating headers etc... So far, I'm only’ up to the optional headers, which might be the problem leading to this question, but...
Question is:
How can I calculate where the end of the PE file is in the stream of bytes?
The SizeOfImage characteristic rarely seems to match the actual size of the file in bytes, so I’m guessing there’s some kind of trickery and magic I need to do with other values to find the actual end of file.
Thank you in advance for any help!!!