I am playing with function hooking so I wrote simple program that calls
DisplayMessage Function which prints out Hello..
void DisplayMessage()
{
cout << "Hello";
}
After this one i found the DisplayMessage offset its (0x00131000)
now my target is write a dll to change DisplayMessage function to say bye instead of hello....
and here comes the problem...
DLL code
dll.h'
#ifndef _DLL_H_
#define _DLL_H_
#if BUILDING_DLL
# define DLLIMPORT __declspec (dllexport)
#else /* Not BUILDING_DLL */
# define DLLIMPORT __declspec (dllimport)
#endif /* Not BUILDING_DLL */
DLLIMPORT void Hook(void);
#endif /* _DLL_H_ *
dll.cpp
void (*PHook)(void);
PHook = (void*)(0x00131000);
PHook(void)
{
cout << "Bye";
}
void Hook()
{
PHook();
}
BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,
DWORD reason /* Reason this function is being called. */ ,
LPVOID reserved /* Not used. */ )
{
switch (reason)
{
case DLL_PROCESS_ATTACH:
Hook();
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
break;
case DLL_THREAD_DETACH:
break;
}
/* Returns TRUE on success, FALSE on failure */
return TRUE;
}
its wont compile no idea why
heres the errors
mpiling...
1>dllmain.cpp
1>.\dllmain.cpp(11) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\dllmain.cpp(11) : error C2373: 'PHook' : redefinition; different type modifiers
1> .\dllmain.cpp(10) : see declaration of 'PHook'
1>.\dllmain.cpp(11) : error C2440: 'initializing' : cannot convert from 'void *' to 'int'
1> There is no context in which this conversion is possible
1>.\dllmain.cpp(13) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>.\dllmain.cpp(13) : error C2365: 'PHook' : redefinition; previous definition was 'data variable'
1> .\dllmain.cpp(10) : see declaration of 'PHook'
1>.\dllmain.cpp(15) : warning C4508: 'PHook' : function should return a value; 'void' return type assumed
1>.\dllmain.cpp(18) : warning C4273: 'Hook' : inconsistent dll linkage
1> c:\users\zippo\documents\visual studio 2008\projects\dynamic link libary\dynamic link libary\dll.h(10) : see previous definition of 'Hook'
1>.\dllmain.cpp(19) : error C3861: 'PHook': identifier not found
it give compile errors