prasannavl / WinApi

A simple, direct, ultra-thin CLR library for high-performance Win32 Native Interop
Apache License 2.0
823 stars 101 forks source link

App locks after taking a screenshot #10

Closed mattkol closed 7 years ago

mattkol commented 7 years ago

Hi,

Thanks for a wonderful project. I also appreciate the migration to ,NET Standard.

I am using Winapi in a new Chromium project - https://github.com/mattkol/Chromely.

So far it has been great, but I have noticed 2 issues ..just want to see if you a quick opinion on what is going on.

  1. Sometime when I take a screenshot of the window, it locks the app, and the Paint app and especially (of concern) Task Manager.. other programs work normal.

  2. In this file -- https://github.com/mattkol/Chromely/blob/master/ChromelySolution/Chromely.Core/ChromeHosts/Winapi/CefGlueBrowserWinapiHost.cs

I get these errors: Chromely.Core.ChromeHosts.Winapi.CefGlueBrowserWinapiHost.OnSize(SizePacket& packet) at WinApi.Windows.Packetizer.ProcessSize(WindowMessage& msg, EventedWindowCore window) at WinApi.Windows.WindowCore.WindowProc(IntPtr hwnd, UInt32 msg, IntPtr wParam, IntPtr lParam)

Object reference not set to an instance of an object. at Chromely.Core.ChromeHosts.Winapi.CefGlueBrowserWinapiHost.OnDestroy(Packet& packet) at WinApi.Windows.Packetizer.ProcessDestroy(WindowMessage& msg, EventedWindowCore window) at WinApi.Windows.WindowCore.WindowProc(IntPtr hwnd, UInt32 msg, IntPtr wParam, IntPtr lParam)

Any advise will be appreciated.

Thanks.

prasannavl commented 7 years ago

@mattkol - Interesting. First I'd try to pin point where the issue is - and if it's even related to WinApi. Where's the null ref happening exactly? Were you able to get it from the debugger which null reference your code was trying to dereference?

prasannavl commented 7 years ago

Also, quickly glancing through your code, it looks like you're mixing and matching charsets. This may or may not be related. But I've found that often strange problems occur when you mix and match Unicode and ANSI variants of the native Windows API - regardless of the language, or library. LoadImage, here uses the charset that's defined through the compiler directive - but I didn't it being set to UNICODE. Would suggest that you keep things consistent, or simply just use use unicode, and drop ANSI.

mattkol commented 7 years ago

Thanks for your quick response. Highly appreciated. I will look into the UNICODE part ..

For the null reference.. yes may may not be related to Winapi ... I will investigate. I just thought I may not be using the Winapi functionalities correctly.'

Thank you.

prasannavl commented 7 years ago

I'm closing this. Please feel free to open it again if you feel there's something more to be discussed.