OGeek|极客世界-中国程序员成长平台

标题: ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-11 20:45
标题: ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS

我正在使用 CellStumbler 获取 iPhone 的手机 ID、位置区号等信息。

调用 getInfo 后,我得到一个 EXC_BAD_ACCESS,但我不知道为什么。这都是未记录的私有(private)函数,但肯定有人可以提供帮助。该问题与函数中的任何行都没有关联,只有在运行它之后才会发生。

Cell Stumbler

我知道这不是 App Store 批准的。

  int cellcount;
_CTServerConnectionCellMonitorGetCellCount(&t1,sc,&cellcount);

printf("Cell count: %x\n",cellcount);

printf("Size = %lx\n", sizeof(struct CellInfo));

unsigned char *a=malloc(sizeof(struct CellInfo));

for(b=0;b<cellcount;b++)
{       
    _CTServerConnectionCellMonitorGetCellInfo(&t1,sc,b,a); memcpy(&cellinfo,a,sizeof(struct CellInfo));
    printf("Cell Site: %d, MNC: %d, ",b,cellinfo.servingmnc);
    printf("Location: %d, Cell ID: %d, Station: %d, ",cellinfo.location, cellinfo.cellid, cellinfo.station);
    printf("Freq: %d, RxLevel: %d, ", cellinfo.freq, cellinfo.rxlevel);
    printf("C1: %d, C2: %d\n", cellinfo.c1, cellinfo.c2);
}
if(a) free(a);

这是上面 CellStumbler 项目中可用的 getCellInfo 函数。错误发生在 this 被调用之后,但不一定在这个函数中,只是在之后,好像运行 this 的后遗症是一些内存损坏。



Best Answer-推荐答案


我暂时解决了这个问题,删除了 for 循环,只运行 _CTServerConnectionCellMonitorGetCellInfo 一次。

关于ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8532677/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4