我正在使用 CellStumbler 获取 iPhone 的手机 ID、位置区号和其他信息。
调用 getInfo 后,我得到一个 EXC_BAD_ACCESS,我不知道为什么。这都是未记录的私有函数,但肯定有人可以提供帮助。该问题与函数中的任何行都无关,只有在运行它之后才会发生。
我知道这不是 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 的后遗症是一些内存修改。