Rev 647 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
647 | andrew_pro | 1 | format ELF |
2 | |||
3 | section '.text' executable |
||
4 | |||
5 | include 'proc32.inc' |
||
6 | public _ksys_get_filesize |
||
7 | public _ksys_readfile |
||
8 | public _ksys_rewritefile |
||
9 | public _ksys_appendtofile |
||
10 | |||
11 | align 4 |
||
12 | proc _ksys_get_filesize stdcall, filename:dword |
||
13 | |||
14 | xor eax,eax |
||
15 | mov ebx,[filename] |
||
16 | mov [fileinfo.subproc],dword 5 |
||
17 | mov [fileinfo.offset_l],eax |
||
18 | mov [fileinfo.offset_h],eax |
||
19 | mov [fileinfo.size],eax |
||
20 | mov [fileinfo.data],dword buffer_for_info |
||
21 | mov [fileinfo.letter],al |
||
22 | mov [fileinfo.filename],ebx |
||
23 | |||
24 | mov eax,70 |
||
25 | mov ebx,fileinfo |
||
26 | int 0x40 |
||
27 | |||
28 | test eax,eax |
||
29 | jnz error_for_file_size |
||
30 | |||
7172 | siemargl | 31 | mov eax,[buffer_for_info+32] ;file size |
32 | ret |
||
647 | andrew_pro | 33 | |
34 | error_for_file_size: |
||
7172 | siemargl | 35 | neg eax |
647 | andrew_pro | 36 | |
37 | ret |
||
38 | endp |
||
39 | |||
40 | |||
41 | align 4 |
||
42 | proc _ksys_readfile stdcall,filename:dword,position:dword,sizeblock:dword,buffer:dword |
||
43 | |||
44 | xor eax,eax |
||
45 | mov ebx,[position] |
||
46 | mov ecx,[sizeblock] |
||
47 | mov edx,[buffer] |
||
48 | mov esi,[filename] |
||
49 | mov [fileinfo.subproc],eax |
||
50 | mov [fileinfo.offset_l],ebx |
||
51 | mov [fileinfo.offset_h],eax |
||
52 | mov [fileinfo.size],ecx |
||
53 | mov [fileinfo.data],edx |
||
54 | mov [fileinfo.letter],al |
||
55 | mov [fileinfo.filename],esi |
||
56 | |||
57 | mov eax,70 |
||
58 | mov ebx,fileinfo |
||
59 | int 0x40 |
||
60 | |||
61 | ret |
||
62 | endp |
||
63 | |||
64 | align 4 |
||
65 | proc _ksys_rewritefile stdcall,filename:dword,sizeblock:dword,data_write:dword |
||
66 | |||
67 | xor eax,eax |
||
68 | mov ebx,[sizeblock] |
||
69 | mov ecx,[data_write] |
||
70 | mov edx,[filename] |
||
71 | mov [fileinfo.subproc],dword 2 |
||
72 | mov [fileinfo.offset_l],eax |
||
73 | mov [fileinfo.offset_h],eax |
||
74 | mov [fileinfo.size],ebx |
||
75 | mov [fileinfo.data],ecx |
||
76 | mov [fileinfo.letter],al |
||
77 | mov [fileinfo.filename],edx |
||
78 | |||
79 | mov eax,70 |
||
80 | mov ebx,fileinfo |
||
81 | int 0x40 |
||
82 | |||
83 | ret |
||
84 | endp |
||
85 | |||
86 | align 4 |
||
87 | proc _ksys_appendtofile stdcall,filename:dword,pos:dword,sizeblock:dword,data_append:dword |
||
88 | |||
89 | xor eax,eax |
||
90 | mov ebx,[pos] |
||
91 | mov ecx,[sizeblock] |
||
92 | mov edx,[data_append] |
||
93 | mov esi,[filename] |
||
94 | mov [fileinfo.subproc],dword 3 |
||
95 | mov [fileinfo.offset_l],ebx |
||
96 | mov [fileinfo.offset_h],eax |
||
97 | mov [fileinfo.size],ecx |
||
98 | mov [fileinfo.data],edx |
||
99 | mov [fileinfo.letter],al |
||
100 | mov [fileinfo.filename],esi |
||
101 | |||
102 | mov eax,70 |
||
103 | mov ebx,fileinfo |
||
104 | int 0x40 |
||
105 | |||
106 | ret |
||
107 | endp |
||
108 | |||
109 | struc FILEIO |
||
110 | { |
||
111 | .subproc rd 1 |
||
112 | .offset_l rd 1 |
||
113 | .offset_h rd 1 |
||
114 | .size rd 1 |
||
115 | .data rd 1 |
||
116 | .letter rb 1 |
||
117 | .filename rd 1 |
||
118 | } |
||
119 | |||
120 | fileinfo FILEIO |
||
121 | buffer_for_info rd 11 |