Skip to content

Commit

Permalink
fix: only slide ptr when necessary
Browse files Browse the repository at this point in the history
Signed-off-by: Zxilly <[email protected]>
  • Loading branch information
Zxilly committed Oct 21, 2024
1 parent 8ca73eb commit ab722e8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion internal/wrapper/macho.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,21 @@ import (
)

type MachoWrapper struct {
file *macho.File
file *macho.File
chainedFixedUp bool
}

func NewMachoWrapper(f *macho.File) *MachoWrapper {
return &MachoWrapper{
file: f,
chainedFixedUp: f.HasDyldChainedFixups(),
}
}

func (m *MachoWrapper) SlidePointer(addr uint64) uint64 {
if !m.chainedFixedUp {
return addr
}
return m.file.SlidePointer(addr) + m.file.GetBaseAddress()
}

Expand Down
2 changes: 1 addition & 1 deletion internal/wrapper/wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func NewWrapper(file any) RawFileWrapper {
case *pe.File:
return &PeWrapper{f, utils.GetImageBase(f)}
case *macho.File:
return &MachoWrapper{f}
return NewMachoWrapper(f)
}
return nil
}

0 comments on commit ab722e8

Please sign in to comment.