Hello. I have a problem in my hands and would be glad if someone could help me... I was playing a game when I got tired of using the keyboard to send key combinations... That was when I decided to create something to do it for me... Basically Im trying to write a hook to intercept window messages to another application, in this case the game window, and then send a combinations of keystrokes to the target window if the user press key X. Sending keys is not the problem, the problem is that I cant get this dll to work.
The problem is that calling a normal function works, but calling a function like this:
simply does not work.. By saying "normal function" I mean a function like void readKbMessages(). Im trying to link to it because I had created all the application logic, but could not connect to the LRESULT CALLBACK funcName(int, HOOKPROC, HINSTANCE, DWORD) function. The pointer is always null
LRESULT __declspec(dllexport)__stdcall CALLBACK readKbMessages(void)
This is the code where I link to the dll:
HMODULE hDll = LoadLibraryA("dll.dll");
LRESULT CALLBACK (*func)() = (LRESULT CALLBACK(*)())GetProcAddress(hDll, "readKbMessages");
it works ok for "normal functions", but I cannot get it to work on that miserable function. The function to intercept key strokes should be similar to that one.. Also I tried every combination I could think of.... LRESULT CALLBACK __stdcall(dllexport), etc, etc, etc... Im not very used to dlls, but I wont stop until I get to the end..
Also any info about hooking applications, intercepting window messages, etc, etc, would be great. This is the first time Im actually tryng this.
The final application should attach to a process, get its process ID, hook to it, intercept its messages, look for the user selected key, and if matched send the user selected key combinations to the target process. Thats all
use dumpbin utility to check the EXPORTS of your dll
your function has a different name in the EXPORTS list
use this name (something like readKbMessages@0 )
or use def file to modify it to your likings
acording to dumpbin, the function is really called readKbMessages@0... I cant believe I deleted everything and started again just because of a @ and a 0... Thank you very much vart...
Is there something I can do to keep the other name without the @0 instead of using define?
you can use def file to specify export names of the dll
Originally Posted by Dante Wingates