mirror of
https://github.com/thunderbrewhq/binana.git
synced 2026-03-22 22:00:13 +00:00
This commit is contained in:
parent
ac268a16c8
commit
2c2815ab0b
22 changed files with 2122 additions and 2 deletions
31
go/app/util/exe.go
Normal file
31
go/app/util/exe.go
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
package util
|
||||
|
||||
import (
|
||||
"debug/pe"
|
||||
"os"
|
||||
)
|
||||
|
||||
func get_exe_base_address(name string) (base_address uint64, err error) {
|
||||
var file *os.File
|
||||
file, err = os.Open(name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
pe_file *pe.File
|
||||
)
|
||||
pe_file, err = pe.NewFile(file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
base_address = uint64(0x400000)
|
||||
|
||||
switch h := pe_file.OptionalHeader.(type) {
|
||||
case *pe.OptionalHeader32:
|
||||
base_address = uint64(h.ImageBase)
|
||||
case *pe.OptionalHeader64:
|
||||
base_address = h.ImageBase
|
||||
}
|
||||
file.Close()
|
||||
return
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue