Rev 3115 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3115 | dunkaist | 1 | use32 |
2 | org 0x0 |
||
3 | db 'MENUET01' |
||
3431 | dunkaist | 4 | dd 0x01,start,i_end,e_end,e_end,0,this_file_name |
3115 | dunkaist | 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 | |||
3431 | dunkaist | 22 | invoke file.open, this_file_name, O_READ |
3115 | dunkaist | 23 | or eax, eax |
24 | jz quit |
||
25 | mov [fh], eax |
||
26 | |||
3431 | dunkaist | 27 | invoke file.size, this_file_name |
3115 | dunkaist | 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 | f70_buf: |
||
105 | funcnum dd 0 |
||
106 | src dd 0 |
||
107 | res1 dd 0 |
||
108 | count dd BUFFER_SIZE |
||
109 | dst dd data_buffer |
||
110 | res2 db 0 |
||
3431 | dunkaist | 111 | fname dd this_file_name |
3115 | dunkaist | 112 | |
113 | align 4 |
||
114 | @IMPORT: |
||
115 | |||
116 | library \ |
||
117 | libio , 'libio.obj' , \ |
||
118 | libcrash, 'libcrash.obj' |
||
119 | |||
120 | import libio , \ |
||
121 | libio.init , 'lib_init' , \ |
||
122 | file.size , 'file_size' , \ |
||
123 | file.open , 'file_open' , \ |
||
124 | file.read , 'file_read' , \ |
||
125 | file.close , 'file_close' |
||
126 | |||
127 | import libcrash , \ |
||
128 | libcrash.init , 'lib_init' , \ |
||
129 | crash.hash , 'crash_hash' , \ |
||
130 | crash.bin2hex , 'crash_bin2hex' |
||
131 | |||
132 | i_end: |
||
133 | hash rd 16 |
||
134 | msglen rd 1 |
||
135 | fd rd 1 |
||
136 | fh rd 1 |
||
137 | data_length rd 1 |
||
138 | hex rb 1024 |
||
139 | data_buffer rb BUFFER_SIZE |
||
140 | file_data rd 1 |
||
141 | file_len rd 1 |
||
142 | |||
3431 | dunkaist | 143 | this_file_name rb 4096 |
3115 | dunkaist | 144 | rb 0x400 ;stack |
145 | e_end:0,100>0,800> |
||
146 |