Coder Social home page Coder Social logo

tnek / hookkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjolano/hookkit

0.0 0.0 0.0 237 KB

An iOS tweak developer framework to unify code substitution APIs in runtime.

License: BSD 3-Clause "New" or "Revised" License

Shell 0.60% Objective-C 97.57% Makefile 1.83%

hookkit's Introduction

HookKit

An iOS tweak developer framework to unify code substitution APIs in runtime.

... I actually don't know how useful this is. (but it's quite fun to see it work)

This framework allows tweak developers to hook functions with a standard and consistent API. Standard hooking functions are accessed through the HKSubstitutor class, or using convenience macros.

Installation

To use this framework:

  • Run install_to_theos.sh to install HookKit to your Theos development environment.
  • Add HookKit to <project_name>_EXTRA_FRAMEWORKS.
  • Add me.jjolano.fmwk.hookkit to your package dependencies.
  • Include the HookKit.h header file. Refer to HookKit.h for more information.

HookKit Framework is available on my repo (https://ios.jjolano.me).

Advantages and Disadvantages

Advantages:

  • Improved performance through use of batch hooking (if supported).
  • Ability to switch hooking libraries from your tweak. Shadow provides this functionality.

Disadvantages:

  • Some library-specific functionality is not implemented (yet)
  • Existing tweaks will need to be rewritten/recompiled to use HookKit

Library Support

So far, support has been (mostly) implemented for the following code substitution libraries:

  • libhooker
  • Substitute
  • Cydia Substrate
  • ElleKit
  • Fishhook
  • Dobby

Migration

An easy way to migrate a Theos tweak to HookKit is to simply override the MSHookFunction and MSHookMessageEx functions. Place the following at the top of the file with hooking code:

#define MSHookFunction      HKHookFunction
#define MSHookMessageEx     HKHookMessage

Note that this does not use batching by default. See the below example for batching.

Examples

MobileSubstrate method:

MSHookFunction(func_1, replaced_func_1, (void **)&orig_func_1);
MSHookFunction(func_2, replaced_func_2, (void **)&orig_func_2);
MSHookFunction(func_3, replaced_func_3, (void **)&orig_func_3);

HookKit method (standard):

HKHookFunction(func_1, replaced_func_1, (void **)&orig_func_1);
HKHookFunction(func_2, replaced_func_2, (void **)&orig_func_2);
HKHookFunction(func_3, replaced_func_3, (void **)&orig_func_3);

HookKit method (batching):

HKEnableBatching();

HKHookFunction(func_1, replaced_func_1, (void **)&orig_func_1);
HKHookFunction(func_2, replaced_func_2, (void **)&orig_func_2);
HKHookFunction(func_3, replaced_func_3, (void **)&orig_func_3);

HKExecuteBatch();

Credits

fishhook

https://github.com/facebook/fishhook

Dobby

https://github.com/jmpews/Dobby

libhooker

https://gist.github.com/coolstar/902bb1a4664f3d987ae954aaf39415f9

Substitute

https://github.com/sbingner/substitute

ElleKit

https://github.com/evelyneee/ellekit

hookkit's People

Contributors

jjolano avatar tnek avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.