Here is the new improved version, it seems to work on all file types I have tested on any readable media so I put the process into its own procedure.
IF 0 ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
Build this template with "CONSOLE ASSEMBLE AND LINK"
ENDIF ; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
include \masm32\include\masm32rt.inc
block_copy PROTO :DWORD,:DWORD,:DWORD
.code
start:
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
call main
inkey
exit
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
main proc
LOCAL bSize :DWORD ; buffer size
LOCAL pCmd :DWORD ; pointer command line
LOCAL bcnt :DWORD ; procedure return value
LOCAL fname[260]:BYTE ; file name buffer
LOCAL pname :DWORD ; file name pointer
mov pname, ptr$(fname) ; cast buffer to pointer
mov bSize, 1024*1024*16 ; set the block size
mov pCmd, cmd$(1) ; get 1st command line argument
fn NameFromPath,pCmd,pname ; get the bare file name
; ------------------
; call the procedure
; ------------------
mov bcnt, rv(block_copy,pCmd,pname,bSize)
print chr$(13,10)
print "Bytes copied = "
print ustr$(bcnt),13,10
ret
main endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
block_copy proc psrc:DWORD,pdst:DWORD,bsize:DWORD
; arguments --------------------------------------
; psrc = the source file name address
; pdst = the destination file name address
; bsize = the memory buffer size in bytes
; ------------------------------------------------
LOCAL hSrc :DWORD
LOCAL hDst :DWORD
LOCAL pBuf :DWORD
LOCAL bWrt :DWORD
LOCAL bRed :DWORD
LOCAL flen :DWORD
LOCAL bcnt :DWORD
mov pBuf, rv(GlobalAlloc,GMEM_FIXED,bsize)
mov hSrc, rv(CreateFile,psrc,GENERIC_READ,NULL,NULL,OPEN_EXISTING,NULL,NULL)
mov hDst, rv(CreateFile,pdst,GENERIC_WRITE,NULL,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL)
mov flen, rv(GetFileSize,hSrc,NULL)
mov bcnt, 0
cplp:
fn ReadFile,hSrc,pBuf,bsize,ADDR bRed,NULL
; ---------------------------------------------------------
; perform any memory modification here.
; memory address = pBuf
; byte count = bRed
; ---------------------------------------------------------
fn WriteFile,hDst,pBuf,bRed,ADDR bWrt,NULL
print "."
mov eax, bWrt
add bcnt, eax
mov eax, flen
cmp bcnt, eax
jb cplp
fn CloseHandle,hSrc
fn CloseHandle,hDst
fn GlobalFree,pBuf
mov eax, bcnt
ret
block_copy endp
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
end start