winleafs/Winleafs

Screen mirror read or writing to proctected memory

Closed this issue · 2 comments

Describe the bug
Screen mirror effect tries to access protected memory and crashes because of it. Note that this happens with both the Screen Mirror and Ambilight.

This only happens with my secondary monitor in both landscape and portrait mode.
Monitor is 1080p, nothing out of the usual. Screen mirror on primary monitor works fine.
Checked the areasToCapture and the X and Y values looked fine.

Screenshots
image

Additional context
File: ScreenGrabber.cs
Line: 91
Method: CalculateAverageColor
@StijnOostdam said it might have to do with Bitmap.LockBits

Could you share your details on the values in areasToCapture when this exception occurs? My guess is that the areas are not normalized since they are generated for the second monitor, meaning they will try to get a value which is out of bounds for the bitmap.

Edit: just checked the code and the areas are normalized, so that cannot be the issue

Issue seems to have been a memory corruption within Visual Studio 2019 itself. Closing issue.