iostheos

Access instance variable of dumped headers (iOS)


I want to know the value of "_lastNotificationReceivedBundleIdentifier" which is an instance variable of a class. The header is dumped from iOS springboard app.

@interface SBRemoteNotificationServer : NSObject <APSConnectionDelegate> {
    NSMutableDictionary* _bundleIdentifiersToClients;
    NSMutableDictionary* _environmentsToConnections;
    unsigned _lastPlayedAlertSound;
    NSString* _lastNotificationReceivedBundleIdentifier;
}

but the following code does not work:

%hook SBRemoteNotificationServer
-(void)noteApplicationFinishedLaunching:(id)launching{
    NSLog(@"identifier=%@",_lastNotificationReceivedBundleIdentifier);
    %orig;
}
%end

and the compiler error is:

error: ‘_lastNotificationReceivedBundleIdentifier’ was not declared in this scope

How do I access and log this NSString?


Solution

  • You could probably use the objective-c runtime capabilities and take a look at the method object_getInstanceVariable(the_object, "_lastNotificationReceivedBundleIdentifier", (void**)&yourPointer);