hook api的乙個簡單的例子

2021-04-23 06:26:58 字數 1151 閱讀 4563

乙個簡單的console工程,vc6,vc7在win2k pro,server上除錯通過.

#include

#include

#include

#pragma comment(lib,"dbghelp.lib")

#pragma comment(lib,"user32.lib")

typedef int (__stdcall *old_messagebox)( hwnd hwnd, lpctstr lptext, lpctstr lpcaption,uint utype );

old_messagebox g_procoldmessagebox = null;

int __stdcall hook_messagebox( hwnd hwnd, lpctstr lptext, lpctstr lpcaption,uint utype)

int replace_iat(const char *pdllname,const char *papiname,bool breplace)

++pimageimport;

}if (! pimageimport->name)

return 2;

pimagethunkoriginal = (pimage_thunk_data)((pbyte)hprocess+pimageimport->originalfirstthunk  );

pimagethunkreal = (pimage_thunk_data)((pbyte)hprocess+pimageimport->firstthunk   );

while (pimagethunkoriginal->u1.function)

else

pimagethunkreal->u1.function = (dword)g_procoldmessagebox;

dword dwoldprotect;

virtualprotect(mbi_thunk.baseaddress, mbi_thunk.regionsize, mbi_thunk.protect, &dwoldprotect);

break;}}

++pimagethunkoriginal;

++pimagethunkreal;

}return 0;

}int main()

hook api的乙個自己寫的例子

幫同學寫了個hook api的例子程式,順便post到這兒,免得將來到處找.乙個簡單的console工程,vc6,vc7在win2k pro,server上除錯通過.include include include pragma ment lib,dbghelp.lib pragma ment lib...

乙個簡單的json例子

名稱 年齡郵箱 response.setcontenttype text html charset utf 8 response.setheader cache control no cache jsonobject json new jsonobject try json.put jobs mem...

乙個poll的簡單例子

該程式使用poll事件機制實現了乙個簡單的訊息回顯的功能,其伺服器端和客戶端的 如下所示 伺服器端 start from the very beginning,and to create greatness author chuangwei lin e mail 979951191 qq.com b...