flat assembler
Message board for the users of flat assembler.

Index > Windows > FASM API help..

Author
Thread Post new topic Reply to topic
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
hi, i have changed from MASM32 to FASM. I am not so good to assembler yet, but i have a problem with some APIs.
This is my code.

Code:
format PE GUI
include '\include\win32a.inc'
invoke GetForegroundWindow
invoke SetWindowText,eax,sse
invoke MessageBox,0,installed,installed,MB_YES
invoke ExitProcess,0
sse             db 'Hello...',0
installed       db 'Changed the Window Text...',0
data import
library user32,'user32.dll',kernel32,'kernel32.dll'
import user32,MessageBox,'MessageBoxA'
import kernel32,GetForegroundWindow,'GetForegroundWindow'
import kernel32,ExitProcess,'ExitProcess'
end data
    


I only play with some API's for fun, the error says that i GetForegroundWindow are defined, but when i remove
import user32,GetForegroundWindow,'GetForegroundWindow'
so its says that its messing.... Rolling Eyes please help

_________________
LOOOL
Post 18 Dec 2004, 13:46
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
All functions from one library have to be imported with one "import" statement:
Code:
format PE GUI
include '%fasminc%\win32a.inc'

        invoke  GetForegroundWindow
        invoke  SetWindowText, eax, sse
        invoke  MessageBox, 0, installed, installed, MB_OK
        invoke  ExitProcess, 0

sse       db 'Hello...',0
installed db 'Changed the Window Text...',0

data import
library user32,'user32.dll',kernel32,'kernel32.dll'

import user32,                           \
       MessageBox, 'MessageBoxA',        \
       GetForegroundWindow,'GetForegroundWindow',       \
       SetWindowText, 'SetWindowTextA'

import kernel32,                                        \
       ExitProcess,'ExitProcess'
end data
    


To avoid such kind of manual import table build, that will make you more troubles than education, you can simply import everything and leave FASM determine what you are using in the program and what not. This approach will not increase the size of your program, only the compilation speed will decrease very slighly, but you will be free to use any function without manually importing it.

Code:
format PE GUI
include '%fasminc%\win32a.inc'

        invoke  GetForegroundWindow
        invoke  SetWindowText, eax, sse
        invoke  MessageBox, 0, installed, installed, MB_OK
        invoke  ExitProcess, 0

sse       db 'Hello...',0
installed db 'Changed the Window Text...',0

data import
  library kernel32, 'kernel32', user32, 'user32'

  include "%fasminc%\APIA\Kernel32.inc"
  include "%fasminc%\APIA\User32.inc"
end data
    
Post 18 Dec 2004, 14:20
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
Thanks. But there is a mistake in it, i allready can see. This should be replaced
library kernel32, 'kernel32', user32, 'user32'
by this
library kernel32, 'kernel32.dll', user32, 'user32.dll'

.. And THANKS for so quick respons
PS i like FASM becuase it have masm invoke, and nasm smallness... And its to other os. And for not make another topic, how do i make a program on the top of something? just tell me the API named, so i try figer out self how it work
Post 18 Dec 2004, 14:59
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
gumletis wrote:
But there is a mistake in it, i allready can see. This should be replaced
library kernel32, 'kernel32', user32, 'user32'
by this
library kernel32, 'kernel32.dll', user32, 'user32.dll'


Both are correct - you can compile and try.
".dll" is extesion by default, so when it miss, Windows searches for .dll with given name.

Quote:
And for not make another topic, how do i make a program on the top of something?


What actually do you mean Confused

Regards
Post 18 Dec 2004, 15:18
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
okay, just my computer there is F*****, you know when you get a setting box or some like that, it are always on the top. What API are used for that?
Post 18 Dec 2004, 15:22
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
gumletis wrote:
okay, just my computer there is F*****, you know when you get a setting box or some like that, it are always on the top. What API are used for that?


If I understand you correctly, you need winndow that will stay at the top all the time. Well, you have to set WS_EX_TOPMOST extended style when you create window with CreateWindowEx API function. That is all.

Regards.
Post 18 Dec 2004, 15:47
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
okay thanks, i see what i can do with that, and msdn. Thanks...
Post 18 Dec 2004, 15:54
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
Hi i got a problem more, i need a program to copy its self to windir....
This is what i got so far
Code:
format PE GUI
include '\include\win32a.inc'
invoke GetSystemDirectory,me,1500
invoke MessageBox,0,mey,mey,MB_OK
invoke ExitProcess,0
me      db ?
mey     db me,'\hello_world.exe',0
data import
library user32,'user32.dll',kernel32,'kernel32.dll'
include '\include\apia\user32.inc'
include '\include\apia\kernel32.inc'
end data            

    

its just says mistake in mey db....

_________________
LOOOL
Post 18 Dec 2004, 23:31
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3502
Location: Bulgaria
JohnFound
"me" is dword address. You can't use "db me" because "db" defines bytes, not dwords. What actually you want to do with this statement?
Post 19 Dec 2004, 06:01
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
?? i wanna make a program there comes with the regedit, the first step is going to find system dir and so set '\heloo_world.exe' in it so it copy to that... PS are its a dd there come from GetSystemDirectory?
Post 19 Dec 2004, 08:54
View user's profile Send private message Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
lol now i find what i need, lstrcat. But its given a wierd result when im using it. What shall i do?

Code:
invoke GetModuleHandle
invoke GetModuleFileName,eax,me,1500
invoke GetSystemDirectory,sysdir,20
invoke lstrcat,sysdir,hello
invoke MessageBox,0,sysdir,sysdir,MB_OK   
    

_________________
LOOOL
Post 19 Dec 2004, 10:35
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you could post whole code. Maybe you didn't reserve enough space in "sysdir" string for "hello_world"?

And another thing, you are not checking return values of APIs, this way your app is very unstable and if you are not willing to work at Micro$oft you shouldn't want that Wink
Post 19 Dec 2004, 12:15
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
here it is

Code:
format PE GUI
include '\include\win32a.inc'
invoke GetModuleHandle
invoke GetModuleFileName,eax,me,1500
invoke GetSystemDirectory,sysdir,20
invoke lstrcat,sysdir,hello
invoke CopyFile,sysdir,me
invoke GetForegroundWindow
invoke SetWindowText,eax,hello
invoke ExitProcess,0
hello   db '\hello.exe',0
me      db ?
sysdir  db ?
data import
library user32,'user32.dll',kernel32,'kernel32.dll'
include '\include\apia\user32.inc'
include '\include\apia\kernel32.inc'
end data               

    


I also need a Reg API, only know how to do that in C/C++

ps how to do that vid

_________________
LOOOL
Post 19 Dec 2004, 12:46
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
"me" and "sysdir" should be strings, eg. more bytes. Try
Code:
me rb 100
sysdir rb 100
    
Post 19 Dec 2004, 12:50
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
IT WORKED...! thanks!
Post 19 Dec 2004, 13:20
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
you are welcome. But make sure you understand the solution, otherwise it would be without effect.
Post 19 Dec 2004, 20:45
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
Yes i do, rb = Reserve byte with 100 maximum char. PS how to do a Regedit compare and add a reg key, i have try to find one, but there is only in MASM, so i try change it. But doesn't work
Post 20 Dec 2004, 10:55
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
i think there are APIs for that
Post 20 Dec 2004, 12:16
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
gumletis



Joined: 18 Dec 2004
Posts: 128
gumletis
I know. But just donno how to get it to work at FASM instead of MASM... Any Ideas?

_________________
LOOOL
Post 20 Dec 2004, 14:39
View user's profile Send private message Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid
instead of "d* X DUP(Y)" (where * is b,w,dw ...)
use "times X d* Y"
or if Y is ? use "r* X"
Post 22 Dec 2004, 19:23
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number 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.