flat assembler
Message board for the users of flat assembler.
Index
> Windows > API problems in FASM (n00be) |
Author |
|
JohnFound 20 Apr 2004, 11:38
You can download FASMW package. It come with very handy editor and some base Windows examples. After that you can search the board for posts of Imagineer - He post Iczelion's tutorials, translated to FASM syntax.
Regards. |
|||
20 Apr 2004, 11:38 |
|
Stcherbatchenko 20 Apr 2004, 12:35
actually i read alot about it actually i know abuot asm but i wanted to get some specific samples that will help me alot if you have any please let me know, and i do have FASM and Fresh, if i didn't have it would i be posting here after all its the official FASM board and i like it and see that FASM is really great much better thatn others.
|
|||
20 Apr 2004, 12:35 |
|
JohnFound 20 Apr 2004, 13:01
Hm-m-m-m. Well, actually I missed something. What kind of examples you need? These in FASMW package are actually are very basic for beginers. Maybe some more advanced? Maybe you have to describe it more detailed. But in all cases searching the board should be helpful.
Regards. |
|||
20 Apr 2004, 13:01 |
|
Stcherbatchenko 20 Apr 2004, 13:36
thanks for the fast reply but what i want to see is how to use API's as the examples i downloaded for FASM are not very getting into all what i need, and i do surf the board but i dont find what i want maybe if you can help me with those samples i would be very glad here are more exmaples that i wanted to see:
1) how to use api's and write them in the code 2) some samples to demonastrate them thats all thanks again |
|||
20 Apr 2004, 13:36 |
|
vid 20 Apr 2004, 18:37
that IS shown in examples.
example of using api is Code: invoke MessageBox, 0, "text", "caption", MB_OK but you must have imported all APIs (or better API procedures) you use. To import API procedure you must know in which DLL is it located. For example MessageBox is in USER32.dll, so importing it is Code: data import library user32,'USER32.DLL' import user32,MessageBox,'MessageBoxA' end data look at examples if windows FASM distribution, it's there. |
|||
20 Apr 2004, 18:37 |
|
Stcherbatchenko 20 Apr 2004, 18:50
thanks very much for your fast reply and for keeping up with me anyway that was an easy one but i was looking for someinth like www.allapi.net has like they show you the api's and gives you a working demo examples so you can get to know what is happening but anyway thanks
|
|||
20 Apr 2004, 18:50 |
|
coconut 20 Apr 2004, 20:53
translating VB and C code to assembly is not hard - for example, setting caption of a window can be done like so:
Code: invoke SendMessage,WM_SETTEXT,[hwnd],0,_text where [hwnd] holds the window handle, and _text is the caption. if you need help translating a specific example from allapi.net, just post it here, we'll be glad to help Last edited by coconut on 21 Apr 2004, 02:43; edited 1 time in total |
|||
20 Apr 2004, 20:53 |
|
Stcherbatchenko 20 Apr 2004, 20:57
thanks coconut for your reply and your help but i was asking generally coz actually i kinda wanted to know how to use all api's and to know how to write em in ASM as am new to it only been reading alot about it for along time, anyway it would be nice to know why the '[]' in the 'hwnd' like if i wrote that in C/C++ i dont have to use any pointers please correct me if am wrong and it yould be appreciated to see some examples or prorams of your own to learn from.
|
|||
20 Apr 2004, 20:57 |
|
Stcherbatchenko 20 Apr 2004, 21:07
heh another question, am not a complete idiot but ASM is really big so i have to use your help so i have noticed in calling API's we use 'INVOKE' which i know is a macro anyway and i know something abuot asm too but not good in coding really
so what i wanted to know if i can use the pure old ASM style coding but in win32asm coz i like to learn it from the begining not search for an easy solution, i dont know but i like to llearn things well so i can then actually learn something better than not learn at all so if you can guide me to stuff like this you can really help also can you help me with doing the hex numbers as i only grab the calculaotr and use it i wanna know how to convert hex to deciman and vice vers in the old fashioned way "BRAIN POWER" thats enough for now i think i have been such a pain for now. |
|||
20 Apr 2004, 21:07 |
|
coconut 21 Apr 2004, 02:55
take a look at this post, he asked the same thing: http://board.flatassembler.net/topic.php?t=1449
in fasm syntax, when we create a variable, example, Code: num dd ? we access the value of the variable by enclosing it in brackets: [num]. if we wanted to send the memory location, a pointer, we wouldnt write the [] just num. you may see in other assemblers they use ADDR or OFFSET keywords to achieve this Code: num dd ? mov eax,72 mov [num],eax ;num = 72 ... ... ... invoke SomeProc,num ;pointer to num i dont have any examples yet, i just started learning too im trying to translate some vb programs i had made long ago, its going pretty well so far. ill post it here when im done |
|||
21 Apr 2004, 02:55 |
|
vid 21 Apr 2004, 18:23
There is no API reference for FASM, but you can use any API reference. Every argument is dword, not depending on what type is it in documentation.
You push argument in reversed order, last in documentation is pushed first, like: int MessageBox( HWND hWnd, // handle of owner window LPCTSTR lpText, // address of text in message box LPCTSTR lpCaption, // address of title of message box UINT uType // style of message box ); in C called as MessageBox(0,"text","caption",MB_OK); is in pure asm push MB_OK push "caption" push "text" push dword 0 call [MessageBox] |
|||
21 Apr 2004, 18:23 |
|
Stcherbatchenko 21 Apr 2004, 19:50
oh okay that helped really but i wwondered when to use thos DWORDS and when not to use them and why do i call the API with '[] before it and stuff like that and ?
|
|||
21 Apr 2004, 19:50 |
|
vid 22 Apr 2004, 08:26
DLL means "dynamic link library". That means it is loaded when it is needed and unloaded when not needed. So address of procedures in memory can change. For that, you can't call static location, like
Code: call MessageBox Instead of that, in your program you declare table of procedures which you want to use. That is that import section, and stuff like Code: library kernel32,'KERNEL32.DLL' import kernel32,\ ExitProcess,'ExitProcess' etc. First, you list which dlls are you using with "library" macro. For each library, there are 2 macro arguments, first is symbol that remepresents library (used for "import" macro) and second is string holding name of library. Then, for each DLL, you list procedures from it using "import" macro. First argument is symbol asociated to DLL with "library", then following groups of two macro arguments identify one procedure. First of two arguments is name of dword variable that will be filled with address of procedure, second is string holding name of procedure. For example, when you use Code: library user32,'USER32.DLL' import user32, MessageBox,'MessageBoxA' you get declared dword variable "MessageBox" which holds address of procedure "MessageBoxA" from "USER32.DLL". For that reason, to call it, you must use Code: call [MessageBox] btw: These macros are declared in "%FASMINC%\macro\import.inc", you have to include it to use them. Code:
include "%FASMINC%\macro\import.inc"
Last edited by vid on 22 Apr 2004, 08:38; edited 1 time in total |
|||
22 Apr 2004, 08:26 |
|
Stcherbatchenko 22 Apr 2004, 08:33
well thanks for your help vod that really haelped me out now i know what is it used for thanks, but i want to know abuot those sections like '.code' '.import' and the other code you write in the same line like readble writable etc...
how can i make my own sections if possible and how to use them etc.. stuff like that would help me more |
|||
22 Apr 2004, 08:33 |
|
vid 22 Apr 2004, 08:45
only meaning of section is to restrict access to parts of memory.
For example, if you have some data that needs only to be read (like strings), you put then into section marked as "readable", not as "writable", so if you mistakenly, because of some bug, write to it, you will get error (general protection failure, GPF). import table (table of pointers to procedures imported from DLLs) is usually stored in own section marked with "import". But it can as well be in any section, just marked with "data import" and "end data". Sections are just some standard, in my opinion not very useful. FASM allows you to create file with only one section, on that all operations can be performed (writable readable executable), where you have everything you need. Such file is created if you dont' use any "section" directive in whole file. You can also use "%FASMINC%\win32axp.inc" that contains macro which create section for you: ".data", ".code", ".end <entry label>" I suggest using only one section, and using "data import" for import table |
|||
22 Apr 2004, 08:45 |
|
roticv 22 Apr 2004, 08:45
What do you mean by making your own sections?
|
|||
22 Apr 2004, 08:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.