Question

I'm writing a program in C# where I read a PE's bytes. But in order to get the RVA I need to use the sections headers. I'd like to know what the maximum number of sections headers is?

I tried Google and I've looked here but I haven't found anything that could point me in the right direction

Thanks.

Was it helpful?

Solution

Since the number of sections is stored in a 16bit integer, the most sections there could ever possibly be is 65535. On XP, programs with more than 96 sections will not run. On Vista and W7, you can use all 65535 sections and the program will still run. Other limits may exist on other operating systems.

OTHER TIPS

You must read the PE header. You can find a description here or you can download a full description from MSDN

Basically you must read the MZ header and after that the PE header. The number of sections is written there, so you can not simply say there are N sections in an average executable.

A rather good introduction, along with some sample code can be found here as well.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top