Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3531 → Rev 3532

/programs/develop/libraries/libcrash/trunk/crashtest.asm
7,11 → 7,11
include '../../../../macros.inc'
include '../../../../dll.inc'
;include '../../../../debug.inc'
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
include 'libcrash.inc'
BUFFER_SIZE = 8192
 
BUFFER_SIZE = 4096
 
 
start:
mcall 68, 11
 
19,38 → 19,6
or eax, eax
jnz quit
 
invoke file.open, this_file_name, O_READ
or eax, eax
jz quit
mov [fh], eax
 
invoke file.size, this_file_name
mov [file_len], ebx
 
stdcall mem.Alloc, ebx
or eax, eax
jz quit
mov [file_data], eax
 
invoke file.read, [fh], eax, [file_len]
cmp eax, -1
je quit
cmp eax, [file_len]
jne quit
 
invoke file.close, [fh]
inc eax
jz quit
stdcall mem.Free, [file_data]
test eax, eax
jz quit
 
 
invoke crash.hash, LIBCRASH_SHA512, hash, data_buffer, 0, update_data_buffer, msglen
invoke crash.bin2hex, hash, hex, LIBCRASH_SHA512
 
 
still:
mcall 10
dec eax
67,10 → 35,34
 
redraw:
mcall 12, 1
mcall 0, <0,800>, <0,100>, 0x34000000, 0x80000000, window_title
mcall 0, <0,900>, <0,150>, 0x34000000, 0x80000000, window_title
 
mcall 4, 0, 0x40ffffff, hex, 128, 0
 
mcall 4, < 0, 0>, 0xc0ffffff, message, , 0
 
mov [hid], 0
mov [text_pos_y], 10
mov [hash_name], hash_strings
.next_hash:
mov dword[f70_buf + 4], 0
mov dword[msglen], 0
mov edi, hex
xor eax, eax
mov ecx, 1024/4
rep stosd
invoke crash.hash, [hid], hash, data_buffer, 0, update_data_buffer, msglen
invoke crash.bin2hex, hash, hex, [hid]
mov ebx, [text_pos_y]
mcall 4, , 0xc0ffffff, [hash_name], , 0
mov ebx, [text_pos_y]
add ebx, 66 SHL 16
mcall 4, , 0x40ffffff, hex, 128, 0
add [text_pos_y], 10
add [hash_name], 12 ; lenght of hash_strings item
inc [hid]
cmp [hid], LIBCRASH_SHA3_512
jng .next_hash
 
mcall 12, 2
jmp still
 
83,7 → 75,13
mcall -1
 
 
proc update_data_buffer
proc update_data_buffer _left
mov eax, data_buffer
add eax, [_left]
mov dword[f70_buf + 16], eax
mov eax, BUFFER_SIZE
sub eax, [_left]
mov dword[f70_buf + 12], eax
mcall 70, f70_buf
mov eax, ebx
cmp eax, -1
90,7 → 88,7
jne @f
inc eax
@@:
add dword[f70_buf + 4], BUFFER_SIZE
add dword[f70_buf + 4], eax
ret
endp
 
97,10 → 95,21
 
szZ window_title ,'libcrash example'
 
sz msg_few_args , '2 arguments required',0x0a
sz msg_bad_hash_type , 'invalid hash type',0x0a
sz msg_file_not_found , 'file not found: '
szZ message , 'hash sums of this file'
 
hash_strings:
md4 db 'md4 : ',0
md5 db 'md5 : ',0
sha1 db 'sha1 : ',0
sha224 db 'sha224 : ',0
sha256 db 'sha256 : ',0
sha384 db 'sha384 : ',0
sha512 db 'sha512 : ',0
sha3_224 db 'sha3-224 : ',0
sha3_256 db 'sha3-256 : ',0
sha3_384 db 'sha3-384 : ',0
sha3_512 db 'sha3-512 : ',0
 
f70_buf:
funcnum dd 0
src dd 0
110,20 → 119,13
res2 db 0
fname dd this_file_name
 
 
align 4
@IMPORT:
 
library \
libio , 'libio.obj' , \
libcrash, 'libcrash.obj'
 
import libio , \
libio.init , 'lib_init' , \
file.size , 'file_size' , \
file.open , 'file_open' , \
file.read , 'file_read' , \
file.close , 'file_close'
 
import libcrash , \
libcrash.init , 'lib_init' , \
crash.hash , 'crash_hash' , \
130,17 → 132,14
crash.bin2hex , 'crash_bin2hex'
 
i_end:
hash rd 16
hash_name rd 1
text_pos_y rd 1
hash rd 50
hid rd 1 ; hash id
msglen rd 1
fd rd 1
fh rd 1
data_length rd 1
hex rb 1024
data_buffer rb BUFFER_SIZE
file_data rd 1
file_len rd 1
 
this_file_name rb 4096
rb 0x400 ;stack
rb 0x800 ;stack
e_end: