facebook / fishhook

A library that enables dynamically rebinding symbols in Mach-O binaries running on iOS.
BSD 3-Clause "New" or "Revised" License
5.18k stars 966 forks source link

Swift support #4

Closed mbazaliy closed 9 years ago

mbazaliy commented 10 years ago

Any plans to support Swift functions ?

ghost commented 9 years ago

Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

grp commented 9 years ago

I think this would be hard without more documentation about the Swift ABI, but we'll see more after Swift goes open source.

zixun commented 7 years ago

is there any progress?

kastiglione commented 7 years ago

@zixun Can you give a general description of what kind of functions you'd like to hook, and what your replacement function would be?

zixun commented 7 years ago

@kastiglione I want to hook print function.because I want to get the print log data automaticly and real time~

this is the print function define: public func print(_ items: Any..., separator: String = default, terminator: String = default)

and my replacement function public func printHook(_ items: Any..., separator: String = default, terminator: String = default)

kastiglione commented 7 years ago

Have you tried getting the mangled symbol names for each of those functions and used fishhook with those symbols?

zixun commented 7 years ago

@kastiglione yes. I tried it,but not word

kastiglione commented 7 years ago

If you're able to post a link to a small project, I'd be happy to take a look.

zixun commented 7 years ago

@kastiglione the demo is very little, just like this:

import UIKit
import fishhook

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()

        let r_list = UnsafeMutablePointer<rebinding>.allocate(capacity: 1)
        let r = rebinding(name: "print", replacement: my_print, replaced: &print)
        r_list[0] = r;

        rebind_symbols(r_list, 2)
    }

}

func my_print(_ items: Any..., separator: String, terminator: String) {
    print(items, separator: separator, terminator: terminator)
}