Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3115 dunkaist 1
use32
2
    org 0x0
3
    db  'MENUET01'
4
    dd  0x01,start,i_end,e_end,e_end,0,0
5
 
6
include '../../../../proc32.inc'
7
include '../../../../macros.inc'
8
include '../../../../dll.inc'
9
;include '../../../../debug.inc'
10
include '../../../../develop/libraries/libs-dev/libio/libio.inc'
11
include 'libcrash.inc'
12
BUFFER_SIZE	= 8192
13
 
14
 
15
start:
16
	mcall	68, 11
17
 
18
	stdcall dll.Load, @IMPORT
19
	or	eax, eax
20
	jnz	quit
21
 
22
	invoke	file.open, input_file, O_READ
23
	or	eax, eax
24
	jz	quit
25
	mov	[fh], eax
26
 
27
	invoke	file.size, input_file
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
 
50
	invoke	crash.hash, LIBCRASH_SHA512, hash, data_buffer, 0, update_data_buffer, msglen
51
	invoke	crash.bin2hex, hash, hex, LIBCRASH_SHA512
52
 
53
 
54
still:
55
	mcall	10
56
	dec	eax
57
	jz	redraw
58
	dec	eax
59
	jz	key
60
 
61
button:
62
	mcall	17
63
	shr	eax, 8
64
 
65
	cmp	eax, 1
66
	je	quit
67
 
68
redraw:
69
	mcall	12, 1
70
	mcall	0, <0,800>, <0,100>, 0x34000000, 0x80000000, window_title
71
 
72
	mcall	4, 0, 0x40ffffff, hex, 128, 0
73
 
74
	mcall	12, 2
75
	jmp	still
76
 
77
key:
78
	mcall	2
79
	jmp	still
80
 
81
 
82
quit:
83
	mcall	-1
84
 
85
 
86
proc update_data_buffer
87
	mcall	70, f70_buf
88
	mov	eax, ebx
89
	cmp	eax, -1
90
	jne	@f
91
	inc	eax
92
    @@:
93
	add	dword[f70_buf + 4], BUFFER_SIZE
94
	ret
95
endp
96
 
97
 
98
szZ window_title		,'libcrash example'
99
 
100
sz msg_few_args		, '2 arguments required',0x0a
101
sz msg_bad_hash_type	, 'invalid hash type',0x0a
102
sz msg_file_not_found	, 'file not found: '
103
 
104
input_file	db '/hd0/1/crashtest',0
105
 
106
f70_buf:
107
	funcnum	dd 0
108
	src	dd 0
109
	res1	dd 0
110
	count	dd BUFFER_SIZE
111
	dst	dd data_buffer
112
	res2	db 0
113
	fname	dd input_file
114
 
115
align 4
116
@IMPORT:
117
 
118
library				  \
119
	libio	, 'libio.obj'	, \
120
	libcrash, 'libcrash.obj'
121
 
122
import	libio				, \
123
	libio.init     , 'lib_init'	, \
124
	file.size      , 'file_size'	, \
125
	file.open      , 'file_open'	, \
126
	file.read      , 'file_read'	, \
127
	file.close     , 'file_close'
128
 
129
import	libcrash			, \
130
	libcrash.init  , 'lib_init'	, \
131
	crash.hash     , 'crash_hash'	, \
132
	crash.bin2hex  , 'crash_bin2hex'
133
 
134
i_end:
135
hash		rd 16
136
msglen		rd 1
137
fd		rd 1
138
fh		rd 1
139
data_length	rd 1
140
hex		rb 1024
141
data_buffer	rb BUFFER_SIZE
142
file_data	rd 1
143
file_len	rd 1
144
 
145
rb 0x400					;stack
146
e_end:
147