Код:
format pe gui
4.0
include
'inc\win32ax.inc'
ofn OPENFILENAME
sdex
HEXTBL: db
48
,
49
,
50
,
51
,
52
,
53
,
54
,
55
,
56
,
57
,
65
,
66
,
67
,
68
,
69
,
70
FilterString1 db
'All Files (*.*)'
,
0
,
'*.*'
,
0
,
0
buffer db
512
dup (?)
hInstance dd ?
hfile dd ?
hfile2 dd ?
buf_len_read dd ?
buf_len_write dd ?
buf dd ?
datat dd ?
scex
entry $
invoke GetModuleHandle,
0
mov [hInstance],eax
mov [ofn.lStructSize],sizeof.OPENFILENAME
push [hInstance]
pop [ofn.hInstance]
mov [ofn.lpstrFilter],FilterString1
mov [ofn.lpstrFile],buffer
mov [ofn.nMaxFile],
512
mov
byte
[buffer],
0
invoke GetOpenFileNameA,ofn
invoke CreateFile,buffer,GENERIC_READ,FILE_SHARE_READ,
0
,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,
0
mov [hfile],eax
.
if
eax
=
INVALID_HANDLE_VALUE
invoke MessageBox,
0
,
'Неудалось открыть файл'
,
'TOHEX - fatal error [ coded by Ancord '
'2011'
' ]'
,
0
jmp .FINISH
.endif
invoke GetModuleHandle,
0
mov [ofn.lStructSize],sizeof.OPENFILENAME
push [hInstance]
pop [ofn.hInstance]
mov [ofn.lpstrFilter],FilterString1
mov [ofn.lpstrFile],buffer
mov [ofn.nMaxFile],
512
mov
byte
[buffer],
0
invoke GetSaveFileNameA,ofn
invoke CreateFile,buffer,GENERIC_WRITE,FILE_SHARE_WRITE,
0
,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,
0
mov [hfile2],eax
.
if
eax
=
INVALID_HANDLE_VALUE
invoke MessageBox,
0
,
'Неудалось открыть файл 2'
,
'TOHEX - fatal error [ coded by Ancord '
'2011'
' ]'
,
0
jmp .FINISH
.endif
invoke SetFilePointer,[hfile],
0
,
0
,
0
.read:
invoke ReadFile,[hfile],datat,
1
,buf_len_read,
0
cmp [buf_len_read],
0
je .endread
push [datat]
pop eax
mov eax,[datat]
shr eax,
4
mov edx,dword
0
mov al,
byte
[HEXTBL+eax]
mov
byte
[buf],al
mov eax,dword
0
mov eax,[datat]
mov ebx,10h
idiv ebx
mov eax,dword
0
mov dl,[HEXTBL+edx]
mov
byte
[buf+
1
],dl
cmp [buf],
0
jnz
@f
invoke WriteFile,[hfile2],
'00'
,
2
,buf_len_write,
0
jmp .read
@@:
invoke lstrlen,buf
cmp eax,
1
jnz
@f
invoke WriteFile,[hfile2],
'0'
,
1
,buf_len_write,
0
invoke WriteFile,[hfile2],buf,
1
,buf_len_write,
0
jmp .read
@@:
invoke WriteFile,[hfile2],buf,
2
,buf_len_write,
0
jmp .read
.endread:
invoke CloseHandle,[hfile]
invoke CloseHandle,[hfile2]
invoke MessageBox,
0
,
'ok'
,
'TOHEX - Finish [ coded by Ancord '
'2011'
' ]'
,
0
.FINISH:
invoke ExitProcess,
0
siex
library kernel,
'kernel32.dll'
,\
user,
'user32.dll'
,\
comdlg32,
'comdlg32.dll'
import
kernel,ExitProcess,
'ExitProcess'
,CreateFile,
'CreateFileA'
,CloseHandle,
'CloseHandle'
,\
SetFilePointer,
'SetFilePointer'
,ReadFile,
'ReadFile'
,\
WriteFile,
'WriteFile'
,lstrlen,
'lstrlen'
,GetModuleHandle,
'GetModuleHandleA'
import
user,MessageBox,
'MessageBoxA'
import
comdlg32,GetSaveFileNameA,
'GetSaveFileNameA'
,GetOpenFileNameA,
'GetOpenFileNameA'