diff --git a/objc.go b/objc.go index f31d53c..724fd58 100644 --- a/objc.go +++ b/objc.go @@ -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") { @@ -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 } diff --git a/types/objc/objc.go b/types/objc/objc.go index b04dcbc..bcb5a47 100644 --- a/types/objc/objc.go +++ b/types/objc/objc.go @@ -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 +}