From e20c8a5cc735a2b3bc3d4e827d3c41c7959029d1 Mon Sep 17 00:00:00 2001 From: Geoffrey McRae Date: Tue, 6 Oct 2020 23:24:01 +1100 Subject: [PATCH] [host] dxgi: don't try to get the hotspot of a null cursor --- host/platform/Windows/capture/DXGI/src/dxgi.c | 29 ++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/host/platform/Windows/capture/DXGI/src/dxgi.c b/host/platform/Windows/capture/DXGI/src/dxgi.c index 322d6aff..e36c7938 100644 --- a/host/platform/Windows/capture/DXGI/src/dxgi.c +++ b/host/platform/Windows/capture/DXGI/src/dxgi.c @@ -832,23 +832,32 @@ static CaptureResult dxgi_capture() CURSORINFO ci = { .cbSize = sizeof(CURSORINFO) }; if (!GetCursorInfo(&ci)) { - DEBUG_ERROR("GetCursorInfo failed"); + DEBUG_WINERROR("GetCursorInfo failed", GetLastError()); return CAPTURE_RESULT_ERROR; } - ICONINFO ii; - if (!GetIconInfo(ci.hCursor, &ii)) + if (ci.hCursor) { - DEBUG_ERROR("GetIconInfo failed"); - return CAPTURE_RESULT_ERROR; - } + ICONINFO ii; + if (!GetIconInfo(ci.hCursor, &ii)) + { + DEBUG_WINERROR("GetIconInfo failed", GetLastError()); + return CAPTURE_RESULT_ERROR; + } - DeleteObject(ii.hbmMask); - DeleteObject(ii.hbmColor); + DeleteObject(ii.hbmMask); + DeleteObject(ii.hbmColor); + + pointer.hx = ii.xHotspot; + pointer.hy = ii.yHotspot; + } + else + { + pointer.hx = 0; + pointer.hy = 0; + } pointer.shapeUpdate = true; - pointer.hx = ii.xHotspot; - pointer.hy = ii.yHotspot; pointer.width = shapeInfo.Width; pointer.height = shapeInfo.Height; pointer.pitch = shapeInfo.Pitch;