iPhone Wifi Scan Stumbler

吃可爱长大的小学妹 提交于 2019-12-12 16:34:20

问题


I am trying to use the SOLStumbler from here: Accessing & Using the MobileWiFi.framework to scan for wifi networks. I am aware that this is not supported by apple but it is for educational purposes and experiments. I add the following files to my application and it compiles fine but it always exits with an error code. (As part of the ".m" file.) Does anyone know how to get this working?

SOLStumbler.h:

SOLStumbler.m:

This part of SOLStumbler.m always outputs a single letter error. Normally e but sometimes u.

libHandle = dlopen("/System/Library/SystemConfiguration/WiFiManager.bundle/WiFiManager", RTLD_LAZY);

    char *error;
    if (libHandle == NULL && (error = dlerror()) != NULL)  {
            NSLog(@"%c",error);
            exit(1);
    }

My ViewController code:

#import "SOLStumbler.h"

-(void)viewDidLoad{
    SOLStumbler *networksManager = [[SOLStumbler alloc] init];      
    [networksManager scanNetworks]; 
    NSLog(@"%@", [networksManager description]);
    [networksManager release];  
}

回答1:


The SOLStumbler code you're trying to use is pretty old. This stuff (e.g. WiFiManager) is in a private framework. That means Apple can, and often will, change it or move if from OS version to version.

I assume you're now using iOS 5?

I logged in to my iOS 5 phone, and indeed,

/System/Library/SystemConfiguration/WiFiManager.bundle/

does not exist. So that's why your code fails.

Have a look at this useful thread.

It looks like you can now find equivalent (?) functions in the IPConfiguration framework. Try this code:

libHandle = dlopen("/System/Library/SystemConfiguration/IPConfiguration.bundle/IPConfiguration", RTLD_LAZY);

I ran it on a jailbroken iOS 5.0.1 phone and it worked (loaded the dylib and found a few of the Apple80211 functions). From that thread I linked to, it looks like you may need to have this installed in /Applications on a jailbroken phone, in order to work fully. Or, possibly have to mess around with adding some entitlements to your sandboxed app.



来源:https://stackoverflow.com/questions/11660169/iphone-wifi-scan-stumbler

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!