flat assembler
Message board for the users of flat assembler.

Index > Windows > declaring api functions

Author
Thread Post new topic Reply to topic
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Code:
 

format MS COFF

extrn '__imp__MessageBoxA@16' as MessageBox:dword

include '%include%\win32a.inc'

section '.text' code readable executable

 public start 

 start:
        invoke MessageBox, 0 ,_caption , _message , 0      

        ret

section '.data' data readable writeable

 _caption db 'Win32 assembly',0
 _message db 'Coffee time!',0
    


I would like to know exactly how the extern directive works. All I know is I need it to use the MessageBox function. I am thinking about creating some include files with declarations for all of the functions in user32.dll and kernel32.dll but I want to know if doing this will increase the size of the object file generated even if I don't use all the functions.

_________________
silkodyssey
Post 24 Oct 2003, 17:49
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7720
Location: Kraków, Poland
Tomasz Grysztar
It is covered in the FAQ on the main fasm's website.
Post 24 Oct 2003, 18:20
View user's profile Send private message Visit poster's website Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Thank you, I'll check it out Smile

_________________
silkodyssey
Post 24 Oct 2003, 19:12
View user's profile Send private message MSN Messenger Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
I am having a problem with the EXTRN macro. Its giving me this error:

Code:
 
flat assembler  version 1.49
msgbox.asm [11]:
EXTRN '__imp__MessageBoxA@16' as MessageBox:dword
msgbox.asm [6] EXTRN [1]:
     if used symbol
error: invalid expression.

Make error(s) occured. 

    


Here's the code

Code:
 
format MS COFF

 macro EXTRN symbol
    {
     if used symbol
      extrn symbol
     end if
    }

EXTRN '__imp__MessageBoxA@16' as MessageBox:dword

include '%include%\win32a.inc'
;include 'c:\fasm\user32.inc' 

section '.text' code readable executable

 public start 

 start:
        invoke MessageBox, 0 ,_caption , _message , 0      

        ret

section '.data' data readable writeable

 _caption db 'Win32 assembly',0
 _message db 'Coffee time!',0

    

_________________
silkodyssey
Post 24 Oct 2003, 20:18
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7720
Location: Kraków, Poland
Tomasz Grysztar
This macro is designed only for the "EXTRN name" syntax, if you want to use the extended one, try something like:
Code:
macro EXTRN symbol,name
{ if used symbol
    if name eq
      extrn symbol
    else
      extrn name as symbol 
    end if
  end if }    

and use it like here:
Code:
EXTRN MessageBox,'MessageBoxA'    
Post 24 Oct 2003, 23:58
View user's profile Send private message Visit poster's website Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
Thanks Privalov it works like a charm, you're a genius Very Happy . The file size went from 70kb down to 2kb Very Happy . I can upload some of the includes I've converted from the masm32 package if anyone's interested.

_________________
silkodyssey
Post 25 Oct 2003, 01:11
View user's profile Send private message MSN Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Sikodyssey,

I have a tool converting masm32 include files to fasm includes:

http://board.win32asmcommunity.net/showthread.php?s=&threadid=8994

_________________
Code it... That's all...
Post 25 Oct 2003, 08:41
View user's profile Send private message Visit poster's website Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
I checked out your program. Just what I needed. If only I knew about it yesterday Very Happy

_________________
silkodyssey
Post 25 Oct 2003, 14:04
View user's profile Send private message MSN Messenger Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Silkodyssey,

You can try also my "scanner" tool,it looks for API functions in the asm source file and creates a list declaring all the necessary functions.With this tool,you don't have to use API include files.

You can have a look at:

http://board.flatassembler.net/topic.php?t=72

_________________
Code it... That's all...
Post 25 Oct 2003, 20:07
View user's profile Send private message Visit poster's website Reply with quote
silkodyssey



Joined: 02 Oct 2003
Posts: 198
Location: St.Vincent & the Grenadines
silkodyssey
This would be a great feature for fasmw. It would be more convient to have the source file scanned from the IDE and the functions declared there instead of having to run an external program. Smile

_________________
silkodyssey
Post 25 Oct 2003, 20:57
View user's profile Send private message MSN Messenger Reply with quote
Tomasz Grysztar
Assembly Artist


Joined: 16 Jun 2003
Posts: 7720
Location: Kraków, Poland
Tomasz Grysztar
Maybe it should become the part of FRESH project?
Post 25 Oct 2003, 21:00
View user's profile Send private message Visit poster's website Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
Nice idea.The problem is that I haven't much time for coding because of long working hours. Yet,I will think of coding a scanner DLL for the FRESH project.

_________________
Code it... That's all...
Post 26 Oct 2003, 09:31
View user's profile Send private message Visit poster's website Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard
Vortex,
Good work with your scan program Smile.
Unfortunately, it doesn't work with multi-sourcefile projects. Maybe you could add a feature that will also scan files included by the file given in command line?
Post 26 Oct 2003, 12:46
View user's profile Send private message Visit poster's website Reply with quote
Vortex



Joined: 17 Jun 2003
Posts: 318
Vortex
decard wrote:
Maybe you could add a feature that will also scan files included by the file given in command line?


Yes,I was thinking about this idea.It can be a solution for multi-source files.

Thanks,

Vortex

_________________
Code it... That's all...
Post 26 Oct 2003, 18:56
View user's profile Send private message 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.

Powered by rwasa.