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);

}

你可能感兴趣的:(Hook-移动办公)