├── Default-568h@2x.png
├── WeChatDemo
├── icon.png
├── Scripts
│ └── quick-resign.sh
├── Config
│ └── MDConfig.plist
└── Info.plist
├── README.md
├── WeChatDemo.xcodeproj
├── project.xcworkspace
│ ├── contents.xcworkspacedata
│ ├── xcuserdata
│ │ └── mac.xcuserdatad
│ │ │ └── UserInterfaceState.xcuserstate
│ └── xcshareddata
│ │ └── IDEWorkspaceChecks.plist
└── xcuserdata
│ └── mac.xcuserdatad
│ ├── xcschemes
│ └── xcschememanagement.plist
│ └── xcdebugger
│ └── Breakpoints_v2.xcbkptlist
└── WeChatDemoDylib
├── WeChatDemoDylib-Prefix.pch
├── NSMutableDictionary+Safe.m
├── NSMutableDictionary+Safe.h
├── Comm.h
├── MyMoreViewController.h
├── MyRedEnvelopesProcc.h
├── WeChatDemoDylib.h
├── Tools
├── LLDBTools.h
└── LLDBTools.mm
├── Config
├── MDCycriptManager.h
├── MDMethodTrace.h
├── MDConfigManager.m
├── MDConfigManager.h
└── MDCycriptManager.m
├── Trace
├── OCSelectorTrampolines.h
├── selectortramps.mac
├── OCMethodTrace.h
├── a1a2-selectortramps-arm64.s
├── a1a2-selectortramps-arm.s
├── a2a3-selectortramps-arm.s
├── a1a2-selectortramps-x86_64.s
├── a2a3-selectortramps-x86_64.s
├── a2a3-selectortramps-i386.s
├── a1a2-selectortramps-i386.s
└── OCSelectorTrampolines.mm
├── Comm.m
├── Header.h
├── WeChatDemoDylib.m
├── fishhook
├── fishhook.h
└── fishhook.c
├── Logos
├── WeChatDemoDylib.xm
└── WeChatDemoDylib.mm
├── MyMoreViewController.m
├── AntiAntiDebug
└── AntiAntiDebug.m
└── MyRedEnvelopesProcc.m
/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/786572258/WeChatDemo/HEAD/Default-568h@2x.png
--------------------------------------------------------------------------------
/WeChatDemo/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/786572258/WeChatDemo/HEAD/WeChatDemo/icon.png
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # WeChatDemo
2 | ios微信自动抢红包和修改运动步数的注入实现。
3 | 博客教程:https://blog.csdn.net/w786572258/article/details/106956582
4 |
--------------------------------------------------------------------------------
/WeChatDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/WeChatDemo.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/786572258/WeChatDemo/HEAD/WeChatDemo.xcodeproj/project.xcworkspace/xcuserdata/mac.xcuserdatad/UserInterfaceState.xcuserstate
--------------------------------------------------------------------------------
/WeChatDemoDylib/WeChatDemoDylib-Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'WeChatDemoDylib' target in the 'WeChatDemoDylib' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #import "/opt/theos/Prefix.pch" //path/to/theos/Prefix.pch
8 | #endif
9 |
--------------------------------------------------------------------------------
/WeChatDemo.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/NSMutableDictionary+Safe.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableDictionary+Safe.m
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/21.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 | #import "NSMutableDictionary+Safe.h"
9 |
10 | #import
11 |
12 |
13 | @implementation NSMutableDictionary (Safe)
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/NSMutableDictionary+Safe.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableDictionary+Safe.h
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/21.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 | #import
9 |
10 |
11 | #import
12 |
13 | NS_ASSUME_NONNULL_BEGIN
14 |
15 | @interface NSMutableDictionary (Safe)
16 |
17 | - (void)safeSetObject:(id)anObject forKey:(id)aKey;
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Comm.h:
--------------------------------------------------------------------------------
1 | //
2 | // Comm.h
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/19.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | NS_ASSUME_NONNULL_BEGIN
12 |
13 | @interface Comm : NSObject
14 | + (void)test:(id)arg1;
15 |
16 | +(void) saveHookConfig:(id)setObject forKey:(NSString*)key;
17 | +(BOOL) confIsRedEnvelopeSwitchEnable;
18 | +(NSString*) confWcWalkNumberString;
19 |
20 | @end
21 |
22 | NS_ASSUME_NONNULL_END
23 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/MyMoreViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // MyMoreViewController.h
3 | // Test2
4 | //
5 | // Created by Mac on 2020/6/19.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "Comm.h"
12 | NS_ASSUME_NONNULL_BEGIN
13 |
14 | @interface MyMoreViewController : NSObject
15 | +(void)redEnvelopeSwitchChange:(id)sender;
16 | +(UITableViewCell*) createWCSportTextField;
17 | +(void)setTableViewObject:(UITableView*)tableView;
18 |
19 | @end
20 |
21 | NS_ASSUME_NONNULL_END
22 |
--------------------------------------------------------------------------------
/WeChatDemo.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SchemeUserState
6 |
7 | WeChatDemo.xcscheme_^#shared#^_
8 |
9 | orderHint
10 | 0
11 |
12 | WeChatDemoDylib.xcscheme_^#shared#^_
13 |
14 | orderHint
15 | 1
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/WeChatDemo/Scripts/quick-resign.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Usage
4 | # Must be an absolute path
5 |
6 | # ./quick-resign.sh [insert] "origin.ipa path" "resign.ipa path"
7 |
8 | INSERT_DYLIB=NO
9 | INPUT_PATH=$1
10 | OUTPUT_PATH=$2
11 |
12 | if [[ $1 == "insert" ]];then
13 | INSERT_DYLIB=YES
14 | INPUT_PATH=$2
15 | OUTPUT_PATH=$3
16 | fi
17 |
18 | if [[ ! $OUTPUT_PATH ]];then
19 | OUTPUT_PATH=$PWD
20 | fi
21 |
22 | cp -rf $INPUT_PATH ../TargetApp/
23 | cd ../../
24 | xcodebuild MONKEYDEV_INSERT_DYLIB=$INSERT_DYLIB | xcpretty
25 | cd LatestBuild
26 | ./createIPA.command
27 | cp -rf Target.ipa $OUTPUT_PATH
28 | exit 0
--------------------------------------------------------------------------------
/WeChatDemoDylib/MyRedEnvelopesProcc.h:
--------------------------------------------------------------------------------
1 | //
2 | // MyRedEnvelopesProcc.h
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/21.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "WeChatDemoDylib/Header.h"
11 | #import "WeChatDemoDylib/Comm.h"
12 | #import
13 | #import "NSMutableDictionary+Safe.h"
14 | NS_ASSUME_NONNULL_BEGIN
15 |
16 | @interface MyRedEnvelopesProcc : NSObject
17 | +(void) onNewSyncAddMessageProcc:(id)arg1;
18 | +(void) OnWCToHongbaoCommonResponseProcc:(id)hongBaoRes Request:(id)hongBaoReq;
19 |
20 | @end
21 |
22 | NS_ASSUME_NONNULL_END
23 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/WeChatDemoDylib.h:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // WeChatDemoDylib.h
5 | // WeChatDemoDylib
6 | //
7 | // Created by Mac on 2020/6/18.
8 | // Copyright (c) 2020 maimai. All rights reserved.
9 | //
10 |
11 | #import
12 |
13 | #define INSERT_SUCCESS_WELCOME " 🎉!!!congratulations!!!🎉\n👍----------------insert dylib success----------------👍\n"
14 |
15 | @interface CustomViewController
16 |
17 | @property (nonatomic, copy) NSString* newProperty;
18 |
19 | + (void)classMethod;
20 |
21 | - (NSString*)getMyName;
22 |
23 | - (void)newMethod:(NSString*) output;
24 |
25 | @end
26 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Tools/LLDBTools.h:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // LLDBTools.h
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/3/8.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #import
12 | #import
13 |
14 | //(lldb) po pviews()
15 |
16 | NSString* pvc(void);
17 |
18 | NSString* pviews(void);
19 |
20 | NSString* pactions(vm_address_t address);
21 |
22 | NSString* pblock(vm_address_t address);
23 |
24 | NSString* methods(const char * classname);
25 |
26 | NSString* ivars(vm_address_t address);
27 |
28 | NSString* choose(const char* classname);
29 |
30 | NSString* vmmap();
31 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Config/MDCycriptManager.h:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // MDCycriptManager.h
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/3/8.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #ifndef __OPTIMIZE__
12 |
13 | #import
14 |
15 | #define PORT 6666
16 |
17 | @interface MDCycriptManager : NSObject
18 |
19 | + (instancetype)sharedInstance;
20 |
21 |
22 | /**
23 | Download script by config.plist
24 |
25 | @param update Force update of all scripts
26 | */
27 | -(void)loadCycript:(BOOL) update;
28 |
29 | /**
30 | eval javascript by cycript
31 |
32 | @param cycript javascript string
33 | @param error error happened
34 | @return eval result
35 | */
36 | -(NSString*)evaluateCycript:(NSString*) cycript error:(NSError **) error;
37 |
38 | @end
39 |
40 | #endif
--------------------------------------------------------------------------------
/WeChatDemoDylib/Config/MDMethodTrace.h:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // MDMethodTrace.h
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2017/9/7.
8 | // Copyright © 2017年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #ifndef MethodTrace_h
12 | #define MethodTrace_h
13 |
14 | #define TRACE_README @"\n📚--------------------OCMethodTrace(Usage)-------------------📚\nhttps://github.com/omxcodec/OCMethodTrace/blob/master/README.md\n📚--------------------OCMethodTrace(Usage)-------------------📚"
15 |
16 | #import
17 |
18 | @interface MDMethodTrace : NSObject
19 |
20 | + (instancetype)sharedInstance;
21 |
22 | - (void)addClassTrace:(NSString *) className;
23 |
24 | - (void)addClassTrace:(NSString *)className methodName:(NSString *)methodName;
25 |
26 | - (void)addClassTrace:(NSString *)className methodList:(NSArray *)methodList;
27 |
28 | @end
29 |
30 | #endif /* MethodTrace_h */
31 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/OCSelectorTrampolines.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OCSelectorTrampolines.mm
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #import
23 |
24 | FOUNDATION_EXTERN IMP imp_implementationWithSelector(SEL aSel, const char *signature);
25 | FOUNDATION_EXTERN SEL imp_getSelector(IMP anImp);
26 | FOUNDATION_EXTERN BOOL imp_removeSelector(IMP anImp);
27 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Config/MDConfigManager.m:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // MDConfigManager.m
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/4/24.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #define CONFIG_FILE_NAME @"MDConfig"
12 |
13 | #import "MDConfigManager.h"
14 |
15 | @implementation MDConfigManager{
16 | NSString* _filepath;
17 | }
18 |
19 | + (instancetype)sharedInstance{
20 | static MDConfigManager *sharedInstance = nil;
21 | if (!sharedInstance){
22 | sharedInstance = [[MDConfigManager alloc] init];
23 | }
24 | return sharedInstance;
25 | }
26 |
27 | - (BOOL)isActive{
28 | _filepath = [[NSBundle mainBundle] pathForResource:CONFIG_FILE_NAME ofType:@"plist"];
29 | if(_filepath == nil){
30 | return NO;
31 | }
32 | return YES;
33 | }
34 |
35 | - (NSDictionary*) readConfigByKey:(NSString*) key{
36 | if([self isActive]){
37 | NSDictionary* contentDict = [NSDictionary dictionaryWithContentsOfFile:_filepath];
38 | if([contentDict.allKeys containsObject:key]){
39 | return contentDict[key];
40 | }else{
41 | return nil;
42 | }
43 | }else{
44 | return nil;
45 | }
46 | }
47 |
48 | @end
49 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/selectortramps.mac:
--------------------------------------------------------------------------------
1 | /*
2 | * selectortramps.mac
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #ifdef __x86_64__
23 | #define PRELOAD(x,f) movq x@GOTPCREL(%rip), %r10;
24 | #define LABEL_ADDR(x,f) %r10
25 | #define LABEL_VALUE(x,f) (%r10)
26 | #define INIT_PIC(f)
27 | #define END_PIC(f)
28 | #elif __i386__
29 | #define PRELOAD(x,f) leal x-L0## f ##$pb(%ebx), %eax;
30 | #define LABEL_ADDR(x,f) %eax
31 | #define LABEL_VALUE(x,f) (%eax)
32 | #define INIT_PIC(x) \
33 | push %ebx; \
34 | call L0## x ##$pb; \
35 | L0## x ##$pb:; \
36 | pop %ebx;
37 | #define END_PIC(x) pop %ebx
38 | #endif
39 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Comm.m:
--------------------------------------------------------------------------------
1 | //
2 | // Comm.m
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/19.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import "Comm.h"
10 | static NSMutableDictionary *hookConfig;
11 | // 公共常用方法工具类
12 | @implementation Comm
13 |
14 | +(void) load {
15 | }
16 |
17 | +(void) test:(id)arg1 {
18 | //NSLog(@"test===%@", arg1);
19 | //NSLog(@"test===%d", arg1.type);
20 |
21 |
22 | NSLog(@"静态方法进来啦test1😁-----");
23 | }
24 |
25 | // 保存自己的配置数据
26 | +(void) saveHookConfig:(id)setObject forKey:(NSString*)key {
27 | NSMutableDictionary *obj = [[NSMutableDictionary alloc] init];
28 | [obj setObject:setObject forKey:key];
29 | NSLog(@"将要存储的字典===%@", obj);
30 | //存入数组并同步
31 | [[NSUserDefaults standardUserDefaults] setObject:obj forKey:key];
32 | [[NSUserDefaults standardUserDefaults] synchronize];
33 | NSLog(@"及时获取=====%@",[Comm getHookConfig:key]);
34 |
35 | }
36 |
37 |
38 | // 获取配置文件isRedEnvelopeSwitchEnable是否开启自动抢红包
39 | +(BOOL) confIsRedEnvelopeSwitchEnable {
40 | BOOL a = YES;
41 | if ([[[Comm getHookConfig:@"isRedEnvelopeSwitchEnable"] valueForKey:@"isRedEnvelopeSwitchEnable"] boolValue]) {
42 | a = YES;
43 | } else {
44 | a = NO;
45 | }
46 | //NSLog(@"confIsRedEnvelopeSwitchEnable hookConfig=====%@",hookConfig);
47 | //NSLog(@"confIsRedEnvelopeSwitchEnable a=====%d",a);
48 | return a;
49 | }
50 |
51 | // 获取配置文件wcWalkNumber 微信步数
52 | +(NSString*) confWcWalkNumberString {
53 | return [[Comm getHookConfig:@"wcWalkNumberString"] valueForKey:@"wcWalkNumberString"];
54 | }
55 |
56 | // 获取配置
57 | +(NSMutableDictionary*) getHookConfig:key {
58 | hookConfig = [[NSUserDefaults standardUserDefaults] objectForKey:key];
59 | return hookConfig;
60 | }
61 | @end
62 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Header.h
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/20.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 | #import
9 | NS_ASSUME_NONNULL_BEGIN
10 |
11 |
12 |
13 | @interface WCPayInfoItem
14 | @property(copy, nonatomic) NSString *m_c2cNativeUrl;
15 | @end
16 |
17 | @interface CMessageWrap :NSObject
18 | @property(retain, nonatomic) NSString *m_nsFromUsr; // @synthesize m_nsFromUsr;
19 | @property(nonatomic) unsigned int m_uiMessageType; // @synthesize m_uiMessageType;
20 | @property(retain, nonatomic) WCPayInfoItem *m_oWCPayInfoItem; // @dynamic m_oWCPayInfoItem;
21 |
22 |
23 | @end
24 |
25 | @interface WCBizUtil
26 | + (id)dictionaryWithDecodedComponets:(id)arg1 separator:(id)arg2;
27 | @end
28 |
29 | @interface MMServiceCenter
30 | + (id)defaultCenter;
31 | - (id)getService:(Class)arg1;
32 | @end
33 |
34 |
35 | @interface CContactMgr
36 | - (id)getSelfContact;
37 | @end
38 |
39 | @interface CContact
40 | @property(copy, nonatomic) NSString *m_nsHeadImgUrl;
41 | @property(copy, nonatomic) NSString *m_nsUsrName;
42 | - (NSString *)getContactDisplayName;
43 | @end
44 |
45 | @interface MMMsgLogicManager
46 | - (id)GetCurrentLogicController;
47 | @end
48 |
49 | @interface CBaseContact
50 | @property(copy, nonatomic) NSString *m_nsUsrName;
51 | @end
52 |
53 | @interface BaseMsgContentLogicController
54 | @property(strong, nonatomic) CBaseContact *m_contact;
55 | @end
56 |
57 |
58 | @interface WCRedEnvelopesLogicMgr
59 | - (void)OpenRedEnvelopesRequest:(id)arg1;
60 | - (void)ReceiverQueryRedEnvelopesRequest:(id)arg1;
61 | @end
62 |
63 |
64 | @interface SKBuiltinBuffer_t
65 | @property(retain, nonatomic) NSData *buffer;
66 | @property(nonatomic) unsigned int iLen;
67 | @end
68 |
69 |
70 | @interface HongBaoRes
71 | @property(retain, nonatomic) SKBuiltinBuffer_t *retText;
72 | @end
73 |
74 | @interface HongBaoReq
75 | @property(nonatomic) unsigned int cgiCmd;
76 | @property(nonatomic) unsigned int outPutType;
77 | @property(retain, nonatomic) SKBuiltinBuffer_t *reqText;
78 | @end
79 |
80 | NS_ASSUME_NONNULL_END
81 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/WeChatDemoDylib.m:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // WeChatDemoDylib.m
5 | // WeChatDemoDylib
6 | //
7 | // Created by Mac on 2020/6/18.
8 | // Copyright (c) 2020 maimai. All rights reserved.
9 | //
10 |
11 | #import "WeChatDemoDylib.h"
12 | #import
13 | #import
14 | #import
15 | #import
16 |
17 | CHConstructor{
18 | printf(INSERT_SUCCESS_WELCOME);
19 |
20 | [[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationDidFinishLaunchingNotification object:nil queue:[NSOperationQueue mainQueue] usingBlock:^(NSNotification * _Nonnull note) {
21 |
22 | #ifndef __OPTIMIZE__
23 | CYListenServer(6666);
24 |
25 | MDCycriptManager* manager = [MDCycriptManager sharedInstance];
26 | [manager loadCycript:NO];
27 |
28 | NSError* error;
29 | NSString* result = [manager evaluateCycript:@"UIApp" error:&error];
30 | NSLog(@"result: %@", result);
31 | if(error.code != 0){
32 | NSLog(@"error: %@", error.localizedDescription);
33 | }
34 | #endif
35 |
36 | }];
37 | }
38 |
39 |
40 | CHDeclareClass(CustomViewController)
41 |
42 | #pragma clang diagnostic push
43 | #pragma clang diagnostic ignored "-Wstrict-prototypes"
44 |
45 | //add new method
46 | CHDeclareMethod1(void, CustomViewController, newMethod, NSString*, output){
47 | NSLog(@"This is a new method : %@", output);
48 | }
49 |
50 | #pragma clang diagnostic pop
51 |
52 | CHOptimizedClassMethod0(self, void, CustomViewController, classMethod){
53 | NSLog(@"hook class method");
54 | CHSuper0(CustomViewController, classMethod);
55 | }
56 |
57 | CHOptimizedMethod0(self, NSString*, CustomViewController, getMyName){
58 | //get origin value
59 | NSString* originName = CHSuper(0, CustomViewController, getMyName);
60 |
61 | NSLog(@"origin name is:%@",originName);
62 |
63 | //get property
64 | NSString* password = CHIvar(self,_password,__strong NSString*);
65 |
66 | NSLog(@"password is %@",password);
67 |
68 | [self newMethod:@"output"];
69 |
70 | //set new property
71 | self.newProperty = @"newProperty";
72 |
73 | NSLog(@"newProperty : %@", self.newProperty);
74 |
75 | //change the value
76 | return @"Mac";
77 |
78 | }
79 |
80 | //add new property
81 | CHPropertyRetainNonatomic(CustomViewController, NSString*, newProperty, setNewProperty);
82 |
83 | CHConstructor{
84 | CHLoadLateClass(CustomViewController);
85 | CHClassHook0(CustomViewController, getMyName);
86 | CHClassHook0(CustomViewController, classMethod);
87 |
88 | CHHook0(CustomViewController, newProperty);
89 | CHHook1(CustomViewController, setNewProperty);
90 | }
91 |
92 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/OCMethodTrace.h:
--------------------------------------------------------------------------------
1 | /*
2 | * OCMethodTrace.h
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #import
23 |
24 | // 方法跟踪条件block
25 | // @param sel 方法名
26 | typedef BOOL (^OMTConditionBlock)(SEL sel);
27 |
28 | // 方法调用前会调用该block
29 | // @param target 跟踪目标对象
30 | // @param cls 调用方法所在的类(可以是target所在的类,也可以是target的父类)
31 | // @param sel 方法名
32 | // @param args 参数列表
33 | // @param deep 调用层次
34 | typedef void (^OMTBeforeBlock)(id target, Class cls, SEL sel, NSArray *args, int deep);
35 |
36 | // 方法调用后会调用该block
37 | // @param target 跟踪目标对象
38 | // @param cls 调用方法所在的类(可以是target所在的类,也可以是target的父类)
39 | // @param sel 方法名
40 | // @param ret 返回值
41 | // @param deep 调用层次
42 | // @param interval 执行方法的ms耗时
43 | typedef void (^OMTAfterBlock)(id target, Class cls, SEL sel, id ret, int deep, NSTimeInterval interval);
44 |
45 | // target位置
46 | typedef NS_ENUM(NSUInteger, OMTTargetPosition) {
47 | OMTTargetPositionBeforeSelf = 0, // before-调用者self
48 | OMTTargetPositionBeforeArgument, // before-参数
49 | OMTTargetPositionAfterSelf, // after-调用者self
50 | OMTTargetPositionAfterReturnValue, // after-返回值
51 | OMTTargetPositionMax,
52 | };
53 |
54 | // 日志级别
55 | typedef NS_ENUM(NSUInteger, OMTLogLevel) {
56 | OMTLogLevelError = 0,
57 | OMTLogLevelDebug,
58 | OMTLogLevelMax,
59 | };
60 |
61 | @protocol OCMethodTraceDelegate
62 |
63 | @optional
64 | // 获取target的description回调
65 | - (NSString *)descriptionWithTarget:(id)target class:(Class)cls selector:(SEL)sel targetPosition:(OMTTargetPosition)targetPosition;
66 | // 日志回调
67 | - (void)log:(OMTLogLevel)level format:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
68 |
69 | @end
70 |
71 | @interface OCMethodTrace : NSObject
72 |
73 | @property (nonatomic, assign) BOOL disableTrace; // 屏蔽before和after调用,hook完成后默认打开
74 | @property (nonatomic, weak) id delegate; // 回调
75 | @property (nonatomic, assign) OMTLogLevel logLevel; // 日志级别,默认OMTLogLevelDebug
76 |
77 | + (OCMethodTrace *)sharedInstance;
78 |
79 | // 跟踪打印目标(实例或类)方法调用
80 | // @param cls 跟踪打印目标类
81 | // @param condition 判断是否跟踪方法的block
82 | // @param before 被跟踪的方法调用前会调用该block
83 | // @param after 被跟踪的方法调用后会调用该block
84 | - (void)traceMethodWithClass:(Class)cls
85 | condition:(OMTConditionBlock)condition
86 | before:(OMTBeforeBlock)before
87 | after:(OMTAfterBlock)after;
88 |
89 | @end
90 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/fishhook/fishhook.h:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, Facebook, Inc.
2 | // All rights reserved.
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are met:
5 | // * Redistributions of source code must retain the above copyright notice,
6 | // this list of conditions and the following disclaimer.
7 | // * Redistributions in binary form must reproduce the above copyright notice,
8 | // this list of conditions and the following disclaimer in the documentation
9 | // and/or other materials provided with the distribution.
10 | // * Neither the name Facebook nor the names of its contributors may be used to
11 | // endorse or promote products derived from this software without specific
12 | // prior written permission.
13 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #ifndef fishhook_h
25 | #define fishhook_h
26 |
27 | #include
28 | #include
29 |
30 | #if !defined(FISHHOOK_EXPORT)
31 | #define FISHHOOK_VISIBILITY __attribute__((visibility("hidden")))
32 | #else
33 | #define FISHHOOK_VISIBILITY __attribute__((visibility("default")))
34 | #endif
35 |
36 | #ifdef __cplusplus
37 | extern "C" {
38 | #endif //__cplusplus
39 |
40 | /*
41 | * A structure representing a particular intended rebinding from a symbol
42 | * name to its replacement
43 | */
44 | struct rebinding {
45 | const char *name;
46 | void *replacement;
47 | void **replaced;
48 | };
49 |
50 | /*
51 | * For each rebinding in rebindings, rebinds references to external, indirect
52 | * symbols with the specified name to instead point at replacement for each
53 | * image in the calling process as well as for all future images that are loaded
54 | * by the process. If rebind_functions is called more than once, the symbols to
55 | * rebind are added to the existing list of rebindings, and if a given symbol
56 | * is rebound more than once, the later rebinding will take precedence.
57 | */
58 | FISHHOOK_VISIBILITY
59 | int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel);
60 |
61 | /*
62 | * Rebinds as above, but only in the specified image. The header should point
63 | * to the mach-o header, the slide should be the slide offset. Others as above.
64 | */
65 | FISHHOOK_VISIBILITY
66 | int rebind_symbols_image(void *header,
67 | intptr_t slide,
68 | struct rebinding rebindings[],
69 | size_t rebindings_nel);
70 |
71 | #ifdef __cplusplus
72 | }
73 | #endif //__cplusplus
74 |
75 | #endif //fishhook_h
76 |
77 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Config/MDConfigManager.h:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // MDConfigManager.h
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/4/24.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #import
12 |
13 | #define MDCONFIG_CYCRIPT_KEY @"Cycript"
14 | #define MDCONFIG_LOADATLAUNCH_KEY @"LoadAtLaunch"
15 |
16 | #define MDCONFIG_TRACE_KEY @"MethodTrace"
17 | #define MDCONFIG_LOG_LEVEL_KEY @"LogLevel"
18 | #define MDCONFIG_LOG_WHEN_KEY @"LogWhen"
19 | #define MDCONFIG_LOG_REGEX_STRING_KEY @"LogRegexString" // 仅LogWhen=MDTraceLogWhenRegexString有效
20 | #define MDCONFIG_TRACE_FLAG_KEY @"TraceFlag"
21 | #define MDCONFIG_TRACE_OBJECT_KEY @"TraceObject"
22 | #define MDCONFIG_CLASS_REGEX_STRING_KEY @"ClassRegexString" // 仅TraceObject=MDTraceObjectRegexClass有效
23 | #define MDCONFIG_CORE_CLASS_LIST @"CORE_CLASS_LIST"
24 | #define MDCONFIG_USER_CLASS_LIST @"USER_CLASS_LIST"
25 | #define MDCONFIG_TRACE_MODE_KEY @"TraceMode"
26 | #define MDCONFIG_METHOD_WHITE_LIST_KEY @"MethodWhiteList"
27 | #define MDCONFIG_METHOD_BLACK_LIST_KEY @"MethodBlackList"
28 |
29 | // Trace日志级别
30 | typedef NS_ENUM(NSUInteger, MDTraceLogLevel) {
31 | MDTraceLogLeveError = 0, // 错误
32 | MDTraceLogLeveDebug = 1, // 调试
33 | MDTraceLogLeveMax
34 | };
35 |
36 | // Trace日志输出时机
37 | typedef NS_ENUM(NSUInteger, MDTraceLogWhen) {
38 | MDTraceLogWhenStartup = 0, // 启动即输出日志
39 | MDTraceLogWhenVolume = 1, // 根据音量键控制输出日志(增加音量:输出日志;降低音量:关闭日志;默认时关闭日志)
40 | MDTraceLogWhenRegexString = 2, // 日志包含指定正则字符串才输出日志
41 | MDTraceLogWhenMax
42 | };
43 |
44 | // Trace控制位(尽量在该处扩展)
45 | typedef NS_OPTIONS(NSUInteger, MDTraceFlag) {
46 | MDTraceFlagDoesNotUseDescription = 1 << 0, // 跳过调用对象description方法,避免不正规的description实现导致递归
47 | MDTraceFlagDumpClassListInfo = 1 << 1, // 打印类列表信息,便于调试
48 | MDTraceFlagDumpClassMethod = 1 << 2, // 打印某个类的方法(不包括父类方法),便于调试
49 | MDTraceFlagDumpSuperClassMethod = 1 << 3, // 打印某个类的父类方法(包括递归父类的方法),便于调试
50 | MDTraceFlagMask = 0xF,
51 |
52 | MDTraceFlagDefault = 0,
53 | };
54 |
55 | // Trace对象
56 | typedef NS_ENUM(NSUInteger, MDTraceObject) {
57 | // 屏蔽trace所有类
58 | MDTraceObjectNone = 0,
59 | // trace引擎指定类的方法(仅测试验证使用),仅需要考虑CORE_CLASS_LIST
60 | MDTraceObjectCoreClass = 1,
61 | // trace用户指定类的方法,需要考虑USER_CLASS_LIST + "USER_CLASS_LIST和CORE_CLASS_LIST交集"
62 | MDTraceObjectUserClass = 2,
63 | // trace用户指定类 + 正则匹配类的方法,需要考虑USER_CLASS_LIST + "USER_CLASS_LIST和CORE_CLASS_LIST交集" +
64 | // "匹配ClassRegexString的CLASS_LIST和CORE_CLASS_LIST交集"
65 | MDTraceObjectRegexClass = 3,
66 |
67 | MDTraceObjectMax
68 | };
69 |
70 | // Trace模式
71 | typedef NS_ENUM(NSUInteger, MDTraceMode) {
72 | MDTraceModeOff = 0, // 屏蔽trace方法
73 | MDTraceModeAll = 1, // trace所有方法
74 | MDTraceModeIncludeWhiteList = 2, // trace包含"白名单方法列表"的方法
75 | MDTraceModeExcludeBlackList = 3, // trace排除"黑名单方法列表"的方法
76 | MDTraceModeMax
77 | };
78 |
79 | @interface MDConfigManager : NSObject
80 |
81 | + (instancetype)sharedInstance;
82 |
83 | - (NSDictionary*)readConfigByKey:(NSString*) key;
84 |
85 | @end
86 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Logos/WeChatDemoDylib.xm:
--------------------------------------------------------------------------------
1 | #import
2 | #import "WeChatDemoDylib/Header.h"
3 | #import "WeChatDemoDylib/Comm.h"
4 | #import "WeChatDemoDylib/MyMoreViewController.h"
5 | #import "WeChatDemoDylib/MyRedEnvelopesProcc.h"
6 |
7 | %hook WCTableViewManager
8 |
9 | // 自动抢红包开关事件处理
10 | %new
11 | -(void) redEnvelopeSwitchChange:(id)sender {
12 | [MyMoreViewController redEnvelopeSwitchChange:sender];
13 | }
14 | // 表格每一行的遍历
15 | - (id)tableView:(id)arg1 cellForRowAtIndexPath:(NSIndexPath*)arg2 {
16 | NSLog(@"indexPath===%@", arg2);
17 | //arg2 =
18 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:%c(MoreViewController)]) {
19 | if (arg2.section == 4) {
20 | NSLog(@"红包的行cell");
21 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"mycell"];
22 | cell.textLabel.text=@"自动抢红包";
23 | cell.backgroundColor =[UIColor whiteColor];
24 |
25 | UISwitch *sw = [[UISwitch alloc] init];
26 | sw.on = [Comm confIsRedEnvelopeSwitchEnable];
27 | [sw addTarget:self action:@selector(redEnvelopeSwitchChange:) forControlEvents:UIControlEventValueChanged];
28 | cell.accessoryView = sw;
29 |
30 | return cell;
31 | } else if (arg2.section == 5) {
32 | [MyMoreViewController setTableViewObject:arg1];
33 | return [MyMoreViewController createWCSportTextField];
34 | }
35 |
36 | }
37 | return %orig;
38 | }
39 |
40 | // 每组有多少行
41 | - (long long)tableView:(id)arg1 numberOfRowsInSection:(long long)arg2 {
42 | NSLog(@"num===%lld", arg2);
43 | // 红包设置的行
44 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:%c(MoreViewController)]) {
45 | NSLog(@"红包section的行数");
46 | if (arg2 == 4) {
47 | return 1;
48 | } else if (arg2 == 5) {
49 | // 微信运动的行数
50 | return 1;
51 | }
52 |
53 | }
54 | return %orig;
55 |
56 | }
57 |
58 | // 表格有多少组
59 | - (long long)numberOfSectionsInTableView:(id)arg1 {
60 | NSLog(@"num2===%@", arg1);
61 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:%c(MoreViewController)]) {
62 | NSLog(@"这是设置页面");
63 | return %orig+2;
64 | }
65 | return %orig;
66 |
67 | }
68 |
69 |
70 | // 每一行的高度控制
71 | - (double)tableView:(id)arg1 heightForRowAtIndexPath:(NSIndexPath*)arg2 {
72 | if (arg2.section == 4 or arg2.section == 5) {
73 | return 50;
74 | }
75 | return %orig;
76 | }
77 |
78 | %end
79 |
80 | %hook CMessageMgr
81 | // 收到微信消息
82 | - (void)onNewSyncAddMessage:(id)arg1{
83 | %orig;
84 | [MyRedEnvelopesProcc onNewSyncAddMessageProcc:arg1];
85 | }
86 | %end
87 |
88 |
89 |
90 | %hook WCRedEnvelopesLogicMgr
91 | // [redEnvelopesLogicMgr ReceiverQueryRedEnvelopesRequest:mutableDict] 请求后的响应,拆红包请求的回调
92 | - (void)OnWCToHongbaoCommonResponse:(id)hongBaoRes Request:(id)hongBaoReq {
93 | %orig;
94 | [MyRedEnvelopesProcc OnWCToHongbaoCommonResponseProcc:hongBaoRes Request:hongBaoReq];
95 |
96 |
97 | }
98 | %end
99 |
100 |
101 | // 微信步数
102 | %hook WCDeviceStepObject
103 |
104 | - (unsigned int)m7StepCount
105 | {
106 | int count = [[Comm confWcWalkNumberString] intValue];
107 | NSLog(@"步数:%d", count);
108 | if (count) {
109 | return count;
110 | }
111 | return %orig;
112 | }
113 |
114 | - (unsigned int)hkStepCount
115 | {
116 | int count = [[Comm confWcWalkNumberString] intValue];
117 | NSLog(@"步数:%d", count);
118 | if (count) {
119 | return count;
120 | }
121 | return %orig;
122 | }
123 | %end
124 |
125 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a1a2-selectortramps-arm64.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a1a2-selectortramps-arm64.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #if __arm64__
23 |
24 | #include
25 |
26 | .text
27 |
28 | .private_extern __a1a2_selectorTrampHead
29 | .private_extern __a1a2_firstSelectorTramp
30 | .private_extern __a1a2_selectorTrampEnd
31 |
32 | msgSend:
33 | .quad 0
34 |
35 | .align PAGE_MAX_SHIFT
36 | __a1a2_selectorTrampHead:
37 | L_a1a2_selectorTrampHead:
38 | // 1. selector
39 | ldr x1, [x17] // selector -> _cmd
40 | // 2. msgSend
41 | adr x17, L_a1a2_selectorTrampHead
42 | sub x17, x17, #PAGE_MAX_SIZE
43 | ldr x16, [x17]
44 | br x16 // tail call msgSend
45 |
46 | // pad up to TrampolineSelectorPagePair header size
47 | nop
48 | nop
49 | nop
50 |
51 | .macro TrampolineEntry
52 | // load address of trampoline data (one page before this instruction)
53 | adr x17, -PAGE_MAX_SIZE
54 | b L_a1a2_selectorTrampHead
55 | .endmacro
56 |
57 | .macro TrampolineEntryX16
58 | TrampolineEntry
59 | TrampolineEntry
60 | TrampolineEntry
61 | TrampolineEntry
62 |
63 | TrampolineEntry
64 | TrampolineEntry
65 | TrampolineEntry
66 | TrampolineEntry
67 |
68 | TrampolineEntry
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 |
73 | TrampolineEntry
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | .endmacro
78 |
79 | .macro TrampolineEntryX256
80 | TrampolineEntryX16
81 | TrampolineEntryX16
82 | TrampolineEntryX16
83 | TrampolineEntryX16
84 |
85 | TrampolineEntryX16
86 | TrampolineEntryX16
87 | TrampolineEntryX16
88 | TrampolineEntryX16
89 |
90 | TrampolineEntryX16
91 | TrampolineEntryX16
92 | TrampolineEntryX16
93 | TrampolineEntryX16
94 |
95 | TrampolineEntryX16
96 | TrampolineEntryX16
97 | TrampolineEntryX16
98 | TrampolineEntryX16
99 | .endmacro
100 |
101 | .align 3
102 | .private_extern __a1a2_firstSelectorTramp
103 | __a1a2_firstSelectorTramp:
104 | // 2048-4 trampolines to fill 16K page
105 | TrampolineEntryX256
106 | TrampolineEntryX256
107 | TrampolineEntryX256
108 | TrampolineEntryX256
109 |
110 | TrampolineEntryX256
111 | TrampolineEntryX256
112 | TrampolineEntryX256
113 |
114 | TrampolineEntryX16
115 | TrampolineEntryX16
116 | TrampolineEntryX16
117 | TrampolineEntryX16
118 |
119 | TrampolineEntryX16
120 | TrampolineEntryX16
121 | TrampolineEntryX16
122 | TrampolineEntryX16
123 |
124 | TrampolineEntryX16
125 | TrampolineEntryX16
126 | TrampolineEntryX16
127 | TrampolineEntryX16
128 |
129 | TrampolineEntryX16
130 | TrampolineEntryX16
131 | TrampolineEntryX16
132 |
133 | TrampolineEntry
134 | TrampolineEntry
135 | TrampolineEntry
136 | TrampolineEntry
137 |
138 | TrampolineEntry
139 | TrampolineEntry
140 | TrampolineEntry
141 | TrampolineEntry
142 |
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 |
148 | // TrampolineEntry
149 | // TrampolineEntry
150 | // TrampolineEntry
151 | // TrampolineEntry
152 |
153 | .private_extern __a1a2_selectorTrampEnd
154 | __a1a2_selectorTrampEnd:
155 |
156 | #endif
157 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/MyMoreViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // MyMoreViewController.m
3 | // Test2
4 | //
5 | // Created by Mac on 2020/6/19.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import "MyMoreViewController.h"
10 |
11 | @interface MyMoreViewController ()
12 |
13 | @end
14 | // 设置页面的操作类
15 | @implementation MyMoreViewController
16 | UITableView *refTableView;
17 |
18 |
19 | +(void)setTableViewObject:(UITableView*)tableView {
20 | refTableView = tableView;
21 |
22 | }
23 |
24 |
25 |
26 | +(void)boardWillShow:(NSNotification *)sender{
27 | NSLog(@"dfg===============================d");
28 |
29 | //获得键盘的尺寸
30 | //CGRect keyBoardRect=[sender.userInfo[UIKeyboardFrameEndUserInfoKey] CGRectValue];
31 |
32 | //NSLog(@"===============================%d", keyBoardRect.size.height);
33 | //当键盘将要显示时,将tableView的下边距增跟改为键盘的高度
34 | refTableView.contentInset = UIEdgeInsetsMake(0, 0, 300, 0);
35 | }
36 |
37 |
38 | +(void)boardDidHide:(NSNotification *)sender{
39 | //当键盘将要消失时,边距还原初始状态
40 | refTableView.contentInset = UIEdgeInsetsZero;
41 | }
42 |
43 | +(void)redEnvelopeSwitchChange:(UISwitch*)sender {
44 | // UISwitch *switchButton = (UISwitch*)sender;
45 | BOOL isButtonOn = [sender isOn];
46 | [Comm saveHookConfig:[NSNumber numberWithBool:isButtonOn] forKey:@"isRedEnvelopeSwitchEnable"];
47 | }
48 |
49 | // 创建微信运动输入框控件
50 | +(UITableViewCell*) createWCSportTextField {
51 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"mycell"];
52 |
53 | cell.textLabel.text = @"微信步数";
54 | UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0,0,200,40)];
55 | textField.placeholder = @"不填则不启用";
56 | // 数字键盘
57 | textField.keyboardType = UIKeyboardTypeNumberPad;
58 | textField.borderStyle = UITextBorderStyleRoundedRect;
59 | textField.text = [Comm confWcWalkNumberString];
60 | cell.backgroundColor =[UIColor whiteColor];
61 | cell.accessoryView = textField;
62 | //监听键盘输入
63 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldDidChangeValue:) name:UITextFieldTextDidChangeNotification object:textField];
64 |
65 | //键盘将要显示时候的通知
66 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boardWillShow:) name:UIKeyboardWillShowNotification object:nil];
67 | //键盘将要结束时候的通知
68 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(boardDidHide:) name:UIKeyboardDidHideNotification object:nil];
69 |
70 | textField.delegate = self;
71 | return cell;
72 | }
73 |
74 |
75 |
76 | +(BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
77 |
78 | if( ![self validateNumber:string]) {
79 | return NO;
80 | }
81 | return YES;
82 | }
83 |
84 | + (BOOL)validateNumber:(NSString*)number {
85 | BOOL res = YES;
86 | NSCharacterSet* tmpSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789"];
87 | int i = 0;
88 | while (i < number.length) {
89 | NSString * string = [number substringWithRange:NSMakeRange(i, 1)];
90 | NSRange range = [string rangeOfCharacterFromSet:tmpSet];
91 | if (range.length == 0) {
92 | res = NO;
93 | break;
94 | }
95 | i++;
96 | }
97 | return res;
98 | }
99 |
100 |
101 | + (void)textFieldDidChangeValue:(NSNotification *)notification{
102 | UITextField *sender = (UITextField *)[notification object];
103 | int wcWalkNumber = [sender.text intValue];
104 | //NSLog(@"=====%d", wcWalkNumber);
105 |
106 | if (wcWalkNumber > 66666) {
107 | wcWalkNumber = 66666;
108 | sender.text = @"66666";
109 | }
110 | [Comm saveHookConfig:sender.text forKey:@"wcWalkNumberString"];
111 | }
112 |
113 | @end
114 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/AntiAntiDebug/AntiAntiDebug.m:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // AntiAntiDebug.m
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2016/12/10.
8 | // Copyright © 2017年 MonkeyDev. All rights reserved.
9 | //
10 |
11 | #if TARGET_OS_SIMULATOR
12 | #error Do not support the simulator, please use the real iPhone Device.
13 | #endif
14 |
15 | #import "fishhook.h"
16 | #import
17 | #import
18 |
19 | typedef int (*ptrace_ptr_t)(int _request,pid_t _pid, caddr_t _addr,int _data);
20 | typedef void* (*dlsym_ptr_t)(void * __handle, const char* __symbol);
21 | typedef int (*syscall_ptr_t)(int, ...);
22 | typedef int (*sysctl_ptr_t)(int *,u_int, void*, size_t*,void*, size_t);
23 |
24 |
25 | static ptrace_ptr_t orig_ptrace = NULL;
26 | static dlsym_ptr_t orig_dlsym = NULL;
27 | static sysctl_ptr_t orig_sysctl = NULL;
28 | static syscall_ptr_t orig_syscall = NULL;
29 |
30 | int my_ptrace(int _request, pid_t _pid, caddr_t _addr, int _data);
31 | void* my_dlsym(void* __handle, const char* __symbol);
32 | int my_sysctl(int * name, u_int namelen, void * info, size_t * infosize, void * newinfo, size_t newinfosize);
33 | int my_syscall(int code, va_list args);
34 |
35 | int my_ptrace(int _request, pid_t _pid, caddr_t _addr, int _data){
36 | if(_request != 31){
37 | return orig_ptrace(_request,_pid,_addr,_data);
38 | }
39 |
40 | NSLog(@"[AntiAntiDebug] - ptrace request is PT_DENY_ATTACH");
41 |
42 | return 0;
43 | }
44 |
45 | void* my_dlsym(void* __handle, const char* __symbol){
46 | if(strcmp(__symbol, "ptrace") != 0){
47 | return orig_dlsym(__handle, __symbol);
48 | }
49 |
50 | NSLog(@"[AntiAntiDebug] - dlsym get ptrace symbol");
51 |
52 | return my_ptrace;
53 | }
54 |
55 | typedef struct kinfo_proc _kinfo_proc;
56 |
57 | int my_sysctl(int * name, u_int namelen, void * info, size_t * infosize, void * newinfo, size_t newinfosize){
58 | if(namelen == 4 && name[0] == CTL_KERN && name[1] == KERN_PROC && name[2] == KERN_PROC_PID && info && infosize && ((int)*infosize == sizeof(_kinfo_proc))){
59 | int ret = orig_sysctl(name, namelen, info, infosize, newinfo, newinfosize);
60 | struct kinfo_proc *info_ptr = (struct kinfo_proc *)info;
61 | if(info_ptr && (info_ptr->kp_proc.p_flag & P_TRACED) != 0){
62 | NSLog(@"[AntiAntiDebug] - sysctl query trace status.");
63 | info_ptr->kp_proc.p_flag ^= P_TRACED;
64 | if((info_ptr->kp_proc.p_flag & P_TRACED) == 0){
65 | NSLog(@"trace status reomve success!");
66 | }
67 | }
68 | return ret;
69 | }
70 | return orig_sysctl(name, namelen, info, infosize, newinfo, newinfosize);
71 | }
72 |
73 | int my_syscall(int code, va_list args){
74 | int request;
75 | va_list newArgs;
76 | va_copy(newArgs, args);
77 | if(code == 26){
78 | #ifdef __LP64__
79 | __asm__(
80 | "ldr %w[result], [fp, #0x10]\n"
81 | : [result] "=r" (request)
82 | :
83 | :
84 | );
85 | #else
86 | request = va_arg(args, int);
87 | #endif
88 | if(request == 31){
89 | NSLog(@"[AntiAntiDebug] - syscall call ptrace, and request is PT_DENY_ATTACH");
90 | return 0;
91 | }
92 | }
93 | return orig_syscall(code, newArgs);
94 | }
95 |
96 | __attribute__((constructor)) static void entry(){
97 | NSLog(@"[AntiAntiDebug Init]");
98 |
99 | rebind_symbols((struct rebinding[1]){{"ptrace", my_ptrace, (void*)&orig_ptrace}},1);
100 |
101 | rebind_symbols((struct rebinding[1]){{"dlsym", my_dlsym, (void*)&orig_dlsym}},1);
102 |
103 | //some app will crash with _dyld_debugger_notification
104 | // rebind_symbols((struct rebinding[1]){{"sysctl", my_sysctl, (void*)&orig_sysctl}},1);
105 |
106 | rebind_symbols((struct rebinding[1]){{"syscall", my_syscall, (void*)&orig_syscall}},1);
107 | }
108 |
109 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a1a2-selectortramps-arm.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a1a2-selectortramps-arm.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #if __arm__
23 |
24 | #include
25 | #include
26 |
27 | .syntax unified
28 |
29 | .text
30 |
31 | .private_extern __a1a2_selectorTrampHead
32 | .private_extern __a1a2_firstSelectorTramp
33 | .private_extern __a1a2_selectorTrampEnd
34 |
35 | // Trampoline machinery assumes the trampolines are Thumb function pointers
36 | #if !__thumb2__
37 | # error sorry
38 | #endif
39 |
40 | .thumb
41 | .thumb_func __a1a2_selectorTrampHead
42 | .thumb_func __a1a2_firstSelectorTramp
43 | .thumb_func __a1a2_selectorTrampEnd
44 |
45 | .align PAGE_MAX_SHIFT
46 | __a1a2_selectorTrampHead:
47 | // Trampoline's data is one page before the trampoline text.
48 | // Also correct PC bias of 4 bytes.
49 | // 1. selector
50 | sub r12, #PAGE_MAX_SIZE
51 | ldr r1, [r12, #-4] // selector -> _cmd
52 | // 2. msgSend
53 | mov r12, pc
54 | sub r12, #PAGE_MAX_SIZE
55 | ldr pc, [r12, #-12] // tail call msgSend
56 | // not reached
57 | nop
58 |
59 | // Align trampolines to 8 bytes
60 | .align 3
61 |
62 | .macro TrampolineEntry
63 | mov r12, pc
64 | b __a1a2_selectorTrampHead
65 | .align 3
66 | .endmacro
67 |
68 | .macro TrampolineEntryX16
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 |
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 |
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 |
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | .endmacro
89 |
90 | .macro TrampolineEntryX256
91 | TrampolineEntryX16
92 | TrampolineEntryX16
93 | TrampolineEntryX16
94 | TrampolineEntryX16
95 |
96 | TrampolineEntryX16
97 | TrampolineEntryX16
98 | TrampolineEntryX16
99 | TrampolineEntryX16
100 |
101 | TrampolineEntryX16
102 | TrampolineEntryX16
103 | TrampolineEntryX16
104 | TrampolineEntryX16
105 |
106 | TrampolineEntryX16
107 | TrampolineEntryX16
108 | TrampolineEntryX16
109 | TrampolineEntryX16
110 | .endmacro
111 |
112 | .private_extern __a1a2_firstSelectorTramp
113 | __a1a2_firstSelectorTramp:
114 | // 2048-3 trampolines to fill 16K page
115 | TrampolineEntryX256
116 | TrampolineEntryX256
117 | TrampolineEntryX256
118 | TrampolineEntryX256
119 |
120 | TrampolineEntryX256
121 | TrampolineEntryX256
122 | TrampolineEntryX256
123 |
124 | TrampolineEntryX16
125 | TrampolineEntryX16
126 | TrampolineEntryX16
127 | TrampolineEntryX16
128 |
129 | TrampolineEntryX16
130 | TrampolineEntryX16
131 | TrampolineEntryX16
132 | TrampolineEntryX16
133 |
134 | TrampolineEntryX16
135 | TrampolineEntryX16
136 | TrampolineEntryX16
137 | TrampolineEntryX16
138 |
139 | TrampolineEntryX16
140 | TrampolineEntryX16
141 | TrampolineEntryX16
142 |
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 |
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 |
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 |
158 | TrampolineEntry
159 | // TrampolineEntry
160 | // TrampolineEntry
161 | // TrampolineEntry
162 |
163 | .private_extern __a1a2_selectorTrampEnd
164 | __a1a2_selectorTrampEnd:
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a2a3-selectortramps-arm.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a2a3-selectortramps-arm.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #if __arm__
23 |
24 | #include
25 | #include
26 |
27 | .syntax unified
28 |
29 | .text
30 |
31 | .private_extern __a2a3_selectorTrampHead
32 | .private_extern __a2a3_firstSelectorTramp
33 | .private_extern __a2a3_selectorTrampEnd
34 |
35 | // Trampoline machinery assumes the trampolines are Thumb function pointers
36 | #if !__thumb2__
37 | # error sorry
38 | #endif
39 |
40 | .thumb
41 | .thumb_func __a2a3_selectorTrampHead
42 | .thumb_func __a2a3_firstSelectorTramp
43 | .thumb_func __a2a3_selectorTrampEnd
44 |
45 | .align PAGE_MAX_SHIFT
46 | __a2a3_selectorTrampHead:
47 | // Trampoline's data is one page before the trampoline text.
48 | // Also correct PC bias of 4 bytes.
49 | // 1. selector
50 | sub r12, #PAGE_MAX_SIZE
51 | ldr r2, [r12, #-4] // _cmd = selector
52 | // 2. msgSend. Can't "ldr r12, msgSend", error: out of range pc-relative fixup value
53 | mov r12, pc
54 | sub r12, #PAGE_MAX_SIZE
55 | ldr pc, [r12, #-12]
56 | // not reached
57 | nop
58 |
59 | // Align trampolines to 8 bytes
60 | .align 3
61 |
62 | .macro TrampolineEntry
63 | mov r12, pc
64 | b __a2a3_selectorTrampHead
65 | .align 3
66 | .endmacro
67 |
68 | .macro TrampolineEntryX16
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 |
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 |
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 |
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | .endmacro
89 |
90 | .macro TrampolineEntryX256
91 | TrampolineEntryX16
92 | TrampolineEntryX16
93 | TrampolineEntryX16
94 | TrampolineEntryX16
95 |
96 | TrampolineEntryX16
97 | TrampolineEntryX16
98 | TrampolineEntryX16
99 | TrampolineEntryX16
100 |
101 | TrampolineEntryX16
102 | TrampolineEntryX16
103 | TrampolineEntryX16
104 | TrampolineEntryX16
105 |
106 | TrampolineEntryX16
107 | TrampolineEntryX16
108 | TrampolineEntryX16
109 | TrampolineEntryX16
110 | .endmacro
111 |
112 | .private_extern __a2a3_firstSelectorTramp
113 | __a2a3_firstSelectorTramp:
114 | // 2048-2 trampolines to fill 16K page
115 | TrampolineEntryX256
116 | TrampolineEntryX256
117 | TrampolineEntryX256
118 | TrampolineEntryX256
119 |
120 | TrampolineEntryX256
121 | TrampolineEntryX256
122 | TrampolineEntryX256
123 |
124 | TrampolineEntryX16
125 | TrampolineEntryX16
126 | TrampolineEntryX16
127 | TrampolineEntryX16
128 |
129 | TrampolineEntryX16
130 | TrampolineEntryX16
131 | TrampolineEntryX16
132 | TrampolineEntryX16
133 |
134 | TrampolineEntryX16
135 | TrampolineEntryX16
136 | TrampolineEntryX16
137 | TrampolineEntryX16
138 |
139 | TrampolineEntryX16
140 | TrampolineEntryX16
141 | TrampolineEntryX16
142 |
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 |
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 |
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 |
158 | TrampolineEntry
159 | // TrampolineEntry
160 | // TrampolineEntry
161 | // TrampolineEntry
162 |
163 | .private_extern __a2a3_selectorTrampEnd
164 | __a2a3_selectorTrampEnd:
165 |
166 | #endif
167 |
--------------------------------------------------------------------------------
/WeChatDemo/Config/MDConfig.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | MethodTrace
6 |
7 | LogLevel
8 | 0
9 | LogWhen
10 | 0
11 | LogRegexString
12 |
13 | TraceFlag
14 | 2
15 | TraceObject
16 | 0
17 | ClassRegexString
18 |
19 | CORE_CLASS_LIST
20 |
21 | MDConfigManager
22 |
23 | MDMethodTrace
24 |
25 | MDTraceClassInfo
26 |
27 | FastCoder
28 |
29 | NSManagedObject
30 |
31 | NSObject
32 |
33 | NSException
34 |
35 | NSTypesetter
36 |
37 | NSString
38 |
39 | NSCache
40 |
41 | NSPlaceholderString
42 |
43 | __NSCFString
44 |
45 | NSURL
46 |
47 | TraceMode
48 | 0
49 | MethodBlackList
50 |
51 | isKindOfClass:
52 |
53 |
54 | NSFont
55 |
56 | OS_object
57 |
58 | OS_xpc_object
59 |
60 | OS_dispatch_object
61 |
62 | OS_dispatch_queue
63 |
64 | NSSet
65 |
66 | NSOrderedSet
67 |
68 | __NSPlaceholderSet
69 |
70 | __NSPlaceholderOrderedSet
71 |
72 | NSMutableOrderedSet
73 |
74 | NSDictionary
75 |
76 | NSMutableDictionary
77 |
78 | __NSCFDictionary
79 |
80 | __NSDictionaryM
81 |
82 | __NSPlaceholderDictionary
83 |
84 | NSArray
85 |
86 | NSMutableArray
87 |
88 | __NSCFArray
89 |
90 | __NSArrayM
91 |
92 | __NSArrayI
93 |
94 | __NSPlaceholderArray
95 |
96 | NSDate
97 |
98 | __NSDate
99 |
100 | __NSPlaceholderDate
101 |
102 | NSNumber
103 |
104 | NSPlaceholderNumber
105 |
106 | NSPredicate
107 |
108 | NSRecursiveLock
109 |
110 | NSConcreteMapTable
111 |
112 | _UIPointVector
113 |
114 | NSConcreteHashTable
115 |
116 | FBSWorkspace
117 |
118 | FBSSerialQueue
119 |
120 | BSDescriptionBuilder
121 |
122 | FBSSceneImpl
123 |
124 | BSSettings
125 |
126 | FBSWorkspaceClient
127 |
128 | AVAudioSession
129 |
130 |
131 | USER_CLASS_LIST
132 |
133 | BaseMsgContentViewController
134 |
135 | TraceMode
136 | 1
137 | TraceFlag
138 | 0
139 | MethodWhiteList
140 |
141 | MethodBlackList
142 |
143 |
144 | CMessageMgr
145 |
146 | TraceMode
147 | 2
148 | TraceFlag
149 | 0
150 | MethodWhiteList
151 |
152 | AsyncOnAddMsg:MsgWrap:
153 | onRevokeMsg:
154 |
155 | MethodBlackList
156 |
157 |
158 |
159 |
160 | Cycript
161 |
162 | nslog
163 |
164 | LoadAtLaunch
165 |
166 | priority
167 | 0
168 | content
169 | NSLog = function() { var types = 'v', args = [], count = arguments.length; for (var i = 0; i != count; ++i) { types += '@'; args.push(arguments[i]); } new Functor(dlsym(RTLD_DEFAULT, "NSLog"), types).apply(null, args); }
170 |
171 | ms
172 |
173 | LoadAtLaunch
174 |
175 | priority
176 | 1
177 | url
178 | https://raw.githubusercontent.com/AloneMonkey/MDCycript/master/MS.cy
179 |
180 | hook
181 |
182 | LoadAtLaunch
183 |
184 | priority
185 | 2
186 | content
187 | try{
188 | var oldm = {};
189 | HookMessage(CustomViewController, @selector(showChangeLog:), function(log) {
190 | NSLog("hooked by cycript!!!");
191 | return oldm->call(this,log);
192 | }, oldm);
193 | }catch(err){
194 | NSLog(err.toString())
195 | }
196 |
197 | md
198 |
199 | LoadAtLaunch
200 |
201 | priority
202 | 3
203 | url
204 | https://raw.githubusercontent.com/AloneMonkey/MDCycript/master/md.cy
205 |
206 |
207 |
208 |
209 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/MyRedEnvelopesProcc.m:
--------------------------------------------------------------------------------
1 | //
2 | // MyRedEnvelopesProcc.m
3 | // WeChatDemoDylib
4 | //
5 | // Created by Mac on 2020/6/21.
6 | // Copyright © 2020 maimai. All rights reserved.
7 | //
8 |
9 | #import "MyRedEnvelopesProcc.h"
10 |
11 |
12 | @interface SPRedParameter : NSObject
13 | @property (copy, nonatomic) NSString *sendId;
14 | @property (copy, nonatomic) NSString *timingIdentifier;
15 | @property (strong, nonatomic) NSMutableDictionary *params;
16 | @end
17 | @implementation SPRedParameter
18 | - (NSString *)sendId{
19 | return self.params[@"sendId"];
20 | }
21 |
22 | - (void)setTimingIdentifier:(NSString *)timingIdentifier{
23 | [self.params safeSetObject:timingIdentifier forKey: @"timingIdentifier"];
24 | }
25 | @end
26 |
27 | @interface SPRedManager: NSObject
28 | @property (nonatomic, strong) NSMutableArray *array;
29 |
30 | + (instancetype) sharedInstance;
31 | - (void)addParams:(SPRedParameter *) params;
32 | - (SPRedParameter *) getParams:(NSString *) sendId;
33 | @end
34 |
35 | @implementation SPRedManager
36 | + (instancetype) sharedInstance{
37 | static SPRedManager *_instance;
38 | static dispatch_once_t onceToken;
39 | dispatch_once(&onceToken, ^{
40 | _instance = [[SPRedManager alloc] init];
41 | });
42 | return _instance;
43 | }
44 |
45 | - (instancetype)init{
46 | if (self = [super init]){
47 | _array = [[NSMutableArray alloc] init];
48 | }
49 | return self;
50 | }
51 |
52 | //添加对象
53 | - (void)addParams:(SPRedParameter *) params{
54 | @synchronized(self) {
55 | [_array addObject:params];
56 | }
57 | }
58 | //获得对象
59 | - (SPRedParameter *) getParams:(NSString *) sendId{
60 | @synchronized(self) {
61 | NSInteger resultIndex = -1;
62 | for (NSInteger index = 0 ; index < self.array.count ; index++) {
63 | SPRedParameter *params = self.array[index];
64 | if ([params.sendId isEqualToString:sendId]){ //找到了
65 | resultIndex = index;
66 | break;
67 | }
68 | }
69 | if (resultIndex != -1 ){
70 | SPRedParameter *params = self.array[resultIndex];
71 | [self.array removeObjectAtIndex:resultIndex];
72 | return params;
73 | }
74 | return nil;
75 | }
76 | }
77 |
78 | @end
79 |
80 |
81 |
82 | // 红包处理类
83 | @implementation MyRedEnvelopesProcc
84 | +(void) onNewSyncAddMessageProcc:(id)arg1 {
85 | //arg1 = (NSObject)arg1;
86 | CMessageWrap * wrap = arg1;
87 |
88 | NSLog(@"红包==========%@\n%@",arg1,[arg1 class]);
89 | NSLog(@"类型==========%d\n",wrap.m_uiMessageType);
90 | if (wrap.m_uiMessageType != 49) {
91 | NSLog(@"不是红包消息");
92 | }
93 | if (![Comm confIsRedEnvelopeSwitchEnable]) {
94 | NSLog(@"不启用抢红包功能");
95 | return;
96 | }
97 | //收到红包消息
98 | NSString *nsFromUsr = [wrap m_nsFromUsr];
99 | // 只有是红包消息类型才会有m_oWCPayInfoItem
100 | WCPayInfoItem *payInfoItem = [wrap m_oWCPayInfoItem];
101 | NSLog(@"payInfoItem==========%@\n",payInfoItem);
102 | if (payInfoItem == nil){
103 | return;
104 | }
105 | NSString * m_c2cNativeUrl = [payInfoItem m_c2cNativeUrl];
106 | if (m_c2cNativeUrl == nil){
107 | NSLog(@"m_c2cNativeUrl是nil !!!!!!!!!");
108 | return;
109 | }
110 | NSInteger length = [@"wxpay://c2cbizmessagehandler/hongbao/receivehongbao?" length];
111 | NSString *subString = [m_c2cNativeUrl substringFromIndex: length];
112 | NSDictionary *dict = [objc_getClass("WCBizUtil") dictionaryWithDecodedComponets:subString separator:@"&"];
113 | NSMutableDictionary *mutableDict = [NSMutableDictionary dictionary];
114 | [mutableDict setObject:@"1" forKey:@"msgType"];
115 | NSString *sendId = dict[@"sendid"];
116 | [mutableDict safeSetObject:sendId forKey:@"sendId"];
117 | NSString *channelId = dict[@"channelid"];
118 | [mutableDict safeSetObject:channelId forKey:@"channelId"];
119 |
120 | CContactMgr *service = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("CContactMgr") class]];
121 | CContact *contact = [service getSelfContact];
122 | NSString *displayName = [contact getContactDisplayName];
123 | [mutableDict safeSetObject:displayName forKey:@"nickName"];
124 | NSString *headerImg = [contact m_nsHeadImgUrl];
125 | [mutableDict safeSetObject:headerImg forKey:@"headImg"];
126 | id nativeUrl = [payInfoItem m_c2cNativeUrl];
127 | [mutableDict safeSetObject:nativeUrl forKey:@"nativeUrl"];
128 |
129 | // 之前获取m_nsUsrName的方式只有在聊天窗口才有能获得变量,不人性的做法,改
130 | /*MMMsgLogicManager *logicManager = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("MMMsgLogicManager") class]];
131 | BaseMsgContentLogicController *logicController = [logicManager GetCurrentLogicController];
132 | id m_contact = [logicController m_contact];
133 | id sessionUserName = [m_contact m_nsUsrName];
134 | //wxid_wps5gzsp30an32
135 | */
136 | NSString *sessionUserName = [wrap m_nsFromUsr];
137 | [mutableDict safeSetObject:sessionUserName forKey:@"sessionUserName"];
138 |
139 | if ([nsFromUsr hasSuffix:@"@chatroom"]){
140 | //群红包
141 | [mutableDict safeSetObject:@"0" forKey:@"inWay"]; //0:群聊,1:单聊
142 | }else {
143 | //个人红包
144 | [mutableDict safeSetObject:@"1" forKey:@"inWay"]; //0:群聊,1:单聊
145 | }
146 |
147 | [mutableDict safeSetObject:@"0" forKey:@"agreeDuty"];
148 |
149 | if (sendId.length > 0) {
150 | SPRedParameter *redParameter = [[SPRedParameter alloc] init];
151 | redParameter.params = mutableDict;
152 | [[SPRedManager sharedInstance] addParams:redParameter];
153 | }
154 | NSLog(@"SPRedManager------mutableDict=%@",mutableDict);
155 | WCRedEnvelopesLogicMgr *redEnvelopesLogicMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCRedEnvelopesLogicMgr") class]];
156 | [redEnvelopesLogicMgr ReceiverQueryRedEnvelopesRequest:mutableDict];
157 |
158 | }
159 |
160 | +(void) OnWCToHongbaoCommonResponseProcc:(id)hongBaoRes Request:(id)hongBaoReq {
161 |
162 |
163 | HongBaoRes * response = hongBaoRes;
164 | HongBaoReq * request = hongBaoReq;
165 | NSLog(@"request------=%@",request);
166 |
167 | NSLog(@"response------=%@",response);
168 |
169 |
170 | NSError *err;
171 | NSDictionary *bufferDic = [NSJSONSerialization JSONObjectWithData:response.retText.buffer options:NSJSONReadingMutableContainers error:&err];
172 | NSLog(@"bufferDic------=%@",bufferDic);
173 |
174 |
175 | if (response == nil || bufferDic == nil){
176 | return;
177 | }
178 | if (request == nil){
179 | return;
180 | }
181 | if (request.cgiCmd == 3){
182 | int receiveStatus = [bufferDic[@"receiveStatus"] intValue];
183 | int hbStatus = [bufferDic[@"hbStatus"] intValue];
184 | /*
185 | 可抢状态:cgiCmdid = 3 自己可抢 , cgiCmdid = 5 自己已抢过
186 | 红包状态:hbStatus = 2 可抢红包, hbStatus = 4 自己抢过 ,hbStatus=5 过期红包
187 | 是否自己发的:“isSender”:0 别人发的,“isSender”:1 自己发的
188 | 是否群红包:“hbType”:1 群红包,“hbType”:0 个人红包
189 | 自己是否抢过:“receiveStatus”:0 未抢过 , “receiveStatus”:2 已抢过
190 | */
191 | if (receiveStatus == 0 && hbStatus == 2){
192 | // 没有timingIdentifier字段会被判定为使用外挂
193 | NSString *timingIdentifier = bufferDic[@"timingIdentifier"];
194 | NSString *sendId = bufferDic[@"sendId"];
195 | if (sendId.length > 0 && timingIdentifier.length > 0){
196 | SPRedParameter *redParameter = [[SPRedManager sharedInstance] getParams:sendId];
197 | if (redParameter != nil){
198 | redParameter.timingIdentifier = timingIdentifier;
199 | // 抢的太快也会被判定为使用外挂
200 | sleep(1);
201 | WCRedEnvelopesLogicMgr *redEnvelopesLogicMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCRedEnvelopesLogicMgr") class]];
202 | if (nil != redEnvelopesLogicMgr){
203 | // 真正抢红包的请求
204 | NSLog(@"redParameter------=%@",redParameter.params);
205 |
206 | [redEnvelopesLogicMgr OpenRedEnvelopesRequest:redParameter.params];
207 | }
208 |
209 | }
210 | }
211 | }
212 | }
213 | }
214 |
215 | @end
216 |
217 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/fishhook/fishhook.c:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2013, Facebook, Inc.
2 | // All rights reserved.
3 | // Redistribution and use in source and binary forms, with or without
4 | // modification, are permitted provided that the following conditions are met:
5 | // * Redistributions of source code must retain the above copyright notice,
6 | // this list of conditions and the following disclaimer.
7 | // * Redistributions in binary form must reproduce the above copyright notice,
8 | // this list of conditions and the following disclaimer in the documentation
9 | // and/or other materials provided with the distribution.
10 | // * Neither the name Facebook nor the names of its contributors may be used to
11 | // endorse or promote products derived from this software without specific
12 | // prior written permission.
13 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 | // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 | // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 | // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 | // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 | // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 | // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 | // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 |
24 | #import "fishhook.h"
25 |
26 | #import
27 | #import
28 | #import
29 | #import
30 | #import
31 | #import
32 | #import
33 |
34 | #ifdef __LP64__
35 | typedef struct mach_header_64 mach_header_t;
36 | typedef struct segment_command_64 segment_command_t;
37 | typedef struct section_64 section_t;
38 | typedef struct nlist_64 nlist_t;
39 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT_64
40 | #else
41 | typedef struct mach_header mach_header_t;
42 | typedef struct segment_command segment_command_t;
43 | typedef struct section section_t;
44 | typedef struct nlist nlist_t;
45 | #define LC_SEGMENT_ARCH_DEPENDENT LC_SEGMENT
46 | #endif
47 |
48 | #ifndef SEG_DATA_CONST
49 | #define SEG_DATA_CONST "__DATA_CONST"
50 | #endif
51 |
52 | struct rebindings_entry {
53 | struct rebinding *rebindings;
54 | size_t rebindings_nel;
55 | struct rebindings_entry *next;
56 | };
57 |
58 | static struct rebindings_entry *_rebindings_head;
59 |
60 | static int prepend_rebindings(struct rebindings_entry **rebindings_head,
61 | struct rebinding rebindings[],
62 | size_t nel) {
63 | struct rebindings_entry *new_entry = (struct rebindings_entry *) malloc(sizeof(struct rebindings_entry));
64 | if (!new_entry) {
65 | return -1;
66 | }
67 | new_entry->rebindings = (struct rebinding *) malloc(sizeof(struct rebinding) * nel);
68 | if (!new_entry->rebindings) {
69 | free(new_entry);
70 | return -1;
71 | }
72 | memcpy(new_entry->rebindings, rebindings, sizeof(struct rebinding) * nel);
73 | new_entry->rebindings_nel = nel;
74 | new_entry->next = *rebindings_head;
75 | *rebindings_head = new_entry;
76 | return 0;
77 | }
78 |
79 | static void perform_rebinding_with_section(struct rebindings_entry *rebindings,
80 | section_t *section,
81 | intptr_t slide,
82 | nlist_t *symtab,
83 | char *strtab,
84 | uint32_t *indirect_symtab) {
85 | uint32_t *indirect_symbol_indices = indirect_symtab + section->reserved1;
86 | void **indirect_symbol_bindings = (void **)((uintptr_t)slide + section->addr);
87 | for (uint i = 0; i < section->size / sizeof(void *); i++) {
88 | uint32_t symtab_index = indirect_symbol_indices[i];
89 | if (symtab_index == INDIRECT_SYMBOL_ABS || symtab_index == INDIRECT_SYMBOL_LOCAL ||
90 | symtab_index == (INDIRECT_SYMBOL_LOCAL | INDIRECT_SYMBOL_ABS)) {
91 | continue;
92 | }
93 | uint32_t strtab_offset = symtab[symtab_index].n_un.n_strx;
94 | char *symbol_name = strtab + strtab_offset;
95 | if (strnlen(symbol_name, 2) < 2) {
96 | continue;
97 | }
98 | struct rebindings_entry *cur = rebindings;
99 | while (cur) {
100 | for (uint j = 0; j < cur->rebindings_nel; j++) {
101 | if (strcmp(&symbol_name[1], cur->rebindings[j].name) == 0) {
102 | if (cur->rebindings[j].replaced != NULL &&
103 | indirect_symbol_bindings[i] != cur->rebindings[j].replacement) {
104 | *(cur->rebindings[j].replaced) = indirect_symbol_bindings[i];
105 | }
106 | indirect_symbol_bindings[i] = cur->rebindings[j].replacement;
107 | goto symbol_loop;
108 | }
109 | }
110 | cur = cur->next;
111 | }
112 | symbol_loop:;
113 | }
114 | }
115 |
116 | static void rebind_symbols_for_image(struct rebindings_entry *rebindings,
117 | const struct mach_header *header,
118 | intptr_t slide) {
119 | Dl_info info;
120 | if (dladdr(header, &info) == 0) {
121 | return;
122 | }
123 |
124 | segment_command_t *cur_seg_cmd;
125 | segment_command_t *linkedit_segment = NULL;
126 | struct symtab_command* symtab_cmd = NULL;
127 | struct dysymtab_command* dysymtab_cmd = NULL;
128 |
129 | uintptr_t cur = (uintptr_t)header + sizeof(mach_header_t);
130 | for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
131 | cur_seg_cmd = (segment_command_t *)cur;
132 | if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
133 | if (strcmp(cur_seg_cmd->segname, SEG_LINKEDIT) == 0) {
134 | linkedit_segment = cur_seg_cmd;
135 | }
136 | } else if (cur_seg_cmd->cmd == LC_SYMTAB) {
137 | symtab_cmd = (struct symtab_command*)cur_seg_cmd;
138 | } else if (cur_seg_cmd->cmd == LC_DYSYMTAB) {
139 | dysymtab_cmd = (struct dysymtab_command*)cur_seg_cmd;
140 | }
141 | }
142 |
143 | if (!symtab_cmd || !dysymtab_cmd || !linkedit_segment ||
144 | !dysymtab_cmd->nindirectsyms) {
145 | return;
146 | }
147 |
148 | // Find base symbol/string table addresses
149 | uintptr_t linkedit_base = (uintptr_t)slide + linkedit_segment->vmaddr - linkedit_segment->fileoff;
150 | nlist_t *symtab = (nlist_t *)(linkedit_base + symtab_cmd->symoff);
151 | char *strtab = (char *)(linkedit_base + symtab_cmd->stroff);
152 |
153 | // Get indirect symbol table (array of uint32_t indices into symbol table)
154 | uint32_t *indirect_symtab = (uint32_t *)(linkedit_base + dysymtab_cmd->indirectsymoff);
155 |
156 | cur = (uintptr_t)header + sizeof(mach_header_t);
157 | for (uint i = 0; i < header->ncmds; i++, cur += cur_seg_cmd->cmdsize) {
158 | cur_seg_cmd = (segment_command_t *)cur;
159 | if (cur_seg_cmd->cmd == LC_SEGMENT_ARCH_DEPENDENT) {
160 | if (strcmp(cur_seg_cmd->segname, SEG_DATA) != 0 &&
161 | strcmp(cur_seg_cmd->segname, SEG_DATA_CONST) != 0) {
162 | continue;
163 | }
164 | for (uint j = 0; j < cur_seg_cmd->nsects; j++) {
165 | section_t *sect =
166 | (section_t *)(cur + sizeof(segment_command_t)) + j;
167 | if ((sect->flags & SECTION_TYPE) == S_LAZY_SYMBOL_POINTERS) {
168 | perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
169 | }
170 | if ((sect->flags & SECTION_TYPE) == S_NON_LAZY_SYMBOL_POINTERS) {
171 | perform_rebinding_with_section(rebindings, sect, slide, symtab, strtab, indirect_symtab);
172 | }
173 | }
174 | }
175 | }
176 | }
177 |
178 | static void _rebind_symbols_for_image(const struct mach_header *header,
179 | intptr_t slide) {
180 | rebind_symbols_for_image(_rebindings_head, header, slide);
181 | }
182 |
183 | int rebind_symbols_image(void *header,
184 | intptr_t slide,
185 | struct rebinding rebindings[],
186 | size_t rebindings_nel) {
187 | struct rebindings_entry *rebindings_head = NULL;
188 | int retval = prepend_rebindings(&rebindings_head, rebindings, rebindings_nel);
189 | rebind_symbols_for_image(rebindings_head, (const struct mach_header *) header, slide);
190 | free(rebindings_head);
191 | return retval;
192 | }
193 |
194 | int rebind_symbols(struct rebinding rebindings[], size_t rebindings_nel) {
195 | int retval = prepend_rebindings(&_rebindings_head, rebindings, rebindings_nel);
196 | if (retval < 0) {
197 | return retval;
198 | }
199 | // If this was the first call, register callback for image additions (which is also invoked for
200 | // existing images, otherwise, just run on existing images
201 | if (!_rebindings_head->next) {
202 | _dyld_register_func_for_add_image(_rebind_symbols_for_image);
203 | } else {
204 | uint32_t c = _dyld_image_count();
205 | for (uint32_t i = 0; i < c; i++) {
206 | _rebind_symbols_for_image(_dyld_get_image_header(i), _dyld_get_image_vmaddr_slide(i));
207 | }
208 | }
209 | return retval;
210 | }
211 |
--------------------------------------------------------------------------------
/WeChatDemo.xcodeproj/xcuserdata/mac.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist:
--------------------------------------------------------------------------------
1 |
2 |
6 |
7 |
9 |
21 |
22 |
23 |
25 |
37 |
38 |
39 |
41 |
48 |
49 |
50 |
51 |
52 |
54 |
66 |
67 |
68 |
70 |
82 |
83 |
84 |
86 |
98 |
99 |
100 |
102 |
114 |
115 |
116 |
118 |
130 |
131 |
132 |
134 |
146 |
147 |
148 |
150 |
162 |
163 |
164 |
166 |
178 |
179 |
180 |
182 |
194 |
195 |
196 |
198 |
210 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Logos/WeChatDemoDylib.mm:
--------------------------------------------------------------------------------
1 | #line 1 "/Users/mac/Documents/xcodeProject/WeChatDemo/WeChatDemoDylib/Logos/WeChatDemoDylib.xm"
2 | #import
3 | #import "WeChatDemoDylib/Header.h"
4 | #import "WeChatDemoDylib/Comm.h"
5 | #import "WeChatDemoDylib/MyMoreViewController.h"
6 | #import "WeChatDemoDylib/MyRedEnvelopesProcc.h"
7 |
8 |
9 | #include
10 | #if defined(__clang__)
11 | #if __has_feature(objc_arc)
12 | #define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
13 | #define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
14 | #define _LOGOS_SELF_CONST const
15 | #define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
16 | #else
17 | #define _LOGOS_SELF_TYPE_NORMAL
18 | #define _LOGOS_SELF_TYPE_INIT
19 | #define _LOGOS_SELF_CONST
20 | #define _LOGOS_RETURN_RETAINED
21 | #endif
22 | #else
23 | #define _LOGOS_SELF_TYPE_NORMAL
24 | #define _LOGOS_SELF_TYPE_INIT
25 | #define _LOGOS_SELF_CONST
26 | #define _LOGOS_RETURN_RETAINED
27 | #endif
28 |
29 | @class CMessageMgr; @class MoreViewController; @class WCRedEnvelopesLogicMgr; @class WCTableViewManager; @class WCDeviceStepObject;
30 | static void _logos_method$_ungrouped$WCTableViewManager$redEnvelopeSwitchChange$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id); static id (*_logos_orig$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$)(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, NSIndexPath*); static id _logos_method$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, NSIndexPath*); static long long (*_logos_orig$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$)(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, long long); static long long _logos_method$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, long long); static long long (*_logos_orig$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$)(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id); static long long _logos_method$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id); static double (*_logos_orig$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$)(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, NSIndexPath*); static double _logos_method$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST, SEL, id, NSIndexPath*); static void (*_logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$)(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST, SEL, id); static void _logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST, SEL, id); static void (*_logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$)(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST, SEL, id, id); static void _logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST, SEL, id, id); static unsigned int (*_logos_orig$_ungrouped$WCDeviceStepObject$m7StepCount)(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST, SEL); static unsigned int _logos_method$_ungrouped$WCDeviceStepObject$m7StepCount(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST, SEL); static unsigned int (*_logos_orig$_ungrouped$WCDeviceStepObject$hkStepCount)(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST, SEL); static unsigned int _logos_method$_ungrouped$WCDeviceStepObject$hkStepCount(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST, SEL);
31 | static __inline__ __attribute__((always_inline)) __attribute__((unused)) Class _logos_static_class_lookup$MoreViewController(void) { static Class _klass; if(!_klass) { _klass = objc_getClass("MoreViewController"); } return _klass; }
32 | #line 7 "/Users/mac/Documents/xcodeProject/WeChatDemo/WeChatDemoDylib/Logos/WeChatDemoDylib.xm"
33 |
34 |
35 |
36 |
37 | static void _logos_method$_ungrouped$WCTableViewManager$redEnvelopeSwitchChange$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id sender) {
38 | [MyMoreViewController redEnvelopeSwitchChange:sender];
39 | }
40 |
41 | static id _logos_method$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1, NSIndexPath* arg2) {
42 | NSLog(@"indexPath===%@", arg2);
43 |
44 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:_logos_static_class_lookup$MoreViewController()]) {
45 | if (arg2.section == 4) {
46 | NSLog(@"红包的行cell");
47 | UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"mycell"];
48 | cell.textLabel.text=@"自动抢红包";
49 | cell.backgroundColor =[UIColor whiteColor];
50 |
51 | UISwitch *sw = [[UISwitch alloc] init];
52 | sw.on = [Comm confIsRedEnvelopeSwitchEnable];
53 | [sw addTarget:self action:@selector(redEnvelopeSwitchChange:) forControlEvents:UIControlEventValueChanged];
54 | cell.accessoryView = sw;
55 |
56 | return cell;
57 | } else if (arg2.section == 5) {
58 | [MyMoreViewController setTableViewObject:arg1];
59 | return [MyMoreViewController createWCSportTextField];
60 | }
61 |
62 | }
63 | return _logos_orig$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$(self, _cmd, arg1, arg2);
64 | }
65 |
66 |
67 | static long long _logos_method$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1, long long arg2) {
68 | NSLog(@"num===%lld", arg2);
69 |
70 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:_logos_static_class_lookup$MoreViewController()]) {
71 | NSLog(@"红包section的行数");
72 | if (arg2 == 4) {
73 | return 1;
74 | } else if (arg2 == 5) {
75 |
76 | return 1;
77 | }
78 |
79 | }
80 | return _logos_orig$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$(self, _cmd, arg1, arg2);
81 |
82 | }
83 |
84 |
85 | static long long _logos_method$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1) {
86 | NSLog(@"num2===%@", arg1);
87 | if ([[[[arg1 nextResponder] nextResponder] nextResponder] isKindOfClass:_logos_static_class_lookup$MoreViewController()]) {
88 | NSLog(@"这是设置页面");
89 | return _logos_orig$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$(self, _cmd, arg1)+2;
90 | }
91 | return _logos_orig$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$(self, _cmd, arg1);
92 |
93 | }
94 |
95 |
96 |
97 | static double _logos_method$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$(_LOGOS_SELF_TYPE_NORMAL WCTableViewManager* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1, NSIndexPath* arg2) {
98 | if (arg2.section == 4 or arg2.section == 5) {
99 | return 50;
100 | }
101 | return _logos_orig$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$(self, _cmd, arg1, arg2);
102 | }
103 |
104 |
105 |
106 |
107 |
108 | static void _logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$(_LOGOS_SELF_TYPE_NORMAL CMessageMgr* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id arg1){
109 | _logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$(self, _cmd, arg1);
110 | [MyRedEnvelopesProcc onNewSyncAddMessageProcc:arg1];
111 | }
112 |
113 |
114 |
115 |
116 |
117 |
118 | static void _logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(_LOGOS_SELF_TYPE_NORMAL WCRedEnvelopesLogicMgr* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, id hongBaoRes, id hongBaoReq) {
119 | _logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$(self, _cmd, hongBaoRes, hongBaoReq);
120 | [MyRedEnvelopesProcc OnWCToHongbaoCommonResponseProcc:hongBaoRes Request:hongBaoReq];
121 |
122 |
123 | }
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 | static unsigned int _logos_method$_ungrouped$WCDeviceStepObject$m7StepCount(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {
132 | int count = [[Comm confWcWalkNumberString] intValue];
133 | NSLog(@"步数:%d", count);
134 | if (count) {
135 | return count;
136 | }
137 | return _logos_orig$_ungrouped$WCDeviceStepObject$m7StepCount(self, _cmd);
138 | }
139 |
140 |
141 | static unsigned int _logos_method$_ungrouped$WCDeviceStepObject$hkStepCount(_LOGOS_SELF_TYPE_NORMAL WCDeviceStepObject* _LOGOS_SELF_CONST __unused self, SEL __unused _cmd) {
142 | int count = [[Comm confWcWalkNumberString] intValue];
143 | NSLog(@"步数:%d", count);
144 | if (count) {
145 | return count;
146 | }
147 | return _logos_orig$_ungrouped$WCDeviceStepObject$hkStepCount(self, _cmd);
148 | }
149 |
150 |
151 | static __attribute__((constructor)) void _logosLocalInit() {
152 | {Class _logos_class$_ungrouped$WCTableViewManager = objc_getClass("WCTableViewManager"); { char _typeEncoding[1024]; unsigned int i = 0; _typeEncoding[i] = 'v'; i += 1; _typeEncoding[i] = '@'; i += 1; _typeEncoding[i] = ':'; i += 1; _typeEncoding[i] = '@'; i += 1; _typeEncoding[i] = '\0'; class_addMethod(_logos_class$_ungrouped$WCTableViewManager, @selector(redEnvelopeSwitchChange:), (IMP)&_logos_method$_ungrouped$WCTableViewManager$redEnvelopeSwitchChange$, _typeEncoding); }MSHookMessageEx(_logos_class$_ungrouped$WCTableViewManager, @selector(tableView:cellForRowAtIndexPath:), (IMP)&_logos_method$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$, (IMP*)&_logos_orig$_ungrouped$WCTableViewManager$tableView$cellForRowAtIndexPath$);MSHookMessageEx(_logos_class$_ungrouped$WCTableViewManager, @selector(tableView:numberOfRowsInSection:), (IMP)&_logos_method$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$, (IMP*)&_logos_orig$_ungrouped$WCTableViewManager$tableView$numberOfRowsInSection$);MSHookMessageEx(_logos_class$_ungrouped$WCTableViewManager, @selector(numberOfSectionsInTableView:), (IMP)&_logos_method$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$, (IMP*)&_logos_orig$_ungrouped$WCTableViewManager$numberOfSectionsInTableView$);MSHookMessageEx(_logos_class$_ungrouped$WCTableViewManager, @selector(tableView:heightForRowAtIndexPath:), (IMP)&_logos_method$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$, (IMP*)&_logos_orig$_ungrouped$WCTableViewManager$tableView$heightForRowAtIndexPath$);Class _logos_class$_ungrouped$CMessageMgr = objc_getClass("CMessageMgr"); MSHookMessageEx(_logos_class$_ungrouped$CMessageMgr, @selector(onNewSyncAddMessage:), (IMP)&_logos_method$_ungrouped$CMessageMgr$onNewSyncAddMessage$, (IMP*)&_logos_orig$_ungrouped$CMessageMgr$onNewSyncAddMessage$);Class _logos_class$_ungrouped$WCRedEnvelopesLogicMgr = objc_getClass("WCRedEnvelopesLogicMgr"); MSHookMessageEx(_logos_class$_ungrouped$WCRedEnvelopesLogicMgr, @selector(OnWCToHongbaoCommonResponse:Request:), (IMP)&_logos_method$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$, (IMP*)&_logos_orig$_ungrouped$WCRedEnvelopesLogicMgr$OnWCToHongbaoCommonResponse$Request$);Class _logos_class$_ungrouped$WCDeviceStepObject = objc_getClass("WCDeviceStepObject"); MSHookMessageEx(_logos_class$_ungrouped$WCDeviceStepObject, @selector(m7StepCount), (IMP)&_logos_method$_ungrouped$WCDeviceStepObject$m7StepCount, (IMP*)&_logos_orig$_ungrouped$WCDeviceStepObject$m7StepCount);MSHookMessageEx(_logos_class$_ungrouped$WCDeviceStepObject, @selector(hkStepCount), (IMP)&_logos_method$_ungrouped$WCDeviceStepObject$hkStepCount, (IMP*)&_logos_orig$_ungrouped$WCDeviceStepObject$hkStepCount);} }
153 | #line 125 "/Users/mac/Documents/xcodeProject/WeChatDemo/WeChatDemoDylib/Logos/WeChatDemoDylib.xm"
154 |
--------------------------------------------------------------------------------
/WeChatDemo/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | BuildMachineOSBuild
6 | 18E226
7 | CFBundleDevelopmentRegion
8 | zh_CN
9 | CFBundleDisplayName
10 | 微信
11 | CFBundleDocumentTypes
12 |
13 |
14 | CFBundleTypeName
15 | officeopenxml
16 | LSHandlerRank
17 | Alternate
18 | LSItemContentTypes
19 |
20 | org.openxmlformats.openxml
21 |
22 |
23 |
24 | CFBundleTypeName
25 | data
26 | LSHandlerRank
27 | Alternate
28 | LSItemContentTypes
29 |
30 | public.data
31 |
32 |
33 |
34 | CFBundleTypeName
35 | ppt
36 | LSHandlerRank
37 | Alternate
38 | LSItemContentTypes
39 |
40 | com.microsoft.powerpoint.ppt
41 |
42 |
43 |
44 | CFBundleTypeName
45 | doc
46 | LSHandlerRank
47 | Alternate
48 | LSItemContentTypes
49 |
50 | com.microsoft.word.doc
51 |
52 |
53 |
54 | CFBundleTypeName
55 | xls
56 | LSHandlerRank
57 | Alternate
58 | LSItemContentTypes
59 |
60 | com.microsoft.excel.xls
61 |
62 |
63 |
64 | CFBundleTypeName
65 | pdf
66 | LSHandlerRank
67 | Alternate
68 | LSItemContentTypes
69 |
70 | com.adobe.pdf
71 |
72 |
73 |
74 | CFBundleTypeName
75 | archive
76 | LSHandlerRank
77 | Alternate
78 | LSItemContentTypes
79 |
80 | org.gnu.gnu-tar-archive
81 |
82 |
83 |
84 | CFBundleTypeName
85 | audivideo
86 | LSHandlerRank
87 | Alternate
88 | LSItemContentTypes
89 |
90 | public.audiovisual-content
91 |
92 |
93 |
94 | CFBundleTypeName
95 | image
96 | LSHandlerRank
97 | Alternate
98 | LSItemContentTypes
99 |
100 | public.image
101 |
102 |
103 |
104 | CFBundleTypeName
105 | txt
106 | LSHandlerRank
107 | Alternate
108 | LSItemContentTypes
109 |
110 | public.text
111 |
112 |
113 |
114 | CFBundleExecutable
115 | WeChat
116 | CFBundleIconFiles
117 |
118 | WeChatDemo/icon.png
119 |
120 | CFBundleIcons
121 |
122 | CFBundlePrimaryIcon
123 |
124 | CFBundleIconFiles
125 |
126 | AppIcon60x60
127 |
128 | CFBundleIconName
129 | AppIcon
130 |
131 |
132 | CFBundleIcons~ipad
133 |
134 | CFBundlePrimaryIcon
135 |
136 | CFBundleIconFiles
137 |
138 | AppIcon60x60
139 | AppIcon76x76
140 | AppIcon83.5x83.5
141 |
142 | CFBundleIconName
143 | AppIcon
144 |
145 |
146 | CFBundleIdentifier
147 | com.maimai.autoSign
148 | CFBundleInfoDictionaryVersion
149 | 6.0
150 | CFBundleName
151 | WeChat
152 | CFBundlePackageType
153 | APPL
154 | CFBundleShortVersionString
155 | 7.0.12
156 | CFBundleSignature
157 | ????
158 | CFBundleSupportedPlatforms
159 |
160 | iPhoneOS
161 |
162 | CFBundleURLTypes
163 |
164 |
165 | CFBundleTypeRole
166 | Editor
167 | CFBundleURLName
168 | com.tencent.xin
169 | CFBundleURLSchemes
170 |
171 | wexinVideoAPI
172 | weixin
173 | weixinapp
174 | fb290293790992170
175 | wechat
176 | QQ41C152CF
177 | prefs
178 | wx703
179 | weixinULAPI
180 |
181 |
182 |
183 | CFBundleVersion
184 | 7.0.12.33
185 | DTAppStoreToolsBuild
186 | 11C29
187 | DTCompiler
188 | com.apple.compilers.llvm.clang.1_0
189 | DTPlatformBuild
190 | 17B102
191 | DTPlatformName
192 | iphoneos
193 | DTPlatformVersion
194 | 13.2
195 | DTSDKBuild
196 | 17B102
197 | DTSDKName
198 | iphoneos13.2
199 | DTXcode
200 | 1130
201 | DTXcodeBuild
202 | 11C29
203 | FacebookAppID
204 | 290293790992170
205 | FacebookAutoInitEnabled
206 |
207 | FacebookAutoLogAppEventsEnabled
208 |
209 | LSApplicationQueriesSchemes
210 |
211 | qqnews
212 | weixinbeta
213 | qqnewshd
214 | qqmail
215 | whatsapp
216 | wxwork
217 | wxworklocal
218 | wxcphonebook
219 | mttbrowser
220 | mqqapi
221 | mqzonev2
222 | qqmusic
223 | tenvideo2
224 | tenvideohd
225 | qnreading
226 | weread
227 | sosomap
228 | comgooglemaps
229 | iosamap
230 | baidumap
231 | sgmap
232 | fbauth2
233 | wx76fc280041c16519
234 | wx3bef52104e238bff
235 | rijvideo
236 | wx95a3a4d7c627e07d
237 | wx44b60f3ea0534cd7
238 | wxacbfe7e1bb3e800f
239 | wxfdab5af74990787a
240 | wx58164a91f1821369
241 | wxd477edab60670232
242 | wx82dd7436af5db835
243 | qqstock
244 | openApp.jdMobile
245 | openapp.toplife
246 | qmkege
247 | mqzonex
248 | txvp
249 | sybapp
250 | wx5a4a8ac0fd48303a
251 | qqsports
252 | qqcar
253 | tencentedu
254 | wemusic
255 | qqmap
256 | mqq
257 | webank
258 | weiyun
259 | weishi
260 |
261 | LSRequiresIPhoneOS
262 |
263 | LSSupportsOpeningDocumentsInPlace
264 |
265 | MidasConfig
266 |
267 | HideLoading
268 |
269 |
270 | MinimumOSVersion
271 | 10.0
272 | NSAppTransportSecurity
273 |
274 | NSAllowsArbitraryLoads
275 |
276 |
277 | NSBluetoothAlwaysUsageDescription
278 | Allow WeChat Use Bluetooth Peripheral.
279 | NSBluetoothPeripheralUsageDescription
280 | Allow WeChat Use Bluetooth Peripheral.
281 | NSCameraUsageDescription
282 | Use your Camera to record video, using VoIP features.
283 | NSContactsUsageDescription
284 | Allow WeChat Use your Contact.
285 | NSFaceIDUsageDescription
286 | Allow WeChat Use FaceID.
287 | NSHealthShareUsageDescription
288 | Allow WeChat Use Health Share.
289 | NSHealthUpdateUsageDescription
290 | Allow WeChat Use Health Update.
291 | NSLocationAlwaysUsageDescription
292 | Allow WeChat Use your Location always.
293 | NSLocationUsageDescription
294 | Allow WeChat Use your Location.
295 | NSLocationWhenInUseUsageDescription
296 | Allow WeChat Use your Location when in use.
297 | NSMicrophoneUsageDescription
298 | Use your Microphone to record voice messages, using VoIP features.
299 | NSMotionUsageDescription
300 | Allow WeChat Use Motion.
301 | NSPhotoLibraryAddUsageDescription
302 | Allow WeChat Save Photo.
303 | NSPhotoLibraryUsageDescription
304 | Allow WeChat Use your PhotoLibrary.
305 | NSSiriUsageDescription
306 | Allow WeChat Use Siri.
307 | NSUserActivityTypes
308 |
309 | com.tencent.xin
310 | com.tencent.xin.watch
311 |
312 | UIAppFonts
313 |
314 | WeChatSansStd-Bold.ttf
315 | WeChatSansStd-Medium.ttf
316 | WeChatSansStd-Regular.ttf
317 | WeChatSansSuperscript-Bold.ttf
318 | WeChatSansSuperscript-Regular.ttf
319 | WeChatSansSuperscript-Medium.ttf
320 |
321 | UIBackgroundModes
322 |
323 | location
324 | audio
325 | fetch
326 | voip
327 | remote-notification
328 | network-authentication
329 |
330 | UIDeviceFamily
331 |
332 | 1
333 | 2
334 |
335 | UILaunchStoryboardName
336 | Launch Screen
337 | UIPrerenderedIcon
338 |
339 | UIRequiredDeviceCapabilities
340 |
341 | arm64
342 |
343 | UIStatusBarHidden
344 |
345 | UIStatusBarStyle
346 | UIStatusBarStyleBlackOpaque
347 | UISupportedInterfaceOrientations
348 |
349 | UIInterfaceOrientationPortrait
350 | UIInterfaceOrientationLandscapeLeft
351 | UIInterfaceOrientationLandscapeRight
352 |
353 | UISupportedInterfaceOrientations~ipad
354 |
355 | UIInterfaceOrientationPortrait
356 | UIInterfaceOrientationLandscapeLeft
357 | UIInterfaceOrientationLandscapeRight
358 | UIInterfaceOrientationPortraitUpsideDown
359 |
360 | UISupportsDocumentBrowser
361 |
362 | UIViewControllerBasedStatusBarAppearance
363 |
364 | WeChatBundleVersion
365 | 7.0.12.33
366 | WeChatFeatureIdentifier
367 | release_appstore_7.0.12
368 | build_time
369 | 2020-03-19 22:14:45
370 | by
371 | wx_ios_code_helper
372 | path
373 | release_appstore_7.0.12_2020_3_17_18_43_18
374 | rev
375 | a328832be688788fb640b9d24fe34be2fbfd4177
376 | tag
377 | release_appstore_7.0.12 #43
378 | uuid
379 | 7195b97e9078311991108bda959283f0
380 | ver
381 | 0x17000c21
382 |
383 |
384 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Config/MDCycriptManager.m:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // MDCycriptManager.m
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/3/8.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #ifndef __OPTIMIZE__
12 |
13 | #import "MDCycriptManager.h"
14 | #import "MDConfigManager.h"
15 | #import
16 | #import
17 | #import
18 | #import
19 | #import
20 |
21 | #define IOS_CELLULAR @"pdp_ip0"
22 | #define IOS_WIFI @"en0"
23 | #define IP_ADDR_IPv4 @"ipv4"
24 | #define IP_ADDR_IPv6 @"ipv6"
25 | #define MDLog(fmt, ...) NSLog((@"[Cycript] " fmt), ##__VA_ARGS__)
26 |
27 | extern JSGlobalContextRef CYGetJSContext(void);
28 | extern void CydgetMemoryParse(const uint16_t **data, size_t *size);
29 |
30 | NSString * const CYErrorLineKey = @"CYErrorLineKey";
31 | NSString * const CYErrorNameKey = @"CYErrorNameKey";
32 | NSString * const CYErrorMessageKey = @"CYErrorMessageKey";
33 |
34 | @interface MDSettingObject : NSObject
35 |
36 | @property (nonatomic, assign) NSInteger priority;
37 | @property (nonatomic, copy) NSString* url;
38 | @property (nonatomic, copy) NSString* content;
39 | @property (nonatomic, assign) BOOL loadAtLaunch;
40 |
41 | -(instancetype)initWithDicationary:(NSDictionary*) dictionary;
42 |
43 | @end
44 |
45 | @implementation MDSettingObject
46 |
47 | -(instancetype)initWithDicationary:(NSDictionary *)dictionary{
48 | self = [super init];
49 | if(self){
50 | self.priority = [dictionary[@"priority"] integerValue];
51 | self.url = dictionary[@"url"];
52 | self.content = dictionary[@"content"];
53 | self.loadAtLaunch = [dictionary objectForKey:MDCONFIG_LOADATLAUNCH_KEY] && [dictionary[MDCONFIG_LOADATLAUNCH_KEY] boolValue];
54 | }
55 | return self;
56 | }
57 |
58 | @end
59 |
60 | @interface MDCycriptManager()
61 |
62 | @property (nonatomic, strong) NSDictionary* configItem;
63 | @property (nonatomic, copy) NSString* cycriptDirectory;
64 | @property (nonatomic, strong) NSMutableArray* downloading;
65 | @property (nonatomic, strong) NSMutableDictionary* loadAtLaunchModules;
66 |
67 | @end
68 |
69 | @implementation MDCycriptManager
70 |
71 | + (instancetype)sharedInstance{
72 | static MDCycriptManager *sharedInstance = nil;
73 | if (!sharedInstance){
74 | sharedInstance = [[MDCycriptManager alloc] init];
75 | }
76 | return sharedInstance;
77 | }
78 |
79 | - (instancetype)init
80 | {
81 | self = [super init];
82 | if (self) {
83 | _loadAtLaunchModules = [NSMutableDictionary dictionary];
84 | _downloading = [NSMutableArray array];
85 | [self check];
86 | [self readConfigFile];
87 | }
88 | return self;
89 | }
90 |
91 | -(void)check{
92 | NSString* ip = [self getIPAddress];
93 | if(ip != nil){
94 | printf("\nDownload cycript(https://cydia.saurik.com/api/latest/3) then run: ./cycript -r %s:%d\n\n", [ip UTF8String], PORT);
95 | }else{
96 | printf("\nPlease connect wifi before using cycript!\n\n");
97 | }
98 |
99 | NSFileManager *fileManager = [NSFileManager defaultManager];
100 | NSString *documentsPath =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) firstObject];
101 | _cycriptDirectory = [documentsPath stringByAppendingPathComponent:@"cycript"];
102 | [fileManager createDirectoryAtPath:_cycriptDirectory withIntermediateDirectories:YES attributes:nil error:nil];
103 | }
104 |
105 | -(NSArray*)sortedArray:(NSDictionary*) dictionary{
106 | NSMutableArray* result = [NSMutableArray arrayWithCapacity:10];
107 |
108 | NSArray* sortedArray = [dictionary.allKeys sortedArrayUsingComparator:^NSComparisonResult(NSNumber* _Nonnull number1, NSNumber* _Nonnull number2) {
109 | if ([number1 integerValue] > [number2 integerValue])
110 | return NSOrderedDescending;
111 | return NSOrderedAscending;
112 | }];
113 |
114 | for (NSNumber* item in sortedArray) {
115 | [result addObject:dictionary[item]];
116 | }
117 |
118 | return [result copy];
119 | }
120 |
121 | -(void)readConfigFile{
122 | MDConfigManager * configManager = [MDConfigManager sharedInstance];
123 | _configItem = [configManager readConfigByKey:MDCONFIG_CYCRIPT_KEY];
124 | }
125 |
126 | -(void)loadCycript:(BOOL) update{
127 | NSFileManager *fileManager = [NSFileManager defaultManager];
128 |
129 | if(_configItem && _configItem.count > 0){
130 |
131 | BOOL download = NO;
132 |
133 | for (NSString* moduleName in _configItem.allKeys) {
134 | MDSettingObject * item = [[MDSettingObject alloc] initWithDicationary:_configItem[moduleName]];
135 | NSString *fullPath = [[_cycriptDirectory stringByAppendingPathComponent:moduleName] stringByAppendingPathExtension:@"cy"];
136 |
137 | if(item.url){
138 | if(![fileManager fileExistsAtPath:fullPath] || update){
139 | download = YES;
140 | [self.downloading addObject:moduleName];
141 | [self downLoadUrl:item.url saveName:moduleName];
142 | }
143 | }
144 |
145 | if(item.content){
146 | if(![fileManager fileExistsAtPath:fullPath] || update){
147 | NSString* writeContent = [NSString stringWithFormat:@"(function(exports) { %@ })(exports);", item.content];
148 | [writeContent writeToFile:fullPath atomically:YES encoding:NSUTF8StringEncoding error:nil];
149 | }
150 | }
151 |
152 | if(item.loadAtLaunch){
153 | [_loadAtLaunchModules setObject:fullPath forKey:@(item.priority)];
154 | }
155 | }
156 |
157 | if(!download){
158 | [self finishDownload];
159 | }
160 | }
161 | }
162 |
163 | -(void)finishDownload{
164 | MDLog(@"Finish download all script!");
165 | NSArray* sortedArray = [self sortedArray:_loadAtLaunchModules];
166 | for (NSString* fullPath in sortedArray) {
167 | NSError* error;
168 | [self evaluateCycript:[NSString stringWithFormat:@"require('%@');",fullPath] error:&error];
169 | if(error.code != 0){
170 | MDLog(@"%@", error.localizedDescription);
171 | }
172 | }
173 | }
174 |
175 | -(void)downLoadUrl:(NSString*) urlString saveName:(NSString*) filename{
176 | __weak typeof(self) weakSelf = self;
177 | NSURLSession *session = [NSURLSession sharedSession];
178 | NSURL *url = [NSURL URLWithString:urlString];
179 | NSURLSessionDownloadTask *downloadTask = [session downloadTaskWithURL:url completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
180 |
181 | if(error){
182 | MDLog(@"Failed download script [%@]: %@", filename, error.localizedDescription);
183 | }else{
184 | NSString *fullPath = [[weakSelf.cycriptDirectory stringByAppendingPathComponent:filename] stringByAppendingPathExtension:@"cy"];
185 | [[NSFileManager defaultManager] moveItemAtURL:location toURL:[NSURL fileURLWithPath:fullPath] error:nil];
186 |
187 | MDLog(@"Successful download script [%@]", filename);
188 | }
189 |
190 | [weakSelf.downloading removeObject:filename];
191 |
192 | if(!weakSelf.downloading.count){
193 | [weakSelf finishDownload];
194 | }
195 | }];
196 | [downloadTask resume];
197 | }
198 |
199 | -(NSString *)evaluateCycript:(NSString *)cycript error:(NSError *__autoreleasing *)error{
200 | NSString *resultString = nil;
201 |
202 | static pthread_mutex_t cycript_metex = PTHREAD_MUTEX_INITIALIZER;
203 | pthread_mutex_lock(&cycript_metex); {
204 | JSGlobalContextRef context = CYGetJSContext();
205 |
206 | size_t length = cycript.length;
207 | unichar *buffer = malloc(length * sizeof(unichar));
208 | [cycript getCharacters:buffer range:NSMakeRange(0, length)];
209 | const uint16_t *characters = buffer;
210 | CydgetMemoryParse(&characters, &length);
211 | JSStringRef expression = JSStringCreateWithCharacters(characters, length);
212 |
213 | // Evaluate the Javascript
214 | JSValueRef exception = NULL;
215 | JSValueRef result = JSEvaluateScript(context, expression, NULL, NULL, 0, &exception);
216 | JSStringRelease(expression);
217 |
218 | // If a result was returned, convert it into an NSString
219 | if (result) {
220 | JSStringRef string = JSValueToStringCopy(context, result, &exception);
221 | if (string) {
222 | resultString = (__bridge_transfer NSString *)JSStringCopyCFString(kCFAllocatorDefault, string);
223 | JSStringRelease(string);
224 | }
225 | }
226 |
227 | // If an exception was thrown, convert it into an NSError
228 | if (exception && error) {
229 | JSObjectRef exceptionObject = JSValueToObject(context, exception, NULL);
230 |
231 | NSInteger line = (NSInteger)JSValueToNumber(context, JSObjectGetProperty(context, exceptionObject, JSStringCreateWithUTF8CString("line"), NULL), NULL);
232 | JSStringRef string = JSValueToStringCopy(context, JSObjectGetProperty(context, exceptionObject, JSStringCreateWithUTF8CString("name"), NULL), NULL);
233 | NSString *name = (__bridge_transfer NSString *)JSStringCopyCFString(kCFAllocatorDefault, string);
234 | JSStringRelease(string);
235 | string = JSValueToStringCopy(context, JSObjectGetProperty(context, exceptionObject, JSStringCreateWithUTF8CString("message"), NULL), NULL);
236 | NSString *message = (__bridge_transfer NSString *)JSStringCopyCFString(kCFAllocatorDefault, string);
237 | JSStringRelease(string);
238 | string = JSValueToStringCopy(context, exception, NULL);
239 | NSString *description = (__bridge_transfer NSString *)JSStringCopyCFString(kCFAllocatorDefault, string);
240 | JSStringRelease(string);
241 |
242 | NSMutableDictionary *userInfo = [NSMutableDictionary dictionary];
243 | [userInfo setValue:@(line) forKey:CYErrorLineKey];
244 | [userInfo setValue:name forKey:CYErrorNameKey];
245 | [userInfo setValue:message forKey:CYErrorMessageKey];
246 | [userInfo setValue:description forKey:NSLocalizedDescriptionKey];
247 | *error = [NSError errorWithDomain:@"CYContextDomain" code:0 userInfo:userInfo];
248 | }
249 | }pthread_mutex_unlock(&cycript_metex);
250 |
251 | return resultString;
252 | }
253 |
254 | - (NSString *)getIPAddress{
255 |
256 | NSDictionary *addresses = [self getIPAddresses];
257 |
258 | if([addresses.allKeys containsObject:IOS_WIFI @"/" IP_ADDR_IPv4]){
259 | return addresses[IOS_WIFI @"/" IP_ADDR_IPv4];
260 | }
261 |
262 | return nil;
263 | }
264 |
265 | - (NSDictionary *)getIPAddresses{
266 | NSMutableDictionary *addresses = [NSMutableDictionary dictionaryWithCapacity:8];
267 |
268 | // retrieve the current interfaces - returns 0 on success
269 | struct ifaddrs *interfaces;
270 | if(!getifaddrs(&interfaces)) {
271 | // Loop through linked list of interfaces
272 | struct ifaddrs *interface;
273 | for(interface=interfaces; interface; interface=interface->ifa_next) {
274 | if(!(interface->ifa_flags & IFF_UP) /* || (interface->ifa_flags & IFF_LOOPBACK) */ ) {
275 | continue; // deeply nested code harder to read
276 | }
277 | const struct sockaddr_in *addr = (const struct sockaddr_in*)interface->ifa_addr;
278 | char addrBuf[ MAX(INET_ADDRSTRLEN, INET6_ADDRSTRLEN) ];
279 | if(addr && (addr->sin_family==AF_INET || addr->sin_family==AF_INET6)) {
280 | NSString *name = [NSString stringWithUTF8String:interface->ifa_name];
281 | NSString *type;
282 | if(addr->sin_family == AF_INET) {
283 | if(inet_ntop(AF_INET, &addr->sin_addr, addrBuf, INET_ADDRSTRLEN)) {
284 | type = IP_ADDR_IPv4;
285 | }
286 | } else {
287 | const struct sockaddr_in6 *addr6 = (const struct sockaddr_in6*)interface->ifa_addr;
288 | if(inet_ntop(AF_INET6, &addr6->sin6_addr, addrBuf, INET6_ADDRSTRLEN)) {
289 | type = IP_ADDR_IPv6;
290 | }
291 | }
292 | if(type) {
293 | NSString *key = [NSString stringWithFormat:@"%@/%@", name, type];
294 | addresses[key] = [NSString stringWithUTF8String:addrBuf];
295 | }
296 | }
297 | }
298 | // Free memory
299 | freeifaddrs(interfaces);
300 | }
301 | return [addresses count] ? addresses : nil;
302 | }
303 |
304 | @end
305 |
306 | #endif
307 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a1a2-selectortramps-x86_64.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a1a2-selectortramps-x86_64.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #ifdef __x86_64__
23 |
24 | #include
25 | #include "selectortramps.mac"
26 |
27 | .text
28 | .private_extern __a1a2_selectorTrampHead
29 | .private_extern __a1a2_firstSelectorTramp
30 | .private_extern __a1a2_nextSelectorTramp
31 | .private_extern __a1a2_selectorTrampEnd
32 |
33 | .align PAGE_SHIFT
34 | __a1a2_selectorTrampHead:
35 | // 1. selector
36 | popq %r10
37 | andq $0xFFFFFFFFFFFFFFF8, %r10
38 | subq $ PAGE_SIZE, %r10
39 | movq (%r10), %rsi // selector -> _cmd
40 | // 2. msgSend
41 | INIT_PIC(__a1a2_selectorTrampHead)
42 | PRELOAD(__a1a2_selectorTrampHead, __a1a2_selectorTrampHead)
43 | subq $ PAGE_SIZE, LABEL_ADDR(__a1a2_selectorTrampHead, __a1a2_selectorTrampHead)
44 | END_PIC()
45 | jmp *0(%r10) // tail call msgSend
46 |
47 | .macro TrampolineEntry
48 | callq __a1a2_selectorTrampHead
49 | nop
50 | nop
51 | nop
52 | .endmacro
53 |
54 | .align 5
55 | __a1a2_firstSelectorTramp:
56 | TrampolineEntry
57 | __a1a2_nextSelectorTramp:
58 | TrampolineEntry
59 | TrampolineEntry
60 | TrampolineEntry
61 | TrampolineEntry
62 | TrampolineEntry
63 | TrampolineEntry
64 | TrampolineEntry
65 | TrampolineEntry
66 | TrampolineEntry
67 | TrampolineEntry
68 | TrampolineEntry
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 | TrampolineEntry
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 | TrampolineEntry
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 | TrampolineEntry
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | TrampolineEntry
89 | TrampolineEntry
90 | TrampolineEntry
91 | TrampolineEntry
92 | TrampolineEntry
93 | TrampolineEntry
94 | TrampolineEntry
95 | TrampolineEntry
96 | TrampolineEntry
97 | TrampolineEntry
98 | TrampolineEntry
99 | TrampolineEntry
100 | TrampolineEntry
101 | TrampolineEntry
102 | TrampolineEntry
103 | TrampolineEntry
104 | TrampolineEntry
105 | TrampolineEntry
106 | TrampolineEntry
107 | TrampolineEntry
108 | TrampolineEntry
109 | TrampolineEntry
110 | TrampolineEntry
111 | TrampolineEntry
112 | TrampolineEntry
113 | TrampolineEntry
114 | TrampolineEntry
115 | TrampolineEntry
116 | TrampolineEntry
117 | TrampolineEntry
118 | TrampolineEntry
119 | TrampolineEntry
120 | TrampolineEntry
121 | TrampolineEntry
122 | TrampolineEntry
123 | TrampolineEntry
124 | TrampolineEntry
125 | TrampolineEntry
126 | TrampolineEntry
127 | TrampolineEntry
128 | TrampolineEntry
129 | TrampolineEntry
130 | TrampolineEntry
131 | TrampolineEntry
132 | TrampolineEntry
133 | TrampolineEntry
134 | TrampolineEntry
135 | TrampolineEntry
136 | TrampolineEntry
137 | TrampolineEntry
138 | TrampolineEntry
139 | TrampolineEntry
140 | TrampolineEntry
141 | TrampolineEntry
142 | TrampolineEntry
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 | TrampolineEntry
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 | TrampolineEntry
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 | TrampolineEntry
158 | TrampolineEntry
159 | TrampolineEntry
160 | TrampolineEntry
161 | TrampolineEntry
162 | TrampolineEntry
163 | TrampolineEntry
164 | TrampolineEntry
165 | TrampolineEntry
166 | TrampolineEntry
167 | TrampolineEntry
168 | TrampolineEntry
169 | TrampolineEntry
170 | TrampolineEntry
171 | TrampolineEntry
172 | TrampolineEntry
173 | TrampolineEntry
174 | TrampolineEntry
175 | TrampolineEntry
176 | TrampolineEntry
177 | TrampolineEntry
178 | TrampolineEntry
179 | TrampolineEntry
180 | TrampolineEntry
181 | TrampolineEntry
182 | TrampolineEntry
183 | TrampolineEntry
184 | TrampolineEntry
185 | TrampolineEntry
186 | TrampolineEntry
187 | TrampolineEntry
188 | TrampolineEntry
189 | TrampolineEntry
190 | TrampolineEntry
191 | TrampolineEntry
192 | TrampolineEntry
193 | TrampolineEntry
194 | TrampolineEntry
195 | TrampolineEntry
196 | TrampolineEntry
197 | TrampolineEntry
198 | TrampolineEntry
199 | TrampolineEntry
200 | TrampolineEntry
201 | TrampolineEntry
202 | TrampolineEntry
203 | TrampolineEntry
204 | TrampolineEntry
205 | TrampolineEntry
206 | TrampolineEntry
207 | TrampolineEntry
208 | TrampolineEntry
209 | TrampolineEntry
210 | TrampolineEntry
211 | TrampolineEntry
212 | TrampolineEntry
213 | TrampolineEntry
214 | TrampolineEntry
215 | TrampolineEntry
216 | TrampolineEntry
217 | TrampolineEntry
218 | TrampolineEntry
219 | TrampolineEntry
220 | TrampolineEntry
221 | TrampolineEntry
222 | TrampolineEntry
223 | TrampolineEntry
224 | TrampolineEntry
225 | TrampolineEntry
226 | TrampolineEntry
227 | TrampolineEntry
228 | TrampolineEntry
229 | TrampolineEntry
230 | TrampolineEntry
231 | TrampolineEntry
232 | TrampolineEntry
233 | TrampolineEntry
234 | TrampolineEntry
235 | TrampolineEntry
236 | TrampolineEntry
237 | TrampolineEntry
238 | TrampolineEntry
239 | TrampolineEntry
240 | TrampolineEntry
241 | TrampolineEntry
242 | TrampolineEntry
243 | TrampolineEntry
244 | TrampolineEntry
245 | TrampolineEntry
246 | TrampolineEntry
247 | TrampolineEntry
248 | TrampolineEntry
249 | TrampolineEntry
250 | TrampolineEntry
251 | TrampolineEntry
252 | TrampolineEntry
253 | TrampolineEntry
254 | TrampolineEntry
255 | TrampolineEntry
256 | TrampolineEntry
257 | TrampolineEntry
258 | TrampolineEntry
259 | TrampolineEntry
260 | TrampolineEntry
261 | TrampolineEntry
262 | TrampolineEntry
263 | TrampolineEntry
264 | TrampolineEntry
265 | TrampolineEntry
266 | TrampolineEntry
267 | TrampolineEntry
268 | TrampolineEntry
269 | TrampolineEntry
270 | TrampolineEntry
271 | TrampolineEntry
272 | TrampolineEntry
273 | TrampolineEntry
274 | TrampolineEntry
275 | TrampolineEntry
276 | TrampolineEntry
277 | TrampolineEntry
278 | TrampolineEntry
279 | TrampolineEntry
280 | TrampolineEntry
281 | TrampolineEntry
282 | TrampolineEntry
283 | TrampolineEntry
284 | TrampolineEntry
285 | TrampolineEntry
286 | TrampolineEntry
287 | TrampolineEntry
288 | TrampolineEntry
289 | TrampolineEntry
290 | TrampolineEntry
291 | TrampolineEntry
292 | TrampolineEntry
293 | TrampolineEntry
294 | TrampolineEntry
295 | TrampolineEntry
296 | TrampolineEntry
297 | TrampolineEntry
298 | TrampolineEntry
299 | TrampolineEntry
300 | TrampolineEntry
301 | TrampolineEntry
302 | TrampolineEntry
303 | TrampolineEntry
304 | TrampolineEntry
305 | TrampolineEntry
306 | TrampolineEntry
307 | TrampolineEntry
308 | TrampolineEntry
309 | TrampolineEntry
310 | TrampolineEntry
311 | TrampolineEntry
312 | TrampolineEntry
313 | TrampolineEntry
314 | TrampolineEntry
315 | TrampolineEntry
316 | TrampolineEntry
317 | TrampolineEntry
318 | TrampolineEntry
319 | TrampolineEntry
320 | TrampolineEntry
321 | TrampolineEntry
322 | TrampolineEntry
323 | TrampolineEntry
324 | TrampolineEntry
325 | TrampolineEntry
326 | TrampolineEntry
327 | TrampolineEntry
328 | TrampolineEntry
329 | TrampolineEntry
330 | TrampolineEntry
331 | TrampolineEntry
332 | TrampolineEntry
333 | TrampolineEntry
334 | TrampolineEntry
335 | TrampolineEntry
336 | TrampolineEntry
337 | TrampolineEntry
338 | TrampolineEntry
339 | TrampolineEntry
340 | TrampolineEntry
341 | TrampolineEntry
342 | TrampolineEntry
343 | TrampolineEntry
344 | TrampolineEntry
345 | TrampolineEntry
346 | TrampolineEntry
347 | TrampolineEntry
348 | TrampolineEntry
349 | TrampolineEntry
350 | TrampolineEntry
351 | TrampolineEntry
352 | TrampolineEntry
353 | TrampolineEntry
354 | TrampolineEntry
355 | TrampolineEntry
356 | TrampolineEntry
357 | TrampolineEntry
358 | TrampolineEntry
359 | TrampolineEntry
360 | TrampolineEntry
361 | TrampolineEntry
362 | TrampolineEntry
363 | TrampolineEntry
364 | TrampolineEntry
365 | TrampolineEntry
366 | TrampolineEntry
367 | TrampolineEntry
368 | TrampolineEntry
369 | TrampolineEntry
370 | TrampolineEntry
371 | TrampolineEntry
372 | TrampolineEntry
373 | TrampolineEntry
374 | TrampolineEntry
375 | TrampolineEntry
376 | TrampolineEntry
377 | TrampolineEntry
378 | TrampolineEntry
379 | TrampolineEntry
380 | TrampolineEntry
381 | TrampolineEntry
382 | TrampolineEntry
383 | TrampolineEntry
384 | TrampolineEntry
385 | TrampolineEntry
386 | TrampolineEntry
387 | TrampolineEntry
388 | TrampolineEntry
389 | TrampolineEntry
390 | TrampolineEntry
391 | TrampolineEntry
392 | TrampolineEntry
393 | TrampolineEntry
394 | TrampolineEntry
395 | TrampolineEntry
396 | TrampolineEntry
397 | TrampolineEntry
398 | TrampolineEntry
399 | TrampolineEntry
400 | TrampolineEntry
401 | TrampolineEntry
402 | TrampolineEntry
403 | TrampolineEntry
404 | TrampolineEntry
405 | TrampolineEntry
406 | TrampolineEntry
407 | TrampolineEntry
408 | TrampolineEntry
409 | TrampolineEntry
410 | TrampolineEntry
411 | TrampolineEntry
412 | TrampolineEntry
413 | TrampolineEntry
414 | TrampolineEntry
415 | TrampolineEntry
416 | TrampolineEntry
417 | TrampolineEntry
418 | TrampolineEntry
419 | TrampolineEntry
420 | TrampolineEntry
421 | TrampolineEntry
422 | TrampolineEntry
423 | TrampolineEntry
424 | TrampolineEntry
425 | TrampolineEntry
426 | TrampolineEntry
427 | TrampolineEntry
428 | TrampolineEntry
429 | TrampolineEntry
430 | TrampolineEntry
431 | TrampolineEntry
432 | TrampolineEntry
433 | TrampolineEntry
434 | TrampolineEntry
435 | TrampolineEntry
436 | TrampolineEntry
437 | TrampolineEntry
438 | TrampolineEntry
439 | TrampolineEntry
440 | TrampolineEntry
441 | TrampolineEntry
442 | TrampolineEntry
443 | TrampolineEntry
444 | TrampolineEntry
445 | TrampolineEntry
446 | TrampolineEntry
447 | TrampolineEntry
448 | TrampolineEntry
449 | TrampolineEntry
450 | TrampolineEntry
451 | TrampolineEntry
452 | TrampolineEntry
453 | TrampolineEntry
454 | TrampolineEntry
455 | TrampolineEntry
456 | TrampolineEntry
457 | TrampolineEntry
458 | TrampolineEntry
459 | TrampolineEntry
460 | TrampolineEntry
461 | TrampolineEntry
462 | TrampolineEntry
463 | TrampolineEntry
464 | TrampolineEntry
465 | TrampolineEntry
466 | TrampolineEntry
467 | TrampolineEntry
468 | TrampolineEntry
469 | TrampolineEntry
470 | TrampolineEntry
471 | TrampolineEntry
472 | TrampolineEntry
473 | TrampolineEntry
474 | TrampolineEntry
475 | TrampolineEntry
476 | TrampolineEntry
477 | TrampolineEntry
478 | TrampolineEntry
479 | TrampolineEntry
480 | TrampolineEntry
481 | TrampolineEntry
482 | TrampolineEntry
483 | TrampolineEntry
484 | TrampolineEntry
485 | TrampolineEntry
486 | TrampolineEntry
487 | TrampolineEntry
488 | TrampolineEntry
489 | TrampolineEntry
490 | TrampolineEntry
491 | TrampolineEntry
492 | TrampolineEntry
493 | TrampolineEntry
494 | TrampolineEntry
495 | TrampolineEntry
496 | TrampolineEntry
497 | TrampolineEntry
498 | TrampolineEntry
499 | TrampolineEntry
500 | TrampolineEntry
501 | TrampolineEntry
502 | TrampolineEntry
503 | TrampolineEntry
504 | TrampolineEntry
505 | TrampolineEntry
506 | TrampolineEntry
507 | TrampolineEntry
508 | TrampolineEntry
509 | TrampolineEntry
510 | TrampolineEntry
511 | TrampolineEntry
512 | TrampolineEntry
513 | TrampolineEntry
514 | TrampolineEntry
515 | TrampolineEntry
516 | TrampolineEntry
517 | TrampolineEntry
518 | TrampolineEntry
519 | TrampolineEntry
520 | TrampolineEntry
521 | TrampolineEntry
522 | TrampolineEntry
523 | TrampolineEntry
524 | TrampolineEntry
525 | TrampolineEntry
526 | TrampolineEntry
527 | TrampolineEntry
528 | TrampolineEntry
529 | TrampolineEntry
530 | TrampolineEntry
531 | TrampolineEntry
532 | TrampolineEntry
533 | TrampolineEntry
534 | TrampolineEntry
535 | TrampolineEntry
536 | TrampolineEntry
537 | TrampolineEntry
538 | TrampolineEntry
539 | TrampolineEntry
540 | TrampolineEntry
541 | TrampolineEntry
542 | TrampolineEntry
543 | TrampolineEntry
544 | TrampolineEntry
545 | TrampolineEntry
546 | TrampolineEntry
547 | TrampolineEntry
548 | TrampolineEntry
549 | TrampolineEntry
550 | TrampolineEntry
551 | TrampolineEntry
552 | TrampolineEntry
553 | TrampolineEntry
554 | TrampolineEntry
555 | TrampolineEntry
556 | TrampolineEntry
557 | TrampolineEntry
558 | TrampolineEntry
559 | TrampolineEntry
560 | TrampolineEntry
561 | // TrampolineEntry
562 | // TrampolineEntry
563 | // TrampolineEntry
564 | // TrampolineEntry
565 |
566 | __a1a2_selectorTrampEnd:
567 |
568 | #endif
569 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a2a3-selectortramps-x86_64.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a2a3-selectortramps-x86_64.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #ifdef __x86_64__
23 |
24 | #include
25 | #include "selectortramps.mac"
26 |
27 | .text
28 | .private_extern __a2a3_selectorTrampHead
29 | .private_extern __a2a3_firstSelectorTramp
30 | .private_extern __a2a3_nextSelectorTramp
31 | .private_extern __a2a3_selectorTrampEnd
32 |
33 | .align PAGE_SHIFT
34 | __a2a3_selectorTrampHead:
35 | // 1. selector
36 | popq %r10
37 | andq $0xFFFFFFFFFFFFFFF8, %r10
38 | subq $ PAGE_SIZE, %r10
39 | movq (%r10), %rdx // selector -> _cmd
40 | // 2. msgSend
41 | INIT_PIC(__a2a3_selectorTrampHead)
42 | PRELOAD(__a2a3_selectorTrampHead, __a2a3_selectorTrampHead)
43 | subq $ PAGE_SIZE, LABEL_ADDR(__a2a3_selectorTrampHead, __a2a3_selectorTrampHead)
44 | END_PIC()
45 | jmp *0(%r10) // tail call msgSend
46 |
47 | .macro TrampolineEntry
48 | callq __a2a3_selectorTrampHead
49 | nop
50 | nop
51 | nop
52 | .endmacro
53 |
54 | .align 5
55 | __a2a3_firstSelectorTramp:
56 | TrampolineEntry
57 | __a2a3_nextSelectorTramp:
58 | TrampolineEntry
59 | TrampolineEntry
60 | TrampolineEntry
61 | TrampolineEntry
62 | TrampolineEntry
63 | TrampolineEntry
64 | TrampolineEntry
65 | TrampolineEntry
66 | TrampolineEntry
67 | TrampolineEntry
68 | TrampolineEntry
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 | TrampolineEntry
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 | TrampolineEntry
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 | TrampolineEntry
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | TrampolineEntry
89 | TrampolineEntry
90 | TrampolineEntry
91 | TrampolineEntry
92 | TrampolineEntry
93 | TrampolineEntry
94 | TrampolineEntry
95 | TrampolineEntry
96 | TrampolineEntry
97 | TrampolineEntry
98 | TrampolineEntry
99 | TrampolineEntry
100 | TrampolineEntry
101 | TrampolineEntry
102 | TrampolineEntry
103 | TrampolineEntry
104 | TrampolineEntry
105 | TrampolineEntry
106 | TrampolineEntry
107 | TrampolineEntry
108 | TrampolineEntry
109 | TrampolineEntry
110 | TrampolineEntry
111 | TrampolineEntry
112 | TrampolineEntry
113 | TrampolineEntry
114 | TrampolineEntry
115 | TrampolineEntry
116 | TrampolineEntry
117 | TrampolineEntry
118 | TrampolineEntry
119 | TrampolineEntry
120 | TrampolineEntry
121 | TrampolineEntry
122 | TrampolineEntry
123 | TrampolineEntry
124 | TrampolineEntry
125 | TrampolineEntry
126 | TrampolineEntry
127 | TrampolineEntry
128 | TrampolineEntry
129 | TrampolineEntry
130 | TrampolineEntry
131 | TrampolineEntry
132 | TrampolineEntry
133 | TrampolineEntry
134 | TrampolineEntry
135 | TrampolineEntry
136 | TrampolineEntry
137 | TrampolineEntry
138 | TrampolineEntry
139 | TrampolineEntry
140 | TrampolineEntry
141 | TrampolineEntry
142 | TrampolineEntry
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 | TrampolineEntry
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 | TrampolineEntry
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 | TrampolineEntry
158 | TrampolineEntry
159 | TrampolineEntry
160 | TrampolineEntry
161 | TrampolineEntry
162 | TrampolineEntry
163 | TrampolineEntry
164 | TrampolineEntry
165 | TrampolineEntry
166 | TrampolineEntry
167 | TrampolineEntry
168 | TrampolineEntry
169 | TrampolineEntry
170 | TrampolineEntry
171 | TrampolineEntry
172 | TrampolineEntry
173 | TrampolineEntry
174 | TrampolineEntry
175 | TrampolineEntry
176 | TrampolineEntry
177 | TrampolineEntry
178 | TrampolineEntry
179 | TrampolineEntry
180 | TrampolineEntry
181 | TrampolineEntry
182 | TrampolineEntry
183 | TrampolineEntry
184 | TrampolineEntry
185 | TrampolineEntry
186 | TrampolineEntry
187 | TrampolineEntry
188 | TrampolineEntry
189 | TrampolineEntry
190 | TrampolineEntry
191 | TrampolineEntry
192 | TrampolineEntry
193 | TrampolineEntry
194 | TrampolineEntry
195 | TrampolineEntry
196 | TrampolineEntry
197 | TrampolineEntry
198 | TrampolineEntry
199 | TrampolineEntry
200 | TrampolineEntry
201 | TrampolineEntry
202 | TrampolineEntry
203 | TrampolineEntry
204 | TrampolineEntry
205 | TrampolineEntry
206 | TrampolineEntry
207 | TrampolineEntry
208 | TrampolineEntry
209 | TrampolineEntry
210 | TrampolineEntry
211 | TrampolineEntry
212 | TrampolineEntry
213 | TrampolineEntry
214 | TrampolineEntry
215 | TrampolineEntry
216 | TrampolineEntry
217 | TrampolineEntry
218 | TrampolineEntry
219 | TrampolineEntry
220 | TrampolineEntry
221 | TrampolineEntry
222 | TrampolineEntry
223 | TrampolineEntry
224 | TrampolineEntry
225 | TrampolineEntry
226 | TrampolineEntry
227 | TrampolineEntry
228 | TrampolineEntry
229 | TrampolineEntry
230 | TrampolineEntry
231 | TrampolineEntry
232 | TrampolineEntry
233 | TrampolineEntry
234 | TrampolineEntry
235 | TrampolineEntry
236 | TrampolineEntry
237 | TrampolineEntry
238 | TrampolineEntry
239 | TrampolineEntry
240 | TrampolineEntry
241 | TrampolineEntry
242 | TrampolineEntry
243 | TrampolineEntry
244 | TrampolineEntry
245 | TrampolineEntry
246 | TrampolineEntry
247 | TrampolineEntry
248 | TrampolineEntry
249 | TrampolineEntry
250 | TrampolineEntry
251 | TrampolineEntry
252 | TrampolineEntry
253 | TrampolineEntry
254 | TrampolineEntry
255 | TrampolineEntry
256 | TrampolineEntry
257 | TrampolineEntry
258 | TrampolineEntry
259 | TrampolineEntry
260 | TrampolineEntry
261 | TrampolineEntry
262 | TrampolineEntry
263 | TrampolineEntry
264 | TrampolineEntry
265 | TrampolineEntry
266 | TrampolineEntry
267 | TrampolineEntry
268 | TrampolineEntry
269 | TrampolineEntry
270 | TrampolineEntry
271 | TrampolineEntry
272 | TrampolineEntry
273 | TrampolineEntry
274 | TrampolineEntry
275 | TrampolineEntry
276 | TrampolineEntry
277 | TrampolineEntry
278 | TrampolineEntry
279 | TrampolineEntry
280 | TrampolineEntry
281 | TrampolineEntry
282 | TrampolineEntry
283 | TrampolineEntry
284 | TrampolineEntry
285 | TrampolineEntry
286 | TrampolineEntry
287 | TrampolineEntry
288 | TrampolineEntry
289 | TrampolineEntry
290 | TrampolineEntry
291 | TrampolineEntry
292 | TrampolineEntry
293 | TrampolineEntry
294 | TrampolineEntry
295 | TrampolineEntry
296 | TrampolineEntry
297 | TrampolineEntry
298 | TrampolineEntry
299 | TrampolineEntry
300 | TrampolineEntry
301 | TrampolineEntry
302 | TrampolineEntry
303 | TrampolineEntry
304 | TrampolineEntry
305 | TrampolineEntry
306 | TrampolineEntry
307 | TrampolineEntry
308 | TrampolineEntry
309 | TrampolineEntry
310 | TrampolineEntry
311 | TrampolineEntry
312 | TrampolineEntry
313 | TrampolineEntry
314 | TrampolineEntry
315 | TrampolineEntry
316 | TrampolineEntry
317 | TrampolineEntry
318 | TrampolineEntry
319 | TrampolineEntry
320 | TrampolineEntry
321 | TrampolineEntry
322 | TrampolineEntry
323 | TrampolineEntry
324 | TrampolineEntry
325 | TrampolineEntry
326 | TrampolineEntry
327 | TrampolineEntry
328 | TrampolineEntry
329 | TrampolineEntry
330 | TrampolineEntry
331 | TrampolineEntry
332 | TrampolineEntry
333 | TrampolineEntry
334 | TrampolineEntry
335 | TrampolineEntry
336 | TrampolineEntry
337 | TrampolineEntry
338 | TrampolineEntry
339 | TrampolineEntry
340 | TrampolineEntry
341 | TrampolineEntry
342 | TrampolineEntry
343 | TrampolineEntry
344 | TrampolineEntry
345 | TrampolineEntry
346 | TrampolineEntry
347 | TrampolineEntry
348 | TrampolineEntry
349 | TrampolineEntry
350 | TrampolineEntry
351 | TrampolineEntry
352 | TrampolineEntry
353 | TrampolineEntry
354 | TrampolineEntry
355 | TrampolineEntry
356 | TrampolineEntry
357 | TrampolineEntry
358 | TrampolineEntry
359 | TrampolineEntry
360 | TrampolineEntry
361 | TrampolineEntry
362 | TrampolineEntry
363 | TrampolineEntry
364 | TrampolineEntry
365 | TrampolineEntry
366 | TrampolineEntry
367 | TrampolineEntry
368 | TrampolineEntry
369 | TrampolineEntry
370 | TrampolineEntry
371 | TrampolineEntry
372 | TrampolineEntry
373 | TrampolineEntry
374 | TrampolineEntry
375 | TrampolineEntry
376 | TrampolineEntry
377 | TrampolineEntry
378 | TrampolineEntry
379 | TrampolineEntry
380 | TrampolineEntry
381 | TrampolineEntry
382 | TrampolineEntry
383 | TrampolineEntry
384 | TrampolineEntry
385 | TrampolineEntry
386 | TrampolineEntry
387 | TrampolineEntry
388 | TrampolineEntry
389 | TrampolineEntry
390 | TrampolineEntry
391 | TrampolineEntry
392 | TrampolineEntry
393 | TrampolineEntry
394 | TrampolineEntry
395 | TrampolineEntry
396 | TrampolineEntry
397 | TrampolineEntry
398 | TrampolineEntry
399 | TrampolineEntry
400 | TrampolineEntry
401 | TrampolineEntry
402 | TrampolineEntry
403 | TrampolineEntry
404 | TrampolineEntry
405 | TrampolineEntry
406 | TrampolineEntry
407 | TrampolineEntry
408 | TrampolineEntry
409 | TrampolineEntry
410 | TrampolineEntry
411 | TrampolineEntry
412 | TrampolineEntry
413 | TrampolineEntry
414 | TrampolineEntry
415 | TrampolineEntry
416 | TrampolineEntry
417 | TrampolineEntry
418 | TrampolineEntry
419 | TrampolineEntry
420 | TrampolineEntry
421 | TrampolineEntry
422 | TrampolineEntry
423 | TrampolineEntry
424 | TrampolineEntry
425 | TrampolineEntry
426 | TrampolineEntry
427 | TrampolineEntry
428 | TrampolineEntry
429 | TrampolineEntry
430 | TrampolineEntry
431 | TrampolineEntry
432 | TrampolineEntry
433 | TrampolineEntry
434 | TrampolineEntry
435 | TrampolineEntry
436 | TrampolineEntry
437 | TrampolineEntry
438 | TrampolineEntry
439 | TrampolineEntry
440 | TrampolineEntry
441 | TrampolineEntry
442 | TrampolineEntry
443 | TrampolineEntry
444 | TrampolineEntry
445 | TrampolineEntry
446 | TrampolineEntry
447 | TrampolineEntry
448 | TrampolineEntry
449 | TrampolineEntry
450 | TrampolineEntry
451 | TrampolineEntry
452 | TrampolineEntry
453 | TrampolineEntry
454 | TrampolineEntry
455 | TrampolineEntry
456 | TrampolineEntry
457 | TrampolineEntry
458 | TrampolineEntry
459 | TrampolineEntry
460 | TrampolineEntry
461 | TrampolineEntry
462 | TrampolineEntry
463 | TrampolineEntry
464 | TrampolineEntry
465 | TrampolineEntry
466 | TrampolineEntry
467 | TrampolineEntry
468 | TrampolineEntry
469 | TrampolineEntry
470 | TrampolineEntry
471 | TrampolineEntry
472 | TrampolineEntry
473 | TrampolineEntry
474 | TrampolineEntry
475 | TrampolineEntry
476 | TrampolineEntry
477 | TrampolineEntry
478 | TrampolineEntry
479 | TrampolineEntry
480 | TrampolineEntry
481 | TrampolineEntry
482 | TrampolineEntry
483 | TrampolineEntry
484 | TrampolineEntry
485 | TrampolineEntry
486 | TrampolineEntry
487 | TrampolineEntry
488 | TrampolineEntry
489 | TrampolineEntry
490 | TrampolineEntry
491 | TrampolineEntry
492 | TrampolineEntry
493 | TrampolineEntry
494 | TrampolineEntry
495 | TrampolineEntry
496 | TrampolineEntry
497 | TrampolineEntry
498 | TrampolineEntry
499 | TrampolineEntry
500 | TrampolineEntry
501 | TrampolineEntry
502 | TrampolineEntry
503 | TrampolineEntry
504 | TrampolineEntry
505 | TrampolineEntry
506 | TrampolineEntry
507 | TrampolineEntry
508 | TrampolineEntry
509 | TrampolineEntry
510 | TrampolineEntry
511 | TrampolineEntry
512 | TrampolineEntry
513 | TrampolineEntry
514 | TrampolineEntry
515 | TrampolineEntry
516 | TrampolineEntry
517 | TrampolineEntry
518 | TrampolineEntry
519 | TrampolineEntry
520 | TrampolineEntry
521 | TrampolineEntry
522 | TrampolineEntry
523 | TrampolineEntry
524 | TrampolineEntry
525 | TrampolineEntry
526 | TrampolineEntry
527 | TrampolineEntry
528 | TrampolineEntry
529 | TrampolineEntry
530 | TrampolineEntry
531 | TrampolineEntry
532 | TrampolineEntry
533 | TrampolineEntry
534 | TrampolineEntry
535 | TrampolineEntry
536 | TrampolineEntry
537 | TrampolineEntry
538 | TrampolineEntry
539 | TrampolineEntry
540 | TrampolineEntry
541 | TrampolineEntry
542 | TrampolineEntry
543 | TrampolineEntry
544 | TrampolineEntry
545 | TrampolineEntry
546 | TrampolineEntry
547 | TrampolineEntry
548 | TrampolineEntry
549 | TrampolineEntry
550 | TrampolineEntry
551 | TrampolineEntry
552 | TrampolineEntry
553 | TrampolineEntry
554 | TrampolineEntry
555 | TrampolineEntry
556 | TrampolineEntry
557 | TrampolineEntry
558 | TrampolineEntry
559 | TrampolineEntry
560 | TrampolineEntry
561 | // TrampolineEntry
562 | // TrampolineEntry
563 | // TrampolineEntry
564 | // TrampolineEntry
565 |
566 | __a2a3_selectorTrampEnd:
567 |
568 | #endif
569 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a2a3-selectortramps-i386.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a2a3-selectortramps-i386.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #ifdef __i386__
23 |
24 | #include
25 | #include "selectortramps.mac"
26 |
27 | .text
28 | .private_extern __a2a3_selectorTrampHead
29 | .private_extern __a2a3_firstSelectorTramp
30 | .private_extern __a2a3_nextSelectorTramp
31 | .private_extern __a2a3_selectorTrampEnd
32 |
33 | .align PAGE_SHIFT
34 | __a2a3_selectorTrampHead:
35 | // 1. selector
36 | popl %eax
37 | andl $0xFFFFFFF8, %eax
38 | subl $ PAGE_SIZE, %eax
39 | movl (%eax), %ecx // selectorPtr -> ecx
40 | movl %ecx, 12(%esp) // ecx -> _cmd
41 | // 2. msgSend
42 | INIT_PIC(__a2a3_selectorTrampHead)
43 | PRELOAD(__a2a3_selectorTrampHead, __a2a3_selectorTrampHead)
44 | subl $ PAGE_SIZE, LABEL_ADDR(__a2a3_selectorTrampHead, __a2a3_selectorTrampHead)
45 | END_PIC()
46 | jmp *0(%eax) // tail call msgSend
47 |
48 | .macro TrampolineEntry
49 | call __a2a3_selectorTrampHead
50 | nop
51 | nop
52 | nop
53 | .endmacro
54 |
55 | .align 5
56 | __a2a3_firstSelectorTramp:
57 | TrampolineEntry
58 | __a2a3_nextSelectorTramp:
59 | TrampolineEntry
60 | TrampolineEntry
61 | TrampolineEntry
62 | TrampolineEntry
63 | TrampolineEntry
64 | TrampolineEntry
65 | TrampolineEntry
66 | TrampolineEntry
67 | TrampolineEntry
68 | TrampolineEntry
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 | TrampolineEntry
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 | TrampolineEntry
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 | TrampolineEntry
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | TrampolineEntry
89 | TrampolineEntry
90 | TrampolineEntry
91 | TrampolineEntry
92 | TrampolineEntry
93 | TrampolineEntry
94 | TrampolineEntry
95 | TrampolineEntry
96 | TrampolineEntry
97 | TrampolineEntry
98 | TrampolineEntry
99 | TrampolineEntry
100 | TrampolineEntry
101 | TrampolineEntry
102 | TrampolineEntry
103 | TrampolineEntry
104 | TrampolineEntry
105 | TrampolineEntry
106 | TrampolineEntry
107 | TrampolineEntry
108 | TrampolineEntry
109 | TrampolineEntry
110 | TrampolineEntry
111 | TrampolineEntry
112 | TrampolineEntry
113 | TrampolineEntry
114 | TrampolineEntry
115 | TrampolineEntry
116 | TrampolineEntry
117 | TrampolineEntry
118 | TrampolineEntry
119 | TrampolineEntry
120 | TrampolineEntry
121 | TrampolineEntry
122 | TrampolineEntry
123 | TrampolineEntry
124 | TrampolineEntry
125 | TrampolineEntry
126 | TrampolineEntry
127 | TrampolineEntry
128 | TrampolineEntry
129 | TrampolineEntry
130 | TrampolineEntry
131 | TrampolineEntry
132 | TrampolineEntry
133 | TrampolineEntry
134 | TrampolineEntry
135 | TrampolineEntry
136 | TrampolineEntry
137 | TrampolineEntry
138 | TrampolineEntry
139 | TrampolineEntry
140 | TrampolineEntry
141 | TrampolineEntry
142 | TrampolineEntry
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 | TrampolineEntry
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 | TrampolineEntry
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 | TrampolineEntry
158 | TrampolineEntry
159 | TrampolineEntry
160 | TrampolineEntry
161 | TrampolineEntry
162 | TrampolineEntry
163 | TrampolineEntry
164 | TrampolineEntry
165 | TrampolineEntry
166 | TrampolineEntry
167 | TrampolineEntry
168 | TrampolineEntry
169 | TrampolineEntry
170 | TrampolineEntry
171 | TrampolineEntry
172 | TrampolineEntry
173 | TrampolineEntry
174 | TrampolineEntry
175 | TrampolineEntry
176 | TrampolineEntry
177 | TrampolineEntry
178 | TrampolineEntry
179 | TrampolineEntry
180 | TrampolineEntry
181 | TrampolineEntry
182 | TrampolineEntry
183 | TrampolineEntry
184 | TrampolineEntry
185 | TrampolineEntry
186 | TrampolineEntry
187 | TrampolineEntry
188 | TrampolineEntry
189 | TrampolineEntry
190 | TrampolineEntry
191 | TrampolineEntry
192 | TrampolineEntry
193 | TrampolineEntry
194 | TrampolineEntry
195 | TrampolineEntry
196 | TrampolineEntry
197 | TrampolineEntry
198 | TrampolineEntry
199 | TrampolineEntry
200 | TrampolineEntry
201 | TrampolineEntry
202 | TrampolineEntry
203 | TrampolineEntry
204 | TrampolineEntry
205 | TrampolineEntry
206 | TrampolineEntry
207 | TrampolineEntry
208 | TrampolineEntry
209 | TrampolineEntry
210 | TrampolineEntry
211 | TrampolineEntry
212 | TrampolineEntry
213 | TrampolineEntry
214 | TrampolineEntry
215 | TrampolineEntry
216 | TrampolineEntry
217 | TrampolineEntry
218 | TrampolineEntry
219 | TrampolineEntry
220 | TrampolineEntry
221 | TrampolineEntry
222 | TrampolineEntry
223 | TrampolineEntry
224 | TrampolineEntry
225 | TrampolineEntry
226 | TrampolineEntry
227 | TrampolineEntry
228 | TrampolineEntry
229 | TrampolineEntry
230 | TrampolineEntry
231 | TrampolineEntry
232 | TrampolineEntry
233 | TrampolineEntry
234 | TrampolineEntry
235 | TrampolineEntry
236 | TrampolineEntry
237 | TrampolineEntry
238 | TrampolineEntry
239 | TrampolineEntry
240 | TrampolineEntry
241 | TrampolineEntry
242 | TrampolineEntry
243 | TrampolineEntry
244 | TrampolineEntry
245 | TrampolineEntry
246 | TrampolineEntry
247 | TrampolineEntry
248 | TrampolineEntry
249 | TrampolineEntry
250 | TrampolineEntry
251 | TrampolineEntry
252 | TrampolineEntry
253 | TrampolineEntry
254 | TrampolineEntry
255 | TrampolineEntry
256 | TrampolineEntry
257 | TrampolineEntry
258 | TrampolineEntry
259 | TrampolineEntry
260 | TrampolineEntry
261 | TrampolineEntry
262 | TrampolineEntry
263 | TrampolineEntry
264 | TrampolineEntry
265 | TrampolineEntry
266 | TrampolineEntry
267 | TrampolineEntry
268 | TrampolineEntry
269 | TrampolineEntry
270 | TrampolineEntry
271 | TrampolineEntry
272 | TrampolineEntry
273 | TrampolineEntry
274 | TrampolineEntry
275 | TrampolineEntry
276 | TrampolineEntry
277 | TrampolineEntry
278 | TrampolineEntry
279 | TrampolineEntry
280 | TrampolineEntry
281 | TrampolineEntry
282 | TrampolineEntry
283 | TrampolineEntry
284 | TrampolineEntry
285 | TrampolineEntry
286 | TrampolineEntry
287 | TrampolineEntry
288 | TrampolineEntry
289 | TrampolineEntry
290 | TrampolineEntry
291 | TrampolineEntry
292 | TrampolineEntry
293 | TrampolineEntry
294 | TrampolineEntry
295 | TrampolineEntry
296 | TrampolineEntry
297 | TrampolineEntry
298 | TrampolineEntry
299 | TrampolineEntry
300 | TrampolineEntry
301 | TrampolineEntry
302 | TrampolineEntry
303 | TrampolineEntry
304 | TrampolineEntry
305 | TrampolineEntry
306 | TrampolineEntry
307 | TrampolineEntry
308 | TrampolineEntry
309 | TrampolineEntry
310 | TrampolineEntry
311 | TrampolineEntry
312 | TrampolineEntry
313 | TrampolineEntry
314 | TrampolineEntry
315 | TrampolineEntry
316 | TrampolineEntry
317 | TrampolineEntry
318 | TrampolineEntry
319 | TrampolineEntry
320 | TrampolineEntry
321 | TrampolineEntry
322 | TrampolineEntry
323 | TrampolineEntry
324 | TrampolineEntry
325 | TrampolineEntry
326 | TrampolineEntry
327 | TrampolineEntry
328 | TrampolineEntry
329 | TrampolineEntry
330 | TrampolineEntry
331 | TrampolineEntry
332 | TrampolineEntry
333 | TrampolineEntry
334 | TrampolineEntry
335 | TrampolineEntry
336 | TrampolineEntry
337 | TrampolineEntry
338 | TrampolineEntry
339 | TrampolineEntry
340 | TrampolineEntry
341 | TrampolineEntry
342 | TrampolineEntry
343 | TrampolineEntry
344 | TrampolineEntry
345 | TrampolineEntry
346 | TrampolineEntry
347 | TrampolineEntry
348 | TrampolineEntry
349 | TrampolineEntry
350 | TrampolineEntry
351 | TrampolineEntry
352 | TrampolineEntry
353 | TrampolineEntry
354 | TrampolineEntry
355 | TrampolineEntry
356 | TrampolineEntry
357 | TrampolineEntry
358 | TrampolineEntry
359 | TrampolineEntry
360 | TrampolineEntry
361 | TrampolineEntry
362 | TrampolineEntry
363 | TrampolineEntry
364 | TrampolineEntry
365 | TrampolineEntry
366 | TrampolineEntry
367 | TrampolineEntry
368 | TrampolineEntry
369 | TrampolineEntry
370 | TrampolineEntry
371 | TrampolineEntry
372 | TrampolineEntry
373 | TrampolineEntry
374 | TrampolineEntry
375 | TrampolineEntry
376 | TrampolineEntry
377 | TrampolineEntry
378 | TrampolineEntry
379 | TrampolineEntry
380 | TrampolineEntry
381 | TrampolineEntry
382 | TrampolineEntry
383 | TrampolineEntry
384 | TrampolineEntry
385 | TrampolineEntry
386 | TrampolineEntry
387 | TrampolineEntry
388 | TrampolineEntry
389 | TrampolineEntry
390 | TrampolineEntry
391 | TrampolineEntry
392 | TrampolineEntry
393 | TrampolineEntry
394 | TrampolineEntry
395 | TrampolineEntry
396 | TrampolineEntry
397 | TrampolineEntry
398 | TrampolineEntry
399 | TrampolineEntry
400 | TrampolineEntry
401 | TrampolineEntry
402 | TrampolineEntry
403 | TrampolineEntry
404 | TrampolineEntry
405 | TrampolineEntry
406 | TrampolineEntry
407 | TrampolineEntry
408 | TrampolineEntry
409 | TrampolineEntry
410 | TrampolineEntry
411 | TrampolineEntry
412 | TrampolineEntry
413 | TrampolineEntry
414 | TrampolineEntry
415 | TrampolineEntry
416 | TrampolineEntry
417 | TrampolineEntry
418 | TrampolineEntry
419 | TrampolineEntry
420 | TrampolineEntry
421 | TrampolineEntry
422 | TrampolineEntry
423 | TrampolineEntry
424 | TrampolineEntry
425 | TrampolineEntry
426 | TrampolineEntry
427 | TrampolineEntry
428 | TrampolineEntry
429 | TrampolineEntry
430 | TrampolineEntry
431 | TrampolineEntry
432 | TrampolineEntry
433 | TrampolineEntry
434 | TrampolineEntry
435 | TrampolineEntry
436 | TrampolineEntry
437 | TrampolineEntry
438 | TrampolineEntry
439 | TrampolineEntry
440 | TrampolineEntry
441 | TrampolineEntry
442 | TrampolineEntry
443 | TrampolineEntry
444 | TrampolineEntry
445 | TrampolineEntry
446 | TrampolineEntry
447 | TrampolineEntry
448 | TrampolineEntry
449 | TrampolineEntry
450 | TrampolineEntry
451 | TrampolineEntry
452 | TrampolineEntry
453 | TrampolineEntry
454 | TrampolineEntry
455 | TrampolineEntry
456 | TrampolineEntry
457 | TrampolineEntry
458 | TrampolineEntry
459 | TrampolineEntry
460 | TrampolineEntry
461 | TrampolineEntry
462 | TrampolineEntry
463 | TrampolineEntry
464 | TrampolineEntry
465 | TrampolineEntry
466 | TrampolineEntry
467 | TrampolineEntry
468 | TrampolineEntry
469 | TrampolineEntry
470 | TrampolineEntry
471 | TrampolineEntry
472 | TrampolineEntry
473 | TrampolineEntry
474 | TrampolineEntry
475 | TrampolineEntry
476 | TrampolineEntry
477 | TrampolineEntry
478 | TrampolineEntry
479 | TrampolineEntry
480 | TrampolineEntry
481 | TrampolineEntry
482 | TrampolineEntry
483 | TrampolineEntry
484 | TrampolineEntry
485 | TrampolineEntry
486 | TrampolineEntry
487 | TrampolineEntry
488 | TrampolineEntry
489 | TrampolineEntry
490 | TrampolineEntry
491 | TrampolineEntry
492 | TrampolineEntry
493 | TrampolineEntry
494 | TrampolineEntry
495 | TrampolineEntry
496 | TrampolineEntry
497 | TrampolineEntry
498 | TrampolineEntry
499 | TrampolineEntry
500 | TrampolineEntry
501 | TrampolineEntry
502 | TrampolineEntry
503 | TrampolineEntry
504 | TrampolineEntry
505 | TrampolineEntry
506 | TrampolineEntry
507 | TrampolineEntry
508 | TrampolineEntry
509 | TrampolineEntry
510 | TrampolineEntry
511 | TrampolineEntry
512 | TrampolineEntry
513 | TrampolineEntry
514 | TrampolineEntry
515 | TrampolineEntry
516 | TrampolineEntry
517 | TrampolineEntry
518 | TrampolineEntry
519 | TrampolineEntry
520 | TrampolineEntry
521 | TrampolineEntry
522 | TrampolineEntry
523 | TrampolineEntry
524 | TrampolineEntry
525 | TrampolineEntry
526 | TrampolineEntry
527 | TrampolineEntry
528 | TrampolineEntry
529 | TrampolineEntry
530 | TrampolineEntry
531 | TrampolineEntry
532 | TrampolineEntry
533 | TrampolineEntry
534 | TrampolineEntry
535 | TrampolineEntry
536 | TrampolineEntry
537 | TrampolineEntry
538 | TrampolineEntry
539 | TrampolineEntry
540 | TrampolineEntry
541 | TrampolineEntry
542 | TrampolineEntry
543 | TrampolineEntry
544 | TrampolineEntry
545 | TrampolineEntry
546 | TrampolineEntry
547 | TrampolineEntry
548 | TrampolineEntry
549 | TrampolineEntry
550 | TrampolineEntry
551 | TrampolineEntry
552 | TrampolineEntry
553 | TrampolineEntry
554 | TrampolineEntry
555 | TrampolineEntry
556 | TrampolineEntry
557 | TrampolineEntry
558 | TrampolineEntry
559 | TrampolineEntry
560 | TrampolineEntry
561 | TrampolineEntry
562 | // TrampolineEntry
563 | // TrampolineEntry
564 | // TrampolineEntry
565 | // TrampolineEntry
566 |
567 | __a2a3_selectorTrampEnd:
568 |
569 | #endif
570 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/a1a2-selectortramps-i386.s:
--------------------------------------------------------------------------------
1 | /*
2 | * a1a2-selectortramps-i386.s
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #ifdef __i386__
23 |
24 | #include
25 | #include "selectortramps.mac"
26 |
27 | .text
28 | .private_extern __a1a2_selectorTrampHead
29 | .private_extern __a1a2_firstSelectorTramp
30 | .private_extern __a1a2_nextSelectorTramp
31 | .private_extern __a1a2_selectorTrampEnd
32 |
33 | .align PAGE_SHIFT
34 | __a1a2_selectorTrampHead:
35 | // 1. selector
36 | popl %eax
37 | andl $0xFFFFFFF8, %eax
38 | subl $ PAGE_SIZE, %eax
39 | movl (%eax), %ecx // selectorPtr -> ecx
40 | movl %ecx, 8(%esp) // ecx -> _cmd
41 | // 2. msgSend
42 | INIT_PIC(__a1a2_selectorTrampHead)
43 | PRELOAD(__a1a2_selectorTrampHead, __a1a2_selectorTrampHead)
44 | subl $ PAGE_SIZE, LABEL_ADDR(__a1a2_selectorTrampHead, __a1a2_selectorTrampHead)
45 | END_PIC()
46 | jmp *0(%eax) // tail call msgSend
47 |
48 | .macro TrampolineEntry
49 | call __a1a2_selectorTrampHead
50 | nop
51 | nop
52 | nop
53 | .endmacro
54 |
55 | .align 5
56 | __a1a2_firstSelectorTramp:
57 | TrampolineEntry
58 | __a1a2_nextSelectorTramp: // used to calculate size of each trampoline
59 | TrampolineEntry
60 | TrampolineEntry
61 | TrampolineEntry
62 | TrampolineEntry
63 | TrampolineEntry
64 | TrampolineEntry
65 | TrampolineEntry
66 | TrampolineEntry
67 | TrampolineEntry
68 | TrampolineEntry
69 | TrampolineEntry
70 | TrampolineEntry
71 | TrampolineEntry
72 | TrampolineEntry
73 | TrampolineEntry
74 | TrampolineEntry
75 | TrampolineEntry
76 | TrampolineEntry
77 | TrampolineEntry
78 | TrampolineEntry
79 | TrampolineEntry
80 | TrampolineEntry
81 | TrampolineEntry
82 | TrampolineEntry
83 | TrampolineEntry
84 | TrampolineEntry
85 | TrampolineEntry
86 | TrampolineEntry
87 | TrampolineEntry
88 | TrampolineEntry
89 | TrampolineEntry
90 | TrampolineEntry
91 | TrampolineEntry
92 | TrampolineEntry
93 | TrampolineEntry
94 | TrampolineEntry
95 | TrampolineEntry
96 | TrampolineEntry
97 | TrampolineEntry
98 | TrampolineEntry
99 | TrampolineEntry
100 | TrampolineEntry
101 | TrampolineEntry
102 | TrampolineEntry
103 | TrampolineEntry
104 | TrampolineEntry
105 | TrampolineEntry
106 | TrampolineEntry
107 | TrampolineEntry
108 | TrampolineEntry
109 | TrampolineEntry
110 | TrampolineEntry
111 | TrampolineEntry
112 | TrampolineEntry
113 | TrampolineEntry
114 | TrampolineEntry
115 | TrampolineEntry
116 | TrampolineEntry
117 | TrampolineEntry
118 | TrampolineEntry
119 | TrampolineEntry
120 | TrampolineEntry
121 | TrampolineEntry
122 | TrampolineEntry
123 | TrampolineEntry
124 | TrampolineEntry
125 | TrampolineEntry
126 | TrampolineEntry
127 | TrampolineEntry
128 | TrampolineEntry
129 | TrampolineEntry
130 | TrampolineEntry
131 | TrampolineEntry
132 | TrampolineEntry
133 | TrampolineEntry
134 | TrampolineEntry
135 | TrampolineEntry
136 | TrampolineEntry
137 | TrampolineEntry
138 | TrampolineEntry
139 | TrampolineEntry
140 | TrampolineEntry
141 | TrampolineEntry
142 | TrampolineEntry
143 | TrampolineEntry
144 | TrampolineEntry
145 | TrampolineEntry
146 | TrampolineEntry
147 | TrampolineEntry
148 | TrampolineEntry
149 | TrampolineEntry
150 | TrampolineEntry
151 | TrampolineEntry
152 | TrampolineEntry
153 | TrampolineEntry
154 | TrampolineEntry
155 | TrampolineEntry
156 | TrampolineEntry
157 | TrampolineEntry
158 | TrampolineEntry
159 | TrampolineEntry
160 | TrampolineEntry
161 | TrampolineEntry
162 | TrampolineEntry
163 | TrampolineEntry
164 | TrampolineEntry
165 | TrampolineEntry
166 | TrampolineEntry
167 | TrampolineEntry
168 | TrampolineEntry
169 | TrampolineEntry
170 | TrampolineEntry
171 | TrampolineEntry
172 | TrampolineEntry
173 | TrampolineEntry
174 | TrampolineEntry
175 | TrampolineEntry
176 | TrampolineEntry
177 | TrampolineEntry
178 | TrampolineEntry
179 | TrampolineEntry
180 | TrampolineEntry
181 | TrampolineEntry
182 | TrampolineEntry
183 | TrampolineEntry
184 | TrampolineEntry
185 | TrampolineEntry
186 | TrampolineEntry
187 | TrampolineEntry
188 | TrampolineEntry
189 | TrampolineEntry
190 | TrampolineEntry
191 | TrampolineEntry
192 | TrampolineEntry
193 | TrampolineEntry
194 | TrampolineEntry
195 | TrampolineEntry
196 | TrampolineEntry
197 | TrampolineEntry
198 | TrampolineEntry
199 | TrampolineEntry
200 | TrampolineEntry
201 | TrampolineEntry
202 | TrampolineEntry
203 | TrampolineEntry
204 | TrampolineEntry
205 | TrampolineEntry
206 | TrampolineEntry
207 | TrampolineEntry
208 | TrampolineEntry
209 | TrampolineEntry
210 | TrampolineEntry
211 | TrampolineEntry
212 | TrampolineEntry
213 | TrampolineEntry
214 | TrampolineEntry
215 | TrampolineEntry
216 | TrampolineEntry
217 | TrampolineEntry
218 | TrampolineEntry
219 | TrampolineEntry
220 | TrampolineEntry
221 | TrampolineEntry
222 | TrampolineEntry
223 | TrampolineEntry
224 | TrampolineEntry
225 | TrampolineEntry
226 | TrampolineEntry
227 | TrampolineEntry
228 | TrampolineEntry
229 | TrampolineEntry
230 | TrampolineEntry
231 | TrampolineEntry
232 | TrampolineEntry
233 | TrampolineEntry
234 | TrampolineEntry
235 | TrampolineEntry
236 | TrampolineEntry
237 | TrampolineEntry
238 | TrampolineEntry
239 | TrampolineEntry
240 | TrampolineEntry
241 | TrampolineEntry
242 | TrampolineEntry
243 | TrampolineEntry
244 | TrampolineEntry
245 | TrampolineEntry
246 | TrampolineEntry
247 | TrampolineEntry
248 | TrampolineEntry
249 | TrampolineEntry
250 | TrampolineEntry
251 | TrampolineEntry
252 | TrampolineEntry
253 | TrampolineEntry
254 | TrampolineEntry
255 | TrampolineEntry
256 | TrampolineEntry
257 | TrampolineEntry
258 | TrampolineEntry
259 | TrampolineEntry
260 | TrampolineEntry
261 | TrampolineEntry
262 | TrampolineEntry
263 | TrampolineEntry
264 | TrampolineEntry
265 | TrampolineEntry
266 | TrampolineEntry
267 | TrampolineEntry
268 | TrampolineEntry
269 | TrampolineEntry
270 | TrampolineEntry
271 | TrampolineEntry
272 | TrampolineEntry
273 | TrampolineEntry
274 | TrampolineEntry
275 | TrampolineEntry
276 | TrampolineEntry
277 | TrampolineEntry
278 | TrampolineEntry
279 | TrampolineEntry
280 | TrampolineEntry
281 | TrampolineEntry
282 | TrampolineEntry
283 | TrampolineEntry
284 | TrampolineEntry
285 | TrampolineEntry
286 | TrampolineEntry
287 | TrampolineEntry
288 | TrampolineEntry
289 | TrampolineEntry
290 | TrampolineEntry
291 | TrampolineEntry
292 | TrampolineEntry
293 | TrampolineEntry
294 | TrampolineEntry
295 | TrampolineEntry
296 | TrampolineEntry
297 | TrampolineEntry
298 | TrampolineEntry
299 | TrampolineEntry
300 | TrampolineEntry
301 | TrampolineEntry
302 | TrampolineEntry
303 | TrampolineEntry
304 | TrampolineEntry
305 | TrampolineEntry
306 | TrampolineEntry
307 | TrampolineEntry
308 | TrampolineEntry
309 | TrampolineEntry
310 | TrampolineEntry
311 | TrampolineEntry
312 | TrampolineEntry
313 | TrampolineEntry
314 | TrampolineEntry
315 | TrampolineEntry
316 | TrampolineEntry
317 | TrampolineEntry
318 | TrampolineEntry
319 | TrampolineEntry
320 | TrampolineEntry
321 | TrampolineEntry
322 | TrampolineEntry
323 | TrampolineEntry
324 | TrampolineEntry
325 | TrampolineEntry
326 | TrampolineEntry
327 | TrampolineEntry
328 | TrampolineEntry
329 | TrampolineEntry
330 | TrampolineEntry
331 | TrampolineEntry
332 | TrampolineEntry
333 | TrampolineEntry
334 | TrampolineEntry
335 | TrampolineEntry
336 | TrampolineEntry
337 | TrampolineEntry
338 | TrampolineEntry
339 | TrampolineEntry
340 | TrampolineEntry
341 | TrampolineEntry
342 | TrampolineEntry
343 | TrampolineEntry
344 | TrampolineEntry
345 | TrampolineEntry
346 | TrampolineEntry
347 | TrampolineEntry
348 | TrampolineEntry
349 | TrampolineEntry
350 | TrampolineEntry
351 | TrampolineEntry
352 | TrampolineEntry
353 | TrampolineEntry
354 | TrampolineEntry
355 | TrampolineEntry
356 | TrampolineEntry
357 | TrampolineEntry
358 | TrampolineEntry
359 | TrampolineEntry
360 | TrampolineEntry
361 | TrampolineEntry
362 | TrampolineEntry
363 | TrampolineEntry
364 | TrampolineEntry
365 | TrampolineEntry
366 | TrampolineEntry
367 | TrampolineEntry
368 | TrampolineEntry
369 | TrampolineEntry
370 | TrampolineEntry
371 | TrampolineEntry
372 | TrampolineEntry
373 | TrampolineEntry
374 | TrampolineEntry
375 | TrampolineEntry
376 | TrampolineEntry
377 | TrampolineEntry
378 | TrampolineEntry
379 | TrampolineEntry
380 | TrampolineEntry
381 | TrampolineEntry
382 | TrampolineEntry
383 | TrampolineEntry
384 | TrampolineEntry
385 | TrampolineEntry
386 | TrampolineEntry
387 | TrampolineEntry
388 | TrampolineEntry
389 | TrampolineEntry
390 | TrampolineEntry
391 | TrampolineEntry
392 | TrampolineEntry
393 | TrampolineEntry
394 | TrampolineEntry
395 | TrampolineEntry
396 | TrampolineEntry
397 | TrampolineEntry
398 | TrampolineEntry
399 | TrampolineEntry
400 | TrampolineEntry
401 | TrampolineEntry
402 | TrampolineEntry
403 | TrampolineEntry
404 | TrampolineEntry
405 | TrampolineEntry
406 | TrampolineEntry
407 | TrampolineEntry
408 | TrampolineEntry
409 | TrampolineEntry
410 | TrampolineEntry
411 | TrampolineEntry
412 | TrampolineEntry
413 | TrampolineEntry
414 | TrampolineEntry
415 | TrampolineEntry
416 | TrampolineEntry
417 | TrampolineEntry
418 | TrampolineEntry
419 | TrampolineEntry
420 | TrampolineEntry
421 | TrampolineEntry
422 | TrampolineEntry
423 | TrampolineEntry
424 | TrampolineEntry
425 | TrampolineEntry
426 | TrampolineEntry
427 | TrampolineEntry
428 | TrampolineEntry
429 | TrampolineEntry
430 | TrampolineEntry
431 | TrampolineEntry
432 | TrampolineEntry
433 | TrampolineEntry
434 | TrampolineEntry
435 | TrampolineEntry
436 | TrampolineEntry
437 | TrampolineEntry
438 | TrampolineEntry
439 | TrampolineEntry
440 | TrampolineEntry
441 | TrampolineEntry
442 | TrampolineEntry
443 | TrampolineEntry
444 | TrampolineEntry
445 | TrampolineEntry
446 | TrampolineEntry
447 | TrampolineEntry
448 | TrampolineEntry
449 | TrampolineEntry
450 | TrampolineEntry
451 | TrampolineEntry
452 | TrampolineEntry
453 | TrampolineEntry
454 | TrampolineEntry
455 | TrampolineEntry
456 | TrampolineEntry
457 | TrampolineEntry
458 | TrampolineEntry
459 | TrampolineEntry
460 | TrampolineEntry
461 | TrampolineEntry
462 | TrampolineEntry
463 | TrampolineEntry
464 | TrampolineEntry
465 | TrampolineEntry
466 | TrampolineEntry
467 | TrampolineEntry
468 | TrampolineEntry
469 | TrampolineEntry
470 | TrampolineEntry
471 | TrampolineEntry
472 | TrampolineEntry
473 | TrampolineEntry
474 | TrampolineEntry
475 | TrampolineEntry
476 | TrampolineEntry
477 | TrampolineEntry
478 | TrampolineEntry
479 | TrampolineEntry
480 | TrampolineEntry
481 | TrampolineEntry
482 | TrampolineEntry
483 | TrampolineEntry
484 | TrampolineEntry
485 | TrampolineEntry
486 | TrampolineEntry
487 | TrampolineEntry
488 | TrampolineEntry
489 | TrampolineEntry
490 | TrampolineEntry
491 | TrampolineEntry
492 | TrampolineEntry
493 | TrampolineEntry
494 | TrampolineEntry
495 | TrampolineEntry
496 | TrampolineEntry
497 | TrampolineEntry
498 | TrampolineEntry
499 | TrampolineEntry
500 | TrampolineEntry
501 | TrampolineEntry
502 | TrampolineEntry
503 | TrampolineEntry
504 | TrampolineEntry
505 | TrampolineEntry
506 | TrampolineEntry
507 | TrampolineEntry
508 | TrampolineEntry
509 | TrampolineEntry
510 | TrampolineEntry
511 | TrampolineEntry
512 | TrampolineEntry
513 | TrampolineEntry
514 | TrampolineEntry
515 | TrampolineEntry
516 | TrampolineEntry
517 | TrampolineEntry
518 | TrampolineEntry
519 | TrampolineEntry
520 | TrampolineEntry
521 | TrampolineEntry
522 | TrampolineEntry
523 | TrampolineEntry
524 | TrampolineEntry
525 | TrampolineEntry
526 | TrampolineEntry
527 | TrampolineEntry
528 | TrampolineEntry
529 | TrampolineEntry
530 | TrampolineEntry
531 | TrampolineEntry
532 | TrampolineEntry
533 | TrampolineEntry
534 | TrampolineEntry
535 | TrampolineEntry
536 | TrampolineEntry
537 | TrampolineEntry
538 | TrampolineEntry
539 | TrampolineEntry
540 | TrampolineEntry
541 | TrampolineEntry
542 | TrampolineEntry
543 | TrampolineEntry
544 | TrampolineEntry
545 | TrampolineEntry
546 | TrampolineEntry
547 | TrampolineEntry
548 | TrampolineEntry
549 | TrampolineEntry
550 | TrampolineEntry
551 | TrampolineEntry
552 | TrampolineEntry
553 | TrampolineEntry
554 | TrampolineEntry
555 | TrampolineEntry
556 | TrampolineEntry
557 | TrampolineEntry
558 | TrampolineEntry
559 | TrampolineEntry
560 | TrampolineEntry
561 | TrampolineEntry
562 | // TrampolineEntry
563 | // TrampolineEntry
564 | // TrampolineEntry
565 | // TrampolineEntry
566 |
567 | __a1a2_selectorTrampEnd:
568 |
569 | #endif
570 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Trace/OCSelectorTrampolines.mm:
--------------------------------------------------------------------------------
1 | /*
2 | * OCSelectorTrampolines.mm
3 | * OCMethodTrace
4 | *
5 | * https://github.com/omxcodec/OCMethodTrace.git
6 | *
7 | * Copyright (C) 2018 Michael Chen
8 | *
9 | * Licensed under the Apache License, Version 2.0 (the "License");
10 | * you may not use this file except in compliance with the License.
11 | * You may obtain a copy of the License at
12 | *
13 | * http://www.apache.org/licenses/LICENSE-2.0
14 | *
15 | * Unless required by applicable law or agreed to in writing, software
16 | * distributed under the License is distributed on an "AS IS" BASIS,
17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 | * See the License for the specific language governing permissions and
19 | * limitations under the License.
20 | */
21 |
22 | #import "OCSelectorTrampolines.h"
23 | #import
24 | #import
25 | #import
26 | #import
27 |
28 | // Define SUPPORT_STRET on architectures that need separate struct-return ABI.
29 | #if defined(__arm64__)
30 | # define SUPPORT_STRET 0
31 | #else
32 | # define SUPPORT_STRET 1
33 | #endif
34 |
35 | #define _ost_fatal(fmt, ...) [NSException raise:@"OCSelectorTrampolines" format:fmt, ##__VA_ARGS__]
36 |
37 | // symbols defined in assembly files
38 | // Don't use the symbols directly; they're thumb-biased on some ARM archs.
39 | #define TRAMP(tramp) \
40 | static inline __unused uintptr_t tramp(void) { \
41 | extern void *_##tramp; \
42 | return ((uintptr_t)&_##tramp) & ~1UL; \
43 | }
44 | // Scalar return
45 | TRAMP(a1a2_selectorTrampHead); // trampoline header code
46 | TRAMP(a1a2_firstSelectorTramp); // first trampoline
47 | TRAMP(a1a2_selectorTrampEnd); // after the last trampoline
48 |
49 | #if SUPPORT_STRET
50 | // Struct return
51 | TRAMP(a2a3_selectorTrampHead);
52 | TRAMP(a2a3_firstSelectorTramp);
53 | TRAMP(a2a3_selectorTrampEnd);
54 | #endif
55 |
56 | // argument mode identifier
57 | typedef enum {
58 | ReturnValueInRegisterArgumentMode,
59 | #if SUPPORT_STRET
60 | ReturnValueOnStackArgumentMode,
61 | #endif
62 |
63 | ArgumentModeCount
64 | } ArgumentMode;
65 |
66 |
67 | // We must take care with our data layout on architectures that support
68 | // multiple page sizes.
69 | //
70 | // The trampoline template in __TEXT is sized and aligned with PAGE_MAX_SIZE.
71 | // On some platforms this requires additional linker flags.
72 | //
73 | // When we allocate a page pair, we use PAGE_MAX_SIZE size.
74 | // This allows trampoline code to find its data by subtracting PAGE_MAX_SIZE.
75 | //
76 | // When we allocate a page pair, we use the process's page alignment.
77 | // This simplifies allocation because we don't need to force greater than
78 | // default alignment when running with small pages, but it also means
79 | // the trampoline code MUST NOT look for its data by masking with PAGE_MAX_MASK.
80 |
81 | struct TrampolineSelectorPagePair
82 | {
83 | IMP msgSend; // msg send hander
84 |
85 | TrampolineSelectorPagePair *nextPagePair; // linked list of all pages
86 | TrampolineSelectorPagePair *nextAvailablePage; // linked list of pages with available slots
87 |
88 | uintptr_t nextAvailable; // index of next available slot, endIndex() if no more available
89 |
90 | // Payload data: selector and free list.
91 | // Bytes parallel with trampoline header code are the fields above or unused
92 | // uint8_t selectors[ PAGE_MAX_SIZE - sizeof(TrampolineSelectorPagePair) ]
93 |
94 | // Code: trampoline header followed by trampolines.
95 | // uint8_t trampolines[PAGE_MAX_SIZE];
96 |
97 | // Per-trampoline selector data format:
98 | // initial value is 0 while page data is filled sequentially
99 | // when filled, value is reference to selector
100 | // when empty, value is index of next available slot OR 0 if never used yet
101 |
102 | union Payload {
103 | SEL selector;
104 | uintptr_t nextAvailable; // free list
105 | };
106 |
107 | static uintptr_t headerSize() {
108 | return (uintptr_t) (a1a2_firstSelectorTramp() - a1a2_selectorTrampHead());
109 | }
110 |
111 | static uintptr_t slotSize() {
112 | return 8;
113 | }
114 |
115 | static uintptr_t startIndex() {
116 | // headerSize is assumed to be slot-aligned
117 | return headerSize() / slotSize();
118 | }
119 |
120 | static uintptr_t endIndex() {
121 | return (uintptr_t)PAGE_MAX_SIZE / slotSize();
122 | }
123 |
124 | static bool validIndex(uintptr_t index) {
125 | return (index >= startIndex() && index < endIndex());
126 | }
127 |
128 | Payload *payload(uintptr_t index) {
129 | assert(validIndex(index));
130 | return (Payload *)((char *)this + index*slotSize());
131 | }
132 |
133 | IMP trampoline(uintptr_t index) {
134 | assert(validIndex(index));
135 | char *imp = (char *)this + index*slotSize() + PAGE_MAX_SIZE;
136 | #if __arm__
137 | imp++; // trampoline is Thumb instructions
138 | #endif
139 | return (IMP)imp;
140 | }
141 |
142 | uintptr_t indexForTrampoline(IMP tramp) {
143 | uintptr_t tramp0 = (uintptr_t)this + PAGE_MAX_SIZE;
144 | uintptr_t start = tramp0 + headerSize();
145 | uintptr_t end = tramp0 + PAGE_MAX_SIZE;
146 | uintptr_t address = (uintptr_t)tramp;
147 | if (address >= start && address < end) {
148 | return (uintptr_t)(address - tramp0) / slotSize();
149 | }
150 | return 0;
151 | }
152 |
153 | static void check() {
154 | assert(TrampolineSelectorPagePair::slotSize() == 8);
155 | assert(TrampolineSelectorPagePair::headerSize() >= sizeof(TrampolineSelectorPagePair));
156 | assert(TrampolineSelectorPagePair::headerSize() % TrampolineSelectorPagePair::slotSize() == 0);
157 |
158 | // _objc_inform("%p %p %p", a1a2_selectorTrampHead(), a1a2_firstSelectorTramp(),
159 | // a1a2_selectorTrampEnd());
160 | assert(a1a2_selectorTrampHead() % PAGE_SIZE == 0); // not PAGE_MAX_SIZE
161 | assert(a1a2_selectorTrampHead() + PAGE_MAX_SIZE == a1a2_selectorTrampEnd());
162 | #if SUPPORT_STRET
163 | // _objc_inform("%p %p %p", a2a3_selectorTrampHead(), a2a3_firstSelectorTramp(),
164 | // a2a3_selectorTrampEnd());
165 | assert(a2a3_selectorTrampHead() % PAGE_SIZE == 0); // not PAGE_MAX_SIZE
166 | assert(a2a3_selectorTrampHead() + PAGE_MAX_SIZE == a2a3_selectorTrampEnd());
167 | #endif
168 |
169 | #if __arm__
170 | // make sure trampolines are Thumb
171 | extern void *_a1a2_firstSelectorTramp;
172 | extern void *_a2a3_firstSelectorTramp;
173 | assert(((uintptr_t)&_a1a2_firstSelectorTramp) % 2 == 1);
174 | assert(((uintptr_t)&_a2a3_firstSelectorTramp) % 2 == 1);
175 | #endif
176 | }
177 |
178 | };
179 |
180 | // two sets of trampoline pages; one for stack returns and one for register returns
181 | static TrampolineSelectorPagePair *headPagePairs[ArgumentModeCount];
182 |
183 | #pragma mark Utility Functions
184 |
185 | static pthread_rwlock_t trampolinesLock = PTHREAD_RWLOCK_INITIALIZER;
186 |
187 | static inline void _lock() {
188 | int err = pthread_rwlock_wrlock(&trampolinesLock);
189 | if (err) _ost_fatal(@"pthread_rwlock_wrlock failed (%d)", err);
190 | }
191 |
192 | static inline void _unlock() {
193 | int err = pthread_rwlock_unlock(&trampolinesLock);
194 | if (err) _ost_fatal(@"pthread_rwlock_unlock failed (%d)", err);
195 | }
196 |
197 | static inline void _assert_locked() {
198 | }
199 |
200 | #pragma mark Trampoline Management Functions
201 | static TrampolineSelectorPagePair *_allocateTrampolinesAndData(ArgumentMode aMode)
202 | {
203 | _assert_locked();
204 |
205 | vm_address_t dataAddress;
206 |
207 | TrampolineSelectorPagePair::check();
208 |
209 | TrampolineSelectorPagePair *headPagePair = headPagePairs[aMode];
210 |
211 | assert(headPagePair == nil || headPagePair->nextAvailablePage == nil);
212 |
213 | kern_return_t result;
214 | result = vm_allocate(mach_task_self(), &dataAddress, PAGE_MAX_SIZE * 2,
215 | VM_FLAGS_ANYWHERE | VM_MAKE_TAG(VM_MEMORY_FOUNDATION));
216 | if (result != KERN_SUCCESS) {
217 | _ost_fatal(@"vm_allocate trampolines failed (%d)", result);
218 | }
219 |
220 | vm_address_t codeAddress = dataAddress + PAGE_MAX_SIZE;
221 |
222 | uintptr_t codePage = NULL;
223 | IMP sendImp = NULL;
224 | switch(aMode) {
225 | case ReturnValueInRegisterArgumentMode:
226 | codePage = a1a2_selectorTrampHead();
227 | sendImp = objc_msgSend;
228 | break;
229 | #if SUPPORT_STRET
230 | case ReturnValueOnStackArgumentMode:
231 | codePage = a2a3_selectorTrampHead();
232 | sendImp = objc_msgSend_stret;
233 | break;
234 | #endif
235 | default:
236 | _ost_fatal(@"unknown return mode %d", (int)aMode);
237 | break;
238 | }
239 |
240 | vm_prot_t currentProtection, maxProtection;
241 | result = vm_remap(mach_task_self(), &codeAddress, PAGE_MAX_SIZE,
242 | 0, VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE,
243 | mach_task_self(), codePage, TRUE,
244 | ¤tProtection, &maxProtection, VM_INHERIT_SHARE);
245 | if (result != KERN_SUCCESS) {
246 | // vm_deallocate(mach_task_self(), dataAddress, PAGE_MAX_SIZE * 2);
247 | _ost_fatal(@"vm_remap trampolines failed (%d)", result);
248 | }
249 |
250 | TrampolineSelectorPagePair *pagePair = (TrampolineSelectorPagePair *) dataAddress;
251 | pagePair->nextAvailable = pagePair->startIndex();
252 | pagePair->nextPagePair = nil;
253 | pagePair->nextAvailablePage = nil;
254 | pagePair->msgSend = sendImp;
255 |
256 | if (headPagePair) {
257 | TrampolineSelectorPagePair *lastPagePair = headPagePair;
258 | while(lastPagePair->nextPagePair) {
259 | lastPagePair = lastPagePair->nextPagePair;
260 | }
261 | lastPagePair->nextPagePair = pagePair;
262 | headPagePairs[aMode]->nextAvailablePage = pagePair;
263 | } else {
264 | headPagePairs[aMode] = pagePair;
265 | }
266 |
267 | return pagePair;
268 | }
269 |
270 | static TrampolineSelectorPagePair *
271 | _getOrAllocatePagePairWithNextAvailable(ArgumentMode aMode)
272 | {
273 | _assert_locked();
274 |
275 | TrampolineSelectorPagePair *headPagePair = headPagePairs[aMode];
276 |
277 | if (!headPagePair)
278 | return _allocateTrampolinesAndData(aMode);
279 |
280 | // make sure head page is filled first
281 | if (headPagePair->nextAvailable != headPagePair->endIndex())
282 | return headPagePair;
283 |
284 | if (headPagePair->nextAvailablePage) // check if there is a page w/a hole
285 | return headPagePair->nextAvailablePage;
286 |
287 | return _allocateTrampolinesAndData(aMode); // tack on a new one
288 | }
289 |
290 | static TrampolineSelectorPagePair *
291 | _pageAndIndexContainingIMP(IMP anImp, uintptr_t *outIndex,
292 | TrampolineSelectorPagePair **outHeadPagePair)
293 | {
294 | _assert_locked();
295 |
296 | for (int arg = 0; arg < ArgumentModeCount; arg++) {
297 | for (TrampolineSelectorPagePair *pagePair = headPagePairs[arg];
298 | pagePair;
299 | pagePair = pagePair->nextPagePair)
300 | {
301 | uintptr_t index = pagePair->indexForTrampoline(anImp);
302 | if (index) {
303 | if (outIndex) *outIndex = index;
304 | if (outHeadPagePair) *outHeadPagePair = headPagePairs[arg];
305 | return pagePair;
306 | }
307 | }
308 | }
309 |
310 | return nil;
311 | }
312 |
313 | static ArgumentMode
314 | _argumentModeForSignature(const char *signature)
315 | {
316 | ArgumentMode aMode = ReturnValueInRegisterArgumentMode;
317 |
318 | #if SUPPORT_STRET
319 | if (signature && signature[0] == '{') {
320 | @try {
321 | // In some cases that returns struct, we should use the '_stret' API:
322 | // http://sealiesoftware.com/blog/archive/2008/10/30/objc_explain_objc_msgSend_stret.html
323 | // NSMethodSignature knows the detail but has no API to return, we can only get the info from debugDescription.
324 | NSMethodSignature *methodSignature = [NSMethodSignature signatureWithObjCTypes:signature];
325 | if ([methodSignature.debugDescription rangeOfString:@"is special struct return? YES"].location != NSNotFound) {
326 | aMode = ReturnValueOnStackArgumentMode;
327 | }
328 | } @catch (__unused NSException *e) {}
329 | }
330 | #endif
331 |
332 | return aMode;
333 | }
334 |
335 | #pragma mark Public API
336 | IMP imp_implementationWithSelector(SEL aSel, const char *signature)
337 | {
338 | IMP returnIMP;
339 |
340 | _lock();
341 |
342 | ArgumentMode aMode = _argumentModeForSignature(signature);
343 |
344 | TrampolineSelectorPagePair *pagePair =
345 | _getOrAllocatePagePairWithNextAvailable(aMode);
346 | if (!headPagePairs[aMode])
347 | headPagePairs[aMode] = pagePair;
348 |
349 | uintptr_t index = pagePair->nextAvailable;
350 | assert(index >= pagePair->startIndex() && index < pagePair->endIndex());
351 | TrampolineSelectorPagePair::Payload *payload = pagePair->payload(index);
352 |
353 | uintptr_t nextAvailableIndex = payload->nextAvailable;
354 | if (nextAvailableIndex == 0) {
355 | // First time through (unused slots are zero). Fill sequentially.
356 | // If the page is now full this will now be endIndex(), handled below.
357 | nextAvailableIndex = index + 1;
358 | }
359 | pagePair->nextAvailable = nextAvailableIndex;
360 | if (nextAvailableIndex == pagePair->endIndex()) {
361 | // PagePair is now full (free list or wilderness exhausted)
362 | // Remove from available page linked list
363 | TrampolineSelectorPagePair *iterator = headPagePairs[aMode];
364 | while(iterator && (iterator->nextAvailablePage != pagePair)) {
365 | iterator = iterator->nextAvailablePage;
366 | }
367 | if (iterator) {
368 | iterator->nextAvailablePage = pagePair->nextAvailablePage;
369 | pagePair->nextAvailablePage = nil;
370 | }
371 | }
372 |
373 | payload->selector = aSel;
374 | returnIMP = pagePair->trampoline(index);
375 |
376 | _unlock();
377 |
378 | return returnIMP;
379 | }
380 |
381 | SEL imp_getSelector(IMP anImp) {
382 | uintptr_t index;
383 | TrampolineSelectorPagePair *pagePair;
384 |
385 | if (!anImp) return nil;
386 |
387 | _lock();
388 |
389 | pagePair = _pageAndIndexContainingIMP(anImp, &index, nil);
390 |
391 | if (!pagePair) {
392 | _unlock();
393 | return nil;
394 | }
395 |
396 | TrampolineSelectorPagePair::Payload *payload = pagePair->payload(index);
397 |
398 | if (payload->nextAvailable <= TrampolineSelectorPagePair::endIndex()) {
399 | // unallocated
400 | _unlock();
401 | return nil;
402 | }
403 |
404 | _unlock();
405 |
406 | return payload->selector;
407 | }
408 |
409 | BOOL imp_removeSelector(IMP anImp) {
410 | TrampolineSelectorPagePair *pagePair;
411 | TrampolineSelectorPagePair *headPagePair;
412 | uintptr_t index;
413 |
414 | if (!anImp) return NO;
415 |
416 | _lock();
417 | pagePair = _pageAndIndexContainingIMP(anImp, &index, &headPagePair);
418 |
419 | if (!pagePair) {
420 | _unlock();
421 | return NO;
422 | }
423 |
424 | TrampolineSelectorPagePair::Payload *payload = pagePair->payload(index);
425 |
426 | payload->nextAvailable = pagePair->nextAvailable;
427 | pagePair->nextAvailable = index;
428 |
429 | // make sure this page is on available linked list
430 | TrampolineSelectorPagePair *pagePairIterator = headPagePair;
431 |
432 | // see if page is the next available page for any existing pages
433 | while (pagePairIterator->nextAvailablePage &&
434 | pagePairIterator->nextAvailablePage != pagePair)
435 | {
436 | pagePairIterator = pagePairIterator->nextAvailablePage;
437 | }
438 |
439 | if (! pagePairIterator->nextAvailablePage) {
440 | // if iteration stopped because nextAvail was nil
441 | // add to end of list.
442 | pagePairIterator->nextAvailablePage = pagePair;
443 | pagePair->nextAvailablePage = nil;
444 | }
445 |
446 | _unlock();
447 |
448 | return YES;
449 | }
450 |
--------------------------------------------------------------------------------
/WeChatDemoDylib/Tools/LLDBTools.mm:
--------------------------------------------------------------------------------
1 | // weibo: http://weibo.com/xiaoqing28
2 | // blog: http://www.alonemonkey.com
3 | //
4 | // LLDBTools.m
5 | // MonkeyDev
6 | //
7 | // Created by AloneMonkey on 2018/3/8.
8 | // Copyright © 2018年 AloneMonkey. All rights reserved.
9 | //
10 |
11 | #pragma GCC diagnostic ignored "-Wundeclared-selector"
12 |
13 | #import "LLDBTools.h"
14 | #import
15 | #import
16 | #import
17 | #import
18 | #import
19 | #import
20 |
21 | enum {
22 | BLOCK_HAS_COPY_DISPOSE = (1 << 25),
23 | BLOCK_HAS_CTOR = (1 << 26), // helpers have C++ code
24 | BLOCK_IS_GLOBAL = (1 << 28),
25 | BLOCK_HAS_STRET = (1 << 29), // IFF BLOCK_HAS_SIGNATURE
26 | BLOCK_HAS_SIGNATURE = (1 << 30),
27 | };
28 |
29 | struct Block_literal_1 {
30 | void *isa; // initialized to &_NSConcreteStackBlock or &_NSConcreteGlobalBlock
31 | int flags;
32 | int reserved;
33 | void (*invoke)(void *, ...);
34 | struct Block_descriptor_1 {
35 | unsigned long int reserved; // NULL
36 | unsigned long int size; // sizeof(struct Block_literal_1)
37 | // optional helper functions
38 | void (*copy_helper)(void *dst, void *src); // IFF (1<<25)
39 | void (*dispose_helper)(void *src); // IFF (1<<25)
40 | // required ABI.2010.3.16
41 | const char *signature; // IFF (1<<30)
42 | } *descriptor;
43 | // imported variables
44 | };
45 |
46 | NSString* decode(NSString* code);
47 | NSArray* choose_inner(const char * classname);
48 | char * protection_bits_to_rwx (vm_prot_t p);
49 | const char * unparse_inheritance (vm_inherit_t i);
50 | char * behavior_to_text (vm_behavior_t b);
51 |
52 | NSString* decode(NSString* code){
53 | NSDictionary * encodeMap = @{
54 | @"c": @"char",
55 | @"i": @"int",
56 | @"s": @"short",
57 | @"l": @"long",
58 | @"q": @"long long",
59 |
60 | @"C": @"unsigned char",
61 | @"I": @"unsigned int",
62 | @"S": @"unsigned short",
63 | @"L": @"unsigned long",
64 | @"Q": @"unsigned long long",
65 |
66 | @"f": @"float",
67 | @"d": @"double",
68 | @"B": @"bool",
69 | @"v": @"void",
70 | @"*": @"char *",
71 | @"@": @"id",
72 | @"#": @"Class",
73 | @":": @"SEL"
74 | };
75 |
76 | if(encodeMap[code]){
77 | return encodeMap[code];
78 | }else if([code characterAtIndex:0] == '@'){
79 | if([code characterAtIndex:1] == '?'){
80 | return code;
81 | }else if([code characterAtIndex:2] == '<'){
82 | return [NSString stringWithFormat:@"id%@", [[code substringWithRange:NSMakeRange(2, code.length-3)] stringByReplacingOccurrencesOfString:@"><" withString:@", "]];
83 | }else{
84 | return [NSString stringWithFormat:@"%@ *", [code substringWithRange:NSMakeRange(2, code.length-3)]];
85 | }
86 | }else if([code characterAtIndex:0] == '^'){
87 | return [NSString stringWithFormat:@"%@ *", decode([code substringFromIndex:1])];
88 | }
89 | return code;
90 | }
91 |
92 | NSString* pvc(){
93 | return [[[UIWindow performSelector:@selector(keyWindow)] performSelector:@selector(rootViewController)] performSelector:@selector(_printHierarchy)];
94 | }
95 |
96 | NSString* pviews(){
97 | return [[[UIApplication sharedApplication] keyWindow] performSelector:@selector(recursiveDescription)];
98 | }
99 |
100 | NSString* pactions(vm_address_t address){
101 | NSMutableString* result = [NSMutableString new];
102 | UIControl* control = (__bridge UIControl*)(void*)address;
103 | NSArray* targets = [[control allTargets] allObjects];
104 | for (id item in targets) {
105 | NSArray* actions = [control actionsForTarget:item forControlEvent:0];
106 | [result appendFormat:@"<%s: 0x%lx>: %@\n", object_getClassName(item), (unsigned long)item, [actions componentsJoinedByString:@","]];
107 | }
108 | return result;
109 | }
110 |
111 | NSString* pblock(vm_address_t address){
112 | struct Block_literal_1 real = *((struct Block_literal_1 *)(void*)address);
113 | NSMutableDictionary *dict = [NSMutableDictionary dictionary];
114 | [dict setObject:[NSNumber numberWithLong:(long)real.invoke] forKey:@"invoke"];
115 | if (real.flags & BLOCK_HAS_SIGNATURE) {
116 | char *signature;
117 | if (real.flags & BLOCK_HAS_COPY_DISPOSE) {
118 | signature = (char *)(real.descriptor)->signature;
119 | } else {
120 | signature = (char *)(real.descriptor)->copy_helper;
121 | }
122 |
123 | NSMethodSignature *sig = [NSMethodSignature signatureWithObjCTypes:signature];
124 | NSMutableArray *types = [NSMutableArray array];
125 |
126 | [types addObject:[NSString stringWithUTF8String:(char *)[sig methodReturnType]]];
127 |
128 | for (NSUInteger i = 0; i < sig.numberOfArguments; i++) {
129 | char *type = (char *)[sig getArgumentTypeAtIndex:i];
130 | [types addObject:[NSString stringWithUTF8String:type]];
131 | }
132 |
133 | [dict setObject:types forKey:@"signature"];
134 | }
135 |
136 | NSMutableArray* sigArr = dict[@"signature"];
137 |
138 | if(!sigArr){
139 | return [NSString stringWithFormat:@"Imp: 0x%lx", [dict[@"invoke"] longValue]];
140 | }else{
141 | NSMutableString* sig = [NSMutableString stringWithFormat:@"%@ ^(", decode(sigArr[0])];
142 | for (int i = 2; i < sigArr.count; i++) {
143 | if(i == sigArr.count - 1){
144 | [sig appendFormat:@"%@", decode(sigArr[i])];
145 | }else{
146 | [sig appendFormat:@"%@ ,", decode(sigArr[i])];
147 | }
148 | }
149 | [sig appendString:@");"];
150 | return [NSString stringWithFormat:@"Imp: 0x%lx Signature: %s", [dict[@"invoke"] longValue], [sig UTF8String]];
151 | }
152 | }
153 |
154 | struct CYChoice {
155 | std::set query_;
156 | std::set results_;
157 | };
158 |
159 | struct CYObjectStruct {
160 | Class isa_;
161 | };
162 |
163 | static void choose_(task_t task, void *baton, unsigned type, vm_range_t *ranges, unsigned count) {
164 | CYChoice *choice(reinterpret_cast(baton));
165 |
166 | for (unsigned i(0); i != count; ++i) {
167 | vm_range_t &range(ranges[i]);
168 | void *data(reinterpret_cast(range.address));
169 | size_t size(range.size);
170 |
171 | if (size < sizeof(CYObjectStruct))
172 | continue;
173 |
174 | uintptr_t *pointers(reinterpret_cast(data));
175 | #ifdef __arm64__
176 | Class isa = (__bridge Class)((void *)(pointers[0] & 0x1fffffff8));
177 | #else
178 | Class isa =(__bridge Class)(void *)pointers[0];
179 | #endif
180 | std::set::const_iterator result(choice->query_.find(isa));
181 | if (result == choice->query_.end())
182 | continue;
183 |
184 | size_t needed(class_getInstanceSize(*result));
185 | // XXX: if (size < needed)
186 |
187 | size_t boundary(496);
188 | #ifdef __LP64__
189 | boundary *= 2;
190 | #endif
191 | if ((needed <= boundary && (needed + 15) / 16 * 16 != size) || (needed > boundary && (needed + 511) / 512 * 512 != size))
192 | continue;
193 | choice->results_.insert((__bridge id)(data));
194 | }
195 | }
196 |
197 | static Class *CYCopyClassList(size_t &size) {
198 | size = objc_getClassList(NULL, 0);
199 | Class *data(reinterpret_cast(malloc(sizeof(Class) * size)));
200 |
201 | for (;;) {
202 | size_t writ(objc_getClassList(data, (int)size));
203 | if (writ <= size) {
204 | size = writ;
205 | return data;
206 | }
207 |
208 | Class *copy(reinterpret_cast(realloc(data, sizeof(Class) * writ)));
209 | if (copy == NULL) {
210 | free(data);
211 | return NULL;
212 | }
213 |
214 | data = copy;
215 | size = writ;
216 | }
217 | }
218 |
219 | static kern_return_t CYReadMemory(task_t task, vm_address_t address, vm_size_t size, void **data) {
220 | *data = reinterpret_cast(address);
221 | return KERN_SUCCESS;
222 | }
223 |
224 | NSArray* choose_inner(const char * classname){
225 |
226 | Class _class = NSClassFromString([NSString stringWithUTF8String:classname]);
227 |
228 | vm_address_t *zones = NULL;
229 | unsigned size = 0;
230 | //获取所有的zone信息 堆上的区域
231 | kern_return_t error = malloc_get_all_zones(mach_task_self(), &CYReadMemory, &zones, &size);
232 | assert(error == KERN_SUCCESS);
233 |
234 | size_t number;
235 | Class *classes(CYCopyClassList(number));
236 | assert(classes != NULL);
237 |
238 | CYChoice choice;
239 |
240 | //找到目标Class
241 | for (size_t i(0); i != number; ++i)
242 | for (Class current(classes[i]); current != Nil; current = class_getSuperclass(current))
243 | if (current == _class) {
244 | choice.query_.insert(classes[i]);
245 | break;
246 | }
247 |
248 | for (unsigned i(0); i != size; ++i) {
249 | const malloc_zone_t *zone(reinterpret_cast(zones[i]));
250 | if (zone == NULL || zone->introspect == NULL)
251 | continue;
252 |
253 | //枚举堆上的对象
254 | zone->introspect->enumerator(mach_task_self(), &choice, MALLOC_PTR_IN_USE_RANGE_TYPE, zones[i], &CYReadMemory, &choose_);
255 | }
256 | NSMutableArray * result = [[NSMutableArray alloc] init];
257 |
258 | for (auto iter = choice.results_.begin(); iter != choice.results_.end(); iter++) {
259 | [result addObject:(id)*iter];
260 | }
261 | return result;
262 | }
263 |
264 | NSString* choose(const char* classname){
265 | NSMutableString* result = [NSMutableString new];
266 | NSArray* results = choose_inner(classname);
267 | [result appendFormat:@"Find %lu instance objects in memory!\n" , (unsigned long)results.count];
268 | for (id item in results) {
269 | [result appendFormat:@"<%s: 0x%llx>\n", object_getClassName(item), (long long)item];
270 | }
271 | return result;
272 | }
273 |
274 | NSString* methods(const char * classname){
275 | return [objc_getClass(classname) performSelector:@selector(_shortMethodDescription)];
276 | }
277 |
278 | NSString* ivars(vm_address_t address){
279 | id target = (__bridge id)(void*)address;
280 | return [target performSelector:@selector(_ivarDescription)];
281 | }
282 |
283 | char * protection_bits_to_rwx (vm_prot_t p){
284 | static char returned[4];
285 |
286 | returned[0] = (p & VM_PROT_READ ? 'r' : '-');
287 | returned[1] = (p & VM_PROT_WRITE ? 'w' : '-');
288 | returned[2] = (p & VM_PROT_EXECUTE ? 'x' : '-');
289 | returned[3] = '\0';
290 |
291 | // memory leak here. No biggy
292 | return (strdup(returned));
293 | }
294 |
295 | const char * unparse_inheritance (vm_inherit_t i){
296 | switch (i){
297 | case VM_INHERIT_SHARE:
298 | return "share";
299 | case VM_INHERIT_COPY:
300 | return "copy";
301 | case VM_INHERIT_NONE:
302 | return "none";
303 | default:
304 | return "???";
305 | }
306 | }
307 |
308 | char * behavior_to_text (vm_behavior_t b){
309 | switch (b){
310 | case VM_BEHAVIOR_DEFAULT: return((char*)"default");
311 | case VM_BEHAVIOR_RANDOM: return((char*)"random");
312 | case VM_BEHAVIOR_SEQUENTIAL: return((char*)"fwd-seq");
313 | case VM_BEHAVIOR_RSEQNTL: return((char*)"rev-seq");
314 | case VM_BEHAVIOR_WILLNEED: return((char*)"will-need");
315 | case VM_BEHAVIOR_DONTNEED: return((char*)"will-need");
316 | case VM_BEHAVIOR_FREE: return((char*)"free-nowb");
317 | case VM_BEHAVIOR_ZERO_WIRED_PAGES: return((char*)"zero-wire");
318 | case VM_BEHAVIOR_REUSABLE: return((char*)"reusable");
319 | case VM_BEHAVIOR_REUSE: return((char*)"reuse");
320 | case VM_BEHAVIOR_CAN_REUSE: return((char*)"canreuse");
321 | default: return ((char*)"?");
322 | }
323 | }
324 |
325 | __BEGIN_DECLS
326 |
327 | extern kern_return_t mach_vm_region
328 | (
329 | vm_map_t target_task,
330 | mach_vm_address_t *address,
331 | mach_vm_size_t *size,
332 | vm_region_flavor_t flavor,
333 | vm_region_info_t info,
334 | mach_msg_type_number_t *infoCnt,
335 | mach_port_t *object_name
336 | );
337 |
338 | __END_DECLS
339 |
340 | NSString* vmmap(){
341 | vm_region_basic_info_data_t info, prev_info;
342 | mach_vm_address_t address = 1, prev_address;
343 | mach_vm_size_t size, prev_size;
344 | mach_msg_type_number_t count = VM_REGION_BASIC_INFO_COUNT_64;
345 | mach_port_t object_name;
346 |
347 | int nsubregions = 0;
348 | kern_return_t kr = mach_vm_region(mach_task_self(), &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&info, &count, &object_name);
349 |
350 | NSMutableString* result = [[NSMutableString alloc] init];
351 |
352 | if(kr != KERN_SUCCESS){
353 | [result appendFormat:@"mach_vm_region: Error %d - %s", kr, mach_error_string(kr)];
354 | return [result copy];
355 | }
356 |
357 | //保存之前查到的info
358 | memcpy (&prev_info, &info, sizeof (vm_region_basic_info_data_t));
359 | prev_address = address;
360 | prev_size = size;
361 | nsubregions = 1;
362 |
363 | while (true) {
364 | int print = 0, done = 0;
365 |
366 | address = prev_address + prev_size;
367 |
368 | if (address == 0){
369 | print = done = 1;
370 | }
371 |
372 | if (!done){
373 | kr = mach_vm_region (mach_task_self(), &address, &size, VM_REGION_BASIC_INFO, (vm_region_info_t)&info, &count, &object_name);
374 |
375 | if (kr != KERN_SUCCESS){
376 | [result appendFormat:@"mach_vm_region failed for address %llu - Error: %x\n",address, (kr)];
377 | print = done = 1;
378 | }
379 | }
380 |
381 | //等于才是连续的内存,不等于才打印
382 | if (address != prev_address + prev_size)
383 | print = 1;
384 |
385 | //或者权限信息改变了也打印
386 | if ((info.protection != prev_info.protection)
387 | || (info.max_protection != prev_info.max_protection)
388 | || (info.inheritance != prev_info.inheritance)
389 | || (info.shared != prev_info.reserved)
390 | || (info.reserved != prev_info.reserved))
391 | print = 1;
392 |
393 | if (print){
394 | char *print_size_unit = NULL;
395 |
396 | mach_vm_size_t print_size = prev_size;
397 | if (print_size > 1024) { print_size /= 1024; print_size_unit = (char*)"K"; }
398 | if (print_size > 1024) { print_size /= 1024; print_size_unit = (char*)"M"; }
399 | if (print_size > 1024) { print_size /= 1024; print_size_unit = (char*)"G"; }
400 |
401 | [result appendFormat:@" %p-%p [%llu%s](%s/%s; %s, %s, %s) %s",
402 | (void*)(prev_address),
403 | (void*)(prev_address + prev_size),
404 | print_size,
405 | print_size_unit,
406 | protection_bits_to_rwx (prev_info.protection),
407 | protection_bits_to_rwx (prev_info.max_protection),
408 | unparse_inheritance (prev_info.inheritance),
409 | prev_info.shared ? "shared" : "private",
410 | prev_info.reserved ? "reserved" : "not-reserved",
411 | behavior_to_text (prev_info.behavior)];
412 |
413 | if (nsubregions > 1)
414 | [result appendFormat:@" (%d sub-regions)", nsubregions];
415 |
416 | [result appendFormat:@"\n"];
417 | prev_address = address;
418 | prev_size = size;
419 | memcpy (&prev_info, &info, sizeof (vm_region_basic_info_data_t));
420 | nsubregions = 1;
421 | }else{
422 | prev_size += size;
423 | nsubregions++;
424 | }
425 |
426 | if (done)
427 | break;
428 | }
429 | return [result copy];
430 | }
431 |
432 |
433 |
--------------------------------------------------------------------------------