[host] dxgi: don't try to get the hotspot of a null cursor

This commit is contained in:
Geoffrey McRae 2020-10-06 23:24:01 +11:00
parent 4f4d2dbf42
commit e20c8a5cc7

View File

@ -832,23 +832,32 @@ static CaptureResult dxgi_capture()
CURSORINFO ci = { .cbSize = sizeof(CURSORINFO) }; CURSORINFO ci = { .cbSize = sizeof(CURSORINFO) };
if (!GetCursorInfo(&ci)) if (!GetCursorInfo(&ci))
{ {
DEBUG_ERROR("GetCursorInfo failed"); DEBUG_WINERROR("GetCursorInfo failed", GetLastError());
return CAPTURE_RESULT_ERROR; return CAPTURE_RESULT_ERROR;
} }
if (ci.hCursor)
{
ICONINFO ii; ICONINFO ii;
if (!GetIconInfo(ci.hCursor, &ii)) if (!GetIconInfo(ci.hCursor, &ii))
{ {
DEBUG_ERROR("GetIconInfo failed"); DEBUG_WINERROR("GetIconInfo failed", GetLastError());
return CAPTURE_RESULT_ERROR; return CAPTURE_RESULT_ERROR;
} }
DeleteObject(ii.hbmMask); DeleteObject(ii.hbmMask);
DeleteObject(ii.hbmColor); DeleteObject(ii.hbmColor);
pointer.shapeUpdate = true;
pointer.hx = ii.xHotspot; pointer.hx = ii.xHotspot;
pointer.hy = ii.yHotspot; pointer.hy = ii.yHotspot;
}
else
{
pointer.hx = 0;
pointer.hy = 0;
}
pointer.shapeUpdate = true;
pointer.width = shapeInfo.Width; pointer.width = shapeInfo.Width;
pointer.height = shapeInfo.Height; pointer.height = shapeInfo.Height;
pointer.pitch = shapeInfo.Pitch; pointer.pitch = shapeInfo.Pitch;