flat assembler
Message board for the users of flat assembler.
 Home   FAQ   Search   Register 
 Profile   Log in to check your private messages   Log in 
flat assembler > Windows > [solved] The code works, but climbs error Windows

Author
Thread Post new topic Reply to topic
rococo795



Joined: 19 Oct 2016
Posts: 6
[solved] The code works, but climbs error Windows

Code:

format PE GUI 4.0 
entry start       

include 'win32a.inc'

section '.bss' data readable writeable 
                                                                           
stime   SYSTEMTIME 
                                  
FileIn dd ?       
FileSizeIn dd ?   
HeapAllocMem dd ? 
FileOut dd ?      
cbRead dd ?       
cbWrite dd ?      
sizeHancAudi dd ?
sizeFileOut dd ?
sizeFileOutWes dd ?
cbWrite1 dd ?

section '.text' code readable executable 
                                                                                
start
    invoke MessageBoxA,0,text9,titl,0

        invoke  GetLocalTime,stime  
        mov ax,[stime.wYear]        
        cmp ax,$07e0                
        jg .errData                 
        mov ax,[stime.wMonth]       
        cmp ax,$000a
        jg .errData
        mov ax,[stime.wDay]         
        cmp ax,$0013
        jg .errData
    
        invoke CreateFile,lpFileIn,GENERIC_READ,0,0,3,0,0 
                cmp eax,-1 
                je .errlpFileIn
                mov [FileIn],eax 

                invoke GetFileSize,eax,0 
                cmp eax,$0ffffffff       
                je .errFileSize          
                mov [FileSizeIn],eax     

                        invoke GetProcessHeap 
                        invoke HeapAlloc,eax,0,[FileSizeIn
                        cmp eax,0  
                        je .errHeapAlloc   
                        mov [HeapAllocMem],eax 

                        invoke ReadFile,[FileIn],[HeapAllocMem],[FileSizeIn],cbRead,0
                        test eax,eax
                        jz .errReadFile
                        invoke CloseHandle,[FileIn]

                                xor eax,eax  
                                xor ebx,ebx

                                mov ebx,[HeapAllocMem

                                mov eax,[ebx+26h
                                cmp eax,'data' 
                                jne .dataNet  

                                mov eax,[ebx+2ah]
                                mov [sizeHancAudi],eax
                                add eax,$24
                                mov [sizeFileOut],eax
                                mov [ebx+4h],eax
                                add eax,$8
                                mov [sizeFileOutWes],eax
                                mov eax,$10
                                mov [ebx+10h],eax

                        invoke CreateFile,lpFileOut,GENERIC_WRITE,2,0,1,0,0
                        cmp eax,-1
                        je .errlpFileOut
                        mov [FileOut],eax

                        invoke WriteFile,[FileOut],[HeapAllocMem],24h,cbWrite,0
                        test eax,eax
                        je .errWriteFile1

                        add ebx,$26 
                        mov esi,[sizeFileOutWes
                        sub esi,$24 

                        invoke WriteFile,[FileOut],ebx,esi,cbWrite1,0
                        test eax,eax
                        je .errWriteFile2
                        invoke CloseHandle,[FileOut]
                jmp .ok

                .dataNet:
                                mov eax,[ebx+24h]
                                cmp eax,'data'
                                jne .errFormat
                                mov eax,[ebx+28h
                                mov [sizeHancAudi],eax 
                                add eax,$24 
                                mov [sizeFileOut],eax 
                                add eax,$8 
                                mov [sizeFileOutWes],eax 

                        invoke CreateFile,lpFileOut,GENERIC_WRITE,2,0,1,0,0
                        cmp eax,-1
                        je .errlpFileOut
                        mov [FileOut],eax

                        invoke WriteFile,[FileOut],[HeapAllocMem],[sizeFileOutWes],cbWrite,0
                        test eax,eax
                        je .errWriteFile3
                        invoke CloseHandle,[FileOut]
        jmp .ok

        .errData:
                invoke MessageBoxA,0,text,titl,0
                jmp .exit
        .errlpFileIn:
                invoke MessageBoxA,0,text5,titl,0
                jmp .exit
        .errFileSize:
                invoke MessageBoxA,0,text6,titl,0
                jmp .exit
        .errHeapAlloc:
                invoke MessageBoxA,0,text7,titl,0
                jmp .exit
        .errReadFile:
                invoke MessageBoxA,0,text2,titl,0
                jmp .exit
        .errlpFileOut:
                invoke MessageBoxA,0,text4,titl,0
                jmp .exit
        .errWriteFile1:
                invoke MessageBoxA,0,text3,titl,0
                jmp .exit
        .errFormat:
                invoke MessageBoxA,0,text8,titl,0
                jmp .exit
        .errWriteFile2:
                invoke MessageBoxA,0,textA,titl,0
                jmp .exit
        .errWriteFile3:
                invoke MessageBoxA,0,textB,titl,0
                jmp .exit


.ok:
    invoke HeapFree,[HeapAllocMem]
    invoke MessageBoxA,0,text1,titl,0

.exit:
invoke ExitProcess,0

section '.data' data readable writeable 

        lpFileIn        db 'C:\1\1.wav',0
        lpFileOut       db 'C:\1\1(1).wav',0

        text            db      'The term of the program expired...',0
        titl            db      'Warning!!!',0

    text1               db      'OK!!!...',0
    text2               db      'errReadFile...',0
    text3               db      'errWriteFile1...',0
    text4               db      'errlpFileOut...',0
    text5               db      'errlpFileIn...',0
    text6               db      'errFileSize...',0
    text7               db      'errHeapAlloc...',0
    text8               db      'errFormat...',0
    text9               db      'The program leaves the wav file only what is necessary for sound...   ',\
                                        'The path and name of the source file should be such C:\1\1.wav...  ',\
                                        'After the program to receive the new file C:\1\1(1).wav ....',0
    textA               db      'errWriteFile2...',0
    textB               db      'errWriteFile3...',0

section '.idata' import data readable
 
  library kernel32,'kernel32.dll',\
        user32,'user32.dll'

        include 'api\user32.inc'
    include 'api\kernel32.inc'




The code works, but climbs error Windows... Where is the error code?? What else is there to correct for engine optimization???
Thanks in advance for your help...
Post 19 Oct 2016, 07:52
View user's profile Send private message Reply with quote
rococo795



Joined: 19 Oct 2016
Posts: 6
https://yadi.sk/d/rmOGgo52x8Ymh
There are two file number 1 is processed without errors and the number 3 - the code works, but mistake Windows.
Post 19 Oct 2016, 09:14
View user's profile Send private message Reply with quote
rococo795



Joined: 19 Oct 2016
Posts: 6
Found error...

invoke GetProcessHeap
mov [GetProcessHeapMem],eax
invoke HeapAlloc,[GetProcessHeapMem],0,[FileSizeIn]

invoke HeapFree,[GetProcessHeapMem],0,[HeapAllocMem]
Post 19 Oct 2016, 10:34
View user's profile Send private message 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


Powered by phpBB © 2001-2005 phpBB Group.

Main index   Download   Documentation   Examples   Message board
Copyright © 2004-2016, Tomasz Grysztar.