Rev 145 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
145 | halyavin | 1 | format ELF |
2 | section '.text' executable |
||
3 | public _msys_read_file |
||
4 | _msys_read_file: |
||
5 | ;arg1 - file name |
||
6 | ;arg2 - file offset |
||
7 | ;arg3 - size to read |
||
8 | ;arg4 - data |
||
9 | ;arg5 - file size |
||
10 | push ebp |
||
11 | mov ebp,esp |
||
12 | xor eax,eax |
||
13 | mov [file_struct.operation],eax |
||
14 | mov eax,[ebp+12] |
||
15 | mov [file_struct.offset],eax |
||
16 | mov eax,[ebp+16] |
||
158 | halyavin | 17 | mov [file_struct.size],eax |
145 | halyavin | 18 | mov eax,[ebp+20] |
158 | halyavin | 19 | mov [file_struct.data],eax |
145 | halyavin | 20 | mov [file_struct.temp_buffer],temp_buffer |
21 | mov edx,[ebp+8] |
||
22 | call copy_file_name |
||
23 | push ebx |
||
24 | mov ebx,file_struct |
||
25 | mov eax,58 |
||
26 | int 0x40 |
||
27 | mov ecx,[ebp+24] |
||
28 | test ecx,ecx |
||
29 | jz .no_file_size |
||
30 | mov [ecx],ebx |
||
31 | .no_file_size: |
||
32 | pop ebx |
||
33 | pop ebp |
||
34 | ret 20 |
||
35 | |||
36 | copy_file_name: |
||
37 | push esi edi |
||
38 | cld |
||
39 | mov edi,edx |
||
40 | xor eax,eax |
||
41 | xor ecx,ecx |
||
42 | dec ecx |
||
43 | repnz scasb |
||
44 | not ecx |
||
45 | mov edi,file_struct.path |
||
46 | mov esi,edx |
||
47 | rep movsb |
||
48 | pop edi esi |
||
49 | ret |
||
50 | |||
51 | public _msys_write_file |
||
52 | _msys_write_file: |
||
53 | ;arg1 - file name |
||
54 | ;arg2 - size |
||
55 | ;arg3 - data |
||
56 | push ebp |
||
57 | mov ebp,esp |
||
58 | xor eax,eax |
||
59 | mov [file_struct.offset],eax |
||
60 | inc eax |
||
61 | mov [file_struct.operation],eax |
||
62 | mov eax,[ebp+12] |
||
63 | mov [file_struct.size],eax |
||
64 | mov eax,[ebp+16] |
||
65 | mov [file_struct.data],eax |
||
66 | mov [file_struct.temp_buffer],temp_buffer |
||
67 | mov edx,[ebp+8] |
||
68 | call copy_file_name |
||
69 | push ebx |
||
70 | mov eax,58 |
||
71 | mov ebx,file_struct |
||
72 | int 0x40 |
||
73 | pop ebx |
||
74 | pop ebp |
||
75 | ret 12 |
||
76 | |||
77 | public _msys_run_program |
||
78 | _msys_run_program: |
||
79 | ;arg1 - program name |
||
80 | ;arg2 - parameters |
||
81 | push ebp |
||
82 | mov ebp,esp |
||
83 | mov [file_struct.operation],16 |
||
84 | xor eax,eax |
||
85 | mov [file_struct.offset],eax |
||
86 | mov [file_struct.data],eax |
||
87 | mov eax,[ebp+12] |
||
88 | mov [file_struct.param],eax |
||
89 | mov [file_struct.temp_buffer],temp_buffer; |
||
90 | mov edx,[ebp+8] |
||
91 | call copy_file_name |
||
92 | push ebx |
||
93 | mov eax,58 |
||
94 | mov ebx,file_struct |
||
95 | int 0x40 |
||
96 | pop ebx |
||
97 | pop ebp |
||
98 | ret 8 |
||
99 | section '.bss' writeable |
||
100 | file_struct: |
||
101 | .operation rd 1 |
||
102 | .offset rd 1 |
||
103 | .param: |
||
104 | .size rd 1 |
||
105 | .data rd 1 |
||
106 | .temp_buffer rd 1 |
||
107 | .path rb 1024 |
||
108 | temp_buffer rb 4096 |
||
109 |