一个函数拦截的下TEST程序~
#include"windows.h"
#include "iostream.h"
typedef int (WINAPI* PROCC) (HWND, LPCTSTR, LPCTSTR ,UINT);
PROCC lpAdder = MessageBoxA;
int APIENTRY MyMessageBox(HWND hwnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType)
{
int ret = 0;
if (lpAdder != NULL)
ret = lpAdder(NULL, "new", "new", MB_OK);
return ret;
}
void SetHookA(LPCSTR lpModuleName, LPCSTR lpFunName, PROCC pNewProc)
{
PROC dwByte;
HINSTANCE hDLL;
hDLL = LoadLibrary(lpModuleName);
dwByte = GetProcAddress(hDLL, lpFunName);
//BOOL Is = ReadProcessMemory(GetCurrentProcess(), (LPVOID) dwByte, LPVOID(cc), sizeof(DWORD), NULL);
BOOL isok = WriteProcessMemory(GetCurrentProcess(), (LPVOID)dwByte, (LPVOID)MyMessageBox, sizeof(DWORD), NULL);
}
void main()
{
SetHookA("user32.dll", "MessageBoxA", MyMessageBox);
MessageBoxA(NULL, "ss","ss", MB_OK);
}
这个是一个实验程序,应该很简单,但是就是运行时候出错。我是个处学者,请大家指点以下错误的所在