Rev 8791 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
8791 | turbocat | 1 | format binary as "kex" |
2 | |||
3 | use32 |
||
4 | org 0x0 |
||
5 | db 'MENUET01' |
||
6 | dd 0x01 |
||
7 | dd START |
||
8 | dd IM_END |
||
9 | dd MEM |
||
10 | dd MEM |
||
11 | dd 0 |
||
12 | dd 0 |
||
13 | |||
14 | include '../../../../macros.inc' |
||
15 | include '../../../../proc32.inc' |
||
16 | include '../../../../KOSfuncs.inc' |
||
17 | include '../../../../dll.inc' |
||
18 | include '../mtar.inc' |
||
19 | ;include '../../../../debug-fdo.inc' |
||
20 | |||
21 | ;__DEBUG__ = 1 |
||
22 | ;__DEBUG_LEVEL__ = 2 |
||
23 | |||
24 | |||
25 | START: |
||
26 | stdcall dll.Load, @IMPORT ; Имортироуем функции из mtar.obj |
||
27 | test eax, eax |
||
28 | jnz exit |
||
29 | |||
30 | ccall [mtar_init] ; Инициализируем библиотеку (на самом деле подгружается libc.obj |
||
31 | ccall [mtar_open], tar, tar_fname, tar_fmode ; Открываем для чтения файл 'test.tar' |
||
32 | |||
33 | ; DEBUGF 2, "%d", eax |
||
34 | |||
35 | print_next: |
||
36 | ccall [mtar_read_header], tar, header ; Читаем заголовок |
||
37 | cmp eax, MTAR_ENULLRECORD ; Если заголовок не был прочитан (return -7) выходим из цикла |
||
38 | je exit |
||
39 | ccall [printf], format_str, header+mtar_header_t.name, dword[header+mtar_header_t.size] ; Выводим в консоль имя файла и размер в байтах |
||
40 | ccall [mtar_next], tar ; Переходим к следующему заголовку |
||
41 | jmp print_next ; прыгаем в начало цикла |
||
42 | |||
43 | exit: |
||
44 | ccall [mtar_close], tar ; Закрываем 'test.tar' |
||
45 | mcall SF_TERMINATE_PROCESS ; Выходим из программы |
||
46 | |||
47 | ; data |
||
48 | |||
49 | tar_fname db 'test.tar', 0 |
||
50 | tar_fmode db 'r', 0 |
||
51 | |||
52 | tar rb sizeof.mtar_t |
||
53 | header rb sizeof.mtar_header_t |
||
54 | |||
55 | format_str db '%-10s (%-4d bytes)', 0x0A,0 |
||
56 | |||
57 | align 4 |
||
58 | |||
59 | @IMPORT: |
||
60 | library mtar, 'mtar.obj', libc , 'libc.obj' |
||
61 | import mtar, \ |
||
62 | mtar_init, 'mtar_init', \ |
||
63 | mtar_open, 'mtar_open', \ |
||
64 | mtar_next, 'mtar_next', \ |
||
65 | mtar_strerror, 'mtar_strerror', \ |
||
66 | mtar_read_header, 'mtar_read_header', \ |
||
67 | mtar_write_data, 'mtar_write_data', \ |
||
68 | mtar_finalize, 'mtar_finalize', \ |
||
8839 | leency | 69 | mtar_close, 'mtar_close' |
8791 | turbocat | 70 | |
71 | import libc, \ |
||
72 | printf, 'printf' |
||
73 | |||
74 | |||
75 | IM_END: |
||
76 | align 4 |
||
77 | rb 4096 ; stack |
||
78 | MEM: |