void (long newOffset) { super.resetOffsets(newOffset); long mainOffset = myPeHeader.getOffset() + myPeHeader.sizeInBytes() + myPadding.sizeInBytes(); long mainOffset2 = myPeHeader.sizeInBytes() + myMsDosStub.sizeInBytes() + myMsDosHeader.sizeInBytes() + myPadding.sizeInBytes(); assert mainOffset == myPeHeader.getImageOptionalHeader().getSizeOfHeaders().getValue(); assert mainOffset == mainOffset2; long offset = 0; for (Section section : mySections) { section.resetOffsets(mainOffset + offset); offset += section.sizeInBytes(); } // Update SizeOfImage with not real bytes size, but with virtual size myImageOptionalHeader.getSizeOfImage().setValue(virtualSizeInBytes()); }