Skip to content

Instantly share code, notes, and snippets.

Class gCtl = NSClassFromString(@"GameController");
Method getMD5ByGameContent = class_getClassMethod(gCtl, @selector(getMD5ByGameContent:));
Method getMD5ByGameContent_hooked = class_getClassMethod(self, @selector(getMD5ByGameContent_hooked:));
...
Class metaClass = objc_getMetaClass(class_getName(gCtl));
class_replaceMethod(metaClass, ...
class_replaceMethod(metaClass, ...
- (void)StartUpload_hooked:(id)arg1 {
CMessageWrap *wrap = (CMessageWrap *)arg1;
if (wrap.m_uiGameType == 2) {
[self StartUpload_hooked:setDice(arg1, 6)];
} else if (wrap.m_uiGameType == 1) {
[self StartUpload_hooked:setJsb(arg1, 1)];
} else {
[self StartUpload_hooked:arg1];
}
}
class_replaceMethod(upMgr, @selector(StartUpload_hooked:), orig, method_getTypeEncoding(StartUpload));
class_replaceMethod(upMgr, @selector(StartUpload:), swz, method_getTypeEncoding(StartUpload_hooked));
IMP orig = method_getImplementation(StartUpload);
IMP swz = method_getImplementation(StartUpload_hooked);
@Li-blog
Li-blog / WeChatDiceEntry.m
Created October 28, 2016 10:34
WeChatDiceEntry
+ (void)load {
Class upMgr = NSClassFromString(@"CEmoticonUploadMgr");
Method StartUpload = class_getInstanceMethod(upMgr, @selector(StartUpload:));
Method StartUpload_hooked = class_getInstanceMethod(self, @selector(StartUpload_hooked:));
...
}
@Li-blog
Li-blog / WeChatDiceEntry.h
Created October 28, 2016 10:31
WeChatDiceEntry class in WeChatDice.framework
//
// WeChatDiceEntry.h
// WeChat
//
// Created by Wang Jinli on 2016/10/28.
// Copyright © 2016 Wang Jinli. All rights reserved.
//
#import <Foundation/Foundation.h>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/ PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.springboard.debugapplications</key>
<true/>
<key>run-unsigned-code</key>
<true/>
<key>get-task-allow</key>
<true/>
%ctor {
if ([WCPreferencesManager sharedManager].lockScreenEnabled) {
%init(LockScreen);
}
if ([WCPreferencesManager sharedManager].nCEnabled) {
%init(NotificationCenter);
}
}
NSString *getWeekStr(int weekInt) {
NSDate *startDate = [WCPreferencesManager sharedManager].startDate;
NSInteger dur = [WCPreferencesManager sharedManager].duration;
NSInteger startDay = [[WCPreferencesManager sharedManager].weekStartDay isEqualToString:@"Monday"] ? 1 : 0;
WCSemester *sem = [[WCSemester alloc] initWithStartDate:startDate duration:dur weekStartAt:startDay];
NSInteger week = [sem weekNo:[NSDate date]];
if (week == -1) { return @""; }
else {
NSString *display = [WCPreferencesManager sharedManager].displayFormat;
display = [display stringByReplacingOccurrencesOfString:@"\%W" withString:[NSString stringWithFormat:@"%ld", (long)week + weekInt]];
-(void)_preferencesChanged {
CFStringRef appID = CFSTR("com.wangjinli.weekcountpb");
CFArrayRef keyList = CFPreferencesCopyKeyList(appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);
if (!keyList) {
[self attemptSettingFallbackPrefs];
return;
}
NSDictionary *preferences = (NSDictionary *)CFBridgingRelease(CFPreferencesCopyMultiple(keyList, appID, kCFPreferencesCurrentUser, kCFPreferencesAnyHost));
CFRelease(keyList);
if (!preferences) {