MB_OK offset msg offset n1


call MessageBoxA
jmp short m2
m4:
push [d1]
call CloseHandle
cmp eax, INVALID_HANDLE_VALUE
jne short m3
push MB_OK offset msg offset n1 0
call MessageBoxA
jmp short m2
m3:
m2:
call ExitProcess
end begin
2. .
Ideal
p586
model flat
extrn ExitProcess:proc
extrn CreateFileA:proc
extrn CloseHandle:proc
extrn ReadFile:proc
extrn WriteFile:proc
extrn CloseHandle:proc
extrn MessageBoxA:proc
include "win.inc"
dataseg
my db ' - 25', 0
val dd ?
n1 db 'io6.exe', 0
n2 db 'proba.txt', 0
msg db 'Error', 0
s1 dd ?
codeseg
proc FileCopy
public FileCopy
arg nin:dword, nout:dword
local buffer:byte:512, d1:dword, d2:dword, count:dword=s
push ebp
mov ebp, esp
sub esp, s
push eax
push 0 0 OPEN_EXISTING 0 0 GENERIC_READ [nin]
call CreateFileA
cmp eax, INVALID_HANDLE_VALUE
jne short @@m1
push MB_OK offset msg [nin] 0
call MessageBoxA
jmp @@m3
@@m1:
mov [d1], eax
push 0 0 CREATE_ALWAYS 0 0 GENERIC_WRITE [nout]
call CreateFileA
cmp eax, INVALID_HANDLE_VALUE
jne short @@m2
push MB_OK offset msg [nout] 0
call MessageBoxA
jmp @@m3
@@m2:
mov [d2], eax
for1:
push 0
lea eax, [count]
push eax 512
lea eax, [buffer]
push eax [d1]
call ReadFile
test eax, eax
jne short @@m4
push MB_OK offset msg [nin] 0
call MessageBoxA
jmp short @@m3
@@m4:
mov eax, [count]
test eax, eax
je short break
push 0
lea eax, [count]
push eax [count]
lea eax, [buffer]
push eax [d2]
call WriteFile
test eax, eax
jne short @@m5
push MB_OK offset msg [nout] 0
call MessageBoxA
jmp short @@m3
@@m5:
mov eax, [count]
cmp eax, 512
jb short break
jmp for1
break:
push [d1]
call CloseHandle
push [d2]
call CloseHandle
@@m3:
pop eax
mov esp, ebp
pop ebp
ret 8
endp
begin:
push offset n2 offset n1
call FileCopy
call ExitProcess
end begin