问题
I am trying to call the GetPointerFrameTouchInfo
function to get the pointer count but the function seems to fail with
Error 998 (Invalid access to memory location).
Any idea why that is happening and how I can resolve it?
I am trying to call the same inside the hook procedure GetMsgProc
as mentioned below:
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);
}
回答1:
You're declaring pointer variables but never setting them to point to anything. You should just declare ordinary variables, and pass the addresses to the function.
constexpr maxpointers = 32;
UINT32 pointerCount = maxpointers;
POINTER_TOUCH_INFO pointerTouchInfo[maxpointers];
if (GetPointerFrameTouchInfo(pointerId, &pointerCount, pointerTouchInfo) == 0)
It's not necessary to use &
for pointerTouchInfo
; since it's an array, it automatically decays to a pointer when used as a function argument.
来源:https://stackoverflow.com/questions/48652286/error-998-invalid-access-to-memory-location-for-when-calling-getpointerframeto