5
votes

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
1

1 Answers

9
votes

You can set it the same way you get it.

MSHookIvar<int>(self, "m_proxyPort") = 23;