The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: ragdog on February 15, 2007, 08:33:01 AM

Title: read smaller file problem
Post by: ragdog on February 15, 2007, 08:33:01 AM
hi people's
I have again times Trouble with a algo
I can pick larger files and this works I do not take a smaller work it any longer  :red


         invoke GetFileSize,hFile,0 
            mov ebx,eax
         invoke GlobalAlloc,0,eax
            mov esi,eax
         invoke GetFileSize,hFile2,0
            mov edi,eax
            mov dwBytes, 0
         invoke ReadFile,hFile2,esi,edi,offset dwBytes,0
           test eax,eax
            jnz @Next4
         invoke MessageBox,hWnd,addr szReadError,addr szInfo,MB_OK
            jmp @ret
  @Next4:         
         invoke WriteFile,hOutputFile,esi,edi,offset dwBytes,0
           test eax,eax
            jnz @Next5
         invoke MessageBox,hWnd,addr szWriteError,addr szInfo,MB_OK
            jmp @ret

can their me further help

thanks in forward
ragdog
Title: Re: read smaller file problem
Post by: Tedd on February 15, 2007, 01:32:53 PM
A little more code would help :P

BUT..
invoke GetFileSize,hFile,0                          ;get size of file1 (S1)
invoke GlobalAlloc,0,eax                            ;allocate memory, S1 bytes
mov esi,eax                                         ;esi = pS1Memory
invoke GetFileSize,hFile2,0                         ;get size of file2 (S2)
mov edi,eax                                         ;edi = S2
invoke ReadFile,hFile2,esi,edi,offset dwBytes,0     ;read S2 bytes from file2, into pS1Memory


if (file2.size > file1.size) Exception!! :bdg
Title: Re: read smaller file problem
Post by: ragdog on February 15, 2007, 03:27:30 PM
I already solved it this problem

thank you