flat assembler
Message board for the users of flat assembler.

Index > Windows > copyfile to, not more!

Author
Thread Post new topic Reply to topic
XY2k



Joined: 18 Feb 2006
Posts: 6
XY2k 19 Feb 2006, 00:00
Hi,
i want only the source-code for a function like this "copyfile" to "target".
The copied file should become at the same time a new name

Example:
Copy File C:\programmes\bla\xy.exe to C:\programmes\renamedfile.exe

Not more guys Smile
When i have the code i compile it and put this code to an executable with a hexeditor. I change then the OEP etc. ...but that can I make.

regards,
XY2k
Post 19 Feb 2006, 00:00
View user's profile Send private message Reply with quote
Reverend



Joined: 24 Aug 2004
Posts: 408
Location: Poland
Reverend 19 Feb 2006, 01:16
Win32 Reference wrote:
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 19 Feb 2006, 01:16
View user's profile Send private message Visit poster's website Reply with quote
XY2k



Joined: 18 Feb 2006
Posts: 6
XY2k 19 Feb 2006, 03:15
Thx Reverend, but the code is not complete. You must know, i´m a newbie and can only compile the source-code. Can u please make it finish with this names...look here --> Example:
Copy File C:\programmes\bla\xy.exe to C:\programmes\renamedfile.exe

regards,
XY2k
Post 19 Feb 2006, 03:15
View user's profile Send private message Reply with quote
dead_body



Joined: 21 Sep 2005
Posts: 187
Location: Ukraine,Kharkov
dead_body 19 Feb 2006, 09:18
Quote:
Example:
Copy File C:\programmes\bla\xy.exe to C:\programmes\renamedfile.exe


Code:
push 0
Call label1
 db "C:\programmes\renamedfile.exe ",0
label1:
Call label2
 db "C:\programmes\bla\xy.exe",0
label2:
Call [CopyFile]    


it must work good, i think.
Post 19 Feb 2006, 09:18
View user's profile Send private message Reply with quote
XY2k



Joined: 18 Feb 2006
Posts: 6
XY2k 19 Feb 2006, 12:50
Sorry it doesn´t work

Code:
BOOL CopyFile( 

LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName, 
BOOL bFailIfExists 
);

push 0 
Call label1 
 db "C:\programmes\renamedfile.exe ",0 
label1: 
Call label2 
 db "C:\programmes\bla\xy.exe",0 
label2: 
Call [CopyFile]
    


by compiling with cmd it say :
copy.asm[1]
BOOL CopyFile(
error invalid expression


And when i want only compile the second code:
Code:
push 0
Call label1 
 db "C:\programmes\renamedfile.exe ",0 
label1: 
Call label2 
 db "C:\programmes\bla\xy.exe",0 
label2: 
Call [CopyFile]
    

It say: --> Call [CopyFile] "is undefined symbol"

Crying or Very sad

regards,
XY2k
Post 19 Feb 2006, 12:50
View user's profile Send private message Reply with quote
UCM



Joined: 25 Feb 2005
Posts: 285
Location: Canada
UCM 19 Feb 2006, 15:33
you need to do put it in a PE executable.
Code:
include 'win32ax.inc' 
format PE console 4.0
.data
label2 db 'C:\blah\blah.blah',0
label1 db 'C:\from.exe',0
.code
start:
invoke CopyFile, label1, label2, 0
invoke ExitProcess,0
.end start
    

Edit: attached code that will process the command line
it goes like this: cp FromFile ToFile


Description: copy code
Download
Filename: cp.asm
Filesize: 1.93 KB
Downloaded: 304 Time(s)


_________________
This calls for... Ultra CRUNCHY Man!
Ta da!! *crunch*
Post 19 Feb 2006, 15:33
View user's profile Send private message Reply with quote
XY2k



Joined: 18 Feb 2006
Posts: 6
XY2k 21 Feb 2006, 09:02
THX UCM...its work Smile
Post 21 Feb 2006, 09:02
View user's profile Send private message Reply with quote
Flier-Mate



Joined: 26 May 2023
Posts: 88
Flier-Mate 23 Jun 2023, 16:33
I got this error when use CopyFile Win32 API...... Is it not in Kernel32.dll, what does the error mean?

Quote:
C:\Users\BOO\Projects>sfc /scanfile=c:\windows\system32\kernel32.dll

Windows Resource Protection did not find any integrity violations.


Description: Error
Filesize: 7.67 KB
Viewed: 2704 Time(s)

Screenshot 2023-06-24 002749.png


Post 23 Jun 2023, 16:33
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 23 Jun 2023, 16:49
It means your source file is corrupted in some way.
Post 23 Jun 2023, 16:49
View user's profile Send private message Visit poster's website Reply with quote
Flier-Mate



Joined: 26 May 2023
Posts: 88
Flier-Mate 03 Jul 2023, 00:51
revolution wrote:
It means your source file is corrupted in some way.


Finally I found out why, because the correct API is "CopyFileA", not "CopyFile", but strange, both can compile without error.
Post 03 Jul 2023, 00:51
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20299
Location: In your JS exploiting you and your system
revolution 03 Jul 2023, 04:58
The name matching is done at runtime. You can put any text you want for API names and it won't fail until you try to run it.
Post 03 Jul 2023, 04:58
View user's profile Send private message Visit poster's website 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.