HOOK钩子机制学习笔记(3) - 钩子常用结构体MSDN翻译整理 收藏

HOOK钩子机制学习笔记(3) - 钩子常用结构体MSDN翻译整理 收藏 

作者:MaybeHelios     blog: http://blog.csdn.net/maybehelios/   

下面是应用Hook时会用到的各种结构。

结构1:CBT_CREATEWND Structure

    The CBT_CREATEWND structure contains information passed to a WH_CBT hook procedure, CBTProc, before a window is created.
    该结构包含有:在一个窗口被创建之前传递给WH_CBT钩子子程,即CBTProc,的信息。

typedef struct {
    LPCREATESTRUCT lpcs;
    HWND hwndInsertAfter;
} CBT_CREATEWND, *LPCBT_CREATEWND;

Members成员
lpcs
    Pointer to a CREATESTRUCT structure that contains initialization parameters for the window about to be created.
    一个指向CREATESTRUCT结构的指针,该结构包含即将被创建的窗体的初始化参数。

hwndInsertAfter
    Handle to the window whose position in the Z order precedes that of the window being created.
    窗体的句柄,该窗体的Z轴位置在正在被创建的窗体的Z轴位置之前。

结构2:CBTACTIVATESTRUCT Structure

    The CBTACTIVATESTRUCT structure contains information passed to a WH_CBT hook procedure, CBTProc, before a window is activated.
    CBTACTIVATESTRUCT 结构包含在窗体被激活之前,传递给WH_CBT钩子子程CBTProc 的信息。

typedef struct {
    BOOL fMouse;
    HWND hWndActive;
} CBTACTIVATESTRUCT, *LPCBTACTIVATESTRUCT;

Members 成员
fMouse
    Specifies whether the window is being activated as a result of a mouse click. This value is TRUE if a mouse click is causing the activation or FALSE if it is not.
    指定窗体是否是由于鼠标的点击而导致被激活.如果是因为鼠标的点击而引发了窗体的激活,返回true,否则返回false。

hWndActive
    Handle to the active window.
    活动窗口的句柄。

结构3:CWPRETSTRUCT Structure

    The CWPRETSTRUCT structure defines the message parameters passed to a WH_CALLWNDPROCRET hook procedure, CallWndRetProc.
    CWPRETSTRUCT结构定义了传递给WH_CALLWNDPROCRET钩子子程CallWndRetProc的消息参数。

typedef struct {
    LRESULT lResult;
    LPARAM lParam;
    WPARAM wParam;
    UINT message;
    HWND hwnd;
} CWPRETSTRUCT, *PCWPRETSTRUCT;

Members成员
lResult
    Specifies the return value of the window procedure that processed the message specified by the message value. 
    指定了窗体程序的返回值,该窗体程序处理由 message 值指定的消息。

lParam / wParam
    Specifies additional information about the message. The exact meaning depends on the message value.
    指定消息的附加信息。附加的意义取决于message的值。

message
    Specifies the message.
    指定消息。

hwnd
    Handle to the window that processed the message specified by the message value.
    处理由message的值指定的消息的窗体的窗体句柄。

结构4:CWPSTRUCT Structure

    The CWPSTRUCT structure defines the message parameters passed to a WH_CALLWNDPROC hook procedure, CallWndProc.
    CWPSTRUCT 结构定义了传递给WH_CALLWNDPROC钩子子程CallWndProc的消息参数。

typedef struct {
    LPARAM lParam;
    WPARAM wParam;
    UINT message;
    HWND hwnd;
} CWPSTRUCT, *PCWPSTRUCT;

Members
lParam  / wParam
    Specifies additional information about the message. The exact meaning depends on the message value.
    指定消息的附加信息。附加的意义取决于message的值。

message
    Specifies the message.
    指定消息

hwnd
    Handle to the window to receive the message.
    接收消息的窗体的句柄。


 
结构5:DEBUGHOOKINFO Structure
    The DEBUGHOOKINFO structure contains debugging information passed to a WH_DEBUG hook procedure, DebugProc.
    DEBUGHOOKINFO结构包含有传递给WH_DEBUG钩子子程DebugProc的调试信息。

typedef struct {
    DWORD idThread;
    DWORD idThreadInstaller;
    LPARAM lParam;
    WPARAM wParam;
    int code;
} DEBUGHOOKINFO, *PDEBUGHOOKINFO;

Members成员
idThread
    Handle to the thread containing the filter function.
    包含过滤方法的线程的句柄。

idThreadInstaller
    Handle to the thread that installed the debugging filter function.
    安装调试过滤方法的线程的句柄。

lParam / wParam
    Specifies the value to be passed to the hook in the lParam parameter of the DebugProc callback function.
    指定在DebugProc回调函数的lParam/ wParam 参数中,要传递给钩子的值。

code
    Specifies the value to be passed to the hook in the nCode parameter of the DebugProc callback function.
    指定在DebugProc回调函数的nCode 参数中,要传递给钩子的值。

结构6:EVENTMSG Structure

    The EVENTMSG structure contains information about a hardware message sent to the system message queue. This structure is used to store message information for the JournalPlaybackProc callback function.
    该结构包含有关于硬件的消息,该消息被发送给系统的消息队列。该结构用来为JournalPlaybackProc回调函数存储消息的信息。

typedef struct {
    UINT message;
    UINT paramL;
    UINT paramH;
    DWORD time;
    HWND hwnd;
} EVENTMSG, *PEVENTMSG;

Members成员
message
    Specifies the message.
    指定消息。

paramH / paramH
    Specifies additional information about the message. The exact meaning depends on the message value.
    指定消息的附加信息。附加的意义取决于message的值。

time
    Specifies the time at which the message was posted.
    消息被传递时的时间 。

hwnd
    Handle to the window to which the message was posted.
    消息被传给的窗口的句柄。

结构7:KBDLLHOOKSTRUCT Structure

    The KBDLLHOOKSTRUCT structure contains information about a low-level keyboard input event.
    该结构包含有低层键盘输入事件的信息。

typedef struct {
    DWORD vkCode;
    DWORD scanCode;
    DWORD flags;
    DWORD time;
    ULONG_PTR dwExtraInfo;
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;

Members成员
vkCode
    Specifies a virtual-key code. The code must be a value in the range 1 to 254. 
    指定虚拟键值。该值必须在1到254的范围内。

scanCode
    Specifies a hardware scan code for the key.
    指定键的硬件扫描码。

flags
    Specifies the extended-key flag, event-injected flag, context code, and transition-state flag. This member is specified as follows. An application can use the following values to test the keystroke flags.
    指定扩展键标志,事件注入标志,上下文代码,转换状态码。成员如下所示。应用程序可以使用下列值来检查键盘敲击标志。

    Value值                            Purpose目的
    LLKHF_EXTENDED     Test the extended-key flag. 测试扩展键标志。
    LLKHF_INJECTED       Test the event-injected flag. 测试事件注入标志。
    LLKHF_ALTDOWN       Test the context code. 测试上下文代码。
    LLKHF_UP                    Test the transition-state flag. 测试转换状态码。
 
    0 :Specifies whether the key is an extended key, such as a function key or a key on the numeric keypad. The value is 1 if the key is an extended key; otherwise, it is 0.
    指定该键是否是扩展键,例如:功能键、数字键盘上的键。是扩展键为1,否则为0。

    1-3 :Reserved. 保留。

    4  :Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0.
    指定事件是否被注入。被注入为1,否则为0。

    5  :Specifies the context code. The value is 1 if the ALT key is pressed; otherwise, it is 0.
    指定上下文代码。如果按下了ALT,该值为1,否则为0

    6  :Reserved. 保留。

    7  :Specifies the transition state. The value is 0 if the key is pressed and 1 if it is being released.
    指定转换状态。如果该键被按下该值为1,如果被释放为0。

time
    Specifies the time stamp for this message, equivalent to what GetMessageTime would return for this message.
    指定消息的时间戳,相当于GetMessageTime返回的值。

dwExtraInfo
    Specifies extra information associated with the message.
    指定和该消息相关联的扩展信息。

结构8 :MOUSEHOOKSTRUCT Structure

      T he MOUSEHOOKSTRUCT structure contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.
     MOUSEHOOKSTRUCT结构包含有传递给WH_MOUSE钩子子程MouseProc的,关于鼠标事件的信息。

typedef struct {
    POINT pt;
    HWND hwnd;
    UINT wHitTestCode;
    ULONG_PTR dwExtraInfo;
} MOUSEHOOKSTRUCT, *PMOUSEHOOKSTRUCT;

Members成员
pt
    Specifies a POINT structure that contains the x- and y-coordinates of the cursor, in screen coordinates.
    指定在屏幕坐标系下,包含有光标x、y坐标的POINT结构。

hwnd
    Handle to the window that will receive the mouse message corresponding to the mouse event.
    希望对鼠标事件做出响应、接收鼠标消息的窗体的句柄。

wHitTestCode
    Specifies the hit-test value. For a list of hit-test values, see the description of the WM_NCHITTEST message.
    指定点击测试值。查看WM_NCHITTEST消息可以得到值的列表。

dwExtraInfo
    Specifies extra information associated with the message.
    指定和该消息相关联的附加信息。

结构9:MOUSEHOOKSTRUCTEX Structure

    The MOUSEHOOKSTRUCTEX structure contains information about a mouse event passed to a WH_MOUSE hook procedure, MouseProc.
    MOUSEHOOKSTRUCTEX结构包含有传递给WH_MOUSE钩子子程MouseProc的关于鼠标事件的信息。

    This is an extension of the MOUSEHOOKSTRUCT structure that includes information about wheel movement or the use of the X button.
    这是对MOUSEHOOKSTRUCT的扩展。包含有滚轮的活动和X键的使用。

typedef struct {
    MOUSEHOOKSTRUCT MOUSEHOOKSTRUCT;
    DWORD mouseData;
} MOUSEHOOKSTRUCTEX, *PMOUSEHOOKSTRUCTEX;

Members成员
MOUSEHOOKSTRUCT
    The members of a MOUSEHOOKSTRUCT structure make up the first part of this structure.
    MOUSEHOOKSTRUCT结构的成员构成了该结构的前面部分。

mouseData
    If the message is WM_MOUSEWHEEL, the HIWORD of this member is the wheel delta. The LOWORD is undefined and reserved. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
    如果消息是WM_MOUSEWHEEL,该成员的HIWORD就是wheel delta。LOWORD做为保留未定义。正值表示滚轮向前旋转,即远离用户的方向;负值表示滚轮向后旋转,即朝向用户的方向。滚轮的点击被定义为WHEEL_DELTA, 具体值为120。

    If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, or WM_NCXBUTTONDBLCLK, the HIWORD of mouseData specifies which X button was pressed or released, and the LOWORD is undefined and reserved. This member can be one or more of the following values. Otherwise, mouseData is not used.
    如果消息是WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, 或者 WM_NCXBUTTONDBLCLK,  mouseData  的HIWORD值指定哪个X键被按下或者释放,LOWORD做为保留未定义。该成员可以是以下值中的一个或者多个。否则,mouseData未使用。
    1.XBUTTON1 :The first X button was pressed or released. 第一个X键被按下或者释放。
    2.XBUTTON2 :The second X button was pressed or released.第二个X键被按下或者释放。

结构9:MSLLHOOKSTRUCT Structure

    The MSLLHOOKSTRUCT structure contains information about a low-level keyboard input event. (msdn错误)
    该MSLLHOOKSTRUCT结构包含有低层键盘输入事件的信息。

typedef struct {
    POINT pt;
    DWORD mouseData;
    DWORD flags;
    DWORD time;
    ULONG_PTR dwExtraInfo;
} MSLLHOOKSTRUCT, *PMSLLHOOKSTRUCT;

Members成员
pt
    Specifies a POINT structure that contains the x- and y-coordinates of the cursor, in screen coordinates.
    指定在屏幕坐标系下,包含有光标x、y坐标的POINT结构。

mouseData
    If the message is WM_MOUSEWHEEL, the HIWORD of this member is the wheel delta. The LOWORD is undefined and reserved. A positive value indicates that the wheel was rotated forward, away from the user; a negative value indicates that the wheel was rotated backward, toward the user. One wheel click is defined as WHEEL_DELTA, which is 120.
    如果消息是WM_MOUSEWHEEL,该成员的HIWORD就是wheel delta。LOWORD做为保留未定义。正值表示滚轮向前旋转,即远离用户的方向;负值表示滚轮向后旋转,即朝向用户的方向。滚轮的点击被定义为WHEEL_DELTA, 具体值为120。
    If the message is WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, or WM_NCXBUTTONDBLCLK, the HIWORD of mouseData specifies which X button was pressed or released, and the LOWORD is undefined and reserved. This member can be one or more of the following values. Otherwise, mouseData is not used.
    如果消息是WM_XBUTTONDOWN, WM_XBUTTONUP, WM_XBUTTONDBLCLK, WM_NCXBUTTONDOWN, WM_NCXBUTTONUP, 或者 WM_NCXBUTTONDBLCLK,  mouseData  的HIWORD值指定哪个X键被按下或者释放,LOWORD做为保留未定义。该成员可以是以下值中的一个或者多个。否则,mouseData未使用。
    1.XBUTTON1:The first X button was pressed or released. 第一个X键被按下或者释放。
    2.XBUTTON2 :The second X button was pressed or released.第二个X键被按下或者释放。

flags
    Specifies the event-injected flag. An application can use the following value to test the mouse flags.    
    指定事件注入标志。应用程序可以使用下列值来测试鼠标标志。

    Value                            Purpose
    LLMHF_INJECTED   Test the event-injected flag.测试事件注入标志。

    0
    Specifies whether the event was injected. The value is 1 if the event was injected; otherwise, it is 0.     事件是否被注入。如果被注入,为 1,否则为0

    1-15 :Reserved.保留

time
    Specifies the time stamp for this message.
    消息的时间戳。

dwExtraInfo
    Specifies extra information associated with the message.
    消息的扩展信息。


本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/jiangxinyu/archive/2010/02/03/5284094.aspx

你可能感兴趣的:(HOOK钩子机制学习笔记(3) - 钩子常用结构体MSDN翻译整理 收藏)