I noticed in OllyDbg that when I make the call GDI32.SetTextColor with a setting of "Red", OllyDbg shows that the color is actually "LightRed"; and when I use "Green", it's actually "LightGreen".
I looked in windows.inc and found some EQU's for a few colors, but none of them were "Light___". I've performed a search through all of the files that came with MASM32, but none of them have "LightRed" or "LightGreen". MSDN hasn't really done much at helping me cross-reference at least these colors to SetTextColor. I know that the macro RGB can be called, but a list of predefined colors could come in useful.
I was wondering if there was a master list available that shows all of the predefined colors SetTextColor recognizes. I know that the macro RGB can be called, but a list of predefined colors could come in useful.
Thanks,
-Shooter
What is light and what is dark is subjective. If you experment, you'll notice Light_Red could be interpreted anywhere from 0x00FFB7B7 to 0x00FFF0F0. That gives us 56 shades, so your best solution is to define a list of your own. CCS & HTML documentation have some charts that may help, but probably quite a bit of work. This page may be of some help establishing colors
http://www.w3schools.com/css/css_colors.asp
Quote from: Tight_Coder_Ex on December 31, 2010, 02:57:47 AM
What is light and what is dark is subjective.
I realize that colors are subjective in the light and dark sense, but when I wrote my code, I used the textual term "Red"; however, after compiling it, OllyDbg shows that the SetTextColor call to GDI32 actually uses the textual term "LightRed", not Red. This tells me that GDI32 has a predefined set of accepted colors. It's there that I'm curious about, as well as why there's a difference between my .asm file and .exe file.
the gdi functions don't know the meaning of "red". "blue", "light_whatever" they only know numbers.... i think that is ollys interp of what the color is the word red that you used is an equ for a number in windows.inc
Quote from: Gunner on December 31, 2010, 03:07:03 AM
i think that is ollys interp of what the color is
That's what I was wondering.
and....
the human eye is more sensitive to green light, and less sensitive to blue light
the "brightness" of a specific color value (refered to as luminance) may be calculated from a simple formula
Y = 0.299 R + 0.587 G + 0.114 B
this is the formula you might use to convert a color image to grey-shade, like a B&W photo
i used to wrok for a company that made LCD display panels - back in the days of grey-shade stuff - lol
i found that you could make a pretty good image if you had at least 24 grey shades
Quote from: Gunner on December 31, 2010, 03:07:03 AM
the gdi functions don't know the meaning of "red". "blue", "light_whatever" they only know numbers.... i think that is ollys interp of what the color is the word red that you used is an equ for a number in windows.inc
I've used a multitude of tools from hex editors to a few debuggers, as well as Windows Search, and I can't seem to find any string that matches that of "LightGreen" or "LightRed" in OllyDbg.exe. This leads me to believe that it's not Olly interpreting the colors, it's something else.
Anyone got any ideas?
I have seen the standard console colors labeled two different ways.
1.
BLACK EQU 0
DARKBLUE EQU 1
DARKGREEN EQU 2
DARKCYAN EQU 3
DARKRED EQU 4
DARKMAGENTA EQU 5
DARKYELLOW EQU 6
GRAY EQU 7
DARKGRAY EQU 8
BLUE EQU 9
GREEN EQU 10
CYAN EQU 11
RED EQU 12
MAGENTA EQU 13
YELLOW EQU 14
WHITE EQU 15
2.
BLACK EQU 0
BLUE EQU 1
GREEN EQU 2
CYAN EQU 3
RED EQU 4
MAGENTA EQU 5
YELLOW EQU 6
LIGHTGRAY EQU 7
GRAY EQU 8
LIGHTBLUE EQU 9
LIGHTGREEN EQU 10
LIGHTCYAN EQU 11
LIGHTRED EQU 12
LIGHTMAGENTA EQU 13
LIGHTYELLOW EQU 14
WHITE EQU 15
Just a matter of perspective I guess.
GregL,
Which ones come from where?
-Shooter
You could download the source for Olly and see if you can figure out how they decode the numbers to names?
Quote from: Shooter on January 02, 2011, 04:24:48 AM
Quote from: Gunner on December 31, 2010, 03:07:03 AM
the gdi functions don't know the meaning of "red". "blue", "light_whatever" they only know numbers.... i think that is ollys interp of what the color is the word red that you used is an equ for a number in windows.inc
I've used a multitude of tools from hex editors to a few debuggers, as well as Windows Search, and I can't seem to find any string that matches that of "LightGreen" or "LightRed" in OllyDbg.exe. This leads me to believe that it's not Olly interpreting the colors, it's something else.
Anyone got any ideas?
That's because they don't come from OllyDbg, they come from the symbol server :wink
QuoteThat's because they don't come from OllyDbg, they come from the symbol server
OK, I think I'm gonna need an education on how that works.
Quote from: Shooter on January 02, 2011, 06:57:16 AM
QuoteThat's because they don't come from OllyDbg, they come from the symbol server
OK, I think I'm gonna need an education on how that works.
No, that is so far beyond where you're at right now it would be a waste of time for you and the person trying to explain it. There are other things that you can learn that will have more impact on your ability to program in MASM. This is an area that requires years of experience and if you don't understand it that's probably because you're not ready to. Learn to write a program first, taking it apart you can save for when you're ready.
i happen to be working on some code where i wanted to create several colors - more than the "normal 16"
i may add a couple greys, but as it stands, the code provides for selection from 27 colors...
TCOLOR_000 EQU 0000000h ;black
TCOLOR_001 EQU 07F0000h ;navy
TCOLOR_002 EQU 0FF0000h ;blue
TCOLOR_010 EQU 000007Fh ;maroon
TCOLOR_011 EQU 07F007Fh ;purple
TCOLOR_012 EQU 0FF007Fh ;violet
TCOLOR_020 EQU 00000FFh ;red
TCOLOR_021 EQU 07F00FFh ;rose
TCOLOR_022 EQU 0FF00FFh ;magenta
TCOLOR_100 EQU 0007F00h ;ao (dark green)
TCOLOR_101 EQU 07F7F00h ;teal
TCOLOR_102 EQU 0FF7F00h ;azure
TCOLOR_110 EQU 0007F7Fh ;olive
TCOLOR_111 EQU 07F7F7Fh ;grey
TCOLOR_112 EQU 0FF7F7Fh ;lavendar
TCOLOR_120 EQU 0007FFFh ;orange (amber)
TCOLOR_121 EQU 07F7FFFh ;pink
TCOLOR_122 EQU 0FF7FFFh ;light magenta
TCOLOR_200 EQU 000FF00h ;green (lime)
TCOLOR_201 EQU 07FFF00h ;spring green
TCOLOR_202 EQU 0FFFF00h ;cyan
TCOLOR_210 EQU 000FF7Fh ;chartreuse
TCOLOR_211 EQU 07FFF7Fh ;light green
TCOLOR_212 EQU 0FFFF7Fh ;light cyan
TCOLOR_220 EQU 000FFFFh ;yellow
TCOLOR_221 EQU 07FFFFFh ;light yellow
TCOLOR_222 EQU 0FFFFFFh ;white
the list is organized, more or less, by lowest-to-highest luminance (GRB order)
i wanted names for the colors - although, i may or may not put them in the menu - lol
i want to put owner-drawn "color swatches" on the selection menu
at any rate, the standard names/colors for html was a bit limited, even thought they use more colors
i found a great website where you can plug in the color value as part of the URL and it shows a page about that color - including the name
(you can also use their applet to enter a value)
note - for our purposes, they are organized in BGR order - the order is reversed for HTML purposes (RGB)
so, 0FF7F00h in masm-speak becomes #007FFF for html
http://www.perbang.dk/rgb/FFFF7F/
you have to scroll down a little to see the color name
here's the toolbar bitmap...
(http://img256.imageshack.us/img256/6228/colormenu.png)
that should be enough colors to pick a background and foreground :P
in fact, i could toss out a half dozen of em
Why not use the Color dialog?
;=========================================================================
include \masm32\include\masm32rt.inc
;=========================================================================
.data
;-------------------------------------------------
; These RGB values approximate the default colors
; for the first 16 VGA Color (DAC) registers.
;-------------------------------------------------
cust dd 00000000h,00aa0000h,0000aa00h,00aaaa00h
dd 000000aah,00aa00aah,000055aah,00aaaaaah
dd 00555555h,00ff5555h,0055ff55h,00ffff55h
dd 005555ffh,00ff55ffh,0055ffffh,00ffffffh
cc CHOOSECOLOR <>
.code
;=========================================================================
start:
;=========================================================================
mov cc.lStructSize, SIZEOF CHOOSECOLOR
mov cc.lpCustColors, OFFSET cust
mov cc.Flags, CC_SOLIDCOLOR
invoke ChooseColor, ADDR cc
print str$(eax),13,10
print hex$(cc.rgbResult),"h",13,10,13,10
inkey "Press any key to exit..."
exit
;=========================================================================
end start
thanks Michael - you make it look so easy
i bet it took me more time to make the toolbar bitmap :lol
As great as it is to know how to do those Micheal and Dave, and way cool to know too, the whole point to my original question was to know where Olly was getting it's interpretation from my .asm word of "Red" to it's interpretation of "LightRed".
GregL's lists seems the closest to answering this, but where did those EQU's come from? Are they in a .DLL someplace that isn't documented? If the compiler did it's job correctly, which it did, "Red" should've translated into a hex number, and that number would be what I'd normally see, but somehow something is re-interpreting that number back into "LightRed" in Olly, and it doesn't look like Olly is the culprit.
Edgar, I can appreciate what you're saying about needing experience on Symbol Servers. Last night I downloaded the MS Symbol Server Pack for XP SP3 (http://msdl.microsoft.com/download/symbols/packages/windowsxp/WindowsXP-KB936929-SP3-x86-symbols-full-ENU.exe) and poked around a little here and there. It does seem a little overwhelming to a guy like me. :eek
My quest continues...
Quote from: Shooter on January 02, 2011, 04:57:27 PM
Edgar, I can appreciate what you're saying about needing experience on Symbol Servers. Last night I downloaded the MS Symbol Server Pack for XP SP3 (http://msdl.microsoft.com/download/symbols/packages/windowsxp/WindowsXP-KB936929-SP3-x86-symbols-full-ENU.exe) and poked around a little here and there. It does seem a little overwhelming to a guy like me. :eek
My quest continues...
If you stumble over the meaning of life while you're heading in that direction let me know :wink
Shooter, do not worry about this as it is gong to hinder you learning and writing in assembly. What a debugger textually calls a number should not matter, you know what color you entered in your code, the correct color shows up in your program.
Instead of using Red, I can change that to UglyRed = the red equate and all will work... the color name just represents a number, the color name can be/mean different things to different people. Hell, you don't even call a dword a dword, or call eax eax.. you can define them anything in your source. Hell, my last name start with Dw, so I do Dw<rest of last name> equ DWORD.
Where are the equates? In header files and on MSDN, but they may be called different colors on different sites depening on the writer of th doc..
Quote from: oex on January 02, 2011, 05:03:21 PM
If you stumble over the meaning of life while you're heading in that direction let me know :wink
Good to know, and I may just take you up on that offer. :bg
Rob, I know in the end it's all just numbers. I was just curious to know how Olly got that name because I wanted to see the complete list of available names. I wondered if "Turquoise" or some other odd color would be in it as well.
I also know that there are a plethora of other sources to convert colors into numbers, such as the RGB macro. Speaking of which: I haven't tried anything like this yet, but I wonder if it's possible to do something like this:
StrangeColor1 DD RGB(125,233,80) ;or
StrangeColor1 EQU RGB(125,233,80)
-Shooter
Quote from: Shooter on January 02, 2011, 05:25:56 PM
I wanted to see the complete list of available names. I wondered if "Turquoise" or some other odd color would be in it as well.
Well, there are list of color name an values on the net. BUT a name is only a name, one website or doc might call a color one name and another site/doc might call it something else.
Quote from: Gunner on January 02, 2011, 05:28:31 PM
Quote from: Shooter on January 02, 2011, 05:25:56 PM
I wanted to see the complete list of available names. I wondered if "Turquoise" or some other odd color would be in it as well.
Well, there are list of color name an values on the net. BUT a name is only a name, one website or doc might call a color one name and another site/doc might call it something else.
Ok, let me rephrase... I wanted to see a complete list of available names that Olly seems to recognize.
Shooter,
Sorry I didn't reply sooner. Those console color equates (1.) come from my own include file. I modeled it after the console COLOR command, although it's not identical. (2.) was from other code I have seen. It's the number that matters the names aren't standard. There is also a table that determines the actual RGB value each of those standard console color numbers 0-15 represent.
For a GUI program it's all RGB.
Quote from: Shooter on January 02, 2011, 05:40:51 PM
Ok, let me rephrase... I wanted to see a complete list of available names that Olly seems to recognize.
That list is available by downloading the development kit and checking the indexes that OllyDbg passes to its syntax highlighter in the plugin header.
from Michael's ChooseColor example, i see that the values approximate the old CGA text-mode colors
it may be that Olly follows this same approximation
http://en.wikipedia.org/wiki/Color_Graphics_Adapter
if you scroll down a little and look on the right side of the page - there is a color table
offhand, i would say the approximation is not that accurate
just to the left of that table is the formula used and an explanation
EDIT - the colors that i see may be a result of modern LCD displays, as opposed to CRT monitors of days past
the backlight behind the LCD display is a little high in blue content, and perhaps a slight green
that may account for red appearing to be a little washed out
Quote from: dedndave on January 02, 2011, 11:21:11 PM
from Michael's ChooseColor example, i see that the values approximate the old CGA text-mode colors
For the VGA, that is by design. And judging from the defines in wincon.h:
#define FOREGROUND_BLUE 0x0001 // text color contains blue.
#define FOREGROUND_GREEN 0x0002 // text color contains green.
#define FOREGROUND_RED 0x0004 // text color contains red.
#define FOREGROUND_INTENSITY 0x0008 // text color is intensified.
#define BACKGROUND_BLUE 0x0010 // background color contains blue.
#define BACKGROUND_GREEN 0x0020 // background color contains green.
#define BACKGROUND_RED 0x0040 // background color contains red.
#define BACKGROUND_INTENSITY 0x0080 // background color is intensified.
The console attributes work the same as the VGA alphanumeric-mode attributes, but there is no knowing what color value they actually index. So far I have not found any substantial list of colors by name in the Microsoft documentation or header files.
i'm pretty sure you can read the palette registers in 16-bit code, Michael
ah yes - INT 10h, AX = 1017h
remember - they are 6-bit values :P
they need to be shifted left to make 8-bit sense
Quote from: dedndave on January 03, 2011, 11:14:12 AM
i'm pretty sure you can read the palette registers in 16-bit code, Michael
ah yes - INT 10h, AX = 1017h
remember - they are 6-bit values :P
they need to be shifted left to make 8-bit sense
Those aren't the "palette registers", they are called DAC registers.
The 16+1 palette registers are read with int 10h, ax=1009h - all at once.
Also, the values most likely are "emulated" if the NTVDM-application isn't in fullscreen-mode.
right - DAC registers
the idea was - to see what they are set to
we can get to full-screen, dump them, then exit
later on today, i may play with it
Quote from: donkey on January 02, 2011, 09:59:46 PM
That list is available by downloading the development kit and checking the indexes that OllyDbg passes to its syntax highlighter in the plugin header.
Edgar,
In my hastened search I haven't yet located the development kit on ollydbg.de website. Am I just not seeing it, or is it someplace else?
-Shooter
http://ollydbg.de/download.htm
bottom of the page
note - it is for v 1.10 :'(
Does rgbResult represent the color chosen by the user? is it a pointer? or does the result come in EAX? thanks
its just that i was using choosecolor but cant get the color out. rbgResult i always zero wether i use the Structures dword variable or point it to somewhere. does anyone have an example? Thanks
The rgbResult member is the COLORREF value of whatever color was selected when the user clicked the OK button, which could be zero if the selected color was black.
;=========================================================================
; Build as console app.
;=========================================================================
include \masm32\include\masm32rt.inc
;=========================================================================
.data
;-------------------------------------------------
; These RGB values approximate the default colors
; for the first 16 VGA Color (DAC) registers.
;-------------------------------------------------
cust dd 00000000h,00aa0000h,0000aa00h,00aaaa00h
dd 000000aah,00aa00aah,000055aah,00aaaaaah
dd 00555555h,00ff5555h,0055ff55h,00ffff55h
dd 005555ffh,00ff55ffh,0055ffffh,00ffffffh
cc CHOOSECOLOR <>
.code
;=========================================================================
start:
;=========================================================================
mov cc.lStructSize, SIZEOF CHOOSECOLOR
mov cc.lpCustColors, OFFSET cust
mov cc.Flags, CC_SOLIDCOLOR
invoke ChooseColor, ADDR cc
print str$(eax),13,10
print hex$(cc.rgbResult),"h",13,10,13,10
inkey "Press any key to exit..."
exit
;=========================================================================
end start
Sorry... it seems there was no problem there. I can't seem to set the color depth to display colors in my little app.
Dave is right here, the most reliable way to specify a colour is in COLORREF format, 00BBGGRRh where blue is BB, green is GG and red is RR. The leading 00 is used with RGB/a (alpha channel) for transparency.
Henry Ford (refering to available colors for the model A)
"You can have any color you like, as long as it's black" :P