flat assembler
Message board for the users of flat assembler.
Index
> Windows > Message Box example |
Author |
|
Torrey 24 May 2005, 19:50
Here you go.
Code: format PE GUI 4.0 entry BeginCode include '%fasminc%\win32a.inc' section '.code' executable readable writeable BeginCode: push 0 push txtTitle push txtMessage push 0 call [MessageBox] ;or alternate way of calling api's or procs invoke MessageBox,0,txtMessage,txtTitle,0 invoke ExitProcess,0 ret section '.data' data readable writeable txtTitle db 'Titlebar',0 txtMessage db 'Hello World',0 section '.idata' import data readable writeable library kernel,'KERNEL32.DLL',\ user,'USER32.DLL' import kernel,\ ExitProcess,'ExitProcess' import user,\ MessageBox,'MessageBoxA' Last edited by Torrey on 24 May 2005, 19:58; edited 1 time in total |
|||
24 May 2005, 19:50 |
|
Tomasz Grysztar 24 May 2005, 19:53
Or just the PEDEMO example in the fasm for Windows package. No macros at all (actually it's the oldest program for Win32 ever written in fasm).
|
|||
24 May 2005, 19:53 |
|
shaolin007 24 May 2005, 20:12
Ok could you help me out with this part of PEDEMO and what exactly is going on? Thanks man...
Code: 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 |
|||
24 May 2005, 20:12 |
|
shaolin007 24 May 2005, 20:14
I'm having trouble getting this to work in your program
Code: include '%fasminc%\win32a.inc' my directory is include 'C:\fasm\include\win32a.inc' Do the '%%' mean anything special? |
|||
24 May 2005, 20:14 |
|
flaith 24 May 2005, 21:02
check your FASMW.INI and change lines inside it :
Quote:
last two lines _________________ Je suis sur de 'rien', mais je ne suis pas sur du 'tout'. |
|||
24 May 2005, 21:02 |
|
coconut 24 May 2005, 21:07
in order to eliminate the use of a hard coded path to include files, you can create an environment variable named FASMINC, and use that when pointing to your includes..
on win2000\xp right click my computer goto advanced, click the Environment Variables button at the bottom, and create a variable in the top listbox.. name it FASMINC and set the value to your include folder - no trailing backslash by setting FASMINC to your "c:\asm\alot\of\folders\fasm\include" you can use the %fasminc% and make it easier for yourself and to share your code among others note: your can use the following resource section in your code, instead of manually importing every api you use, fasm will only generate import code for the api you actually use Code: section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL' include 'apia\kernel32.inc' include 'apia\user32.inc' if you use an api from other DLLs, simply add it here |
|||
24 May 2005, 21:07 |
|
shaolin007 25 May 2005, 00:53
Hey thanks everyone that helped out! I finally got it to work correctly. Thanks for helping out a Windows Newbie.
One last questions, why do you do this? Code: call [MessageBox] instead of call MessageBox I take its an address in the .dll? |
|||
25 May 2005, 00:53 |
|
JohnFound 25 May 2005, 06:58
MessageBox is not a procedure label, but simply DWORD, where Windows puts actual address of MessageBox from user32.dll. This happens during loading of the PE exe file and this is the essense of so called "importing functions from dynamic linkable library (dll)).
This is the reason why imported functions should be called using indirect addressing [MessageBox]. See also the macro "invoke", intended to call imported functions. Regards. |
|||
25 May 2005, 06:58 |
|
Nikolay Petrov 25 May 2005, 19:33
|
|||||||||||
25 May 2005, 19:33 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.