flat assembler
Message board for the users of flat assembler.

Index > Windows > FillConsoleOutputCharacter doesn't work with a COORD struct

Author
Thread Post new topic Reply to topic
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan 27 Apr 2010, 21:00
Hello !

I've got a problem with the FillConsoleOutputCharacter function

When I use a structure COORD in oder to fix the start cell, it doesn't work,.... nothin apear

The only on way which workin is to put "0"/"NULL" instead of the COORD struct,....but I loose the positionning of the string Crying or Very sad Crying or Very sad, which is the main interressant feature of this fonction ^^


This is the code which doesn't work...:

Code:
format PE console 4.0 
entry start 

include '%fasminc%/win32ax.inc' 

section '.data' data readable writeable 

hCSB      dd ? 
Temp    dd ? 
     struc COORD{ 
                .X dw ?       
              .Y dw ?     
               } 
          
          testt COORD


section '.code' code readable executable 
start:    
    invoke  CreateConsoleScreenBuffer,GENERIC_WRITE,0,0,1,0 
     mov     [hCSB],eax 
  inc     eax 
 jz      exit            ;if eax=-1 error 
    invoke  SetConsoleActiveScreenBuffer,[hCSB] 
          
mov [testt.X],52
mov [testt.Y],10
                    
          
    invoke  FillConsoleOutputCharacter,\ 
               [hCSB],80,\ 
             80,testt,Temp 

    invoke  Sleep,4000 
  invoke  CloseHandle,[hCSB] 
exit:  
    invoke  ExitProcess,0 


                
;include 'csb.imp' 
section '.idata' import data readable writeable 

  library kernel32,'kernel32.dll' 

  import kernel32,\ 
         CloseHandle,'CloseHandle',\ 
         CreateConsoleScreenBuffer,'CreateConsoleScreenBuffer',\ 
         ExitProcess,'ExitProcess',\ 
         FillConsoleOutputCharacter,'FillConsoleOutputCharacterA',\ 
         SetConsoleActiveScreenBuffer,'SetConsoleActiveScreenBuffer',\ 
         Sleep,'Sleep'     
Post 27 Apr 2010, 21:00
View user's profile Send private message Reply with quote
Picnic



Joined: 05 May 2007
Posts: 1403
Location: Piraeus, Greece
Picnic 27 Apr 2010, 23:19
hi vanzan, try this:
Code:
    invoke  FillConsoleOutputCharacter,\ 
               [hCSB],80,\ 
             80,DWORD[testt],Temp     
Post 27 Apr 2010, 23:19
View user's profile Send private message Visit poster's website Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan 28 Apr 2010, 05:33
Thank you very, very much ! Smile


How can I know when I had to precise the type of data ?
Post 28 Apr 2010, 05:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20459
Location: In your JS exploiting you and your system
revolution 28 Apr 2010, 05:55
vanzan wrote:
How can I know when I had to precise the type of data ?
When you read the C-code structure in the API docs you look for the prefix 'lp'.
Code:
BOOL FillConsoleOutputCharacter(

    HANDLE hConsoleOutput,    // handle to screen buffer 
    TCHAR cCharacter,    // character to write 
    DWORD nLength,    // number of character cells to write to 
    COORD dwWriteCoord,    // x- and y-coordinates of first cell 
    LPDWORD lpNumberOfCharsWritten    // pointer to number of cells written to 
);    
Notice that dwWriteCoord does not have the 'lp' prefix so it is not a pointer, it is a value with the size 'dw'.
Post 28 Apr 2010, 05:55
View user's profile Send private message Visit poster's website Reply with quote
baldr



Joined: 19 Mar 2008
Posts: 1651
baldr 28 Apr 2010, 05:59
vanzan,

When structure is passed by value (i.e. argument type is not a pointer) as function argument, you have to copy it to stack entirely.
Post 28 Apr 2010, 05:59
View user's profile Send private message Reply with quote
vanzan



Joined: 27 Apr 2010
Posts: 14
vanzan 29 Apr 2010, 10:30
Ok ! Thank You very much for the explanation Wink

I think I've understood the principle =)


PS: I'm creating an ASCII Arkanoid for my IT Shcool ASM project
Post 29 Apr 2010, 10:30
View user's profile Send private message 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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.