user2187400
user2187400

Reputation: 21

Hooking IVAR in theos error

I have decrypted some header files and this is the header file I would like to hook some ivars from it.

/**
 * This header is generated by class-dump-z 0.2a.
 * class-dump-z is Copyright (C) 2009 by KennyTM~, licensed under GPLv3.
 *
 * Source: (null)
 */

#import <XXUnknownSuperclass.h> // Unknown library
#import "InAppNotificationMessageViewDelegate.h"
#import "FBMSessionClassProvidable.h"

@class InAppNotificationContainerView, ProjectGatingChecker, FBMViewProvider, InAppNotificationBadgeCounter, FBMBeeperListFetcher;
@protocol FBMNavigator, FBProvider, FBMAppProperties;

@interface InAppNotificationManager : XXUnknownSuperclass <InAppNotificationMessageViewDelegate, FBMSessionClassProvidable> {
    id<FBMNavigator> _navigator;
    FBMBeeperListFetcher* _beeperListFetcher;
    InAppNotificationBadgeCounter* _badgeCounter;
    FBMViewProvider* _notificationMessageViewProvider;
    InAppNotificationContainerView* _notificationContainerView;
    FBMViewProvider* _notificationContainerViewProvider;
    id<FBMAppProperties> _appProperties;
    ProjectGatingChecker* _gatingChecker;
    id<FBProvider> _rootNavControllerProvider;
    id<FBProvider> _threadViewControllerProvider;
}
@property(retain, nonatomic) id<FBMAppProperties> appProperties;
@property(retain, nonatomic) id<FBProvider> threadViewControllerProvider;
@property(retain, nonatomic) id<FBMNavigator> navigator;
@property(retain, nonatomic) ProjectGatingChecker* gatingChecker;

So I would like to hook the gatingChecker ivar, I used logify and it created these lines:

%hook InAppNotificationManager


- (void)setGatingChecker:(ProjectGatingChecker* )gatingChecker { %log; %orig; }
- (ProjectGatingChecker* )gatingChecker { %log; ProjectGatingChecker*  r = %orig; NSLog(@" = %@", r); return r; }


%end

When I try to compile this, I get:

Tweak.xm:9: error: ‘ProjectGatingChecker’ has not been declared
Tweak.xm:9: error: ‘ProjectGatingChecker’ has not been declared
Tweak.xm:9: error: expected initializer before ‘*’ token
Tweak.xm:9: error: expected initializer before ‘*’ token
Tweak.xm:353: error: ‘ProjectGatingChecker’ has not been declared
Tweak.xm:354: error: expected initializer before ‘*’ token
Tweak.xm: In function ‘void _logosLocalInit()’:
Tweak.xm:361: error: ‘_logos_method$_ungrouped$InAppNotificationManager$gatingChecker’ was not declared in this scope
Tweak.xm:361: error: ‘_logos_orig$_ungrouped$InAppNotificationManager$gatingChecker’ was not declared in this scope
make[2]: *** [obj/Tweak.xm.673b4229.o] Error 1
make[1]: *** [internal-library-all_] Error 2

Upvotes: 2

Views: 1884

Answers (1)

johnny peter
johnny peter

Reputation: 4882

you hook into instance variables using MSHookIvar

ProjectGatingChecker *myGatingChecker = MSHookIvar<ProjectGatingChecker *>(self, "_gatingChecker");

You can now use myGatingChecker, which will be a pointer to the hooked variable.

Upvotes: 4

Related Questions