开发者

low level Hooker

开发者 https://www.devze.com 2023-01-11 07:28 出处:网络
I want to make a hook that will act like \"event\" (and not with agly GetAsyncKeyState) in C# (I want to do it in C++).

I want to make a hook that will act like "event" (and not with agly GetAsyncKeyState) in C# (I want to do it in C++). so, I've made a dll with this content: http://pastebin.com/yEHJKSS7 .

well, it doesn't call to Handler Function.

by the way, here's how I used the dll:

void KeysHandler(int vkKey, int flags)
{
    if(vkKey == VK_ESCAPE)
        exit(0);
    File << vkKey << endl << flags << endl;
}

int main
{
    SetHandler(HandlerFunc);
   开发者_运维问答 //sleep here
}

edit: now I saw how I can "debug" in the dll, here are the findings: the SetWindowsHookEx returns 255 - i think it's starnge because it worth to char exactly - I'm going to check in the documentation what does it mean.

edit: 255 is valid return value :O only NULL (0) is error.

I have no idea what's the problem.

edit: well, now my friend brought me a hooker that worked for him. and guess... it didn't work.

I decided it's very strange so I did GetLastError and got 127 - procedure haven't found. I don't see any reason my procedure won't be found, help please :(


Is your main really only calling SetHandler followed by sleep?

You need a MessageLoop in order for any events to be called.

0

精彩评论

暂无评论...
验证码 换一张
取 消