Are there any tutorials for those experienced with MASM who are interested in using FASM? I found a few tutorials on this site however they explained the basics of assembly language rather than delving into where FASM differs from MASM in its usage and syntax.
To get myself acquainted I had a play around with a simple MessageBox example this afternoon. I wanted to use the commandline Win32 version of FASM as its easier to integrate this with my editor than the Windowed version (which appears to have a different syntax for its import section). I originally started with the following:
format PE GUI 4.0
include '%fasminc%/windows.inc'
section '.data' data readable writeable
MsgCaption db "Iczelion's tutorial no.2",0
MsgBoxText db "Win32 Assembly is Great!",0
section '.code' code readable executable
entry start
start:
push MB_OK
push MsgCaption
push MsgBoxText
push 0
call [MessageBox]
push 0
call [ExitProcess]
section '.idata' import data readable writeable
dd 0,0,0,RVA kernel_name,RVA kernel_table
dd 0,0,0,RVA user_name,RVA user_table
dd 0,0,0,0,0
kernel_table:
ExitProcess dd RVA _ExitProcess
dd 0
user_table:
MessageBox dd RVA _MessageBoxA
dd 0
kernel_name db 'KERNEL32.DLL',0
user_name db 'USER32.DLL',0
_ExitProcess dw 0
db 'ExitProcess',0
_MessageBoxA dw 0
db 'MessageBoxA',0
section '.reloc' fixups data readable discardable
I added a simple macro that would work in a similar fashion to the MASM Invoke directive. So, after the 'include' line above I entered:
macro invoke proc, [arg]
{
reverse push arg
common call [proc]
}
I then changed the push... call ... instructions to:
invoke MessageBox, NULL, .... (etc.).
However one thing had me scratching my head. This was the syntax of the import data section. RVA is obviously an acronym for Relative Virtual Address. It appears to me that this section creates some kind of lookup table for the procedure names used in the code. Could someone elaborate further? I have a few references on the PE file format, but would like to understand in depth how this section works.
Thanks.