/FishHook

A lightweight, pure-Swift library that enables dynamically rebinding symbols in Mach-O binaries running on iOS .

Primary LanguageSwiftMIT LicenseMIT

Carthage compatible badge-pms Swift Version

FishHook is a lightweight, pure-Swift library that enables dynamically rebinding symbols in Mach-O binaries running on iOS in the simulator and on device. This project is heavily inspired by the popular fishhook.

Usage

typealias NewPrintf = @convention(thin) (String, Any...) -> Void

func newPrinf(str: String, arg: Any...) -> Void {
    print("test success")
}

public func fishhookPrint(newMethod: UnsafeMutableRawPointer) {
    var oldMethod: UnsafeMutableRawPointer?
    rebindSymbol("printf", replacement: newMethod, replaced: &oldMethod)
}

fishhookPrint(newMethod: unsafeBitCast(newPrinf as NewPrintf, to: UnsafeMutableRawPointer.self))

Requirements

  • iOS 8.0+
  • Swift 4.0-5.x

Installation

Carthage

Add the following line to your Cartfile

git "https://github.com/woshiccm/FishHook.git" "master"

Thanks

fishhook
anti-fishhook.

License

Aspect is released under the MIT license. See LICENSE for details.