Call实现自身重定位代码
通过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 } } |