flat assembler
Message board for the users of flat assembler.

Index > Windows > FASM Program

Author
Thread Post new topic Reply to topic
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 14 Mar 2006, 10:44
Greetings,
I have been learning FASM for 2 months now and have read many tutorials, manuals, books etc. It just seems that I can't write something useful. For example - I want to right a program that copies a file from one path to another. But I don't know even where to start. What's my problem? I know the directives and syntax, but that doesn't help me like, for example, in a High-level language. I don't expect it to, but I don't seem to know WHAT to learn. I hope that the COPY program is not a big example so, if someone has the time, please direct me on how to do it or explain where to start. Thank you.
Post 14 Mar 2006, 10:44
View user's profile Send private message Reply with quote
lilljocke



Joined: 28 Dec 2004
Posts: 34
Location: Sweden
lilljocke 14 Mar 2006, 11:34
I use to design the dialog first and the controls. If i would make a program that copeis a file to another path i would start to make the dialog and controls and define a 2 buffers that can receve the text from the textboxes and then use CopyFile to copy the file.

BOOL CopyFile(

LPCTSTR lpExistingFileName, // pointer to name of an existing file
LPCTSTR lpNewFileName, // pointer to filename to copy to
BOOL bFailIfExists // flag for operation if file exists
);
Post 14 Mar 2006, 11:34
View user's profile Send private message Visit poster's website Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 14 Mar 2006, 11:48
write in upper box name of existing file, and in box below - new file name, and press OK: if fail try to use full pathnames.
check there for more complex examples: http://board.flatassembler.net/topic.php?t=4359


Description:
Download
Filename: fcopy.1.zip
Filesize: 2.45 KB
Downloaded: 260 Time(s)


_________________
UNICODE forever!
Post 14 Mar 2006, 11:48
View user's profile Send private message Visit poster's website Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 14 Mar 2006, 18:37
What's that "BOOL CopyFile ... " thing. It looks to me like a function. I'm fairly new to FASM, so I can't understand every aspect of it. Can you tell me more? I was thinking more of a console solution (if I can express myself that way). Nongraphic, nonwindow... Like the COPY command in windows. A complete example would be great with some comments. But I don't expect this. Just an explanation or a direction. Where to start? How could I achieve this. Wink
Post 14 Mar 2006, 18:37
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 14 Mar 2006, 18:53
That "BOOL CopyFile" is NOT Fasm.. It's C language Wink

Anyway, if you want to write a simple console, you can use only one API call (CopyFile). In C, BOOL CopyFile means that, after you 'call' the function, in the register 'eax' it will be a boolean value (00000000h or 00000001h). The other parameters (lpExistingFileName, lpNewFileName, bFailIfExists) are just 'dwords' on the stack (via push instruction). So, you can look at MSDN for more info (remember, ignore "LPCTSTR", it's just a 'dword', and the last "BOOL bFailIfExists" is also just a 'dword' Wink )

Then use that API to copy files.


Sure, if you don't know how to get the command line, see the GetCommandLine function.. remember, the "LPTSTR" before it's name is actually nothing (i.e the return value is simply eax after you called your function).
So, after you invoke that function, in 'eax' you should be able to find the pointer to the command line. You'll need to extract it manually with this method, though (i.e skip spaces, find arguments.. the string pointed by eax (after you called function) will just be somewhat like you typed it, i.e: "MyCopyProgram param1 param2", this is the exact string that will be put in that string, if you typed it that way).

The rest.. i hope you'll be able to find it yourself, it's really not that hard, trust me Smile have patience

Sorry if I confused you, I'm not very good at it though Very Happy
Hope it helps Wink
Post 14 Mar 2006, 18:53
View user's profile Send private message Reply with quote
jumpex



Joined: 29 Jan 2006
Posts: 38
jumpex 14 Mar 2006, 19:21
Thank you for your response. Amazing. Thanks again. Smile

P.S: I thought that BOOL ~ looked familiar. Wink
Post 14 Mar 2006, 19:21
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 15 Mar 2006, 15:00
Post 15 Mar 2006, 15:00
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.