public long getFileOffset ( SectionTable table ) { checkArgument ( table != null , "section table must not be null" ) ; Optional < SectionHeader > section = maybeGetSectionTableEntry ( table ) ; if ( section . isPresent ( ) ) { long sectionRVA = section . get ( ) . getAlignedVirtualAddress ( ) ; long sectionOffset = section . get ( ) . getAlignedPointerToRaw ( ) ; return ( virtualAddress - sectionRVA ) + sectionOffset ; } return virtualAddress ; // TODO should be smaller than file length! }
Calculates the file offset of the data directory based on the virtual address and the entries in the section table . This method is subject to change .