c#中的WH_JOURNALPLAYBACK钩子
本文关键字:JOURNALPLAYBACK 钩子 WH 中的 | 更新日期: 2023-09-27 18:09:30
我试图在c#中创建一个回调"WH_JOURNALPLAYBACK"钩子。这是代码
private delegate IntPtr JournalPlaybackProc(int nCode, IntPtr wParam, IntPtr lParam);
private static IntPtr JournalPlaybackCallback(int nCode, IntPtr wParam, IntPtr lParam)
{
if (HC_GETNEXT == nCode && curr < EventMsgs.Count)
{
EVENTMSG hookStruct = (EVENTMSG)Marshal.PtrToStructure(lParam, typeof(EVENTMSG));
EVENTMSG currentMsg = EventMsgs[curr];
hookStruct.message = currentMsg.message;
hookStruct.paramL = currentMsg.paramL;
hookStruct.paramH = currentMsg.paramH;
hookStruct.hwnd = currentMsg.hwnd;
hookStruct.time = currentMsg.time;
}
if (HC_SKIP == nCode)
{
curr++;
}
if (curr == EventMsgs.Count)
{
UnhookWindowsHookEx(_journalPlaybackProcHookID);
_journalPlaybackProcHookID = IntPtr.Zero;
}
return CallNextHookEx(_journalPlaybackProcHookID, nCode, wParam, lParam);
}
我得到正确的回调,我想我需要修改lParam的值与我的数据播放事件。我该怎么做呢?
我想你需要
Marshal.StructureToPtr (hookStruct lParam,真的);
在某个点将它写回来。当我运行时,它只是挂起。