简体   繁体   English

iOS Theos Hook并设置ivar / property

[英]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. 我有以下类,我正在挂钩,我试图弄清楚如何挂钩和设置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? 有3个NSString ivars的setter,但没有m_proxyPort的setter,想知道是否有办法设置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

您可以按照相同的方式设置它。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM