winleafs / Winleafs

Winleafs: Windows application for Nanoleaf lights
GNU General Public License v3.0
85 stars 9 forks source link

Screen mirror read or writing to proctected memory #110

Closed bartdebever closed 4 years ago

bartdebever commented 4 years ago

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

StijnOostdam commented 4 years ago

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

bartdebever commented 4 years ago

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