我正在使用CellStumbler来获取iPhone的手机ID、位置区号和其他信息。
在调用getInfo之后,我得到了一个EXC_BAD_ACCESS,但我不知道为什么。这些都是没有文档记录的私有函数,但肯定有人能帮上忙。这个问题与函数中的任何一行都没有关联,只有在运行它之后才会发生。
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函数。错误发生在调用此函数之后,但不一定在此函数中,只是在之后,就好像运行此函数的后遗症是一些内存损坏。
发布于 2011-12-19 17:54:31
我暂时解决了这个问题,删除了for循环,只运行_CTServerConnectionCellMonitorGetCellInfo一次。
https://stackoverflow.com/questions/8532677
复制相似问题