o0Jon0o
Feb 14th, 2002, 02:09 PM
Hi all,
I'm just trying to make a program that hooks all keystrokes and displays them in a console window. I only
learnt how to use DLLs today so I not very good yet.
Hears my code, I didn't expect it to work and it didn't, any ideas why?:
The DLL:
#include <iostream.h>
#include "stdafx.h"
LRESULT CALLBACK FilterFunc(int nCode, WPARAM wparam,LPARAM lParam)
{
MessageBox (NULL, "IT WORKS!" , "WORKS!", 0 + MB_ICONQUESTION);
return CallNextHookEx(NULL, nCode, wparam , lParam);
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
The APP:
//#pragma hdrstop
//#include <condefs.h>
#include <iostream.h>
#include <conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
HINSTANCE dllres;
HOOKPROC adss;
HHOOK setres;
cout << GetLastError() << endl;
dllres = LoadLibrary("hook.dll");
cout << GetLastError();
if(dllres != NULL)
{
adss = (HOOKPROC)GetProcAddress(dllres, "FilterFunc");
setres = SetWindowsHookEx(WH_KEYBOARD, adss, dllres, 0);
if(setres == NULL )
cout << "Yeah, it is shagged :(";
}
else
cout << "Error loading hook.dll";
getch();
return 0;
}
P.S I dose compile :D
Thanks in advance
-Jon
I'm just trying to make a program that hooks all keystrokes and displays them in a console window. I only
learnt how to use DLLs today so I not very good yet.
Hears my code, I didn't expect it to work and it didn't, any ideas why?:
The DLL:
#include <iostream.h>
#include "stdafx.h"
LRESULT CALLBACK FilterFunc(int nCode, WPARAM wparam,LPARAM lParam)
{
MessageBox (NULL, "IT WORKS!" , "WORKS!", 0 + MB_ICONQUESTION);
return CallNextHookEx(NULL, nCode, wparam , lParam);
}
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
The APP:
//#pragma hdrstop
//#include <condefs.h>
#include <iostream.h>
#include <conio.h>
//---------------------------------------------------------------------------
#pragma argsused
int main(int argc, char* argv[])
{
HINSTANCE dllres;
HOOKPROC adss;
HHOOK setres;
cout << GetLastError() << endl;
dllres = LoadLibrary("hook.dll");
cout << GetLastError();
if(dllres != NULL)
{
adss = (HOOKPROC)GetProcAddress(dllres, "FilterFunc");
setres = SetWindowsHookEx(WH_KEYBOARD, adss, dllres, 0);
if(setres == NULL )
cout << "Yeah, it is shagged :(";
}
else
cout << "Error loading hook.dll";
getch();
return 0;
}
P.S I dose compile :D
Thanks in advance
-Jon