Home > Software engineering >  [q] what back data structure to CallNextHookEx?
[q] what back data structure to CallNextHookEx?

Time:09-20

Use WH_KEYBOARD_LL hook, in callback structure:
Dim As KBDLLHOOKSTRUCT P

'the lParam a pointer to the KBDLLHOOKSTRUCT structure
Call CopyMemory (P, ByVal lParam, LenB (P))

Excuse me, I have modified the P content, how to go back to pass to the next hook

Call CallNextHookEx (nCode wParam, lParam (P?? )

CodePudding user response:

Now that is a "pointer", biography, byval Varptr (P),

CodePudding user response:

But no response!
Private Declare Function CallNextHookEx Lib "user32" (ByVal hHook As Long, ByVal nCode As Long, ByVal wParam As Long, lParam As Any) As Long

Start
MHook=SetWindowsHookEx (WH_KEYBOARD_LL, AddressOf HookKbProc, App. The hInstance, 0)

The callback function, A, forward A B,
 Public Function HookKbProc (ByVal nCode As Long, ByVal wParam As Long, ByVal lParam) As Long As Long 
Dim uP As KBDLLHOOKSTRUCT
If nCode & lt; 0 Or nCode & gt; 0 Then
ExLine:
HookKbProc=CallNextHookEx (0, nCode, wParam, lParam) 'a hook under the message to the function return value, is decided by the next hook
The Exit Function
End the If
Call CopyMemory (uP, ByVal lParam LenB (uP))
With the uP
If the vkCode=vbKeyA Then
. VkCode=vbKeyB
The Debug. Print "A> B
"End the If
End With
HookKbProc=CallNextHookEx (0, nCode wParam, ByVal VarPtr (uP))
End the Function

CodePudding user response:

Anecdotal hearsay, SetWindowsHookEx must be in a DLL,

CodePudding user response:

reference zhao4zhong1 reply: 3/f
anecdotal hearsay, SetWindowsHookEx must be in a DLL,


Have certain global hooks can not rely on any DLL and normal work, including the hook, the WH_JOURNALPLAYBACK, WH_JOURNALRECORD, WH_KEYBOARD_LL, WH_MOUSE_LL, why can not rely on the hook DLL and normal work? We can get the answer from the MSDN, MSDN for This four hooks are described as "This hook is called in the context of the thread that installed it.", translated into Chinese it means hook function call is in the thread context of install hooks, speak more clearly, which means that the hook is in the midst of which thread installation, the hooks on which thread of execution, so using the four hooks are short of code injection effect, of course, also can not rely on any DLL, only for the individual hook in the MSDN is pointed out that must or it is not necessary to use the DLL,

Also because can't code injection, thus unable to pass the modified data to the next hook?

CodePudding user response:

Assembly instruction in front, no secret,
http://edu.csdn.net/course/detail/2344 C language pointer and assembly - a memory address. The code element

CodePudding user response:

Didn't want to understand why no effect,

Previously tried it on, I not only changes the vkCode, and also the keyboard scan code "synchronization correction", also didn't also effect,
(I'm not change again after copymemory data, but direct change lParam data area)

Is system behind the keyboard messages sent, not the "hook" data shall prevail, but will be subject to the original keyboard data?
(message passing hook data is just a "copy", after processing to hook directly discarded?)
If so, then the practical significance of the "bottom HOOK" and how much...
Is for the convenience of "Trojan horse" keyboard record, please!

CodePudding user response:

The
reference 4 floor VBAHZ reply:
......
Also because can't code injection, thus unable to pass the modified data to the next hook?


Don't say "across processes" first, even for "process" also doesn't work!
You can try:
Draw yourself a Text controls, the program runs, install hooks,
Then input characters in the Text, you can see, even change the button information in the hook procedure, also did not have the effect of "change",

I also saw "response to the order" :
The response of the hook, did before the Text control event!

CodePudding user response:

refer to 6th floor Chen8013 response:
didn't want to understand why no effect,

Previously tried it on, I not only changes the vkCode, and also the keyboard scan code "synchronization correction", also didn't also effect,
(I'm not change again after copymemory data, but direct change lParam data area)

Is system behind the keyboard messages sent, not the "hook" data shall prevail, but will be subject to the original keyboard data?
(message passing hook data is just a "copy", after processing to hook directly discarded?)
If so, then the practical significance of the "bottom HOOK" and how much...
Is for the convenience of "Trojan horse" keyboard record, please!



Boss carefully ah, to be honest, I really didn't expect the scan code synchronization correction, careless careless,

Just tried to use global variables, data transfer, the result -- -- -- -- -- -- -- -- -- -- -- - no, of course, : (

CodePudding user response:

refer to 7th floor Chen8013 response:
Quote: refer to 4th floor VBAHZ response:

.......
Also because can't code injection, thus unable to pass the modified data to the next hook?


Don't say "across processes" first, even for "process" also doesn't work!
You can try:
Draw yourself a Text controls, the program runs, install hooks,
Then input characters in the Text, you can see, even change the button information in the hook procedure, also did not have the effect of "change",

I also saw "response to the order" :
The response of the hook, did before the Text control event!


Very much agree with, because I tried, it is this kind of situation, even can't change their own process,
So the question...

Online search along while, over the years, didn't anyone found this problem?

CodePudding user response:

reference 5 floor zhao4zhong1 reply:
assembly instruction in front, no secret,
http://edu.csdn.net/course/detail/2344 C language pointer and assembly - a memory address. The code elements


Unknown sleep and complete good things ah, although not understand now, but collection:) first
  •  Tags:  
  • API
  • Related