The following is the code in the DLL, to block the key message, but written in their exe injection after a successful cannot realize the hooks, the last parameter in the SetWindowsHookEx to 0 to become global hooks also not line, and not injection, let messagebox pops up in a DLL can be, but can't, why want to ask next, should be the problem of principle
LRESULT a CALLBACK KeyBordProc (int nCode, WPARAM WPARAM, LPARAM LPARAM)
{
return 1;
}
BOOL APIENTRY DllMain (HMODULE HMODULE,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
The switch (ul_reason_for_call)
{
Case DLL_PROCESS_ATTACH:
{
SetWindowsHookEx (WH_KEYBOARD, KeyBordProc hModule, GetCurrentProcessId ());
}
return TRUE;
}
CodePudding user response:
SetWindowsHookEx last parameter should be a Thread Id, check the SetWindowsHookEx and the return value of the confirmation link is successful, and then again in KeyBordProc next breakpoint debugging and see if I can break down
CodePudding user response:
Saw the return value is the setwindowsHook returns null, but do not know why,,, someone else is also wrote the forehead I cannot here how the hooks
CodePudding user response:
reference 1st floor CharlesSimonyi response: SetWindowsHookEx last parameter should be a Thread Id, check the SetWindowsHookEx and the return value of the confirmation link is successful, and then again in KeyBordProc next breakpoint debugged and see if I can break down saw the return value is the setwindowsHook returns null, but do not know why,,, someone else is also wrote the forehead I cannot here how the hooks CodePudding user response:
reference 1st floor CharlesSimonyi response: SetWindowsHookEx last parameter should be a Thread Id, check the SetWindowsHookEx and the return value of the confirmation link is successful, and then again in KeyBordProc next breakpoint debugged and see if I can break down I put the SetWindowsHookEx last parameter to 0, namely global hooks the return value is not empty, but there is no hook effect, typing no shielding,,, CodePudding user response:
GetLastError what return error CodePudding user response:
There may be such as anti-virus software/firewall to stop CodePudding user response:
reference 5 floor zgl7903 reply: GetLastError what return error error is 87, check up should be a parameter has a problem, you can see what problem? I think is so write ah, is in the DLL call hook will be a problem? CodePudding user response:
GetCurrentProcessId () or is the process ID, the last parameter requirements of the SetWindowsHookEx is thread ID, so the parameter error, As to the problem of global hooks is invalid, you can write a Messagebox KeyBordProc () to see will popup Messagebox, to prove that hook after KeyBordProc really is invoked CodePudding user response:
refer to the eighth floor CharlesSimonyi response: GetCurrentProcessId () or is the process ID, the last parameter requirements of the SetWindowsHookEx is thread ID, so the parameter error, As to the problem of global hooks is invalid, you can write a Messagebox KeyBordProc () to see will popup Messagebox, to prove that hook KeyBordProc really be called after the about global hooks I want to ask, when I last parameter is set to 0, the function returns a null value, show a success, but not my keyboardProc execution, really think impassability,,, could you tell me what do you think? CodePudding user response:
In the http://www.codeproject.com search "hook" CodePudding user response:
references to the tenth floor zhao4zhong1 response: at http://www.codeproject.com search "hook" miss zhao, see you a lot of posts are back this way, I really appreciate it, I want to say to you: last year I bought a backpack CodePudding user response:
11 references yikuaiqiaokeli response: Quote: reference to the tenth floor zhao4zhong1 response: In the http://www.codeproject.com search "hook" miss zhao, you saw the post is back this way, I really appreciate it, I want to say to you: last year I bought a backpack Unknown sleep and complete CodePudding user response:
I am currently also encountered this problem has been solved now CodePudding user response:
Use GetWindowThreadProcessId tied the last argument CodePudding user response:
If the third parameter is the current thread hook to NULL CodePudding user response:
Reference WinAPIOverride source code related fragments,