我试图调用GetPointerFrameTouchInfo
函数来获取指针计数,但函数似乎失败了
错误998(对内存位置的无效访问)。
知道为什么会这样,以及如何解决它?
我试图在钩子程序GetMsgProc
内调用相同的内容,如下所述:
LRESULT WINAPI GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPMSG lpMsg = (LPMSG)lParam;
UINT32 pointerId = GET_POINTERID_WPARAM(lpMsg->wParam);
switch (lpMsg->message)
{
case WM_POINTERUPDATE:
UINT32 *pointerCount;
POINTER_TOUCH_INFO *pointerTouchInfo;
TCHAR outputLogTouchTst[100];
if (GetPointerFrameTouchInfo(pointerId, pointerCount, pointerTouchInfo) == 0)
{
_stprintf(outputLogTouchTst, _T("Hook: The error code for proc is %d"), GetLastError());
OutputDebugString(outputLogTouchTst);
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
_stprintf(outputLogTouchTst, _T("Hook: The count of pointers is %d"), pointerCount);
OutputDebugString(outputLogTouchTst);
return CallNextHookEx(NULL, nCode, wParam, lParam);
}
return CallNextHookEx(getmsghook, nCode, wParam, lParam);
}
答案 0 :(得分:0)
您正在声明指针变量但从未将它们设置为指向任何内容。您应该只声明普通变量,并将地址传递给函数。
constexpr maxpointers = 32;
UINT32 pointerCount = maxpointers;
POINTER_TOUCH_INFO pointerTouchInfo[maxpointers];
if (GetPointerFrameTouchInfo(pointerId, &pointerCount, pointerTouchInfo) == 0)
&
没有必要使用pointerTouchInfo
;因为它是一个数组,当它用作函数参数时会自动衰减为指针。