原函数如下:
#include<iostream>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
int psw=10010;
int input_psw;
cout<<"please input the password\n";
cin>>input_psw;
if(psw==input_psw)
{
cout<<"gradutaions\n";
}
else
{
cout<<"sorry";
}
return 0;
}
现在只需要找到if(psw==input_psw)对应的指令即可
.text:00401027 call ds:__imp_??5?$basic_istream@DU?$char_traits@D@std@@@std@@QAEAAV01@AAH@Z ; std::basic_istream<char,std::char_traits<char>>::operator>>(int &)
.text:0040102D cmp [esp+8+input_psw], 271Ah
.text:00401035 jnz short loc_401051
.text:00401037 mov edx, ds:__imp_?cout@std@@3V?$basic_ostream@DU?$char_traits@D@std@@@1@A ;
.text:0040103D push offset aGradutaions ; "gradutaions\n"
.text:00401042 push edx ; _Ostr
.text:00401043 call ??$?6U?$char_traits@D@std@@@std@@YAAAV?$basic_ostream@DU?$char_traits@D@std@@@0@AAV10@PBD@Z ; std::operator<<<std::char_traits<char>>(std::basic_ostream<char,std::char_traits<char>> &,char const *)
.text:00401048 add esp, 8
.text:0040104B xor eax, eax
.text:0040104D mov esp, ebp
.text:0040104F pop ebp
.text:00401050 retn
经过查找“.text:0040102D cmp [esp+8+input_psw], 271Ah”即时比较指令,如果比较结果不匹配,则跳转到loc_401051,现在修改如下:
.text:00401035 jnz short loc_401037 即可
经测试跳转成功。。。。无论输入什么,都提示"graduations"