hook api的乙個自己寫的例子

2021-03-31 08:56:31 字數 1197 閱讀 4241

幫同學寫了個hook api的例子程式,順便post到這兒,免得將來到處找.

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

#include

#include

#include

#pragma ***ment(lib,"dbghelp.lib")

#pragma ***ment(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的乙個簡單的例子

乙個簡單的console工程,vc6,vc7在win2k pro,server上除錯通過.include include include pragma comment lib,dbghelp.lib pragma comment lib,user32.lib typedef int stdcall ...

自己寫的乙個Vue

下面這裡是我自己寫的乙個小型的vue,原理就是proxy proxy天生沒有prototype,因此要加上,不然extends會報錯 proxy.prototype proxy.prototype object.prototype class myvue extends proxy super da...

自己寫乙個LIST

pragma once forward declarations templateclass clistnode templateclass clist template class clistnode void insertafter t data template void clistnode ...