Rev 4922 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
3701 | hidnplayr | 1 | cmd_help: |
2 | |||
3 | push str_help |
||
4 | call [con_write_asciiz] |
||
5 | |||
3790 | hidnplayr | 6 | jmp wait_for_usercommand |
7 | |||
4920 | hidnplayr | 8 | |
3800 | hidnplayr | 9 | cmd_bye: |
10 | |||
4920 | hidnplayr | 11 | ; Send BYE message to the server |
4922 | ashmew2 | 12 | mov dword[buf_cmd], "BYE" + 13 shl 24 |
13 | mov byte[buf_cmd+4], 10 |
||
5011 | hidnplayr | 14 | mcall send, [controlsocket], buf_cmd, 5, 0 |
4920 | hidnplayr | 15 | |
16 | ; Close the control connection |
||
5011 | hidnplayr | 17 | mcall close, [controlsocket] |
3800 | hidnplayr | 18 | jmp main |
19 | |||
4920 | hidnplayr | 20 | |
3794 | hidnplayr | 21 | cmd_pwd: |
22 | |||
4922 | ashmew2 | 23 | mov dword[buf_cmd], "PWD" + 13 shl 24 |
24 | mov byte[buf_cmd+4], 10 |
||
5011 | hidnplayr | 25 | mcall send, [controlsocket], buf_cmd, 5, 0 |
3794 | hidnplayr | 26 | |
27 | jmp wait_for_servercommand |
||
28 | |||
4920 | hidnplayr | 29 | |
3790 | hidnplayr | 30 | cmd_cwd: |
31 | |||
4922 | ashmew2 | 32 | mov dword[buf_cmd], "CWD " |
3790 | hidnplayr | 33 | |
34 | mov ecx, 256 |
||
35 | xor al, al |
||
4922 | ashmew2 | 36 | mov edi, buf_cmd |
3790 | hidnplayr | 37 | repne scasb |
4922 | ashmew2 | 38 | lea esi, [edi - buf_cmd] |
3814 | hidnplayr | 39 | mov word [edi - 2], 0x0a0d |
3790 | hidnplayr | 40 | |
5011 | hidnplayr | 41 | mcall send, [controlsocket], buf_cmd, , 0 |
3790 | hidnplayr | 42 | |
3793 | hidnplayr | 43 | jmp wait_for_servercommand |
44 | |||
4920 | hidnplayr | 45 | |
3800 | hidnplayr | 46 | cmd_dele: |
3793 | hidnplayr | 47 | |
4922 | ashmew2 | 48 | mov dword[buf_cmd], "DELE" |
49 | mov byte[buf_cmd], " " |
||
3800 | hidnplayr | 50 | |
51 | mov ecx, 256 |
||
52 | xor al, al |
||
4922 | ashmew2 | 53 | mov edi, buf_cmd |
3800 | hidnplayr | 54 | repne scasb |
4922 | ashmew2 | 55 | lea esi, [edi - buf_cmd] |
3814 | hidnplayr | 56 | mov word [edi - 2], 0x0a0d |
3800 | hidnplayr | 57 | |
5011 | hidnplayr | 58 | mcall send, [controlsocket], buf_cmd, , 0 |
3800 | hidnplayr | 59 | |
60 | jmp wait_for_servercommand |
||
61 | |||
4920 | hidnplayr | 62 | |
3800 | hidnplayr | 63 | cmd_list: |
64 | call open_dataconnection |
||
65 | |||
66 | mov [operation], OPERATION_LIST |
||
67 | |||
4922 | ashmew2 | 68 | mov dword[buf_cmd], "LIST" |
69 | mov word[buf_cmd+4], 0x0a0d |
||
5011 | hidnplayr | 70 | mcall send, [controlsocket], buf_cmd, 6, 0 |
3800 | hidnplayr | 71 | |
72 | jmp wait_for_servercommand |
||
73 | |||
74 | |||
3793 | hidnplayr | 75 | cmd_retr: |
76 | call open_dataconnection |
||
4920 | hidnplayr | 77 | |
78 | ; Create/open the file |
||
3793 | hidnplayr | 79 | |
4922 | ashmew2 | 80 | ; Create/open the file |
81 | |||
82 | mov esi, buf_cmd+5 |
||
4920 | hidnplayr | 83 | mov ecx, 256-5 |
84 | call set_filename |
||
3800 | hidnplayr | 85 | |
86 | mov [filestruct.subfn], 2 ; create/rewrite file |
||
87 | mov [filestruct.offset], 0 |
||
88 | mov [filestruct.offset+4], 0 |
||
89 | mov [filestruct.size], 0 |
||
90 | mov [filestruct.ptr], 0 |
||
91 | |||
92 | mcall 70, filestruct |
||
93 | cmp eax, -1 |
||
94 | ; je fileerror |
||
95 | |||
4920 | hidnplayr | 96 | ; Prepare to write to the file |
97 | |||
3800 | hidnplayr | 98 | mov [filestruct.subfn], 3 ; write to file |
4920 | hidnplayr | 99 | mov [operation], OPERATION_RETR |
3800 | hidnplayr | 100 | |
4920 | hidnplayr | 101 | ; Request the file from server |
4922 | ashmew2 | 102 | |
103 | mov dword[buf_cmd], "RETR" |
||
104 | mov byte[buf_cmd+4], " " |
||
4920 | hidnplayr | 105 | |
3793 | hidnplayr | 106 | mov ecx, 256 |
107 | xor al, al |
||
4922 | ashmew2 | 108 | mov edi, buf_cmd |
3793 | hidnplayr | 109 | repne scasb |
4922 | ashmew2 | 110 | lea esi, [edi - buf_cmd] |
4920 | hidnplayr | 111 | mov dword[edi - 2], 0x0a0d |
5011 | hidnplayr | 112 | mcall send, [controlsocket], buf_cmd, , 0 |
3793 | hidnplayr | 113 | |
4922 | ashmew2 | 114 | invoke con_write_asciiz, buf_cmd ; print command |
3793 | hidnplayr | 115 | jmp wait_for_servercommand |
116 | |||
4922 | ashmew2 | 117 | cmd_rdir: |
3793 | hidnplayr | 118 | |
4922 | ashmew2 | 119 | mov [operation], OPERATION_RDIR |
120 | |||
121 | ; Request filename list from the server |
||
122 | |||
5011 | hidnplayr | 123 | call open_dataconnection |
124 | |||
125 | mov [ptr_fname], 0 |
||
126 | mov [size_fname], 0 |
||
4922 | ashmew2 | 127 | mov dword[buf_cmd], "NLST" |
128 | mov word[buf_cmd+4], 0x0a0d |
||
5011 | hidnplayr | 129 | mcall send, [controlsocket], buf_cmd, 6, 0 |
4922 | ashmew2 | 130 | |
5011 | hidnplayr | 131 | jmp wait_for_servercommand |
132 | |||
3793 | hidnplayr | 133 | cmd_stor: |
134 | |||
135 | call open_dataconnection |
||
136 | |||
3800 | hidnplayr | 137 | mov [operation], OPERATION_STOR |
138 | |||
139 | mov [filestruct.subfn], 0 ; read file |
||
140 | mov [filestruct.offset], 0 |
||
141 | mov [filestruct.offset+4], 0 |
||
142 | mov [filestruct.size], BUFFERSIZE |
||
4922 | ashmew2 | 143 | mov [filestruct.ptr], buf_buffer2 |
3800 | hidnplayr | 144 | |
4922 | ashmew2 | 145 | mov esi, buf_cmd+5 |
3800 | hidnplayr | 146 | mov ecx, 256-5 |
147 | call set_filename |
||
148 | |||
4922 | ashmew2 | 149 | mov dword[buf_cmd], "STOR" |
150 | mov byte[buf_cmd+4], " " |
||
3793 | hidnplayr | 151 | |
152 | mov ecx, 256 |
||
153 | xor al, al |
||
4922 | ashmew2 | 154 | mov edi, buf_cmd |
3793 | hidnplayr | 155 | repne scasb |
4922 | ashmew2 | 156 | lea esi, [edi - buf_cmd] |
3814 | hidnplayr | 157 | mov word [edi - 2], 0x0a0d |
5011 | hidnplayr | 158 | mcall send, [controlsocket], buf_cmd, , 0 |
3793 | hidnplayr | 159 | |
3800 | hidnplayr | 160 | jmp wait_for_servercommand |
161 | |||
162 | |||
3802 | hidnplayr | 163 | cmd_lcwd: |
3800 | hidnplayr | 164 | |
4922 | ashmew2 | 165 | mov esi, buf_cmd+5 |
5011 | hidnplayr | 166 | cmp byte[esi], 10 |
167 | je .print |
||
3802 | hidnplayr | 168 | mov ecx, 256-5 |
169 | .loop: |
||
170 | lodsb |
||
171 | cmp al, 10 |
||
172 | je .done |
||
173 | test al, al |
||
174 | je .done |
||
175 | loop .loop |
||
176 | .done: |
||
177 | mov byte[esi-1], 0 |
||
4922 | ashmew2 | 178 | mcall 30, 1, buf_cmd+5 ; set working directory |
5011 | hidnplayr | 179 | .print: |
4922 | ashmew2 | 180 | mcall 30, 2, buf_cmd, 256 ; and read it again |
3802 | hidnplayr | 181 | |
182 | invoke con_write_asciiz, str_lcwd |
||
4922 | ashmew2 | 183 | invoke con_write_asciiz, buf_cmd |
3813 | hidnplayr | 184 | invoke con_write_asciiz, str_newline |
3802 | hidnplayr | 185 | |
186 | jmp wait_for_usercommand |
||
187 | |||
4920 | hidnplayr | 188 | |
3804 | hidnplayr | 189 | cmd_cdup: |
3802 | hidnplayr | 190 | |
4922 | ashmew2 | 191 | mov dword[buf_cmd], "CDUP" |
192 | mov word[buf_cmd+4], 0x0d0a |
||
5011 | hidnplayr | 193 | mcall send, [controlsocket], buf_cmd, 6, 0 |
3802 | hidnplayr | 194 | |
3804 | hidnplayr | 195 | jmp wait_for_servercommand |
196 | |||
4920 | hidnplayr | 197 | |
3804 | hidnplayr | 198 | cmd_rmd: |
199 | |||
4922 | ashmew2 | 200 | mov dword[buf_cmd], "RMD " |
3804 | hidnplayr | 201 | |
202 | mov ecx, 256 |
||
203 | xor al, al |
||
4922 | ashmew2 | 204 | mov edi, buf_cmd |
3804 | hidnplayr | 205 | repne scasb |
4922 | ashmew2 | 206 | lea esi, [edi - buf_cmd] |
3814 | hidnplayr | 207 | mov word [edi - 2], 0x0a0d |
3804 | hidnplayr | 208 | |
5011 | hidnplayr | 209 | mcall send, [controlsocket], buf_cmd, , 0 |
3804 | hidnplayr | 210 | |
211 | jmp wait_for_servercommand |
||
212 | |||
4920 | hidnplayr | 213 | |
3804 | hidnplayr | 214 | cmd_mkd: |
215 | |||
4922 | ashmew2 | 216 | mov dword[buf_cmd], "MKD " |
3804 | hidnplayr | 217 | |
218 | mov ecx, 256 |
||
219 | xor al, al |
||
4922 | ashmew2 | 220 | mov edi, buf_cmd |
3804 | hidnplayr | 221 | repne scasb |
4922 | ashmew2 | 222 | lea esi, [edi - buf_cmd] |
3814 | hidnplayr | 223 | mov word [edi - 2], 0x0a0d |
3804 | hidnplayr | 224 | |
5011 | hidnplayr | 225 | mcall send, [controlsocket], buf_cmd, , 0 |
3804 | hidnplayr | 226 | |
227 | jmp wait_for_servercommand |
||
228 | |||
229 | |||
3800 | hidnplayr | 230 | ; esi = source ptr |
231 | ; ecx = max length of source buffer |
||
232 | set_filename: |
||
233 | |||
4920 | hidnplayr | 234 | mov edi, filestruct.name |
3800 | hidnplayr | 235 | .loop: |
236 | lodsb |
||
237 | test al, al |
||
238 | jz .done |
||
239 | cmp al, 10 |
||
240 | je .done |
||
241 | stosb |
||
242 | loop .loop |
||
243 | .done: |
||
244 | xor al, al ; append a 0 byte |
||
245 | stosb |
||
246 | |||
4920 | hidnplayr | 247 | ret |