Commit 44bcc1fc authored by Wei Guangjing's avatar Wei Guangjing Committed by Russ Cox

debug/pe: ImportedSymbols fixes

R=golang-dev, brainman, mattn, rsc
CC=golang-dev
https://golang.org/cl/4001058
parent 9fe490ee
...@@ -57,7 +57,6 @@ type ImportDirectory struct { ...@@ -57,7 +57,6 @@ type ImportDirectory struct {
FirstThunk uint32 FirstThunk uint32
dll string dll string
rva []uint32
} }
// Data reads and returns the contents of the PE section. // Data reads and returns the contents of the PE section.
...@@ -267,34 +266,28 @@ func (f *File) ImportedSymbols() ([]string, os.Error) { ...@@ -267,34 +266,28 @@ func (f *File) ImportedSymbols() ([]string, os.Error) {
} }
ida = append(ida, dt) ida = append(ida, dt)
} }
for i, _ := range ida { names, _ := ds.Data()
for len(d) > 0 { var all []string
va := binary.LittleEndian.Uint32(d[0:4]) for _, dt := range ida {
d = d[4:] dt.dll, _ = getString(names, int(dt.Name-ds.VirtualAddress))
if va == 0 { d, _ = ds.Data()
break // seek to OriginalFirstThunk
} d = d[dt.OriginalFirstThunk-ds.VirtualAddress:]
ida[i].rva = append(ida[i].rva, va)
}
}
for _, _ = range ida {
for len(d) > 0 { for len(d) > 0 {
va := binary.LittleEndian.Uint32(d[0:4]) va := binary.LittleEndian.Uint32(d[0:4])
d = d[4:] d = d[4:]
if va == 0 { if va == 0 {
break break
} }
} if va&0x80000000 > 0 { // is Ordinal
} // TODO add dynimport ordinal support.
names, _ := ds.Data() //ord := va&0x0000FFFF
var all []string } else {
for _, dt := range ida {
dt.dll, _ = getString(names, int(dt.Name-ds.VirtualAddress))
for _, va := range dt.rva {
fn, _ := getString(names, int(va-ds.VirtualAddress+2)) fn, _ := getString(names, int(va-ds.VirtualAddress+2))
all = append(all, fn+":"+dt.dll) all = append(all, fn+":"+dt.dll)
} }
} }
}
return all, nil return all, nil
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment