Skip to content

Latest commit

 

History

History
48 lines (38 loc) · 1.36 KB

README.md

File metadata and controls

48 lines (38 loc) · 1.36 KB

PEFile

GitHub Actions Workflow Status Maven Central Version License

Yet another library for Windows Portable Executable (PE) files

Features

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

Requirements

  • Java 17 or later
    • For Java >= 22, we read the PE file by MMAP

Usage

Main.kt

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)
    }
  }
}