flat assembler
Message board for the users of flat assembler.

Index > Windows > Win32 Console Apps

Author
Thread Post new topic Reply to topic
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004 16 Dec 2004, 19:04
I've only just started with ASM and FASM, but all I can create are DOS .COM's and DOS executables (.EXE's) I want to be able to create Win32 Console programs, Sorry if this is a very Newbie question, Any help appreciated.

cal
Post 16 Dec 2004, 19:04
View user's profile Send private message MSN Messenger Reply with quote
MCD



Joined: 21 Aug 2004
Posts: 602
Location: Germany
MCD 16 Dec 2004, 19:14
Well, to code Win32 applications, you should first put
Code:
format  PE console
    

right at the beginning of your file.

The format directive is descibed in the Fasm documentation (see doc\Fasm.txt or doc\Fasm.pdf)

Furthermore, Win32 application can contain several sections (a bit like segments in MZ executables)

E.g. you have at least 3 sections:

The first (default) section is a .flat section, with data/code combined.

The next one is at least an import section for stuff imported from dlls (there almost no interrupts under Win32, you must use dll calls or invokes)
Code:
section '.idata' import data readable writeable
...
    


And another section should be a fixup section
Code:
section '.reloc' fixups data readable discardable
    

This section should contain nothing, since it is automatically filled

_________________
MCD - the inevitable return of the Mad Computer Doggy

-||__/
.|+-~
.|| ||
Post 16 Dec 2004, 19:14
View user's profile Send private message Reply with quote
snifit



Joined: 10 Dec 2004
Posts: 12
Location: Sweden
snifit 17 Dec 2004, 08:19
Here you have an example that prints a textstring to the standard output:

Code:
format PE console
entry start

include '%fasminc%\win32a.inc'



section '.data' data readable writeable
  output    dd ?
  bwritten  dd ?

  _text     db 'output text',0



section '.code' code readable executable
  start:
        invoke  GetStdHandle,STD_OUTPUT_HANDLE
        cmp     eax,INVALID_HANDLE_VALUE
        je      exit
        mov     [output],eax

        invoke  WriteConsole,[output],_text,12,bwritten,0

  exit:
        xor     eax,eax
        ret



section '.idata' import data readable writeable
  library kernel,'KERNEL32.DLL'

  import kernel,\
         GetStdHandle,'GetStdHandle',\
         WriteConsole,'WriteConsoleA'    
Post 17 Dec 2004, 08:19
View user's profile Send private message Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex 17 Dec 2004, 18:29
Hi calpol2004,

Welcome to the forum.

Here is a console example for you.


Description: Console example
Download
Filename: Conssamp.zip
Filesize: 1.68 KB
Downloaded: 307 Time(s)


_________________
Code it... That's all...
Post 17 Dec 2004, 18:29
View user's profile Send private message Visit poster's website Reply with quote
Tommy



Joined: 17 Jun 2003
Posts: 489
Location: Norway
Tommy 18 Dec 2004, 09:42
You can also have a look at the win32 console template in the newest fresh package... Wink (contains an example of how to use as well)
Post 18 Dec 2004, 09:42
View user's profile Send private message Visit poster's website Reply with quote
2



Joined: 26 Sep 2006
Posts: 92
2 10 Dec 2006, 06:03
Thanks for that! I needed this info.
Post 10 Dec 2006, 06:03
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.