Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why I don't bind CFReadStreamCreateForHTTPRequest, #71

Open
jscpkare opened this issue Jan 7, 2020 · 1 comment
Open

Why I don't bind CFReadStreamCreateForHTTPRequest, #71

jscpkare opened this issue Jan 7, 2020 · 1 comment

Comments

@jscpkare
Copy link

jscpkare commented Jan 7, 2020

@implementation UIViewController (Hook1)
+(void)load {
    struct rebinding _request_binding = { "CFReadStreamCreateForHTTPRequest", wt_CFReadStreamCreateForHTTPRequest, (void *)&original_CFReadStreamCreateForHTTPRequest};

    struct rebinding rebs[]={_request_binding};
    rebind_symbols(rebs, 1);
}

static CFReadStreamRef
wt_CFReadStreamCreateForHTTPRequest(CFAllocatorRef __nullable alloc, CFHTTPMessageRef request);
CFReadStreamRef wt_CFReadStreamCreateForHTTPRequest(CFAllocatorRef __nullable alloc, CFHTTPMessageRef request) {
    
    NSURL *url = (__bridge NSURL *)CFHTTPMessageCopyRequestURL(request);
    NSString *method = (__bridge NSString *)CFHTTPMessageCopyRequestMethod(request);
    
    CFReadStreamRef readStream = original_CFReadStreamCreateForHTTPRequest(alloc, request);
    
    return readStream;
}

static CFReadStreamRef (*original_CFReadStreamCreateForHTTPRequest)(CFAllocatorRef, CFHTTPMessageRef);
@end

This's my code, bind CFNetwork CFReadStreamCreateForHttpRequest function, I want monitoring network status, but, i don't recive result in wt_CFReadStreamCreateForHTTPRequest function, please help me, thanks

@daybreak1024
Copy link

hi, It works in my project in your way, maybe you are not using the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants