Subversion Repositories Kolibri OS

Rev

Rev 3431 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3431 Rev 3532
Line 5... Line 5...
5
 
5
 
6
include '../../../../proc32.inc'
6
include '../../../../proc32.inc'
7
include '../../../../macros.inc'
7
include '../../../../macros.inc'
8
include '../../../../dll.inc'
8
include '../../../../dll.inc'
9
;include '../../../../debug.inc'
-
 
10
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
9
;include '../../../../debug.inc'
-
 
10
include 'libcrash.inc'
11
include 'libcrash.inc'
11
 
Line 12... Line 12...
12
BUFFER_SIZE	= 8192
12
BUFFER_SIZE	= 4096
13
 
13
 
Line 14... Line 14...
14
 
14
 
15
start:
15
start:
16
	mcall	68, 11
16
	mcall	68, 11
Line 17... Line -...
17
 
-
 
18
	stdcall dll.Load, @IMPORT
-
 
19
	or	eax, eax
-
 
20
	jnz	quit
-
 
21
 
-
 
22
	invoke	file.open, this_file_name, O_READ
-
 
23
	or	eax, eax
-
 
24
	jz	quit
-
 
25
	mov	[fh], eax
-
 
26
 
-
 
27
	invoke	file.size, this_file_name
-
 
28
	mov	[file_len], ebx
-
 
29
 
-
 
30
	stdcall mem.Alloc, ebx
-
 
31
	or	eax, eax
-
 
32
	jz	quit
-
 
33
	mov	[file_data], eax
-
 
34
 
-
 
35
	invoke	file.read, [fh], eax, [file_len]
-
 
36
	cmp	eax, -1
-
 
37
	je	quit
-
 
38
	cmp	eax, [file_len]
-
 
39
	jne	quit
-
 
40
 
-
 
41
	invoke	file.close, [fh]
-
 
42
	inc	eax
-
 
43
	jz	quit
-
 
44
	
-
 
45
	stdcall	mem.Free, [file_data]
-
 
46
	test	eax, eax
-
 
47
	jz	quit
-
 
48
 
-
 
49
 
17
 
50
	invoke	crash.hash, LIBCRASH_SHA512, hash, data_buffer, 0, update_data_buffer, msglen
18
	stdcall dll.Load, @IMPORT
51
	invoke	crash.bin2hex, hash, hex, LIBCRASH_SHA512
19
	or	eax, eax
52
 
20
	jnz	quit
53
 
21
 
Line 65... Line 33...
65
	cmp	eax, 1
33
	cmp	eax, 1
66
	je	quit
34
	je	quit
Line 67... Line 35...
67
 
35
 
68
redraw:
36
redraw:
69
	mcall	12, 1
37
	mcall	12, 1
-
 
38
	mcall	0, <0,900>, <0,150>, 0x34000000, 0x80000000, window_title
Line -... Line 39...
-
 
39
 
-
 
40
 
-
 
41
	mcall	4, < 0,  0>, 0xc0ffffff, message, , 0
-
 
42
 
-
 
43
        mov     [hid], 0
-
 
44
        mov     [text_pos_y], 10
-
 
45
        mov     [hash_name], hash_strings
-
 
46
  .next_hash:
-
 
47
        mov     dword[f70_buf + 4], 0
-
 
48
        mov     dword[msglen], 0
-
 
49
        mov     edi, hex
-
 
50
        xor     eax, eax
-
 
51
        mov     ecx, 1024/4
-
 
52
        rep     stosd
-
 
53
	invoke	crash.hash, [hid], hash, data_buffer, 0, update_data_buffer, msglen
-
 
54
	invoke	crash.bin2hex, hash, hex, [hid]
-
 
55
        mov     ebx, [text_pos_y]
-
 
56
	mcall	4, , 0xc0ffffff, [hash_name],    , 0
70
	mcall	0, <0,800>, <0,100>, 0x34000000, 0x80000000, window_title
57
        mov     ebx, [text_pos_y]
-
 
58
        add     ebx, 66 SHL 16
-
 
59
	mcall	4, , 0x40ffffff, hex, 128, 0
-
 
60
        add     [text_pos_y], 10
-
 
61
        add     [hash_name], 12 ; lenght of hash_strings item
-
 
62
        inc     [hid]
Line 71... Line 63...
71
 
63
        cmp     [hid], LIBCRASH_SHA3_512
72
	mcall	4, 0, 0x40ffffff, hex, 128, 0
64
        jng     .next_hash
Line 73... Line 65...
73
 
65
 
Line 81... Line 73...
81
 
73
 
82
quit:
74
quit:
Line 83... Line 75...
83
	mcall	-1
75
	mcall	-1
-
 
76
 
-
 
77
 
-
 
78
proc update_data_buffer _left
-
 
79
	mov	eax, data_buffer
-
 
80
	add	eax, [_left]
-
 
81
	mov	dword[f70_buf + 16], eax
84
 
82
	mov	eax, BUFFER_SIZE
85
 
83
	sub	eax, [_left]
86
proc update_data_buffer
84
	mov	dword[f70_buf + 12], eax
87
	mcall	70, f70_buf
85
	mcall	70, f70_buf
88
	mov	eax, ebx
86
	mov	eax, ebx
89
	cmp	eax, -1
87
	cmp	eax, -1
90
	jne	@f
88
	jne	@f
91
	inc	eax
89
	inc	eax
92
    @@:
90
    @@:
Line 93... Line 91...
93
	add	dword[f70_buf + 4], BUFFER_SIZE
91
	add	dword[f70_buf + 4], eax
Line 94... Line 92...
94
	ret
92
	ret
-
 
93
endp
-
 
94
 
-
 
95
 
-
 
96
szZ window_title	,'libcrash example'
-
 
97
 
-
 
98
szZ message             , 'hash sums of this file'
-
 
99
 
-
 
100
hash_strings:
-
 
101
md4        db 'md4      : ',0
-
 
102
md5        db 'md5      : ',0
-
 
103
sha1       db 'sha1     : ',0
95
endp
104
sha224     db 'sha224   : ',0
96
 
105
sha256     db 'sha256   : ',0
Line 97... Line 106...
97
 
106
sha384     db 'sha384   : ',0
98
szZ window_title		,'libcrash example'
107
sha512     db 'sha512   : ',0
99
 
108
sha3_224   db 'sha3-224 : ',0
100
sz msg_few_args		, '2 arguments required',0x0a
109
sha3_256   db 'sha3-256 : ',0
101
sz msg_bad_hash_type	, 'invalid hash type',0x0a
110
sha3_384   db 'sha3-384 : ',0
102
sz msg_file_not_found	, 'file not found: '
111
sha3_512   db 'sha3-512 : ',0
103
 
112
 
104
f70_buf:
113
f70_buf:
Line -... Line 114...
-
 
114
	funcnum	dd 0
105
	funcnum	dd 0
115
	src	dd 0
106
	src	dd 0
116
	res1	dd 0
Line 107... Line 117...
107
	res1	dd 0
117
	count	dd BUFFER_SIZE
108
	count	dd BUFFER_SIZE
-
 
109
	dst	dd data_buffer
118
	dst	dd data_buffer
Line 110... Line -...
110
	res2	db 0
-
 
111
	fname	dd this_file_name
-
 
112
 
-
 
113
align 4
-
 
114
@IMPORT:
-
 
115
 
-
 
116
library				  \
-
 
117
	libio	, 'libio.obj'	, \
119
	res2	db 0
118
	libcrash, 'libcrash.obj'
120
	fname	dd this_file_name
119
 
121
 
120
import	libio				, \
122
 
Line 121... Line 123...
121
	libio.init     , 'lib_init'	, \
123
align 4
-
 
124
@IMPORT:
-
 
125
 
122
	file.size      , 'file_size'	, \
126
library				  \
-
 
127
	libcrash, 'libcrash.obj'
123
	file.open      , 'file_open'	, \
128
 
124
	file.read      , 'file_read'	, \
-
 
125
	file.close     , 'file_close'
-
 
126
 
-
 
127
import	libcrash			, \
129
import	libcrash			, \
128
	libcrash.init  , 'lib_init'	, \
130
	libcrash.init  , 'lib_init'	, \
129
	crash.hash     , 'crash_hash'	, \
-
 
130
	crash.bin2hex  , 'crash_bin2hex'
-
 
131
 
-
 
132
i_end:
131
	crash.hash     , 'crash_hash'	, \
133
hash		rd 16
132
	crash.bin2hex  , 'crash_bin2hex'
134
msglen		rd 1
133