I can get this DLL to work, i'm just trying to make a DLL which will hook the keyboard messages and send them to VB. Heres the code:



.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib

.data
AppName db "DLL Keyboard Hook",0
LoadMsg db "The DLL is loaded",0
UnloadMsg db "The DLL is unloaded",0
ThreadCreated db "A thread is created in this process",0
ThreadDestroyed db "A thread is destroyed in this process",0
.code

.data?
hHook dd ?
hWnd dd ?
hDllInstance dd ?

DllEntry proc hInstance:HINSTANCE, reason:DWORD, reserved1:DWORD
mov eax,TRUE
push hInstance
pop hDllInstance
ret
DllEntry Endp

KeyBoardProc proc nCode:DWORD,wParam:DWORD,lParam:DWORD
invoke CallNextHookEx,hHook,nCode,wParam,lParam
invoke SendMessage,hWnd,nCode,wParam,lParam
ret
KeyBoardProc endp

UnHookKeyboard proc
invoke UnhookWindowsHookEx,hHook
ret
UnHookKeyboard endp

HookKeyboard proc hwnd: DWORD
push hwnd
pop hWnd
invoke SetWindowsHookEx, WH_KEYBOARD, addr KeyBoardProc, hDllInstance, NULL
mov hHook, eax
invoke UnHookKeyboard
ret
HookKeyboard endp

End DllEntry


It quits with "error A2107: cannot have implicit far jump or call to near label"

Its probably something stupid, any idea's?

Thanks

P.S. I don't use VB that often :), this is a special occasion
Posted on 2003-01-08 12:53:52 by VBprogrammer
Um, all your code seems to be in the .data? section...
That probably isn't helping much...

Mirno
Posted on 2003-01-08 13:02:57 by Mirno
...

.data
AppName db "DLL Keyboard Hook",0
LoadMsg db "The DLL is loaded",0
UnloadMsg db "The DLL is unloaded",0
ThreadCreated db "A thread is created in this process",0
ThreadDestroyed db "A thread is destroyed in this process",0

.data?
hHook dd ?
hWnd dd ?
hDllInstance dd ?

.code
...
Posted on 2003-01-08 13:36:50 by natas
Yeah, i think you might just be right! :alright:
Posted on 2003-01-08 15:53:58 by VBprogrammer