Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- include \masm32\include\masm32rt.inc
- IDD_DIALOG1 = 100
- ID_LTEXT = 101
- IDC_EDIT1 = 102
- IDC_EDIT2 = 103
- IDC_BUTTON2 = 104
- IDC_PB_AKCJA = 105
- IDC_PB_OK = 106
- .data?
- hInstance dd ?
- fSize dd ?
- hFile dd ?
- hBuff dd ?
- readBytes dd ?
- tmpV dd ?
- .data
- buff1 db 65 dup(NULL)
- txt2 db "Blad otwarcia pliku.", NULL
- txt3 db "Blad odczytu pliku.", NULL
- txt4 db "Blad alokacji pamieci.", NULL
- .code
- DlgProc proc hDlg,uMsg,wParam,lParam:DWORD
- pushad
- .IF uMsg==WM_CLOSE
- INVOKE EndDialog,hDlg,0
- .ELSEIF uMsg==WM_COMMAND
- .IF wParam==IDC_BUTTON2
- INVOKE EndDialog,hDlg,0
- .ELSEIF wParam==IDC_PB_AKCJA
- INVOKE GetDlgItemText, hDlg, IDC_EDIT1, OFFSET buff1, SIZEOF buff1
- INVOKE CreateFile, OFFSET buff1, GENERIC_READ, 0, NULL, OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,0
- mov hFile, eax
- .IF eax==INVALID_HANDLE_VALUE
- INVOKE lstrlen, OFFSET txt2
- INVOKE WriteConsole, hInstance, OFFSET txt2, eax,ADDR tmpV, NULL
- .ENDIF
- INVOKE GetFileSize,hFile,0
- mov fSize, eax
- INVOKE VirtualAlloc,0,eax,MEM_COMMIT,PAGE_READWRITE
- .IF eax == NULL
- INVOKE lstrlen, OFFSET txt4
- INVOKE WriteConsole, hInstance,OFFSET txt4, eax,OFFSET tmpV, NULL
- .ELSE
- mov hBuff, eax
- INVOKE ReadFile, hFile, eax, fSize, OFFSET readBytes, 0
- .IF eax == -1
- INVOKE lstrlen, OFFSET txt3
- INVOKE WriteConsole, hInstance,OFFSET txt3, eax,ADDR tmpV, NULL
- .ELSE
- INVOKE SetDlgItemText, hDlg, IDC_EDIT2, hBuff
- .ENDIF
- .ENDIF
- INVOKE VirtualFree,eax,OFFSET fSize,MEM_RELEASE
- INVOKE CloseHandle, hFile
- .ELSEIF wParam==IDC_PB_OK
- INVOKE GetDlgItemText, hDlg, IDC_EDIT1, OFFSET buff1, SIZEOF buff1
- INVOKE CreateFile, OFFSET buff1, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS,FILE_ATTRIBUTE_ARCHIVE,0
- mov hFile, eax
- .IF eax==INVALID_HANDLE_VALUE
- INVOKE lstrlen, OFFSET txt2
- INVOKE WriteConsole, hInstance, OFFSET txt2, eax,ADDR tmpV, NULL
- .ENDIF
- INVOKE GetFileSize,hFile,0
- mov fSize, eax
- INVOKE VirtualAlloc,0,eax,MEM_COMMIT,PAGE_READWRITE
- .IF eax == NULL
- INVOKE lstrlen, OFFSET txt4
- INVOKE WriteConsole, hInstance,OFFSET txt4, eax,OFFSET tmpV, NULL
- .ELSE
- mov hBuff, eax
- INVOKE GetDlgItemText, hDlg, IDC_EDIT2, OFFSET buff1, SIZEOF buff1
- INVOKE WriteFile, hFile, eax, fSize, OFFSET buff1, 0
- .IF eax == -1
- INVOKE lstrlen, OFFSET txt3
- INVOKE WriteConsole, hInstance,OFFSET txt3, eax,ADDR tmpV, NULL
- .ELSE
- .ENDIF
- .ENDIF
- .ENDIF
- .ENDIF
- popad
- xor eax,eax
- ret
- DlgProc endp
- Start:
- INVOKE GetModuleHandle,NULL
- mov hInstance,eax
- INVOKE DialogBoxParam,hInstance,IDD_DIALOG1,0,ADDR DlgProc,0
- INVOKE ExitProcess,0
- END Start
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement