Skip to content

Instantly share code, notes, and snippets.

@akkuman
Created Oct 13, 2021
Embed
What would you like to do?
[go解析导出表] golang解析pe的导出表 #golang #pe
package main
import (
"fmt"
"os"
"github.com/fcharlie/buna/debug/pe"
)
func main() {
if len(os.Args) < 2 {
fmt.Fprintf(os.Stderr, "usage: %s pefile\n", os.Args[0])
os.Exit(1)
}
fd, err := pe.Open(os.Args[1])
if err != nil {
fmt.Fprintf(os.Stderr, "unable open file: %s %v\n", os.Args[1], err)
os.Exit(1)
}
defer fd.Close()
ft, err := fd.LookupFunctionTable()
if err != nil {
fmt.Fprintf(os.Stderr, "unable LookupExports: %s %v\n", os.Args[1], err)
os.Exit(1)
}
for _, d := range ft.Exports {
// fmt.Fprintf(os.Stderr, "\x1b[35mE %5d %08X %s (Hint: %d)\x1b[0m\n", d.Ordinal, d.Address, demangle.Demangle(d.Name), d.Hint)
fmt.Fprintf(os.Stderr, "\x1b[35mE %5d %08X %s (Hint: %d)\x1b[0m\n", d.Ordinal, d.Address, d.Name, d.Hint)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment