【问题标题】:List names of DLL linked in an arbitrary PE ( EXE ) file列出任意 PE (EXE) 文件中链接的 DLL 的名称
【发布时间】:2020-09-29 02:11:10
【问题描述】:

我偶然发现了读取链接到 Windows 上任意 PE 可执行文件的 DLL 文件列表的任务。虽然debug/pe 看起来很有希望,但发现却很糟糕:

// ImportedLibraries returns the names of all libraries
// referred to by the binary f that are expected to be
// linked with the binary at dynamic link time.
func (f *File) ImportedLibraries() ([]string, error) {
    // TODO
    // cgo -dynimport don't use this for windows PE, so just return.
    return nil, nil
}

那么我可以使用什么来从 EXE 文件中提取 DLL 列表吗?

【问题讨论】:

标签: windows go portable-executable


【解决方案1】:

这似乎可以做到:

package main
import "github.com/Binject/debug/pe"

func main() {
   f, e := pe.Open(`C:\Windows\notepad.exe`)
   if e != nil {
      panic(e)
   }
   defer f.Close()
   a, e := f.ImportedLibraries()
   if e != nil {
      panic(e)
   }
   for _, s := range a {
      println(s)
   }
}

https://pkg.go.dev/github.com/Binject/debug/pe

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-02-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-07
    • 2013-05-24
    相关资源
    最近更新 更多