Radiumflux - 17 Mar. 2008 - 11:38:
NEW MOD!! Changing Calculator button colors
I haven't been too active on the modding scene for a couple of years, but I was recently laid off from my job, which gives me PLENTY of time to mod. So, I decided to delve a bit deeper down the rabbit hole, fire up a hex editor, and see what I could do with a hex editor that I can't do with a resource editor.
I think that everyone can agree that the BS_OWNERDRAW colored buttons on the calculator are pretty atrocious; and the fact that we can't change the colors in the resources makes it all the more attractive to set them to BS_PUSHBUTTON.
However, after hex editing the colors in my task manager (props to des for figuring it out on XP) I decided to apply the same methodology to finding the color values in the calculator. This pertains directly to 2000, but hopefully will still apply to other versions.
What you're going to need for this mod is a hex editor, reshacker, and a spare copy of calc.exe. For choice of hex editors, I recommend XVI32 as a good starting point.
For the stock calculator we are going to be dealing with Red (FF0000) Blue (0000FF) and Magenta (FF00FF) exclusively, which would seem easy enough. However, some of you experienced hex editors may already be cringing a bit -- yeah, look at those Fs and 0s. There are tons of FF and 00 bytes in the average PE, and they often happen to be next to each other. Which certainly makes tracking down a color value time consuming when you have to filter out all the false positives. Luckily, Calc appears to have been put together somewhat logically, and the byte strings aren't too terribly difficult to find. Mostly because the bulk of the strings are grouped together.
Colors are applied to individual buttons, which means there are a lot of strings; in addition, there appears to be a superficial byte usually pertaining or somehow related to the control number. More on that... its weird. Also, most of the color strings are preceded by "00 00 00", followed by a final 00 and the "control number" descriptor byte.
In general strings look like: 000000[0000FF]0050, where the value within the brackets is the default color value. The above listed string is for the "+/-" button which sure enough is control 80 in the resources. The next string is 000000[FF0000]0051, which is the "C" button, which is control 81, so on and so forth for a while. Just remember the preceding 00s and the control number at the end, which you can check in reshacker.
Then somebody had to screw it up at descriptor byte 67/control 81 (sqrt button). The next descriptor is 8C and it points to the "x^2" button, which is control 104 in the resource.
The descriptor after that is 68, which points to control 105, or x^3. So, your descriptor values are now pointing to control number minus one. This holds true until value 78/control 121, and then things change again.
The next string should contain value 28, and points to " ( " but the control number is 110. likewise 29 points to " ) " but that control is 122. Following that are ten strings that all have value 30; these are the numeric buttons. After that are six strings with value 41, which are the A-F for hex.
That covers the bulk of them, however the "1/x" button is still missing. To find that one, I pretty much had to search for it by trial and error. Starting from the top of the file, I ran a search for 0000FF00. Each time I ran into it, I'd replace it with 00FF0000, save, fire up my edited copy of calc, look for "1/x" in green, and change the string back to the original value if it isn't. This may be obvious, but since a sperate copy of calc is not protected, no replacing or restarting is necessary. In my case, the 0000FF string was preceded by F86B7507B8, which may or may not work for you, possibly depending on whether you have 2K or not.
If you do find yourself having to hunt down elusive color values, a word of caution: PE files contain a lot of FF/00/mix of strings though. Most of them are surrounded by a sea of nothing but 00s and FFs, you can probably disregard these. What you are looking for is a 3 byte color value (hopefully with an extra set of zeroes at the end) surrounded by "data" i.e. (...F512A4[0000FF00]459C...) in some discernable way. Generally, the color value is one of these, and they are luckily fewer since you will most likely have to check several before you do find the right string.
And that about covers it. Hopefully the strings and values above are relevant, and if not, the correct strings shouldn't be too terribly difficult to find if your time is cheap.
Now for a screen:
http://img258.imageshack.us/img258/9107/calcel9.jpg