flat assembler
Message board for the users of flat assembler.

Index > Windows > How to tell if file exists

Author
Thread Post new topic Reply to topic
pwseo



Joined: 03 May 2009
Posts: 2
pwseo 03 May 2009, 18:30
Hello,

I'm a total newbie at this whole asm thing. I've been trying to read something to get to know the assembly and most people told me fasm was the way to go.

I'm trying to make a simple "bootloader" for a small java app I have... and I wanted to create the loader in assembly (a simple exercise, if you like). The purpose of the app is to see if there is a "java.exe" file in %PATH%, and if there is, execute it with some parameters (-jar myapp.jar).. if the file does not exist, i'd like the loader to open up the default browser and point it to Sun's site so the user can download java...

The problem is I don't know how to check for java.exe's existance... nor do I know how to check the returned values from *any* api call in asm/fasm

Can anyone help? Thanks.
Post 03 May 2009, 18:30
View user's profile Send private message Reply with quote
IronFelix



Joined: 09 Dec 2004
Posts: 141
Location: Russia, Murmansk region
IronFelix 03 May 2009, 21:10
Hi, pwseo!
As for API call return value - it is returned in EAX register. Also some API's return data via reference-type passed parameters (pointers to buffers, etc.).
Maybe you should use GetEnvironmentVariable function to get data from %PATH% environment variable, then check if there is "java.exe" in returned buffer, then use wsprintf (should be called via "cinvoke", not via "invoke" macro) or lstrcpy/lstrcat functions to prepare necessary strings, and use CreateProcess or WinExec function to launch java with your parameters, if java is installed. Please, read SDK about this functions, maybe it will help you.
Post 03 May 2009, 21:10
View user's profile Send private message Reply with quote
pwseo



Joined: 03 May 2009
Posts: 2
pwseo 03 May 2009, 21:46
IronFelix, thanks for the EAX bit!

I did the following: I shellexec java.exe and then check eax's value. If eax <= 32, then I goto some code which launches the default browser and opens up sun's page... If eax > 32, it just terminates the launcher.

Again, many thanks!
Post 03 May 2009, 21:46
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-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.