Skip to content
Karsten Hahn edited this page Feb 11, 2023 · 11 revisions

Print Information

PEData data = PELoader.loadPE(file);
ReportCreator reporter = new ReportCreator(data);
System.out.println(reporter.importsReport());

Loading the Import Section

SectionLoader loader = new SectionLoader(data);
ImportSection idata = loader.loadImportSection();

List of Imports

Loading import DLL list (since 4.0.0)

PEData data = PELoader.loadPE(file);
List<ImportDLL> importList = data.loadImports();

Loading import DLL list (before 4.0.0 this is the only way)

PEData data = PELoader.loadPE(file);
SectionLoader loader = new SectionLoader(data);
ImportSection idata = loader.loadImportSection();
List<ImportDLL> imports = idata.getImports();

Iterating import DLLs, obtaining name and ordinal imports, and printing information

for(ImportDLL dll : imports) {
    System.out.println("Imports from " + dll.getName());
    for(NameImport nameImport : dll.getNameImports()) {
        System.out.print("Name: " + nameImport.getName());
        System.out.print(" Hint: " + nameImport.getHint());
        System.out.println(" RVA: " + nameImport.getRVA());
    }
			
    for(OrdinalImport ordImport : dll.getOrdinalImports()) {
        System.out.println("Ordinal: " + ordImport.getOrdinal());
    }
    System.out.println();
}

Access to Import Section Structures

List<DirectoryEntry> dirTable = idata.getDirectory();
    for (DirectoryEntry tableEntry : dirTable) {
    Map<DirectoryEntryKey, StandardField> map = tableEntry.getEntries();

    for (StandardField field : map.values()) {
        System.out.println(field.getDescription() + ": " + field.getValue());
    }
}