How to see if .Net control is visible with windbg

I have a crashdump where we discuss whether the control was visible to the end user or not. I do not see an explicit field in which the true / false value matches the Visible property, which is not surprisingly as strong as we probably are in the win32 dash. Does anyone know how to determine what Visible will return from a dump file?

thanks Oskar

+3
source share
1 answer

My initial thought was that it was just a matter of finding the right field, but actually it took a little more. If you look at Control in Reflector, you will see that the Visible property calls GetVisibleCore, which checks the internal state field for a value of 2 (which is the STATE_VISIBLE constant).

So, to find out if the control is visible, we need to find the status field and do some bit manipulation.

If you have an instance address, you can do the following:

.shell -ci "!do <ADDRESS>" grep state   (use findstr, if you don't have grep)

The result is similar to this.

0:000> .shell -ci "!do 015892a4" grep state
03aeedcc  400112c       4c         System.Int32  1 instance 17432589 state  <=== HERE!
03aeedcc  400112d       50         System.Int32  1 instance     2060 state2
049ac32c  40011ef       d0 ...lized.BitVector32  1 instance 01589374 state
03aeedcc  40011f0      ad4         System.Int32  1   static        1 stateScalingNeededOnLayout
03aeedcc  40011f1      ad8         System.Int32  1   static        2 stateValidating
03aeedcc  40011f2      adc         System.Int32  1   static        4     stateProcessingMnemonic
03aeedcc  40011f3      ae0         System.Int32  1   static        8 stateScalingChild
03aeedcc  40011f4      ae4         System.Int32  1   static       16 stateParentChanged

Note that there are two status fields. I did not look why this is so, but the one you want is System.Int32. In my example, it has a value of 17432589.

The code in GetState is as follows

return ((this.state & flag) != 0);

, , (17432589 & 2) != 0, .

, , , . false, . , .

+4

Source: https://habr.com/ru/post/1720784/


All Articles