调用 GetPointerFrameTouchInfo 时出现错误 998(对内存位置的访问无效)

Error 998 (Invalid access to memory location) for when calling GetPointerFrameTouchInfo

我正在尝试调用 GetPointerFrameTouchInfo 函数来获取指针计数,但该函数似乎失败并显示

Error 998 (Invalid access to memory location).

知道为什么会这样吗?我该如何解决?
我正在尝试在挂钩过程 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);
}

您正在声明指针变量,但从未将它们设置为指向任何东西。您应该只声​​明普通变量,并将地址传递给函数。

constexpr maxpointers = 32;
UINT32 pointerCount = maxpointers;
POINTER_TOUCH_INFO pointerTouchInfo[maxpointers];

if (GetPointerFrameTouchInfo(pointerId, &pointerCount, pointerTouchInfo) == 0)

pointerTouchInfo没必要用&;因为它是一个数组,当用作函数参数时它会自动衰减为一个指针。