GithubHelp home page GithubHelp logo

refusebt / plpatchmaster Goto Github PK

View Code? Open in Web Editor NEW

This project forked from plausiblelabs/plpatchmaster

0.0 2.0 0.0 329 KB

Mirror of the official PLPatchMaster repository

Home Page: https://opensource.plausible.coop/src/projects/PLTP/repos/plpatchmaster

License: Other

Objective-C 14.68% C 4.94% Objective-C++ 23.81% C++ 30.34% Shell 26.24%

plpatchmaster's Introduction

PLPatchMaster

PLPatchMaster provides an easy-to-use block-based swizzling API, using the block trampoline library provided by PLBlockIMP, and a set of custom assembly trampolines for ARMv7, ARMv7s, ARM64, and x86-64.

PLPatchMaster can apply patches to currently loaded classes, as well as classes that have not yet been loaded (eg, will be loaded at a future time) by registering a listener for dyld image events.

Use it at your own risk; swizzling in production software is rarely, if ever, a particularly good idea.

PLPatchMaster is released under the MIT license.

Basic Use

Use a block to swizzle -[UIWindow sendEvent:]:

[UIWindow pl_patchInstanceSelector: @selector(sendEvent:) withReplacementBlock: ^(PLPatchIMP *patch, UIEvent *event) {
    NSObject *obj = PLPatchGetSelf(patch);
    
    // Ignore 'remote control' events
    if (event.type == UIEventTypeRemoteControl)
        return;

    // Forward everything else
    return PLPatchIMPFoward(patch, void (*)(id, SEL, UIEvent *), event);
}];

Advanced Use

Register a future patch on a class that has not been loaded yet (eg, it's loaded dynamically at runtime):

[[PLPatchMaster master] patchFutureClassWithName: @"ExFATCameraDeviceManager" withReplacementBlock: ^(PLPatchIMP *patch, id *arg) {
    /* Forward the message to the next IMP */
    PLPatchIMPFoward(patch, void (*)(id, SEL, id *));
    
    /* Log the event */
    NSLog(@"FAT camera device ejected");
}];

PLPatchMaster registers a listener for dyld image events, and will automatically swizzle the target class when its Mach-O image is loaded.

plpatchmaster's People

Contributors

landonf avatar

Watchers

James Cloos avatar 進撃の技術者 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.