Yet another library for Windows Portable Executable (PE) files
Reading the following data from PE file:
- COFF Header
- Optional Header(both of standard & Windows-specific fields)
- Section Lists
- Import Table(DLL names and symbols)
- Resource Tree
- Java 17 or later
- For Java >= 22, we read the PE file by MMAP
fun main() {
val notepad = Path.of(System.getenv("SystemRoot"), "System32", "notepad.exe")
PEFile.open(notepad).use { peFile->
// print COFF header
println(peFile.coffHeader)
// print import table
for (entry in peFile.importTable) {
println("DLL: ${entry.name}")
for (symbol in entry.symbols()) {
println(" $symbol")
}
}
// print resource tree
println("Resource Tree:")
for (entry in ResourceWalker(peFile.resourceRoot!!)) {
println(" ".repeat(entry.depth) + entry.node)
}
}
}