Subversion Repositories Kolibri OS

Rev

Rev 3532 | 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 'libcrash.inc'
11
 
6461 dunkaist 12
BUFFER_SIZE     = 4096
3115 dunkaist 13
 
3532 dunkaist 14
 
3115 dunkaist 15
start:
6461 dunkaist 16
        pushfd
17
        pop     eax
18
        or      eax, 1 SHL 18   ; Alignment Check flag
19
        push    eax
20
        popfd
3115 dunkaist 21
 
6461 dunkaist 22
        mcall   68, 11
3115 dunkaist 23
 
6461 dunkaist 24
        stdcall dll.Load, @IMPORT
25
        or      eax, eax
26
        jnz     quit
27
 
3115 dunkaist 28
still:
6461 dunkaist 29
        mcall   10
30
        dec     eax
31
        jz      redraw
32
        dec     eax
33
        jz      key
3115 dunkaist 34
 
35
button:
6461 dunkaist 36
        mcall   17
37
        shr     eax, 8
3115 dunkaist 38
 
6461 dunkaist 39
        cmp     eax, 1
40
        je      quit
3115 dunkaist 41
 
42
redraw:
6461 dunkaist 43
        mcall   12, 1
44
        mcall   0, <0,900>, <0,160>, 0x34000000, 0x80000000, window_title
3115 dunkaist 45
 
46
 
6461 dunkaist 47
        mcall   4, < 0,  0>, 0xc0ffffff, message, , 0
3532 dunkaist 48
 
49
        mov     [hid], 0
50
        mov     [text_pos_y], 10
51
        mov     [hash_name], hash_strings
52
  .next_hash:
53
        mov     dword[f70_buf + 4], 0
54
        mov     dword[msglen], 0
55
        mov     edi, hex
56
        xor     eax, eax
57
        mov     ecx, 1024/4
58
        rep     stosd
6461 dunkaist 59
        invoke  crash.hash, [hid], data_buffer, update_data_buffer, ctx
60
        invoke  crash.bin2hex, ctx, hex, [hid]
3532 dunkaist 61
        mov     ebx, [text_pos_y]
6461 dunkaist 62
        mcall   4, , 0xc0ffffff, [hash_name],    , 0
3532 dunkaist 63
        mov     ebx, [text_pos_y]
64
        add     ebx, 66 SHL 16
6461 dunkaist 65
        mcall   4, , 0x40ffffff, hex, 128, 0
3532 dunkaist 66
        add     [text_pos_y], 10
67
        add     [hash_name], 12 ; lenght of hash_strings item
68
        inc     [hid]
69
        cmp     [hid], LIBCRASH_SHA3_512
70
        jng     .next_hash
71
 
6461 dunkaist 72
        mcall   12, 2
73
        jmp     still
3115 dunkaist 74
 
75
key:
6461 dunkaist 76
        mcall   2
77
        jmp     still
3115 dunkaist 78
 
79
 
80
quit:
6461 dunkaist 81
        mcall   -1
3115 dunkaist 82
 
83
 
3532 dunkaist 84
proc update_data_buffer _left
6461 dunkaist 85
        mov     eax, data_buffer
86
        add     eax, [_left]
87
        mov     dword[f70_buf + 16], eax
88
        mov     eax, BUFFER_SIZE
89
        sub     eax, [_left]
90
        mov     dword[f70_buf + 12], eax
91
        mcall   70, f70_buf
92
        mov     eax, ebx
93
        cmp     eax, -1
94
        jne     @f
95
        inc     eax
3115 dunkaist 96
    @@:
6461 dunkaist 97
        add     dword[f70_buf + 4], eax
98
        ret
3115 dunkaist 99
endp
100
 
101
 
6461 dunkaist 102
szZ window_title        ,'libcrash example'
3115 dunkaist 103
 
3532 dunkaist 104
szZ message             , 'hash sums of this file'
3115 dunkaist 105
 
3532 dunkaist 106
hash_strings:
6461 dunkaist 107
                db 'crc32    : ',0
108
                db 'md4      : ',0
109
                db 'md5      : ',0
110
                db 'sha1     : ',0
111
                db 'sha224   : ',0
112
                db 'sha256   : ',0
113
                db 'sha384   : ',0
114
                db 'sha512   : ',0
115
                db 'sha3-224 : ',0
116
                db 'sha3-256 : ',0
117
                db 'sha3-384 : ',0
118
                db 'sha3-512 : ',0
3532 dunkaist 119
 
3115 dunkaist 120
f70_buf:
6461 dunkaist 121
        funcnum dd 0
122
        src     dd 0
123
        res1    dd 0
124
        count   dd BUFFER_SIZE
125
        dst     dd data_buffer
126
        res2    db 0
127
        fname   dd this_file_name
3115 dunkaist 128
 
3532 dunkaist 129
 
3115 dunkaist 130
align 4
131
@IMPORT:
132
 
6461 dunkaist 133
library                           \
134
        libcrash, 'libcrash.obj'
3115 dunkaist 135
 
6461 dunkaist 136
import  libcrash                        , \
137
        libcrash.init  , 'lib_init'     , \
138
        crash.hash     , 'crash_hash'   , \
139
        crash.bin2hex  , 'crash_bin2hex'
3115 dunkaist 140
 
141
i_end:
3532 dunkaist 142
hash_name       rd 1
6461 dunkaist 143
text_pos_y      rd 1
144
hash            rd 50
3532 dunkaist 145
hid             rd 1    ; hash id
6461 dunkaist 146
msglen          rd 1
147
hex             rb 1024
148
data_buffer     rb BUFFER_SIZE
149
this_file_name  rb 4096
150
rb 0x800                                        ;stack
151
align 16        ; should be enough
152
ctx             rb 0x1000
3115 dunkaist 153
e_end:
154