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

 

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);
}

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值