生活的天平本不平衡,只有通过努力改变其偏向。

Call实现自身重定位代码

2010-04-25

通过call调用将返回地址压栈的方式,达到自身数据重定位,想出这法子的,绝对是大牛。早有看到,昨天突然想起来,实现一下。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
void ShowMsg()
{
	HMODULE hUser32 = LoadLibrary("user32.dll");
	if( hUser32 == NULL ) return;
	DWORD pMsg = (DWORD) GetProcAddress(hUser32, "MessageBoxA");
	if( pMsg == NULL ) return;
	__asm
	{
		push NULL
		call TITLE
		_emit 't'
		_emit 'i'
		_emit 't'
		_emit 'l'
		_emit 'e'
		_emit 0
TITLE:
		call CONTENT
		_emit 'c'
		_emit 'o'
		_emit 'n'
		_emit 't'
		_emit 'e'
		_emit 'n'
		_emit 't'
		_emit 0
CONTENT:
		push NULL
		call pMsg
	}
}
作者:lonkil | 分类目录:编程开发 | 标签:

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>