flat assembler
Message board for the users of flat assembler.

Index > Windows > For Newbies

Author
Thread Post new topic Reply to topic
imagineer



Joined: 09 Aug 2003
Posts: 14
imagineer
; MsgBox example: FASMW version

format PE GUI 4.0
entry start

include '%include%\win32a.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

start:
invoke MessageBox, HWND_DESKTOP,\
_MsgBoxText, _MsgCaption, MB_ICONINFORMATION+MB_OK
exit:
invoke ExitProcess, 0


; import data in the same section
data import

library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'

import kernel32,\
ExitProcess,'ExitProcess'

import user32,\
MessageBox,'MessageBoxA'

end data

;Cheers,

;The I
Post 13 Aug 2003, 08:42
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
It's an exelent idea to make simple examples for newbies.
Only one note: Better make separate section for imports. The newbie will understand more clear this approach.
Post 13 Aug 2003, 09:34
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica
Nice, but please use the code tags: (they work like html tags <code></code> but with the "< >" replaced with "[ ]")
Code:
; MsgBox example: FASMW version

format PE GUI 4.0
entry start

include '%include%\win32a.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

start:
invoke MessageBox, HWND_DESKTOP,\
_MsgBoxText, _MsgCaption, MB_ICONINFORMATION+MB_OK
exit:
invoke ExitProcess, 0


; import data in the same section
data import

library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'

import kernel32,\
ExitProcess,'ExitProcess'

import user32,\
MessageBox,'MessageBoxA'

end data

;Cheers,

;The I    

I learned the most asm actually from looking at examples (well documented are the best), and a good opcode/win32 API reference is very useful to understand the example(s).

Here's teh example using the win32ax.inc: (and the macros)
Code:
; MsgBox example: FASMW version
include '%include%\win32ax.inc'
.data
  _MsgCaption db "Iczelion's tutorial no. 2",0
  _MsgBoxText db "Win32 Assembly is Great!",0
.code
start:
  invoke MessageBox, HWND_DESKTOP,\
  _MsgBoxText, _MsgCaption, MB_ICONINFORMATION+MB_OK
exit:
  invoke ExitProcess, 0

.end start    

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 13 Aug 2003, 10:49
View user's profile Send private message Visit poster's website Reply with quote
imagineer



Joined: 09 Aug 2003
Posts: 14
imagineer
JohnFound wrote:
Quote:

Only one note: Better make separate section for imports. The newbie will understand more clear this approach.


Thanks, the revised code is here.
Code:
; MsgBox example: FASMW version

format PE GUI 4.0
entry start

include '%include%\win32a.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

  start:
        invoke  MessageBox, HWND_DESKTOP,\
               _MsgBoxText, _MsgCaption,  MB_ICONINFORMATION+MB_OK
  exit:
        invoke  ExitProcess, 0


section '.idata' import data readable writeable

  library kernel32,'KERNEL32.DLL',\
         user32,'USER32.DLL'

  import kernel32,\
         ExitProcess,'ExitProcess'

  import user32,\
        MessageBox,'MessageBoxA'

    


Cheers,

The I
Post 14 Aug 2003, 02:16
View user's profile Send private message Reply with quote
imagineer



Joined: 09 Aug 2003
Posts: 14
imagineer
Scientica wrote:
Quote:

using the win32ax.inc


I see that there are 3 macro sets ( for both ASCII and WIDE versions). For beginners, which version is recommended?

Thks,

The I
Post 14 Aug 2003, 02:19
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
imagineer wrote:

I see that there are 3 macro sets ( for both ASCII and WIDE versions). For beginners, which version is recommended?


Actually, I think that it's a little bit dangerously to use big complex macro sets for beginers. Plain source (even larger as size) is better, because it gives the newbie clear idea what actually happens. When newbie becomes more experienced, he will discover these macro tricks.
Post 14 Aug 2003, 05:36
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9
thanks!

easy to understand it. but it is out of my attention.
i think the macro set is not normalized, it's usage is very chaotic and unpredictable.

--
sorry, i always interested in programmable graphic.(instead of letters!)
Post 14 Aug 2003, 05:39
View user's profile Send private message Reply with quote
imagineer



Joined: 09 Aug 2003
Posts: 14
imagineer
JohnFound wrote:
Quote:

Actually, I think that it's a little bit dangerously to use big complex macro sets for beginers.


Thanks, so I'll stick with win32a.inc.


fasm9 wrote:

Quote:

i think the macro set is not normalized, it's usage is very chaotic and unpredictable.


You are absolutely right fasm9. Especially among the assemblers available, there are many different macro sets. Unfortunately, there is no uniform macro sets among assemblers. Even within one assembler itself. I also use NASM and there are different macro sets, one from NaGoA and others. Sad


Cheers,

The I
Post 14 Aug 2003, 06:00
View user's profile Send private message Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
[quote="imagineer"]JohnFound wrote:
[quote]
Only one note: Better make separate section for imports. The newbie will understand more clear this approach.
[/quote]

Thanks, the revised code is here.
[code]
; MsgBox example: FASMW version

format PE GUI 4.0
entry start

include '%include%\win32a.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

start:
invoke MessageBox, HWND_DESKTOP,\
_MsgBoxText, _MsgCaption, MB_ICONINFORMATION+MB_OK
exit:
invoke ExitProcess, 0


section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'

import kernel32,\
ExitProcess,'ExitProcess'

import user32,\
MessageBox,'MessageBoxA'

[/code]

Cheers,

The I[/quote]



Hi everybody i think dont need programming assembler, you can take a MessageBox with OS Windows....

you start
Start -- Run -- then you type
rundll32 user32.dll,MessageBoxA
and enter

Hey do you see it fun?
Post 24 Sep 2003, 13:37
View user's profile Send private message Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024
Translations of the first 7 (2 -9) of Iczelion's Tutorials can be found at http://board.win32asmcommunity.net/showthread.php?s=&threadid=7358
Post 25 Sep 2003, 05:57
View user's profile Send private message Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
[quote="imagineer"]JohnFound wrote:
[quote]
Only one note: Better make separate section for imports. The newbie will understand more clear this approach.
[/quote]

Thanks, the revised code is here.
[code]
; MsgBox example: FASMW version

format PE GUI 4.0
entry start

include '%include%\win32a.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

start:
invoke MessageBox, HWND_DESKTOP,\
_MsgBoxText, _MsgCaption, MB_ICONINFORMATION+MB_OK
exit:
invoke ExitProcess, 0


section '.idata' import data readable writeable

library kernel32,'KERNEL32.DLL',\
user32,'USER32.DLL'

import kernel32,\
ExitProcess,'ExitProcess'

import user32,\
MessageBox,'MessageBoxA'

[/code]

Cheers,

The I[/quote]


Hi i need add icon for Hello.asm

include '%include%/win32ax.inc'

.code

start:
invoke MessageBox,HWND_DESKTOP,"Hi! I'm the example program!","Win32 Assembly",MB_OK
invoke ExitProcess,0

.end start


wherer i can put icon?
Post 25 Sep 2003, 06:39
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
Hi, boysoledad.

At first: UNcheck "Disable BBCode in this post" when you posting.

At second: There is no need to quote whole previous post. Simply press [PostReply] button instead of [quote] button.

Your question: No, you can't do this using simple MessageBox function. You must see MessageBoxIndirect description in API reference.

regards.
Post 25 Sep 2003, 08:04
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
If you mean the icon for the executable file, it can be done this way:
Code:
include '%include%/win32ax.inc'

.code

  start:
        invoke  MessageBox,HWND_DESKTOP,"Hi! I'm the example program!","Win32 Assembly",MB_OK
        invoke  ExitProcess,0

.end start

section '.rsrc' resource data readable

  directory RT_ICON,icons,\
            RT_GROUP_ICON,group_icons

  resource icons,\
           1,LANG_NEUTRAL,icon_data

  resource group_icons,\
           1,LANG_NEUTRAL,main_icon

  icon main_icon,icon_data,'hello.ico'    
Post 25 Sep 2003, 09:15
View user's profile Send private message Visit poster's website Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
Thanks Privalov ... i complier it have icon in view file tree....
Thanks
Post 26 Sep 2003, 03:02
View user's profile Send private message Reply with quote
boysoledad



Joined: 14 Sep 2003
Posts: 10
boysoledad
Please help
I want take a dialog box as About notepad as a files gif i send...


Description:
Filesize: 9.79 KB
Viewed: 9579 Time(s)

notepad.gif


Post 26 Sep 2003, 03:09
View user's profile Send private message Reply with quote
Dunduk



Joined: 08 Sep 2003
Posts: 38
Location: Russia
Dunduk
Use ShellAbout function from SHELL32.DLL. Using:

int ShellAbout (
HWND hWnd, // handle of parent window
LPCTSTR szApp, // title bar and first line text
LPCTSTR szOtherStuff, // other dialog text
HICON hIcon // icon to display
);

That is:
Code:
....
invoke ShellAbout, [hwnd], _title, _about, [hicon]
....
_title db 'About my prog...', 0
_about db 'My prog', 13, 10, 'Copyright ', 169, ' Myself', 0
....
    

Something like that
Post 26 Sep 2003, 05:34
View user's profile Send private message Reply with quote
MattBro



Joined: 08 Nov 2003
Posts: 37
MattBro
Here's a real newbie question.

Where is the documentation for the api macro/instruction. I've seen it used in code like this

api CreateFile,[filename],GENERIC_READ,0,NULL,\
OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL


There is nothing about this in the manual.


Rolling Eyes

_________________
-- -------------------------------------------------------
"I am the Way and the Truth and the Light, no one comes to the Father except through me" - Jesus
---------------------------------------------------------
Post 08 Nov 2003, 20:06
View user's profile Send private message Visit poster's website Reply with quote
eet_1024



Joined: 22 Jul 2003
Posts: 59
eet_1024
I hope you don't think information on API's are suppost to be in the fasm manual.

Do a search for win32.hlp
Post 11 Nov 2003, 07:09
View user's profile Send private message Reply with quote
kaafe



Joined: 15 Oct 2003
Posts: 18
kaafe
Post 11 Nov 2003, 22:27
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 7797
Location: Kraków, Poland
Tomasz Grysztar
Some similar links you can find in this thread: http://board.flatassembler.net/topic.php?t=230 (also fasm's "official" package of help files for Win32 programming).
Post 12 Nov 2003, 01:39
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. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.