mirror of
https://github.com/DKJone/DKWechatHelper.git
synced 2025-05-25 20:36:08 +08:00
92 lines
2.4 KiB
Objective-C
92 lines
2.4 KiB
Objective-C
// weibo: http://weibo.com/xiaoqing28
|
|
// blog: http://www.alonemonkey.com
|
|
//
|
|
// dkhelperDylib.m
|
|
// dkhelperDylib
|
|
//
|
|
// Created by 朱德坤 on 2019/1/23.
|
|
// Copyright (c) 2019 DKJone. All rights reserved.
|
|
//
|
|
|
|
#import "dkhelperDylib.h"
|
|
#import <CaptainHook/CaptainHook.h>
|
|
#import <UIKit/UIKit.h>
|
|
#import <Cycript/Cycript.h>
|
|
#import <MDCycriptManager.h>
|
|
|
|
CHConstructor{
|
|
printf(INSERT_SUCCESS_WELCOME);
|
|
|
|
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
|
|
|
|
#ifndef __OPTIMIZE__
|
|
CYListenServer(6666);
|
|
|
|
MDCycriptManager* manager = [MDCycriptManager sharedInstance];
|
|
[manager loadCycript:NO];
|
|
|
|
NSError* error;
|
|
NSString* result = [manager evaluateCycript:@"UIApp" error:&error];
|
|
NSLog(@"result: %@", result);
|
|
if(error.code != 0){
|
|
NSLog(@"error: %@", error.localizedDescription);
|
|
}
|
|
#endif
|
|
|
|
}];
|
|
}
|
|
|
|
|
|
CHDeclareClass(CustomViewController)
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wstrict-prototypes"
|
|
|
|
//add new method
|
|
CHDeclareMethod1(void, CustomViewController, newMethod, NSString*, output){
|
|
NSLog(@"This is a new method : %@", output);
|
|
}
|
|
|
|
#pragma clang diagnostic pop
|
|
|
|
CHOptimizedClassMethod0(self, void, CustomViewController, classMethod){
|
|
NSLog(@"hook class method");
|
|
CHSuper0(CustomViewController, classMethod);
|
|
}
|
|
|
|
CHOptimizedMethod0(self, NSString*, CustomViewController, getMyName){
|
|
//get origin value
|
|
NSString* originName = CHSuper(0, CustomViewController, getMyName);
|
|
|
|
NSLog(@"origin name is:%@",originName);
|
|
|
|
//get property
|
|
NSString* password = CHIvar(self,_password,__strong NSString*);
|
|
|
|
NSLog(@"password is %@",password);
|
|
|
|
[self newMethod:@"output"];
|
|
|
|
//set new property
|
|
self.newProperty = @"newProperty";
|
|
|
|
NSLog(@"newProperty : %@", self.newProperty);
|
|
|
|
//change the value
|
|
return @"朱德坤";
|
|
|
|
}
|
|
|
|
//add new property
|
|
CHPropertyRetainNonatomic(CustomViewController, NSString*, newProperty, setNewProperty);
|
|
|
|
CHConstructor{
|
|
CHLoadLateClass(CustomViewController);
|
|
CHClassHook0(CustomViewController, getMyName);
|
|
CHClassHook0(CustomViewController, classMethod);
|
|
|
|
CHHook0(CustomViewController, newProperty);
|
|
CHHook1(CustomViewController, setNewProperty);
|
|
}
|
|
|