Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Theos Hook and set ivar/property

I have the following class that I am hooking, I am trying to figure out how to hook and set m_proxyPort. I can read it without issue, but how about if I want to change it?

There is a setter for the 3 NSString ivars, but theres no setter for m_proxyPort, would like to know if there is a way to set that ivar?

@interface DDURLProtocol : NSURLProtocol <NSURLAuthenticationChallengeSender, DDURLProtocolHttpAdapterDelegate>
{
    int m_proxyPort;
    NSString *_proxyHost;
    NSString *_proxyUsername;
    NSString *_proxyPassword;
}


%hook DDURLProtocol

- (void) check 
{
   [self setProxyHost:@"127.0.0.1"];
   int pp = MSHookIvar<int>(self, "m_proxyPort");
   NSLog(@"proxyPort: %d", pp);
   // How to set m_proxyPort????
}


%end
like image 670
d123 Avatar asked Mar 13 '15 17:03

d123


1 Answers

You can set it the same way you get it.

MSHookIvar<int>(self, "m_proxyPort") = 23;
like image 146
Aaron Ash Avatar answered Oct 08 '22 23:10

Aaron Ash