列出在任意PEEXE文件中链接的DLL的名称

问题描述

我偶然发现了要读取链接到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列表?

解决方法

这似乎做到了:

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

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...