今天在逆向一款经典软件,创建软件里面一个类的对象,调用里面的方法却没有在控制台打印,挺疑惑的

贴出tweak代码
就是LocationRetriever这个类,然后在button的点击事件中创建一个LocationRetriever对象 并调用LocationRetriever的对象方法 在xcode控制台并没有打印,而且用lldb下断点也没反应,通过打印测试(“11111111111”) 可以确定点击事件确实执行了 懂得大神给小弟指点一下。

%hook LocationRetriever

  • (double)getLocationAccuracy:(id)arg1 { %log; double r = %orig; HBLogDebug(@" = %f", r); return r; }
  • (void)CancelRetrieveHeading { %log; %orig; }
  • (void)CancelRetrieveLocation { %log; %orig; }
  • (void)CleanDelegate { %log; %orig; }
  • (void)Reset { %log; %orig; }
  • (void)RetrieveHeading { %log; %orig; }
  • (void)RetrieveLocation { %log; %orig; }
  • (void)addToRecentLocationList:(id)arg1 { %log; %orig; }
  • (unsigned int)countOfRecentLocationList { %log; unsigned int r = %orig; HBLogDebug(@" = %u", r); return r; }
  • (void)dealloc { %log; %orig; }
  • (id)getBestResultFromLocationList { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
  • (id)initWithDelegate:(id)arg1 { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
  • (BOOL)isHeadingOK:(id)arg1 { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (BOOL)isLocationOK:(id)arg1 { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (void)setM_bCanRepeatReportLocation:(BOOL )m_bCanRepeatReportLocation { %log; %orig; }
  • (BOOL )m_bCanRepeatReportLocation { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (void)setM_bShieldAccuracy:(BOOL )m_bShieldAccuracy { %log; %orig; }
  • (BOOL )m_bShieldAccuracy { %log; BOOL r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (void)setM_delegate:(id )m_delegate { %log; %orig; }
  • (id )m_delegate { %log; id r = %orig; HBLogDebug(@" = 0x%@", r ); return r; }
  • (void)setM_eBusType:(unsigned int )m_eBusType { %log; %orig; }
  • (unsigned int )m_eBusType { %log; unsigned int r = %orig; HBLogDebug(@" = %u", r); return r; }
  • (void)setM_geoMode:(int )m_geoMode { %log; %orig; }
  • (int )m_geoMode { %log; int r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (void)setM_recentLocationList:(NSMutableArray *)m_recentLocationList { %log; %orig; }
  • (NSMutableArray *)m_recentLocationList { %log; NSMutableArray * r = %orig; HBLogDebug(@" = %@", r); return r; }
  • (void)setM_requiredAccuracy:(float )m_requiredAccuracy { %log; %orig; }
  • (float )m_requiredAccuracy { %log; float r = %orig; HBLogDebug(@" = %f", r); return r; }
  • (void)setM_sysCacheUpdater:(id )m_sysCacheUpdater { %log; %orig; }
  • (id )m_sysCacheUpdater { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
  • (void)setM_timeoutCount:(int )m_timeoutCount { %log; %orig; }
  • (int )m_timeoutCount { %log; int r = %orig; HBLogDebug(@" = %d", r); return r; }
  • (id)objectInRecentLocationListAtIndex:(unsigned int)arg1 { %log; id r = %orig; HBLogDebug(@" = %@", r); return r; }
  • (void)onGPSLocationChanged:(id)arg1 withTag:(unsigned long)arg2 { %log; %orig; }
  • (void)onGPSLocationError:(int)arg1 withTag:(unsigned long)arg2 { %log; %orig; }
  • (void)onGpsTimerTimeCheck { %log; %orig; }
  • (void)onHeadingChanged:(id)arg1 withTag:(unsigned long)arg2 { %log; %orig; }
  • (void)onHeadingTimeCheck { %log; %orig; }
  • (void)onMapLocationChanged:(id)arg1 withTag:(int)arg2 { %log; %orig; }
  • (void)onMapLocationError:(id)arg1 withTag:(int)arg2 { %log; %orig; }
  • (void)reportRetriever:(id)arg1 retrieverSuccess:(BOOL)arg2 inCache:(BOOL)arg3 { %log; %orig; }
  • (void)stopCheckTimer { %log; %orig; }
    %end

@interface SeePeopleNearByLogicController : NSObject

  • (void)OnUpdateCertInfo;
  • (void)updateLbsContactInfo;
    @end
    @interface SeePeopleNearbyViewController : UIViewController
    @property(retain, nonatomic) SeePeopleNearByLogicController *logicController;
    @property(null_resettable, nonatomic,strong) UIView *view;
  • (void)onRefreshMyFriends;
  • (void)startLoading;
    @end

%hook SeePeopleNearbyViewController

  • (void)viewDidLoad{
    %orig;
    %log;
    UIButton * button = [[UIButton alloc]initWithFrame:CGRectMake(100, 100, 100, 100)];
    button.backgroundColor = [UIColor redColor];
    [button addTarget:self action:@selector(redButtonClick) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:button];

}
%new
-(void)redButtonClick{

//[self onRefreshMyFriends];
//[self startLoading];
// [self.logicController updateLbsContactInfo];

LocationRetriever * retriever = [[%c(LocationRetrieve) alloc]initWithDelegate:self.logicController];

NSLog(@"111111111111 ");
[retriever setM_eBusType:2];
[retriever Reset];
[retriever RetrieveLocation];

}

%end

哎,我的阅读能力有问题。。。。并没有打印什么?

只打印了 111111111 所以没贴出来 创建了LocationRetrieve这个类的对象 却没有执行对象方法

问题已解决,谢谢各位大神:grinning:

解决方法贴一下啦,万一以后有小伙伴遇到哈

没脸贴:joy:

那低级错误,也算个原因啦

LocationRetrieve 少个“r”, 哈哈 也不知道为什么不报错和崩机

可以看看%c的原理,估计就是当字符串 NSClassFromString 之类的了:joy:

好的喃,大神,早点休息