代码
#include
<
iostream.h
>
#include < windows.h >
void main()
{
DWORD p;
_asm
{
call l1
l1:
pop eax
mov p,eax // 确定当前程序段的位置
call f1
_EMIT 0xEA // 花指令,此处永远不会执行到
jmp l2 // call结束以后执行到这里
f1: // 这里用F8OD会终止调试,F7跟进的话就正常,why?
pop ebx
inc ebx
push ebx
mov eax, 0x11111111
ret
l2:
call f2 // 用ret指令实现跳转
mov ebx, 0x33333333 // 这里永远不会执行到
jmp e // 这里永远不会执行到
f2:
mov ebx, 0x11111111
pop ebx // 弹出压栈的地址
mov ebx,offset e // 要跳转到的地址
push ebx // 压入要跳转到的地址
ret // 跳转
e:
mov ebx, 0x22222222
}
cout << hex << p << endl;
}
#include < windows.h >
void main()
{
DWORD p;
_asm
{
call l1
l1:
pop eax
mov p,eax // 确定当前程序段的位置
call f1
_EMIT 0xEA // 花指令,此处永远不会执行到
jmp l2 // call结束以后执行到这里
f1: // 这里用F8OD会终止调试,F7跟进的话就正常,why?
pop ebx
inc ebx
push ebx
mov eax, 0x11111111
ret
l2:
call f2 // 用ret指令实现跳转
mov ebx, 0x33333333 // 这里永远不会执行到
jmp e // 这里永远不会执行到
f2:
mov ebx, 0x11111111
pop ebx // 弹出压栈的地址
mov ebx,offset e // 要跳转到的地址
push ebx // 压入要跳转到的地址
ret // 跳转
e:
mov ebx, 0x22222222
}
cout << hex << p << endl;
}