Rev 3618 | Rev 3704 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3618 | Rev 3623 | ||
---|---|---|---|
Line 28... | Line 28... | ||
28 | 28 | ||
29 | db 'MENUET01' ; header |
29 | db 'MENUET01' ; header |
30 | dd 0x01 ; header version |
30 | dd 0x01 ; header version |
31 | dd START ; entry point |
31 | dd START ; entry point |
32 | dd IM_END ; image size |
32 | dd IM_END ; image size |
33 | dd I_END+0x100 ; required memory |
33 | dd I_END+0x1000 ; required memory |
34 | dd I_END+0x100 ; esp |
34 | dd I_END+0x1000 ; esp |
35 | dd params ; I_PARAM |
35 | dd params ; I_PARAM |
Line 36... | Line 36... | ||
36 | dd 0x0 ; I_Path |
36 | dd 0x0 ; I_Path |
37 | 37 | ||
Line 44... | Line 44... | ||
44 | 44 | ||
Line 45... | Line 45... | ||
45 | START: |
45 | START: |
Line 46... | Line -... | ||
46 | - | ||
47 | mcall 68, 11 ; init heap so we can allocate memory dynamically |
- | |
48 | 46 | ||
49 | mcall 40, EV_STACK |
47 | mcall 68, 11 ; init heap so we can allocate memory dynamically |
50 | 48 | ||
51 | ; load libraries |
49 | ; load libraries |
Line 67... | Line 65... | ||
67 | stosb |
65 | stosb |
68 | mov al, ' ' |
66 | mov al, ' ' |
69 | mov ecx, URLMAXLEN-1 |
67 | mov ecx, URLMAXLEN-1 |
70 | rep stosb |
68 | rep stosb |
Line 71... | Line 69... | ||
71 | 69 | ||
- | 70 | ; load proxy settings |
|
72 | call load_settings |
71 | invoke ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr |
73 | cmp byte[params], 0 |
72 | invoke ini.get_int, inifile, sec_proxy, key_proxyport, 80 |
- | 73 | mov [proxyPort], eax |
|
- | 74 | invoke ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser |
|
Line 74... | Line 75... | ||
74 | je prepare_event ;red |
75 | invoke ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword |
75 | 76 | ||
76 | ; we have an url |
- | |
77 | mov edi, document_user |
77 | ; check parameters |
78 | mov al, ' ' |
- | |
Line -... | Line 78... | ||
- | 78 | cmp byte[params], 0 ; no parameters ? |
|
79 | mov ecx, URLMAXLEN |
79 | je reset_events ; load the GUI |
80 | rep stosb |
80 | |
81 | - | ||
- | 81 | ; we have an url, copy untill space or 0 |
|
82 | mov esi, params |
82 | mov esi, params |
83 | mov edi, document_user |
83 | mov edi, document_user |
84 | 84 | mov ecx, 1024 ; max parameter size |
|
85 | ; copy untill space or 0 |
85 | mov [shared_name], 0 |
86 | .copy_param: |
86 | .copy_param: |
Line 87... | Line 87... | ||
87 | mov al, [esi] |
87 | lodsb |
88 | test al, al |
88 | test al, al |
Line 89... | Line 89... | ||
89 | jz .done |
89 | jz .done |
90 | 90 | ||
91 | cmp al, ' ' |
91 | cmp al, ' ' |
92 | jz .done_inc |
92 | jz .done_with_shared |
93 | - | ||
94 | mov [edi], al |
93 | |
Line 95... | Line -... | ||
95 | inc esi |
- | |
96 | inc edi |
94 | stosb |
97 | jmp .copy_param |
- | |
98 | 95 | dec ecx |
|
- | 96 | jnz .copy_param |
|
99 | .done_inc: |
97 | DEBUGF 2, "Invalid parameters\n" |
- | 98 | jmp exit |
|
- | 99 | ||
- | 100 | .done_with_shared: |
|
- | 101 | mov [shared_name], esi |
|
- | 102 | .done: |
|
- | 103 | xor al, al |
|
- | 104 | stosb |
|
- | 105 | ||
- | 106 | ||
- | 107 | download: |
|
- | 108 | ||
- | 109 | DEBUGF 1, "Starting download\n" |
|
- | 110 | ||
- | 111 | call parse_url |
|
- | 112 | call open_socket |
|
- | 113 | call send_request |
|
- | 114 | ||
- | 115 | mcall 68, 12, BUFFERSIZE ; create buffer, we'll resize it later if needed.. |
|
- | 116 | mov [buf_ptr], eax |
|
- | 117 | mov [buf_size], 0 |
|
- | 118 | ||
- | 119 | call read_incoming_data |
|
- | 120 | ||
- | 121 | mcall close, [socketnum] |
|
- | 122 | ||
- | 123 | call parse_result |
|
- | 124 | call save |
|
- | 125 | ||
- | 126 | mcall 68, 13, [final_buffer] ; free buffer |
|
- | 127 | ||
Line 100... | Line -... | ||
100 | - | ||
101 | ; url is followed by shared memory name. |
128 | cmp byte [params], 0 |
102 | inc esi |
129 | jne exit |
103 | .done: |
130 | |
Line 104... | Line 131... | ||
104 | mov [shared_name], esi |
131 | reset_events: |
105 | jmp download |
132 | |
Line 106... | Line 133... | ||
106 | 133 | DEBUGF 1, "resetting events\n" |
|
107 | prepare_event: |
134 | |
108 | ; Report events |
- | |
Line 109... | Line 135... | ||
109 | ; Stack 8 + defaults |
135 | ; Report events |
110 | mcall 40, 10100111b |
- | |
111 | - | ||
Line 112... | Line 136... | ||
112 | red: ; redraw |
136 | ; defaults + mouse |
- | 137 | mcall 40, EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE |
|
- | 138 | ||
- | 139 | redraw: |
|
113 | call draw_window |
140 | call draw_window |
Line 114... | Line 141... | ||
114 | 141 | ||
115 | still: |
142 | still: |
Line 116... | Line 143... | ||
116 | cmp byte [params], 0 |
143 | DEBUGF 1, "waiting for events\n" |
117 | jne exit |
144 | |
Line 118... | Line 145... | ||
118 | 145 | mcall 10 ; wait here for event |
|
Line 119... | Line -... | ||
119 | mcall 10 ; wait here for event |
- | |
120 | cmp eax, 1 ; redraw request ? |
146 | |
121 | je red |
147 | cmp eax, EV_REDRAW |
Line 122... | Line 148... | ||
122 | 148 | je redraw |
|
Line 143... | Line 169... | ||
143 | jmp still |
169 | jmp still |
Line 144... | Line 170... | ||
144 | 170 | ||
Line 145... | Line 171... | ||
145 | button: |
171 | button: |
- | 172 | ||
146 | 173 | mcall 17 ; get id |
|
147 | mcall 17 ; get id |
174 | |
148 | cmp ah, 26 |
175 | cmp ah, 26 |
149 | jne @f |
176 | jne @f |
150 | call save_to_file |
177 | call save_to_file |
Line 161... | Line 188... | ||
161 | 188 | ||
162 | exit: |
189 | exit: |
163 | or eax, -1 ; close this program |
190 | or eax, -1 ; close this program |
Line 164... | Line -... | ||
164 | mcall |
- | |
165 | - | ||
166 | download: |
- | |
167 | - | ||
168 | DEBUGF 1, "Starting download\n" |
- | |
169 | - | ||
170 | call parse_url |
- | |
171 | call open_socket |
- | |
172 | call send_request |
- | |
173 | - | ||
174 | mcall 68, 12, BUFFERSIZE |
- | |
175 | mov [buf_ptr], eax |
- | |
176 | mov [buf_size], 0 |
- | |
177 | - | ||
178 | call read_incoming_data |
- | |
179 | - | ||
180 | mcall close, [socketnum] |
- | |
181 | - | ||
182 | call parse_result |
- | |
183 | call save |
- | |
184 | - | ||
185 | mcall 68, 13, [final_buffer] |
- | |
186 | - | ||
Line 187... | Line 191... | ||
187 | jmp still |
191 | mcall |
- | 192 | ||
- | 193 | ||
Line 188... | Line 194... | ||
188 | 194 | save: |
|
189 | - | ||
190 | save: |
195 | cmp [shared_name], 0 |
191 | - | ||
192 | mov ecx, [shared_name] |
- | |
- | 196 | je .use_file |
|
193 | test ecx, ecx |
197 | |
Line 194... | Line 198... | ||
194 | jz @f |
198 | call save_in_shared |
Line -... | Line 199... | ||
- | 199 | jmp .done |
|
- | 200 | ||
195 | cmp [ecx], byte 0 |
201 | .use_file: |
196 | jnz save_in_shared |
202 | |
197 | @@: |
203 | call save_to_file |
Line 198... | Line 204... | ||
198 | 204 | ||
Line 199... | Line 205... | ||
199 | call save_to_file |
205 | .done: |
Line 200... | Line 206... | ||
200 | 206 | ||
201 | ; if called from command line, then exit |
207 | ; if called from command line, then exit |
- | 208 | cmp byte[params], 0 |
|
202 | cmp byte[params], 0 |
209 | jne exit |
203 | jne exit |
210 | |
Line 204... | Line -... | ||
204 | - | ||
205 | ret |
- | |
206 | - | ||
207 | save_in_shared: |
211 | ret |
208 | - | ||
209 | mov esi, 1 ; SHM_OPEN+SHM_WRITE |
212 | |
210 | mcall 68, 22 |
- | |
211 | test eax, eax |
- | |
212 | jz exit |
- | |
213 | 213 | save_in_shared: |
|
- | 214 | ||
- | 215 | ; open the shared memory area |
|
214 | sub edx, 4 |
216 | mov esi, 1 |
215 | jbe exit |
217 | mcall 68, 22, [shared_name], , 1 ; SHM_OPEN+SHM_WRITE |
216 | 218 | test eax, eax |
|
217 | mov ecx, [final_size] |
219 | jz exit |
218 | cmp ecx, edx |
220 | |
219 | jb @f |
221 | mov ecx, [final_size] |
220 | 222 | ; store the size |
|
221 | mov ecx, edx |
223 | mov [eax], ecx |
Line 222... | Line 224... | ||
222 | @@: |
224 | |
Line 223... | Line 225... | ||
223 | mov [eax], ecx |
225 | ; now copy the data |
224 | lea edi, [eax+4] |
226 | lea edi, [eax+4] |
225 | mov esi, [final_buffer] |
227 | mov esi, [final_buffer] |
Line 339... | Line 341... | ||
339 | 341 | ||
340 | mov esi, edi |
342 | mov esi, edi |
341 | sub esi, request ; length |
343 | sub esi, request ; length |
342 | xor edi, edi ; flags |
344 | xor edi, edi ; flags |
- | 345 | mcall send, [socketnum], request ;' HTTP/1.1 .. ' |
|
343 | mcall send, [socketnum], request ;' HTTP/1.1 .. ' |
346 | |
Line 344... | Line 347... | ||
344 | ret |
347 | ret |
345 | 348 | ||
346 | ;**************************************************************************** |
349 | ;**************************************************************************** |
Line 353... | Line 356... | ||
353 | ;**************************************************************************** |
356 | ;**************************************************************************** |
354 | read_incoming_data: |
357 | read_incoming_data: |
Line 355... | Line 358... | ||
355 | 358 | ||
Line -... | Line 359... | ||
- | 359 | DEBUGF 1, "Reading incoming data\n" |
|
- | 360 | ||
356 | DEBUGF 1, "Reading incoming data\n" |
361 | mcall 40, EVM_STACK ; we only want stack events now |
357 | 362 | ||
Line 358... | Line 363... | ||
358 | mov eax, [buf_ptr] |
363 | mov eax, [buf_ptr] |
359 | mov [pos], eax |
364 | mov [pos], eax |
Line 626... | Line 631... | ||
626 | ja .bad |
631 | ja .bad |
Line 627... | Line 632... | ||
627 | 632 | ||
628 | .adding: |
633 | .adding: |
629 | shl eax, 4 |
634 | shl eax, 4 |
630 | or eax, ecx |
- | |
631 | ; jmp .not_number |
- | |
632 | ;.bad: |
635 | or eax, ecx |
633 | .bad: |
636 | .bad: |
634 | jmp .next |
637 | jmp .next |
Line 635... | Line 638... | ||
635 | .done: |
638 | .done: |
Line 804... | Line 807... | ||
804 | mov [edi], al |
807 | mov [edi], al |
805 | xor eax, eax |
808 | xor eax, eax |
806 | inc edi |
809 | inc edi |
807 | cmp edi, server_ip+3 |
810 | cmp edi, server_ip+3 |
808 | jbe ip1 |
811 | jbe ip1 |
- | 812 | ||
809 | jmp pu_011 |
813 | ret |
Line 810... | Line 814... | ||
810 | 814 | ||
811 | pu_010: |
815 | pu_010: |
Line 812... | Line 816... | ||
812 | DEBUGF 1, "Resolving %s\n", webAddr |
816 | DEBUGF 1, "Resolving %s\n", webAddr |
Line 828... | Line 832... | ||
828 | mov eax, [eax + sockaddr_in.sin_addr] |
832 | mov eax, [eax + sockaddr_in.sin_addr] |
829 | mov [server_ip], eax |
833 | mov [server_ip], eax |
Line 830... | Line 834... | ||
830 | 834 | ||
Line 831... | Line -... | ||
831 | DEBUGF 1, "Resolved to %u.%u.%u.%u\n", [server_ip]:1, [server_ip + 1]:1, [server_ip + 2]:1, [server_ip + 3]:1 |
- | |
832 | - | ||
833 | pu_011: |
- | |
834 | - | ||
835 | ret |
- | |
836 | - | ||
837 | ;*************************************************************************** |
- | |
838 | ; Function |
- | |
839 | ; load_settings |
- | |
840 | ; |
- | |
841 | ; Description |
- | |
842 | ; Load settings from configuration file network.ini |
- | |
843 | ; |
- | |
844 | ;*************************************************************************** |
- | |
845 | load_settings: |
- | |
846 | - | ||
847 | invoke ini.get_str, inifile, sec_proxy, key_proxy, proxyAddr, 256, proxyAddr |
- | |
848 | invoke ini.get_int, inifile, sec_proxy, key_proxyport, 80 |
- | |
849 | mov [proxyPort], eax |
- | |
850 | invoke ini.get_str, inifile, sec_proxy, key_user, proxyUser, 256, proxyUser |
- | |
851 | invoke ini.get_str, inifile, sec_proxy, key_password, proxyPassword, 256, proxyPassword |
835 | DEBUGF 1, "Resolved to %u.%u.%u.%u\n", [server_ip]:1, [server_ip + 1]:1, [server_ip + 2]:1, [server_ip + 3]:1 |
Line 852... | Line 836... | ||
852 | 836 | ||
853 | ret |
837 | ret |
854 | 838 | ||
Line 958... | Line 942... | ||
958 | mov ecx, [sc.work_button_text] |
942 | mov ecx, [sc.work_button_text] |
959 | or ecx, 80000000h |
943 | or ecx, 80000000h |
960 | mcall 4, <102, 59>, , button_text |
944 | mcall 4, <102, 59>, , button_text |
Line 961... | Line 945... | ||
961 | 945 | ||
- | 946 | mcall 12, 2 ; end window redraw |
|
962 | mcall 12, 2 ; end window redraw |
947 | |
Line 963... | Line 948... | ||
963 | ret |
948 | ret |
964 | 949 |