News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Colors

Started by Shooter, December 31, 2010, 02:41:52 AM

Previous topic - Next topic

MichaelW

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
eschew obfuscation

dedndave

thanks Michael - you make it look so easy
i bet it took me more time to make the toolbar bitmap  :lol

Shooter

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 and poked around a little here and there. It does seem a little overwhelming to a guy like me.  :eek

My quest continues...
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

oex

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 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
We are all of us insane, just to varying degrees and intelligently balanced through networking

http://www.hereford.tv

Gunner

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..
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

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
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Gunner

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.
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

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.
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

GregL

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.


donkey

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.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

dedndave

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

MichaelW

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.

eschew obfuscation

dedndave

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

japheth

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.

dedndave

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