flat assembler
Message board for the users of flat assembler.

Index > Windows > another newbie from me about windows hooks

Author
Thread Post new topic Reply to topic
sina



Joined: 18 Aug 2003
Posts: 132
Location: istanbul turkey
sina 19 Aug 2003, 10:37
i want to create a spy that monitors keyboard
i have managed to do this but it does not work can u please help me
i want to take the keystroke to the edit control
also another problem is the characters i can make them wok with my turkish charset
yes i know i am newbie Sad

this is the code

format PE GUI 4.0
entry start

include '%include%\win32a.inc'

IDC_Button1 = 1
IDC_Edit1 = 4
IDC_Button2 = 5


section '.data' data readable writeable

flags dd ?
caption rb 40h
message rb 100h
height dd ?
widht dd ?
infotext1 db 'Bu program FASM v1.48 (Flat Assembler)',0dh,0ah,\
'Kullanılarak VeSCeRa-YSG Tarafından',0dh,0ah,\
'Deneme Amaçlı Olarak Yazılmıştır',0
infotext2 db 'Program Hakkında',0
temp db ?

section '.code' code readable executable

start:

invoke GetModuleHandle,0
invoke DialogBoxParam,eax,37,HWND_DESKTOP,DialogProc,0
or eax,eax
jz exit
exit:
invoke ExitProcess,0

proc DialogProc,hwnddlg,msg,wparam,lparam
enter
push ebx esi edi
cmp [msg],WM_INITDIALOG
je wminitdialog
cmp [msg],WM_COMMAND
je wmcommand
cmp [msg],WM_CLOSE
je wmclose
xor eax,eax
jmp finish

wminitdialog:
invoke SetWindowsHookEx,WH_KEYBOARD,KeyboardProc,KeyboardProc,0
jmp processed

wmcommand:

jmp processed

showinfo:
invoke MessageBox,[hwnddlg],infotext1,infotext2,MB_OK
jmp processed

wmclose:
invoke EndDialog,[hwnddlg],0
invoke UnhookWindowsHookEx,KeyboardProc

processed:
mov eax,1

finish:
pop edi esi ebx
return

proc KeyboardProc,code,wparam,lparam
enter
push ebx esi edi
invoke SetDlgItemText,[hwnddlg],IDC_Edit1,[wparam]
xor eax,eax
jmp finish


section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
user,'USER32.DLL'

import kernel,\
GetModuleHandle,'GetModuleHandleA',\
ExitProcess,'ExitProcess'

import user,\
DialogBoxParam,'DialogBoxParamA',\
MessageBox,'MessageBoxA',\
SetWindowsHookEx,'SetWindowsHookExA',\
UnhookWindowsHookEx,'UnhookWindowsHookEx',\
SetDlgItemText,'SetDlgItemTextA',\
EndDialog,'EndDialog'

section '.rsrc' resource data readable

directory RT_DIALOG,dialogs

resource dialogs,\
37,LANG_TURKISH+SUBLANG_DEFAULT,ysgdlg1

dialog ysgdlg1,'Casus v1.0',100,100,185,175,WS_CAPTION+WS_POPUP+WS_SYSMENU
dialogitem 'EDIT','',IDC_Edit1,0,0, 185, 160, WS_VISIBLE+WS_CHILD+WS_BORDER+WS_VSCROLL+ES_AUTOVSCROLL+ES_MULTILINE+ES_WANTRETURN
enddialog
Post 19 Aug 2003, 10:37
View user's profile Send private message ICQ Number Reply with quote
inskipp



Joined: 23 Jun 2003
Posts: 25
Location: Poland
inskipp 19 Aug 2003, 14:02
I'm not sure, but I thing you have to put your hook procedure in a seperate DLL file with shared code section. I do it always in tahat way and it works.
Post 19 Aug 2003, 14:02
View user's profile Send private message ICQ Number Reply with quote
holes



Joined: 01 Jul 2004
Posts: 4
Location: Eastern Europe
holes 01 Jul 2004, 07:31
Quote:

I thing you have to put your hook procedure in a seperate DLL file with shared code section.


That depends if you are using winnt or win9x. In winnt you can place it in the same app.
Post 01 Jul 2004, 07:31
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex 01 Jul 2004, 10:03
selam VeSCeRa,

Inskipp'in dedigi gibi "hook" yordamInI ayrI bir DLL dosyasIna yerlestirmen gerek, o zaman basIlan tusları takip etmen cok kolay olur.
Iczelion'un 24.dersi bu konuya guzel bir ornektir.

_________________
Code it... That's all...
Post 01 Jul 2004, 10:03
View user's profile Send private message Visit poster's website Reply with quote
holes



Joined: 01 Jul 2004
Posts: 4
Location: Eastern Europe
holes 01 Jul 2004, 12:21
Vortex, what does that mean?
Post 01 Jul 2004, 12:21
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex 01 Jul 2004, 17:30
It means that:

As Inskipp said, you need to put your "hook" procedure in a separate DLL so you can easyl keep track of pressed keys. Iczelion's tutorial #24 is an example of using hooks.

_________________
Code it... That's all...
Post 01 Jul 2004, 17:30
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.