flat assembler
Message board for the users of flat assembler.

Index > Windows > API calls

Author
Thread Post new topic Reply to topic
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
Hi there! I have never written any Win32 ASM Source and I have no clue about it. I wanted to know whether and how difficult it is to do API calls from Win32 ASM. I think it takes only one line Very Happy Could someone give me a short example of API usage (Assembler-Ready Code, not only one line if possible). ThX a lot!
Post 18 Jul 2006, 20:58
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
examples are in FASM win32 package
Post 19 Jul 2006, 07:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17658
Location: In your JS exploiting you and your system
revolution
Have a look at "BEER.ASM" in the examples. It is short and simple and show the usage of macros to ease the task of API calls.
Post 19 Jul 2006, 10:52
View user's profile Send private message Visit poster's website Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
ThX! I'ma check it out.
Edit: Ok. Quite easy! But what about the included files? How do I know what to include?
Post 19 Jul 2006, 14:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
include "win32axp.inc" and then you don't have to care what to include.

PS: if you would care to read docs...
http://flatassembler.net/docs.php

you would see "Win32 headers" as second thing there
Post 19 Jul 2006, 15:14
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
Yeah but I don't want to include too much. I want my programm to be as small as possible. Sorry for not reading the docs, but I'm absolutely new to FASM and this board... Well I'll have a look at them.
Post 19 Jul 2006, 15:25
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
fasm has proper includes, and nothing will be there if not used.
Post 19 Jul 2006, 16:27
View user's profile Send private message MSN Messenger Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
So if I include a whole file and use only one "function" of it, only this function will be imported? Beer.exe is exactly 1024 Bytes big... Is that size normal for the 2 API calls used?!
Post 19 Jul 2006, 17:06
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
yes, exactly.

it's size could be somewhat smaller, but FASM rounds size of PE to nearest higher 512B bound
Post 19 Jul 2006, 17:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
Is that useful?
Post 19 Jul 2006, 20:34
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
It's called 'following the standards'.
Post 19 Jul 2006, 20:45
View user's profile Send private message MSN Messenger Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
Oh.Ok! Sorry I do really have no idea about Win32 ASM, EXE-Format and so on. I just wanna do some easy API stuff Smile So when assembling the mentioned example (beer.asm), FASM includes only the things that are ABSOLUTELY necessary and/or standard?
Post 19 Jul 2006, 21:16
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
View it with hex-editor, you can see that it's so big because of alignment
Post 19 Jul 2006, 21:34
View user's profile Send private message MSN Messenger Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
All I see is that the actual Code ist at the end of the file. So Header must be very big, huh?!? Could you provide a boolean answer to my question above? ("So when assembling the mentioned example (beer.asm), FASM includes only the things that are ABSOLUTELY necessary and/or standard?")
Post 19 Jul 2006, 22:06
View user's profile Send private message Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi
TRUE



edit: as you can see, there is 3 times blocks of 96bytes nothing but alignment
Post 19 Jul 2006, 22:14
View user's profile Send private message MSN Messenger Reply with quote
RedGhost



Joined: 18 May 2005
Posts: 443
Location: BC, Canada
RedGhost
Firefall you should really read/test for yourself man

_________________
redghost.ca
Post 20 Jul 2006, 00:15
View user's profile Send private message AIM Address MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
in small PEs header is 512 bytes (has to be... otherwise it's VERY unstandard), in larger PEs (more than 3 sections) header has 10B
Post 20 Jul 2006, 09:07
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Firefall



Joined: 18 Jul 2006
Posts: 8
Firefall
@ RedGhost: As I have already mentioned I have no clue about WinASM, and neither about PE EXE's. It's hard to test things if you don't know Header definitions and OP-Codes. Yeah I could look 'em up. But it'd take me a few days or weeks to find, apply, check. So why not searching the answer there where it already exists, and that's in the brains of you experts. ThX for your help!
Post 21 Jul 2006, 09:47
View user's profile Send private message Reply with quote
madmatt



Joined: 07 Oct 2003
Posts: 1045
Location: Michigan, USA
madmatt
Firefall, I wouldn't worry about size when it comes to the includes. The includes you see at the top of an fasm Windows assembly file 95% of the time don't define any data, just constant's used by many of the windows functions. At the bottom of the assembly you find api includes, but even though you include whole api defines, only the ones you use in the program are actually turned into function table data. And, finally, a lot of times you'll see resource data also at the bottom of an assembly file. These almost always produce some kind of data, but, this is what you want in this situation.
Anyways, bottom line is don't waste your time worrying about the size of a file, especially in a windows assembly file (Today's systems have 100's and sometimes thousands of megabytes of memory). Assembly files unoptimized, are in most case's many times smaller than there C/C++ equivalents. Instead, worry about how to speed up critical sections of your code #1, and how to make your program's interface look terrific and user friendly #2, How to comment your code #3, so when you leave your code for a while, and then come back to it later on, you'll have a clue as to what you were doing when you left it (I still need to work on this myself. Laughing )
Post 21 Jul 2006, 12:25
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-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.