Hook-移动办公

这里给出核心的hook代码,具体见

#import "CaptainHook.h"#import#import//Hook的class

CHDeclareClass(AttendanceViewController);

//Hook的函数

//-(void)checkButton:(int)button;

CHMethod(1, void, AttendanceViewController, checkButton, int, button)

{

if (button == 2) {

CLLocationCoordinate2D coordinate;

coordinate.latitude = 30.183031 + (rand()%10)/10000.0;

coordinate.longitude = 120.1722623 + (rand()%10)/10000.0;

CLLocation *newLocation = [[CLLocation alloc]initWithLatitude:coordinate.latitude longitude:coordinate.longitude];

[self setValue:newLocation forKey:@"locationUser"]; //Use kvc set new value

UIAlertView *testAlert = [[UIAlertView alloc] initWithTitle:@"Haha~" message:@"打卡成功啰" delegate:self

cancelButtonTitle:@"OK" otherButtonTitles:nil];

[testAlert show];

}

CHSuper(1, AttendanceViewController, checkButton, button);

}

__attribute__((constructor)) static void entry()

{

CHLoadLateClass(AttendanceViewController);

CHClassHook(1, AttendanceViewController, checkButton);

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容