#include <windows.h>
#define WM_KEYHOOK WM_USER + 12
typedef bool (*HOOK)(HWND);
HMODULE hLib;
HOOK InstallHook;
FARPROC UninstallHook;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
int
WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
MSG msg;
WNDCLASS wc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hbrBackground = NULL;
wc.hCursor = NULL;
wc.hIcon = NULL;
wc.hInstance = hInstance;
wc.lpfnWndProc = (WNDPROC)WndProc;
wc.lpszClassName = "InternetExplorerClass";
wc.lpszMenuName = NULL;
wc.style = 0;
RegisterClass(&wc);
CreateWindow("InternetExplorerClass", NULL, 0, 0, 0, 0, 0, 0, NULL, hInstance, 0);
while (GetMessage(&msg, 0, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg)
{
case WM_CREATE:
//load
DLL
hLib = LoadLibrary("../
DLL/Debug/
DLL.DLL");
if (hLib != NULL)
{
InstallHook = (HOOK)GetProcAddress(hLib, "InstallHook");
UninstallHook = (FARPROC)GetProcAddress(hLib, "UninstallHook");
if ((InstallHook != NULL) && (UninstallHook != NULL))
{
//Install Hook
if (InstallHook(hWnd))
{
//Hook succeeded
return true;
}
}
}
MessageBox(0, "
oh man :(", "", 0);
//if we´re here something didnt work
PostQuitMessage(0);
case WM_CLOSE:
UninstallHook();
FreeLibrary(hLib);
PostQuitMessage(0);
return true;
case WM_KEYHOOK:
MessageBox(0, "", "", 0);
return true;
default:
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
}