Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 1.47 KB

challenges.md

File metadata and controls

52 lines (38 loc) · 1.47 KB

How Do You Create a Tweak?

Challenge 1

Convert this piece of Substrate code to Logos.

#import <UIKit/UIKit.h>
#import <substrate.h>

@interface SBIconImageView : UIView
@end

@interface SBHomeScreenBackdropView : UIView
@end

void orig_SBIconImageView_didMoveToWindow(SBIconImageView *self, SEL _cmd);

void new_SBIconImageView_didMoveToWindow(SBIconImageView *self, SEL _cmd) {
    self.alpha = 0.5;
    orig_didMoveToWindow(self, _cmd);
}

void orig_SBHomeScreenBackdropView_didMoveToSuperview(SBHomeScreenBackdropView *self, SEL _cmd);

void new_SBHomeScreenBackdropView_didMoveToSuperview(SBHomeScreenBackdropView *self, SEL _cmd) {
    self.hidden = true;
    orig_SBHomeScreenBackdropView_didMoveToSuperview(self, _cmd);
}

__attribute__((constructor)) static void initialize() {
    MSHookMessageEx(
        NSClassFromString(@"SBIconImageView"),
        @selector(didMoveToWindow),
        (IMP) &new_SBIconImageView_didMoveToWindow,
        (IMP *) &orig_SBIconImageView_didMoveToWindow
    );
    MSHookMessageEx(
        NSClassFromString(@"SBHomeScreenBackdropView"),
        @selector(didMoveToSuperview),
        (IMP) &new_SBHomeScreenBackdropView_didMoveToSuperview,
        (IMP *) &orig_SBHomeScreenBackdropView_didMoveToSuperview
    );
}

// TODO: Challenge 2

Solutions to the challenges can be found here.

Previous Page (Respringless Tweaks)