获取单元信息后,引发EXC_BAD_ACCESS

我正在使用CellStumbler获取iPhone的手机ID,位置区号和其他信息。

调用getInfo后,我得到一个EXC_BAD_ACCESS,我不明白为什么。 这是所有无证的私人function,但肯定有人可以帮助。 这个问题与函数中的任何行都没有关联,只是在运行之后才发生。

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函数。 这个错误发生在这个被调用之后,但是不一定在这个函数中,只有在这之后,仿佛运行这个后来的效果才是一些内存损坏。

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