if(searchIpNum<0xFF)...{
return -1;
}
ifstream fs;
fs.open(dat, ios::binary | ios::in, 0);
if((!fs.is_open()) || (!fs.good())) ...{
return -2;
}
#if defined _DEBUG_
cout<<" searchIpNum="<<searchIpNum<<", exeOffset="<<exeOffset<<endl;
#endif
fs.seekg(exeOffset, ios_base::beg);
ipBeginPos=read4Bit(fs);
#if defined _DEBUG_
cout<<" ipBeginPos="<<ipBeginPos<<endl;
#endif
ipEndPos=read4Bit(fs);
#if defined _DEBUG_
cout<<" ipEndPos="<<ipEndPos<<endl;
#endif
totalNum = (ipEndPos - ipBeginPos) / 7;
#if defined _DEBUG_
cout<<" totalNum="<<totalNum<<endl;
#endif
if(totalNum<1)...{
return -3;
}
beginNum = 0;
endNum = totalNum;
while( 1 ) ...{ //IP的索引是有順序的,按照個數來二分查找.
midNum= beginNum+(DWORD)((endNum - beginNum)/2);
pos = ipBeginPos+midNum*7;
fs.seekg(exeOffset+pos, ios_base::beg);
#if defined _DEBUG_
cout<<"times="<<++times<<", beginNum="<<beginNum<<", endNum="<<endNum
<<", midNum="<<midNum<<", exeOffset+pos="<<exeOffset+pos
<<endl;
#endif
ip1Num=read4Bit(fs);
if( ip1Num<1 ) ...{
fs.close(); cout<<"[1]while(){...}"<<endl;
return -2;
}
#if defined _DEBUG_
//printIpNum(ip1Num);
#endif
fs.seekg(3, ios_base::cur);
ip2Num=read4Bit(fs);
if( ip2Num<1 ) ...{
fs.close(); cout<<"[3]while(){...}"<<endl;
return -2;
}
#if defined _DEBUG_
//printIpNum(ip2Num);
#endif