title: Why does section virtual addresses need to be continuous?
body: <p>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 <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680341(v=vs.85).aspx" rel="nofollow">IMAGE_SECTION_HEADER</a>, changed NumberOfSections field in <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680313(v=vs.85).aspx" rel="nofollow">IMAGE_FILE_HEADER</a>, recalculated SizeOfImage/SizeOfHeaders in <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680339(v=vs.85).aspx" rel="nofollow">IMAGE_OPTIONAL_HEADER</a> 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.</p>
  
  <p>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.</p>