VC++ 定位特征码方法《方法来自 小蓝VC++ 传奇3 逆向三部曲》

xiaoxiao2025-04-09  16

 

VC++ 定位特征码方法《方法来自 小蓝VC++ 传奇3 逆向三部曲》 在此感谢小蓝的教程!! //格式化输出字符串信息 CString gameCall::formatString(CString msg,CString addr,CString value) { addr = msg + " " + "地址 ----> 0x" + addr + " "; value = "数值 ----> 0x" + value; return addr + value + "\r\n"; } /************************************************************************/ /*查找call地址 msgString 提示信息字符串 code 特征码数组 codeSize 数组长度 startAddr 开始查找地址 direction 查找方向 e8Count e8的数量 callValue call的数值 callAddr call的地址 --也就是e8的地址 /************************************************************************/ //第一种方法为查找连续的特征码方法,不连续的请看下面第二种 CString gameCall::findCallAddr(CString msgString,CString code[],int codeSize,long startAddr,int direction,int e8Count,int *callValue,int *callAddr) { int idx = 1; //默认向下找 if (direction == up) { idx = -1; //向上找则idx为-1 } bool bFind = false; CString addr = ""; CString value = ""; CString msg = msgString; int e8_count = 0; //e8的数量 也就是有几个call long searchAddr = startAddr; //搜索的起始地址 byte * pByte = (unsigned char *)searchAddr; //把起始地址以byte的显示,定义为byte指针类型 char* p = ""; int i = 0; //查找死码位置 while(i < 100000){ //10w次循环 直到找到和特征码匹配的 for (int j = 0;j < codeSize ;j++) { if (*(pByte + j) == strtol(code[j],&p,16)) { bFind = true; }else { bFind = false; break; } } if (bFind == true) { break; } /* if ((*pByte == 0xff) //查找非连续特征码的方法 && (*(pByte+ 0x1) == 0x08) && (*(pByte+ 0x2) == 0x00) && (*(pByte+ 0x3) == 0x00) && (*(pByte+ 0x4) == 0x00) && (*(pByte+ 0x5) == 0x3f) && (*(pByte+ 0x6) == 0x3f) && (*(pByte+ 0x7) == 0x3f) && (*(pByte+ 0x8) == 0x3f) ) { //str.Format("%x",pByte); break; } */ i++; pByte++; } //查找call的位置 while(i < 100000){ if ((*pByte == 0xe8)) { e8_count ++; if (e8_count == e8Count) { value.Format("%x",pByte); addr.Format("%x",pByte); break; } } i++; pByte += idx; } value.Format("%x",(pByte + (*(int *)(pByte + 1)) + 5)); if ( NULL != callAddr) { *callAddr = (int)pByte; } //计算call地址 if ( NULL != callValue) { *callValue = (int )(pByte + (*(int *)(pByte+1)) + 5); } return formatString(msg,addr,value); }

 

转载请注明原文地址: https://www.6miu.com/read-5027834.html

最新回复(0)