format PE console 4.0
include 'win32axp.inc'
.data
filef	dd ? ;source file
filet	dd ? ;destination file
high	dd ? ;high dword of filesize
Read	dd ?
crlf	db 0Dh,0Ah,0h ;a return; 0Ah would be sufficient though
handle	dd ?
COPYING db 'Copying ',0
TO	db ' to ',0
COPIED	db 'Copied',0
ERRORR	db 'Panic - Something bad happened',0
.code
proc	echo,.string
	mov	eax,[handle]
	cmp	eax,INVALID_HANDLE_VALUE
	je	.die
	stdcall StrLen,[.string]
	invoke	WriteFile,eax,[.string],ecx,Read,0
.die:	ret
endp
proc	StrLen,.string
	push	edi eax
	mov	edi,[.string]
	mov	ecx,-1
	and	al,0
	cld
repne	scasb
	not	ecx
	sub	ecx,1
	pop	eax edi
	ret
endp
start:
invoke	GetStdHandle,STD_OUTPUT_HANDLE
mov	[handle],eax
invoke	GetCommandLine
mov	esi,eax
;start finding end of command line.
mov	edi,eax
.loop1:;loop for space
cmp	[edi],byte ' '
je	.endloop1 ;found the end
cmp	[edi],byte 0
je	.die ;hmm... no file
add	edi,1
jmp	.loop1
.endloop1:

lea	esi,[edi+1];move edi+1 to esi
mov	edi,esi
;now esi points to first file. start scanning again for space
.loop2:
cmp	[edi],byte ' '
je	.endloop2 ;found it
cmp	[edi],byte 0
je	.begincopy ;its the last argument, but its ok
add	edi,1
jmp	.loop2
.endloop2:
;now edi points to the second file. scan for space again
mov	[edi],byte 0 ;change esi to zero-ending string
add	edi,1
push	edi  ;save edi; we need it
.loop3: ;ANOTHER loop to change the end to 0
cmp	[edi],byte ' '
je	.endloop3
cmp	[edi],byte 0
je	.endloop3 ;wierd
add	edi,1
jmp	.loop3
.endloop3:
mov	[edi],byte 0 ;yeah
pop	edi
;copy now.
.begincopy:
stdcall echo,COPYING
stdcall echo,esi
stdcall echo,TO
stdcall echo,edi
stdcall echo,crlf
invoke	CopyFile,esi,edi,0
test	eax,eax
jz	.die
stdcall echo,COPIED
invoke	ExitProcess,0
.die:
;insert error here
stdcall echo,ERRORR ;really useful error message... right
invoke	ExitProcess,1
;.overflow:
;sub 1 from [high]
;sub     [high],1
;jmp     .copyloop
.end start