主题:[讨论]诡异的程序,连续三次调用 help() 函数?
[code=c]
// VC6.0
#include "stdio.h"
#include "windows.h"
#include "tchar.h"
BYTE addr_old[8] = {0};
BYTE addr_new[8] = { 0xB8, 0x20, 0x10, 0x40, 0x00, 0xFF, 0xE0, 0x00 };
DWORD pfnMsgBox=0; //API函数地址
int help()
{
printf(" help ??\n");
return 0;
}
//----------------------------------------------程序入口
int main()
{
DWORD dwOldProtect;
MEMORY_BASIC_INFORMATION mbi;
MessageBox(NULL,_T("Hook Demo!"),_T("API Hook"),MB_ICONINFORMATION);
pfnMsgBox=(DWORD)GetProcAddress(GetModuleHandle(_T("user32.dll")),_T("MessageBoxA"));
printf("api 入口地址: %x\n",pfnMsgBox);
VirtualQuery( (void *)pfnMsgBox, &mbi, sizeof(mbi) );
//修改我们要改的地址的页属性,为可读可写
VirtualProtect( (void *)pfnMsgBox, 8, PAGE_READWRITE, &dwOldProtect);
// 保存原来的执行代码
memcpy(addr_old, (void *)pfnMsgBox, 8);
// 写入新的执行代码
WriteProcessMemory( GetCurrentProcess(),
(void *)pfnMsgBox,
addr_new,
sizeof(DWORD)*2,
NULL);
//修改为原来的属性属性
VirtualProtect((void *)pfnMsgBox, 8, mbi.Protect, 0);
//当调用这个函数的时候就跳到我的函数上面了
MessageBox(NULL,_T("Hook Demo!"),_T("API Hook"),MB_ICONINFORMATION);
getchar();
return 0;
}
[/code]
大家能看到我的程序中哪里调用了 help() 函数吗?
// VC6.0
#include "stdio.h"
#include "windows.h"
#include "tchar.h"
BYTE addr_old[8] = {0};
BYTE addr_new[8] = { 0xB8, 0x20, 0x10, 0x40, 0x00, 0xFF, 0xE0, 0x00 };
DWORD pfnMsgBox=0; //API函数地址
int help()
{
printf(" help ??\n");
return 0;
}
//----------------------------------------------程序入口
int main()
{
DWORD dwOldProtect;
MEMORY_BASIC_INFORMATION mbi;
MessageBox(NULL,_T("Hook Demo!"),_T("API Hook"),MB_ICONINFORMATION);
pfnMsgBox=(DWORD)GetProcAddress(GetModuleHandle(_T("user32.dll")),_T("MessageBoxA"));
printf("api 入口地址: %x\n",pfnMsgBox);
VirtualQuery( (void *)pfnMsgBox, &mbi, sizeof(mbi) );
//修改我们要改的地址的页属性,为可读可写
VirtualProtect( (void *)pfnMsgBox, 8, PAGE_READWRITE, &dwOldProtect);
// 保存原来的执行代码
memcpy(addr_old, (void *)pfnMsgBox, 8);
// 写入新的执行代码
WriteProcessMemory( GetCurrentProcess(),
(void *)pfnMsgBox,
addr_new,
sizeof(DWORD)*2,
NULL);
//修改为原来的属性属性
VirtualProtect((void *)pfnMsgBox, 8, mbi.Protect, 0);
//当调用这个函数的时候就跳到我的函数上面了
MessageBox(NULL,_T("Hook Demo!"),_T("API Hook"),MB_ICONINFORMATION);
getchar();
return 0;
}
[/code]
大家能看到我的程序中哪里调用了 help() 函数吗?