菜鸟教程小白 发表于 2022-12-11 20:45:02

ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS


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

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

<p> <a href="http://code.google.com/p/iphone-wireless/source/browse/trunk/CellStumbler/main.c?r=140" rel="noreferrer noopener nofollow">Cell Stumbler</a> </p>

<p>我知道这不是 App Store 批准的。</p>

<pre><code>int cellcount;
_CTServerConnectionCellMonitorGetCellCount(&amp;t1,sc,&amp;cellcount);

printf(&#34;Cell count: %x\n&#34;,cellcount);

printf(&#34;Size = %lx\n&#34;, sizeof(struct CellInfo));

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

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

<p>这是上面 CellStumbler 项目中可用的 getCellInfo 函数。错误发生在 this 被调用之后,但不一定在这个函数中,只是在之后,好像运行 this 的后遗症是一些内存损坏。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我暂时解决了这个问题,删除了 for 循环,只运行 _CTServerConnectionCellMonitorGetCellInfo 一次。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/8532677/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/8532677/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 获取 Cell Info 后,抛出 EXC_BAD_ACCESS