Rev 6465 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6465 | hidnplayr | 1 | use32 |
2 | org 0x0 |
||
3 | db 'MENUET01' |
||
4 | dd 0x01,start,i_end,e_end,e_end,0,this_file_name |
||
5 | |||
9216 | dunkaist | 6 | include 'proc32.inc' |
7 | include 'macros.inc' |
||
8 | include 'dll.inc' |
||
9 | ;include 'debug-fdo.inc' |
||
6465 | hidnplayr | 10 | include 'libcrash.inc' |
11 | |||
9216 | dunkaist | 12 | BUFFER_SIZE = 0x1000 |
6465 | hidnplayr | 13 | |
14 | |||
15 | start: |
||
16 | pushfd |
||
17 | pop eax |
||
9216 | dunkaist | 18 | ; or eax, 1 SHL 18 ; Alignment Check flag, FIXME in libcrash |
6465 | hidnplayr | 19 | push eax |
20 | popfd |
||
21 | |||
22 | mcall 68, 11 |
||
23 | |||
24 | stdcall dll.Load, @IMPORT |
||
25 | or eax, eax |
||
26 | jnz quit |
||
27 | |||
28 | still: |
||
29 | mcall 10 |
||
30 | dec eax |
||
31 | jz redraw |
||
32 | dec eax |
||
33 | jz key |
||
34 | |||
35 | button: |
||
36 | mcall 17 |
||
37 | shr eax, 8 |
||
38 | |||
39 | cmp eax, 1 |
||
40 | je quit |
||
41 | |||
42 | redraw: |
||
43 | mcall 12, 1 |
||
44 | mcall 0, <0,900>, <0,160>, 0x34000000, 0x80000000, window_title |
||
45 | |||
9216 | dunkaist | 46 | mov [f70_buf.src], 0 |
47 | invoke crash.hash, LIBCRASH_SHA2_256, read_data, 0, bin |
||
48 | stdcall bin2hex, bin, SHA2_256_LEN, hex |
||
49 | mcall 4, <0,0>, 0xc0ffffff, hex, 0, 0 |
||
6465 | hidnplayr | 50 | |
9216 | dunkaist | 51 | invoke crash.hash_oneshot, LIBCRASH_SHA2_256, ctx, 0, i_end |
52 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
||
53 | mcall 4, <0,10>, 0xc0ffffff, hex, 0, 0 |
||
6465 | hidnplayr | 54 | |
9216 | dunkaist | 55 | invoke sha2_256.oneshot, ctx, 0, i_end |
56 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
||
57 | mcall 4, <0,20>, 0xc0ffffff, hex, 0, 0 |
||
6465 | hidnplayr | 58 | |
9216 | dunkaist | 59 | invoke sha2_256.init, ctx |
60 | invoke sha2_256.update, ctx, 0, 42 |
||
61 | invoke sha2_256.update, ctx, 42, i_end-42 |
||
62 | invoke sha2_256.finish, ctx |
||
63 | stdcall bin2hex, ctx, SHA2_256_LEN, hex |
||
64 | mcall 4, <0,30>, 0xc0ffffff, hex, 0, 0 |
||
65 | |||
6465 | hidnplayr | 66 | mcall 12, 2 |
67 | jmp still |
||
68 | |||
69 | key: |
||
70 | mcall 2 |
||
71 | jmp still |
||
72 | |||
73 | |||
74 | quit: |
||
75 | mcall -1 |
||
76 | |||
77 | |||
9216 | dunkaist | 78 | proc bin2hex uses esi edi, _bin, _len, _hex |
79 | mov esi, [_bin] |
||
80 | mov edi, [_hex] |
||
81 | mov ecx, [_len] |
||
82 | .next_byte: |
||
83 | movzx eax, byte[esi] |
||
84 | shr al, 4 |
||
85 | cmp al, 10 |
||
86 | sbb al, 0x69 |
||
87 | das |
||
88 | stosb |
||
89 | lodsb |
||
90 | and al, 0x0f |
||
91 | cmp al, 10 |
||
92 | sbb al, 0x69 |
||
93 | das |
||
94 | stosb |
||
95 | loop .next_byte |
||
96 | mov byte[edi], 0 |
||
97 | ret |
||
98 | endp |
||
99 | |||
100 | |||
101 | proc read_data uses ebx, _user, _buf, _len |
||
102 | mov eax, [_buf] |
||
103 | mov [f70_buf.dst], eax |
||
104 | mov eax, [_len] |
||
105 | mov [f70_buf.count], eax |
||
6465 | hidnplayr | 106 | mcall 70, f70_buf |
107 | mov eax, ebx |
||
108 | cmp eax, -1 |
||
9216 | dunkaist | 109 | jnz @f |
6465 | hidnplayr | 110 | inc eax |
111 | @@: |
||
9216 | dunkaist | 112 | add [f70_buf.src], eax |
6465 | hidnplayr | 113 | ret |
114 | endp |
||
115 | |||
116 | |||
9216 | dunkaist | 117 | sz window_title, 'libcrash example',0 |
6465 | hidnplayr | 118 | |
119 | f70_buf: |
||
9216 | dunkaist | 120 | .funcnum dd 0 |
121 | .src dd 0 |
||
122 | dd 0 |
||
123 | .count dd BUFFER_SIZE |
||
124 | .dst dd data_buffer |
||
125 | db 0 |
||
126 | .fname dd this_file_name |
||
6465 | hidnplayr | 127 | |
128 | |||
129 | align 4 |
||
130 | @IMPORT: |
||
131 | |||
132 | library \ |
||
133 | libcrash, 'libcrash.obj' |
||
134 | |||
9216 | dunkaist | 135 | import libcrash, \ |
136 | libcrash.init, 'lib_init', \ |
||
137 | crash.hash, 'crash_hash', \ |
||
138 | crash.hash_oneshot, 'crash_hash_oneshot', \ |
||
139 | crash.mac, 'crash_mac', \ |
||
140 | crash.mac_oneshot, 'crash_mac_oneshot', \ |
||
141 | crash.crypt, 'crash_crypt', \ |
||
142 | crash.crypt_oneshot, 'crash_crypt_oneshot', \ |
||
143 | sha2_256.init, 'sha2_256_init', \ |
||
144 | sha2_256.update, 'sha2_256_update', \ |
||
145 | sha2_256.finish, 'sha2_256_finish', \ |
||
146 | sha2_256.oneshot, 'sha2_256_oneshot', \ |
||
147 | hmac_sha2_256.init, 'hmac_sha2_256_init', \ |
||
148 | hmac_sha2_256.update, 'hmac_sha2_256_update', \ |
||
149 | hmac_sha2_256.finish, 'hmac_sha2_256_finish', \ |
||
150 | hmac_sha2_256.oneshot, 'hmac_sha2_256_oneshot', \ |
||
151 | aes256ctr.init, 'aes256ctr_init', \ |
||
152 | aes256ctr.update, 'aes256ctr_update', \ |
||
153 | aes256ctr.finish, 'aes256ctr_finish', \ |
||
154 | aes256ctr.oneshot, 'aes256ctr_oneshot' |
||
6465 | hidnplayr | 155 | |
156 | i_end: |
||
9216 | dunkaist | 157 | bin rb MAX_HASH_LEN |
158 | hex rb MAX_HASH_LEN*2+1 |
||
6465 | hidnplayr | 159 | data_buffer rb BUFFER_SIZE |
9216 | dunkaist | 160 | this_file_name rb 0x1000 |
161 | align LIBCRASH_ALIGN |
||
162 | ctx rb LIBCRASH_CTX_LEN |
||
163 | rb 0x1000 ;stack |
||
6465 | hidnplayr | 164 | e_end:0,30>0,20>0,10>0,0>0,160>0,900> |