I am currently working on something in the work that requires me to delete the section from the executable file in PE format. At first, I have just removed IMAGE_SECTION_HEADER, changed NumberOfSections field in IMAGE_FILE_HEADER, recalculated SizeOfImage/SizeOfHeaders in IMAGE_OPTIONAL_HEADER and moved the raw address of following sections by the raw size of deleted section. However, Windows refused to load the file with the error message "XXX is not a valid Win32 application". I have been struggling for a while but tried to also move virtual address of following sections by the virtual size of deleted sections and everything works fine.
What is the reason that virtual addresses need to be continuous and there cannot be any gap? I have tried to read through official PE documentation, but unsuccessfully. I have always thought that it doesn't matter what address individual sections have as long as SizeOfImage has right value.
dumpbinresults from the three files? - Luaan