Giter Site home page Giter Site logo

kzmacho's Introduction

KZMachO

Some files for hacking mach binaries in memory. This has not been thorougly tested. Use at your own risk.

A blog post walking through the rationale and discussing the details.

What appears to work:

  • Monkey-patching classes and string symbols into iOS 7 on the simulator
  • Swizzling class references on an iOS 8 device

What doesn't appear to work:

  • Swizzling string symbols (you can only add them)

Example 1: Adding classes

KZMachOSymbolTable *symtab = [KZMachOSymbolTable new];

if([UIDevice currentDevice].systemVersion.intValue == 7) {
    // this not only fixes soft references to the class, but hard references
    [symtab addClass:[KZUIAlertController class] forName:@"UIAlertController"];
    [symtab addClass:[KZUIAlertAction class] forName:@"UIAlertAction"];

    // under iOS 7, even if we called objc_allocateClassPair, alertControllerClass would be nil
    Class alertControllerClass = [UIAlertController class];
    // it's not nil and neither is NSClassFromString("UIAlertController")

    // under iOS 7, this controller would normally be nil.  it is not.
    UIAlertController *controller = [UIAlertController new];

}

#Example 2: Adding string symbols

// sometimes string constants are missing - for example, iOS 6 cannot have UIFontTextStyleBody
// the best thing you could do in iOS 6 is swizzle in preferredFontForTextStyle: and #define UIFontTextStyleBody
// until...
[symtab setAddress:&MyUIFontTextStyleBody forSymbol:@"_UIFontTextStyleBody"];
UIFont *bodyFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

kzmacho's People

Contributors

xtravar avatar

Stargazers

SpaceGoat avatar Max Bazaliy avatar Ben Yellin avatar Jevin Sweval avatar Aleks avatar  avatar  avatar Mokhlas Hussein avatar Zhang avatar Venj avatar Claud Xiao avatar Cristian Filipov avatar Jack Pooley avatar Patrick Hart avatar Guilherme Rambo avatar ipfans avatar Cédric Luthi avatar Spotlight avatar

Watchers

Jevin Sweval avatar James Cloos avatar  avatar

Forkers

0xced terry2012

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.