flat assembler
Message board for the users of flat assembler.

Index > Windows > Getting the console text attributes

Author
Thread Post new topic Reply to topic
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes
Hey, im am trying to create a function that will get the foreground and background colors of the console. I was looking through MSDN and it says that you need to use GetConsoleScreenBufferInfo, which requires a CONSOLE_SCREEN_BUFFER_INFO structure. I want to know why I cant simply create one as a local variable like so
Code:
local info:CONSOLE_SCREEN_BUFFER_INFO    

So could you show me how to do this
I have considered using HeapAlloc, but im not sure that that is the best idea

_________________
He is no fool who gives what he cannot
keep to gain what he cannot loose.
Post 09 Dec 2011, 03:07
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1288
Location: behind the arc
Picnic
Hi,

Here is a sample using CSBI.
Post 09 Dec 2011, 06:31
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
You can get some room on stack simply by moving ESP register:
Code:
sub esp, sizeof.CONSOLE_SCREEN_BUFFER_INFO
mov   edi, esp
invoke      GetConsoleScreenBufferInfo, [hOutput], edi
mov       ax, [edi + GetConsoleScreenBufferInfo.wAttributes]
add       esp, sizeof.CONSOLE_SCREEN_BUFFER_INFO
    
Post 09 Dec 2011, 11:34
View user's profile Send private message Send e-mail Reply with quote
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes
I decided to do what AsmGuru said and just create the nessesary space for the data. BUT his examplt didnt work, FASM continualy says
Code:
Undefined Symbol: esp,sizeof.CONSOLE_SCREEN_BUFFER_INFO    

The error is refering to the operand of 'sizeof' so I am assuming that I simply did not include a nessesary file

_________________
He is no fool who gives what he cannot
keep to gain what he cannot loose.
Post 11 Dec 2011, 23:23
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1413
Location: Toronto, Canada
AsmGuru62
Strange... my FASM package does not have the definition of that structure and its components. Here they are:
Code:
struct COORD
    X dw ?
    Y dw ?
ends
struct SMALL_RECT
    Left    dw ?
    Top     dw ?
    Right   dw ?
    Bottom  dw ?
ends
struct CONSOLE_SCREEN_BUFFER_INFO
    dwSize               COORD
    dwCursorPosition     COORD
    wAttributes          dw ?
    srWindow             SMALL_RECT
    dwMaximumWindowSize  COORD
ends
    

Put this somewhere in your .INC file(s) and try the code again.
Post 12 Dec 2011, 00:05
View user's profile Send private message Send e-mail Reply with quote
NanoBytes



Joined: 02 Jun 2011
Posts: 57
Location: Iowa, United States
NanoBytes
Perfect, thank you
Post 12 Dec 2011, 00:21
View user's profile Send private message Send e-mail Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.