-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathTweak.xm
392 lines (241 loc) · 12.7 KB
/
Tweak.xm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
#import "WeChatRedEnvelop.h"
#import "HongBaoRes.h"
#import "SKBuiltinBuffer_t.h"
#import "HongBaoReq.h"
#import "ProtobufCGIWrap.h"
%hook CMessageMgr
- (void)AsyncOnAddMsg:(NSString *)msg MsgWrap:(CMessageWrap *)wrap {
%orig;
NSLog(@" type: %@ message : %@",msg , wrap);
switch(wrap.m_uiMessageType) {
case 49: { // AppNode
CContactMgr *contactManager = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("CContactMgr") class]];
CContact *selfContact = [contactManager getSelfContact];
BOOL isMesasgeFromMe = NO;
if ([wrap.m_nsFromUsr isEqualToString:selfContact.m_nsUsrName]) {
isMesasgeFromMe = YES;
}
if ([wrap.m_nsContent rangeOfString:@"wxpay://"].location != NSNotFound) { // 红包
if ([wrap.m_nsFromUsr rangeOfString:@"@chatroom"].location != NSNotFound ||
(isMesasgeFromMe && [wrap.m_nsToUsr rangeOfString:@"@chatroom"].location != NSNotFound)) { // 群组红包或群组里自己发的红包
NSString *nativeUrl = [[wrap m_oWCPayInfoItem] m_c2cNativeUrl];
NSLog(@" receiveHongbao: %@", nativeUrl);
nativeUrl = [nativeUrl substringFromIndex:[@"wxpay://c2cbizmessagehandler/hongbao/receivehongbao?" length]];
NSDictionary *nativeUrlDict = [%c(WCBizUtil) dictionaryWithDecodedComponets:nativeUrl separator:@"&"];
NSLog(@" select: %@", [%c(WCBizUtil) getWCRedEnvelopesLastRadomHBSelctedCountPath]);
/** 构造参数 */
NSMutableDictionary *params = [@{} mutableCopy];
params[@"msgType"] = nativeUrlDict[@"msgtype"] ?: @"1";
params[@"sendId"] = nativeUrlDict[@"sendid"] ?: @"";
params[@"channelId"] = nativeUrlDict[@"channelid"] ?: @"1";
params[@"nickName"] = [selfContact getContactDisplayName] ?: @"小锅";
params[@"headImg"] = [selfContact m_nsHeadImgUrl] ?: @"";
params[@"nativeUrl"] = [[wrap m_oWCPayInfoItem] m_c2cNativeUrl] ?: @"";
params[@"sessionUserName"] = wrap.m_nsFromUsr ?: @"";
NSLog(@"url params : %@",params);
WCRedEnvelopesLogicMgr *logicMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCRedEnvelopesLogicMgr") class]];
[logicMgr OpenRedEnvelopesRequest:params];
// [logicMgr AsyncBizSubcribeRequest:params];
// [logicMgr ReceiverQueryRedEnvelopesRequest:params];
// [logicMgr QueryRedEnvelopesDetailRequest:params];
// [logicMgr GenRedEnvelopesPayRequest:params];
// WCSnsRedEnvelopesLogicMgrV4 *logicMgr4 = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCSnsRedEnvelopesLogicMgrV4") class]];
//[logicMgr4 GenRedEnvelopesPayRequest:params];
}
}
break;
}
default:
break;
}
}
%end
%hook WCRedEnvelopesLogicMgr
// Hook openRedEnvelop Event
- (void)OpenRedEnvelopesRequest:(id)params {
%log;
%orig;
//NSLog(@" : %@",params);
}
/*
-(void)GetHongbaoBusinessRequest:(id)request CMDID:(unsigned long)cmdid OutputType:(unsigned long)type {
%log;
HongBaoReq * req = [[objc_getClass("HongBaoReq") alloc] init]; // [%c(HongBaoReq) init]; //[[HongBaoReq alloc] init];
SKBuiltinBuffer_t * bufferA = [[objc_getClass("SKBuiltinBuffer_t") alloc] init]; //[%c(SKBuiltinBuffer) init]; //[[SKBuiltinBuffer_t alloc] init];
NSLog(@"------------------------------------------");
NSMutableDictionary * dictionary = [NSMutableDictionary dictionary];
//NSString * redEnv = @"WCRedEnvelopes";
//NSData * data = [NSData dataWithBytes:[redEnv UTF8String] length:redEnv.length];
NSDictionary * dic = (NSDictionary *)request;
[dic.allKeys enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
NSString * key = (NSString *)obj;
[dictionary safeSetObject:[[dic objectForKey:key] gtm_stringByEscapingForURLArgument] forKey:key];
}];
// NSDictionary * newdic = @{redEnv:dictionary};
NSString * strEncoding = [%c(WCBizUtil) stringWithFormEncodedComponentsAscending:dictionary ascending:YES skipempty:YES separator:@"&"];
NSLog(@"string encoding : %@",strEncoding);
//NSLog(@"---- %@ ",newdic);
// Get request string.
NSData * data1 = [NSData dataWithBytes:[strEncoding UTF8String] length:strEncoding.length];
[bufferA setBuffer:data1];
[bufferA setILen:strEncoding.length];
[req setReqText:bufferA];
[req setCgiCmd:cmdid];
[req setOutPutType:type];
//WCRedEnvelopesLogicMgr *logicMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCRedEnvelopesLogicMgr") class]];
WCRedEnvelopesNetworkHelper * netHelper = [[objc_getClass("WCRedEnvelopesNetworkHelper") alloc] init];
// [[ WCRedEnvelopesNetworkHelper alloc] init]; //[logicMgr m_networkHelper];
netHelper.m_delegate = (id<WCRedEnvelopesNetworkHelperDelegate>)self;
[netHelper WCToEnterpriseCommonBizReq:req];
NSLog(@" ------- send ok -----------");
// %orig;
// %log;
}
*/
-(void)ReceiverQueryRedEnvelopesRequest:(id)request {
%log;
NSLog(@"rece res: %@",request);
%orig;
}
-(void)OnWCToHongbaoCommonResponse:(id)hongbaoCommonResponse Request:(id)request {
%log;
NSLog(@"================success hongbao =============");
NSLog(@"%@",[NSThread callStackSymbols]);
HBLogDebug(@" hongbaoCommonResponse %@",hongbaoCommonResponse);
HongBaoRes *hongbaores = (HongBaoRes *)hongbaoCommonResponse;
SKBuiltinBuffer_t *buffer = [hongbaores retText];
// JSON String:
NSString * jsonstring = [[NSString alloc] initWithData:buffer.buffer encoding:NSUTF8StringEncoding];
NSDictionary * dic = [NSDictionary dictionaryWithDictionary: [jsonstring JSONDictionary]];
NSLog(@"dic %@",dic);
if (dic != nil) {
int aa = [[dic objectForKey:@"amount"] integerValue];
int bb = [[dic objectForKey:@"totoalAmount"] integerValue];
//int bb = (int)tamount;
//int aa = (int)amount;
NSString * notify = [NSString stringWithFormat:@"成功抢到红包%f元,总共:%f元",float(aa)/10,float(bb)/10 ] ;
//定义本地通知对象
UILocalNotification *notification=[[UILocalNotification alloc]init];
notification.fireDate=[NSDate dateWithTimeIntervalSinceNow:0.2];
notification.repeatInterval=1;
notification.alertBody= notify;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
// JSON Requset:
HongBaoReq * requests = (HongBaoReq *) request;
SKBuiltinBuffer_t *bufferq = [requests reqText];
NSString * jsonstringRes = [[NSString alloc] initWithData:bufferq.buffer encoding:NSUTF8StringEncoding];
NSDictionary * dicRes = [NSDictionary dictionaryWithDictionary: [jsonstringRes JSONDictionary]];
// WCRedEnvelopesLogicMgr *logicMgr = [[objc_getClass("MMServiceCenter") defaultCenter] getService:[objc_getClass("WCRedEnvelopesLogicMgr") class]];
// [logicMgr SendShareRedEnvelopesoRequest:request];
NSLog(@"parseFromData :%@",dicRes );
NSLog(@" request data: %@ ", request );
NSLog(@"============receive hongbao success end=================");
%orig;
}
-(void)OnWCToHongbaoCommonErrorResponse:(id)hongbaoCommonErrorResponse Request:(id)request {
}
-(void)OnWCToHongbaoCommonSystemErrorResponse:(id)hongbaoCommonSystemErrorResponse Request:(id)request {
}
%end
%hook WCRedEnvelopesControlLogic
- (NSString* )debugDescription { %log; NSString* r = %orig; HBLogDebug(@" = %@", r); return r; }
- (NSString* )description { %log; NSString* r = %orig; HBLogDebug(@" = %@", r); return r; }
- (Class )superclass { %log; Class r = %orig; HBLogDebug(@" = %@", r); return r; }
- (unsigned )hash { %log; unsigned r = %orig; HBLogDebug(@" = %u", r); return r; }
-(void)OnWCRedEnvBizBaseRequestCommonSystemError:(id)error HBCmdType:(int)type { %log; %orig; }
-(void)OnWCRedEnvBizBaseRequestCommonError:(id)error HBCmdType:(int)type { %log; %orig; }
-(void)OnWCRedEnvEnterpriseBaseRequestCommonSystemError:(id)error HBCmdType:(int)type { %log; %orig; }
-(void)OnWCRedEnvEnterpriseBaseRequestCommonError:(id)error HBCmdType:(int)type { %log; %orig; }
-(void)OnWCRedEnvelopesBaseRequestCommonSystemError:(id)error HongbaoCmdType:(int)type { %log; %orig; }
-(void)OnWCRedEnvelopesBaseRequestCommonError:(id)error HongbaoCmdType:(int)type { %log; %orig; }
-(BOOL)onNeedToControlCurrentPublicError { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
-(BOOL)onError:(id)error { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
-(void)onErrorAlertViewDismiss:(id)dismiss { %log; %orig; }
-(void)onErrorAlertViewStopLogic:(id)logic { %log; %orig; }
-(BOOL)OnCheckDismissCurrentViewControllerAndStopLogicAfterDismiss { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
-(BOOL)OnCheckDismissCurrentViewControllerAndStopLogicBeforeDismiss { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
-(void)stopLoading { %log; %orig; }
-(void)startWCPayLoading { %log; %orig; }
-(void)startLoading { %log; %orig; }
-(void)stopLogic { %log; %orig; }
-(id)initWithData:(id)data { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
-(id)init { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
%end
%hook WCRedEnvelopesNetworkHelper
+(void)idkeyCmdReport:(unsigned long)report keyName:(id)name value:(unsigned long)value { %log; %orig; }
+(void)idkeyCmdReport:(unsigned long)report keyName:(id)name { %log; %orig; }
-(void)MessageReturn:(id)aReturn Event:(unsigned long)event { %log; %orig; }
-(void)MessageReturnOnAsyncBizSubScribe:(id)scribe Event:(unsigned long)event { %log; %orig; }
-(void)MessageReturnOnCommonBizHongbao:(id)hongbao Event:(unsigned long)event { %log; %orig;
NSLog(@"========= message return on hongbao msg: ====================");
NSLog(@"%@",[NSThread callStackSymbols]);
HBLogDebug(@" hongbaoCommonResponse %@",hongbao);
ProtobufCGIWrap *hongbaores = (ProtobufCGIWrap *)hongbao;
// JSON String:
NSString * jsonstring = [[NSString alloc] initWithData:hongbaores.m_dtResponseDecryptKey encoding:NSUTF8StringEncoding];
NSDictionary * dic = [NSDictionary dictionaryWithDictionary: [jsonstring JSONDictionary]];
NSLog(@"dic %@",dic);
WXPBGeneratedMessage* m_pbResponse = hongbaores.m_pbResponse;
NSLog(@"%@ - %lu - %@ - %@ - %@ - %@ ", hongbaores.m_eventHandlerClass, hongbaores.m_uiMessage, hongbaores.m_nsUri, hongbaores.m_nsCgiName, hongbaores.m_pbRespClass, hongbaores.debugDescription);
NSLog(@" ->>> %@ %@", hongbaores.m_pbResponse , m_pbResponse.baseResponse );
HongBaoRes *hongbaores1 = (HongBaoRes *) hongbaores.m_pbResponse;
SKBuiltinBuffer_t *buffer = [hongbaores1 retText];
// JSON String:
NSString * jsonstring1 = [[NSString alloc] initWithData:buffer.buffer encoding:NSUTF8StringEncoding];
NSDictionary * dic1 = [NSDictionary dictionaryWithDictionary: [jsonstring1 JSONDictionary]];
NSLog(@"dic %@",dic1);
if (dic1 != nil) {
NSString * msg = (NSString *)[dic1 objectForKey:@"retmsg"];
NSLog(@"error: %@",msg);
}
}
-(void)MessageReturnOnEnterpriseHongbao:(id)hongbao Event:(unsigned long)event { %log; %orig; }
-(void)MessageReturnOnHongbao:(id)hongbao Event:(unsigned long)event { %log; %orig;
NSLog(@"========= message return on hongbao msg: ====================");
NSLog(@"%@",[NSThread callStackSymbols]);
HBLogDebug(@" hongbaoCommonResponse %@",hongbao);
ProtobufCGIWrap *hongbaores = (ProtobufCGIWrap *)hongbao;
// JSON String:
NSString * jsonstring = [[NSString alloc] initWithData:hongbaores.m_dtResponseDecryptKey encoding:NSUTF8StringEncoding];
NSDictionary * dic = [NSDictionary dictionaryWithDictionary: [jsonstring JSONDictionary]];
NSLog(@"dic %@",dic);
WXPBGeneratedMessage* m_pbResponse = hongbaores.m_pbResponse;
NSLog(@"%@ - %lu - %@ - %@ - %@ - %@ ", hongbaores.m_eventHandlerClass, hongbaores.m_uiMessage, hongbaores.m_nsUri, hongbaores.m_nsCgiName, hongbaores.m_pbRespClass, hongbaores.debugDescription);
NSLog(@" ->>> %@ %@", hongbaores.m_pbResponse , m_pbResponse.baseResponse );
HongBaoRes *hongbaores1 = (HongBaoRes *) hongbaores.m_pbResponse;
SKBuiltinBuffer_t *buffer = [hongbaores1 retText];
// JSON String:
NSString * jsonstring1 = [[NSString alloc] initWithData:buffer.buffer encoding:NSUTF8StringEncoding];
NSDictionary * dic1 = [NSDictionary dictionaryWithDictionary: [jsonstring1 JSONDictionary]];
NSLog(@"dic %@",dic1);
if (dic1 != nil) {
NSString * msg = (NSString *)[dic1 objectForKey:@"retmsg"];
NSLog(@"error: %@",msg);
}
}
-(void)WCToAsyncBizSubcribeReq:(id)asyncBizSubcribeReq { %log; %orig;
}
-(void)WCToEnterpriseCommonBizReq:(id)enterpriseCommonBizReq { %log; %orig; }
-(void)WCToEnterpriseHBBizReq:(id)enterpriseHBBizReq { %log; %orig; }
-(void)WCToHongbaoCommonRequest:(id)hongbaoCommonRequest { %log; %orig; }
-(id)init { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
%end
%hook NotificationActionsMgr
-(void)handleReceiveLocalNotification:(id)notification {
%log;
%orig;
}
-(void)handleStatusNotifyResp:(id)resp {
%log;
%orig;
}
-(void)handleSendMsgResp:(id)resp{
%log;
%orig;
}
-(void)handleSetPushMuteResp:(id)resp{
%log;
%orig;
}
%end