Re: trouble decoding managed call stack causing kernel complaint

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance





Second, as MSDN stated, the WPARAM and LPARAM of the WM_PAINT message is
not used. Where do you find the doc talks about them?

http://msdn2.microsoft.com/en-us/library/ms534901.aspx

The last paragraph "For some common controls, the default WM_PAINT message
processing checks the wParam parameter. If wParam is non-NULL, the control
assumes that the value is an HDC and paints using that device context."

The .NET Framework does this also, despite the language suggesting that
this behavior is only for common controls.

Got Spy++ running and it shows that WM_PAINT messages always have an "hdc:
00000000" (I assume that Spy++ is labelling wParam as "hdc" as it cracks
WM_PAINT).

So based on the .NET Framework code, viewed through Reflector, the bad HDC
must be returned from BeginPaint.

Except that I've just realized that the error doesn't occur during the call
to SelectPalette from inside Control.SetupPalette, but from the call in
Control.WmPaint to restore the palette.

Figured out how to use !DumpStackObjects (immediately after the return from
the complaining call to SelectPalette) to look into the PaintEventArgs, the
dc member matches the value in the error printed by SelectPalette, and it is
not a multiple of 4 (that is sufficient to make it an invalid handle,
right?).

I grabbed the address of the clipRect member of the PaintEventArgs and used
the memory window to view it -- is there a better way to view managed value
types? At any rate, all four 32-bit integers were zero.

.... ran some more, stopped on the call to Control.SetupPalette. Listed the
arguments. Ran again. The first call to SelectPalette went fine, the
second generated the complaint, yet the "bad handle" matched the argument to
Control.SetupPalette. Not sure why the same HDC would be good in one
SelectPalette and bad in the next (I can't see any way that EndPaint would
be called in between).


.



Relevant Pages

  • Re: window image
    ... "For some common controls, the default WM_PAINT message processing ... If wParam is non-NULL, the control assumes ... message and pass in your own HDC in wParam to get it to paint on your ...
    (microsoft.public.vc.language)
  • Re: trouble decoding managed call stack causing kernel complaint
    ... I used the user-mode debugger with a breakpoint on SelectPalette (a ... lot of false positives but eventually stopped in the place that caused ... non-zero wParam, which triggers special processing in the BCL and doesn't ... The WM_PAINT docs say that some common controls ...
    (microsoft.public.win32.programmer.kernel)