home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 11 Util
/
11-Util.zip
/
MKHOOK1.ZIP
/
HOOK_DLL.ASM
< prev
next >
Wrap
Assembly Source File
|
1992-09-05
|
4KB
|
97 lines
;---------------------------------------------------------------------------;
; M.F.Kaplon Begun:Tue 07-14-1992 Revised:Sat 09-05-1992
; Title : hook_dll.asm
;
; This is the dll to be used with hook_kb.asm
; Its purpose is to test the system message stream for WM_CHAR
; and when selected keys are struck to post a message to hook_kb
;
; The function InputHook monitors the System message queue and responds
; whenever the WinGetMsg or WinPeekMsg is about to return a message.
;
; This is assembled and linked as dll by calling dll-w386 hook_dll
;
; this cmd file also moves the created dll to c:\os2\dll
;
; This program Posts a Message to hook_kb,exe when a message to
; WM_CHAR is detected. It uses WM_USER+200h as the message ID
; and the mp1,mp2 parameters of the WM_CHAR message.
;
;---------------------------------------------------------------------------;
;
;------------------ PRELIMINARIES ----------------------
.386 ;preceeding .MODEL makes USE32 default
.MODEL FLAT,SYSCALL,OS_OS2
INCL_DOSMEMMGR equ 1
INCL_WINERRORS equ 1
INCL_WIN equ 1
INCLUDE c:\toolkt20\asm\os2inc\os2def.inc ;structure defns includes POINTL
INCLUDE c:\toolkt20\asm\os2inc\pmwin.inc ;structure defns POINTL defn required
INCLUDE c:\toolkt20\asm\os2inc\bsememf.inc ;memory
INCLUDE c:\toolkt20\asm\os2inc\pmerr.inc ;errors
INCLUDELIB c:\toolkt20\os2lib\os2386.lib ;Library
INCLUDE doswin32.mac ;macros for calls
.STACK 2048
.DATA
;------------- handles --------
jr_hab DWORD ? ;Anchor block handle
hook DWORD ? ;Handle of hook-kb
;------------ structures
jr_qmsg DWORD ? ;Address of Journal Record Message structure
;----Shared Memory Variables---
SharedMem DWORD 0 ;base address returned
SharedMemName BYTE "\SHAREMEM\DATAE.DAT",0
SharedMemFlags DWORD 12h ;(PAG_COMMIT OR OBJ_GETTABLE OR PAG_WRITE)
.CODE
;---------- ESTABLISH InputHook --------------
;Has the form BOOL EXPENTRY InputHook(HAB hab, PQMSG pQmsg,ULONG fs)
;QMSG TRUCT has following parms as offsets
;offset 0 hwnd ,offset 4 msg ,offset 8 mp1 ,offset 12 mp2 ,etc.
;fs contains flags from WinPeekMsg function
InputHook proc
push ebp ;return address = 4 bytes,this push = 4 bytes
mov ebp,esp ;so first parameter is 8 bytes from top
mov eax,[ebp+8] ;hab
mov jr_hab,eax ;anchor block handle
mov eax,[ebp+12] ;address of qmsg truct
mov jr_qmsg,eax ;store address of QMSG STRUCT structure
;---- GET ADDRESS OF SHARED MEMORY ---
.IF SharedMem == 0
$Call DosGetNamedSharedMem,offset SharedMem,offset SharedMemName,1
.IF eax != 0
$Alarm ;$WinErrMsg " : DosAllocSharedMem"
.ENDIF
;---- Get handle of hook_kb and Release Shared Memory ----
mov edi,SharedMem
mov eax,[edi]
mov hook,eax ;now has handle of hook-kb
$Call DosFreeMem,SharedMem ;release since no longer needed
.IF eax != 0
$Alarm ;$WinErrMsg " : DosAllocSharedMem"
.ENDIF
.ENDIF
;---- IF WM_CHAR MESSAGE DETECTED -----
mov esi,jr_qmsg
.IF dword ptr [esi+4] == WM_CHAR
;------ NOW [esi+8]=mp1 [esi+12]=mp2 ------
$Call WinPostMsg,hook,WM_USER+200h,[esi+8],[esi+12]
.ENDIF
xxout:
mov esp,ebp ;restore stack pointer
pop ebp ;back to way it was at entrance
mov eax,FALSE ;pass to next hook in chain
ret
InputHook endp
END