Skip to content

Commit

Permalink
feat: more useful selRef parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
blacktop committed Nov 1, 2020
1 parent 336f5fb commit e8688ea
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
11 changes: 7 additions & 4 deletions objc.go
Original file line number Diff line number Diff line change
Expand Up @@ -876,9 +876,9 @@ func (f *File) GetObjCProperties(vmAddr uint64) ([]objc.Property, error) {
return objcProperties, nil
}

func (f *File) GetObjCSelectorReferences() (map[uint64]string, error) {
func (f *File) GetObjCSelectorReferences() (map[uint64]*objc.Selector, error) {
var selPtrs []uint64
selRefs := make(map[uint64]string)
selRefs := make(map[uint64]*objc.Selector)

for _, s := range f.Segments() {
if strings.HasPrefix(s.Name, "__DATA") {
Expand All @@ -893,12 +893,15 @@ func (f *File) GetObjCSelectorReferences() (map[uint64]string, error) {
return nil, fmt.Errorf("failed to read selector pointers: %v", err)
}

for _, sel := range selPtrs {
for idx, sel := range selPtrs {
selName, err := f.GetCString(f.convertToVMAddr(sel))
if err != nil {
return nil, fmt.Errorf("failed to read cstring: %v", err)
}
selRefs[f.convertToVMAddr(sel)] = selName
selRefs[sec.Addr+uint64(idx*sizeOfInt64)] = &objc.Selector{
VMAddr: f.convertToVMAddr(sel),
Name: selName,
}
}
return selRefs, nil
}
Expand Down
5 changes: 5 additions & 0 deletions types/objc/objc.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,3 +601,8 @@ func (i *Ivar) String() string {
return fmt.Sprintf("+%#02x %s %s (%#x)", i.Offset, i.Type, i.Name, i.Size)
// return fmt.Sprintf("+%#02x %s %s (%#x)", i.Offset, getReturnType(i.Type), i.Name, i.Size)
}

type Selector struct {
VMAddr uint64
Name string
}

0 comments on commit e8688ea

Please sign in to comment.