Case of the Black Background Window (.NET Patching)

On Windows XP  a Windows form had a white background, something like this:


However on Windows 8 it had a black background like this, making text on the form unreadable:



This is a common AppCompat bug…where the developer instead of selecting “White” to make a Windows form background, selected Active Caption Text.


This is a change from the default Control


If the source code is not available/developer can’t patch it, there are a few ways we can fix this. We can change Active Title Bar colour back to White on a Windows 7 machine, save it as a .themepack and apply it to Windows 8 or later.




Patching .NET EXE directly:

1) Open EXE in ILDasm and click File –> Dump then select the default settings. ILDasm is found in the Windows SDK, it will be in a folder similar to C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.6 Tools\

2) Open the .IL file in a text editor and search replace





Typically you will only want to replace those that just precede a set_BackColor

call       valuetype [System.Drawing]System.Drawing.Color [System.Drawing]System.Drawing.SystemColors::get_ActiveCaptionText()
callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_BackColor(valuetype [System.Drawing]System.Drawing.Color)


call       valuetype [System.Drawing]System.Drawing.Color [System.Drawing]System.Drawing.SystemColors::get_Control()
callvirt   instance void [System.Windows.Forms]System.Windows.Forms.Control::set_BackColor(valuetype [System.Drawing]System.Drawing.Color)


3) We then recompile the EXE, using ilasm which lives in the .NET framework directories, specifying the IL file and the .RES file output from ILDASM


c:\windows\\Framework\v2.0.50727\ilasm /RESOURCE=WorkflowApplication.res

4) You program should now be fixed!

For more patching examples refer to

About chentiangemalc

specializes in end-user computing technologies. disclaimer 1) use at your own risk. test any solution in your environment. if you do not understand the impact/consequences of what you're doing please stop, and ask advice from somebody who does. 2) views are my own at the time of posting and do not necessarily represent my current view or the view of my employer and family members/relatives. 3) over the years Microsoft/Citrix/VMWare have given me a few free shirts, pens, paper notebooks/etc. despite these gifts i will try to remain unbiased.
This entry was posted in .NET, AppCompat, IL, Patching. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s