Rev 8083 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 8083 | Rev 8088 | ||
---|---|---|---|
1 | ;13.03.2013 - use @notify |
1 | ;13.03.2013 - use @notify |
2 | ;08.06.2010 - new macros @use_library_mem |
2 | ;08.06.2010 - new macros @use_library_mem |
3 | ;08.05.2009 - bugfix |
3 | ;08.05.2009 - bugfix |
4 | ;14.04.2009 - a macros for code load library the box_lib.obj from '/sys/lib/' or current dirrectory. |
4 | ;14.04.2009 - a macros for code load library the box_lib.obj from '/sys/lib/' or current dirrectory. |
5 | ; The macros for load any library/libraries: |
5 | ; The macros for load any library/libraries: |
6 | ; Copyright (c) 2009, |
6 | ; Copyright (c) 2009, |
7 | ; All rights reserved. |
7 | ; All rights reserved. |
8 | ; |
8 | ; |
9 | ; Redistribution and use in source and binary forms, with or without |
9 | ; Redistribution and use in source and binary forms, with or without |
10 | ; modification, are permitted provided that the following conditions are met: |
10 | ; modification, are permitted provided that the following conditions are met: |
11 | ; * Redistributions of source code must retain the above copyright |
11 | ; * Redistributions of source code must retain the above copyright |
12 | ; notice, this list of conditions and the following disclaimer. |
12 | ; notice, this list of conditions and the following disclaimer. |
13 | ; * Redistributions in binary form must reproduce the above copyright |
13 | ; * Redistributions in binary form must reproduce the above copyright |
14 | ; notice, this list of conditions and the following disclaimer in the |
14 | ; notice, this list of conditions and the following disclaimer in the |
15 | ; documentation and/or other materials provided with the distribution. |
15 | ; documentation and/or other materials provided with the distribution. |
16 | ; * Neither the name of the |
16 | ; * Neither the name of the |
17 | ; names of its contributors may be used to endorse or promote products |
17 | ; names of its contributors may be used to endorse or promote products |
18 | ; derived from this software without specific prior written permission. |
18 | ; derived from this software without specific prior written permission. |
19 | ; |
19 | ; |
20 | ; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka |
20 | ; THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka |
21 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
21 | ; EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
22 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
22 | ; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
23 | ; DISCLAIMED. IN NO EVENT SHALL |
23 | ; DISCLAIMED. IN NO EVENT SHALL |
24 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
24 | ; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
25 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
25 | ; (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
26 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
26 | ; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
27 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 | ; ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
28 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
28 | ; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
29 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 | ; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
30 | ;***************************************************************************** |
30 | ;***************************************************************************** |
31 | ; This macros based on source code: |
31 | ; This macros based on source code: |
32 | ; |
32 | ; |
33 | ; Mario79, Mario - Marat Zakiyanov / à â ª¨ï®¢ |
33 | ; Mario79, Mario - Marat Zakiyanov / à â ª¨ï®¢ |
34 | ; Diamondz - Evgeny Grechnikov / ¢£¥¨© à¥ç¨ª®¢ |
34 | ; Diamondz - Evgeny Grechnikov / ¢£¥¨© à¥ç¨ª®¢ |
35 | ;------------------------ |
35 | ;------------------------ |
36 | ; DESCRIPTION |
36 | ; DESCRIPTION |
37 | ; Macro load_library |
37 | ; Macro load_library |
38 | ; Logick of work. |
38 | ; Logick of work. |
39 | ; A first time we must to check system path, where I belive find a system library. System path is "/sys/lib/". |
39 | ; A first time we must to check system path, where I belive find a system library. System path is "/sys/lib/". |
40 | ; If I cannot found my library, i must to check second way. Second way is current dirrectory. |
40 | ; If I cannot found my library, i must to check second way. Second way is current dirrectory. |
41 | ; If we cannot load library, we must show the error message: |
41 | ; If we cannot load library, we must show the error message: |
42 | ; "I'm sorry,the programm cannot found system library box_lib.obj." |
42 | ; "I'm sorry,the programm cannot found system library box_lib.obj." |
43 | ; "The find was make on 2 ways: /sys/lib/ and current dirrectory." |
43 | ; "The find was make on 2 ways: /sys/lib/ and current dirrectory." |
44 | ; |
44 | ; |
45 | ; |
45 | ; |
46 | ;--------------------------------------------------------------------- |
46 | ;--------------------------------------------------------------------- |
47 | ; Macro sys_load_library |
47 | ; Macro sys_load_library |
48 | ; A first time we must to check own path in current dirrectory the program, where I belive find a system library. |
48 | ; A first time we must to check own path in current dirrectory the program, where I belive find a system library. |
49 | ; If I cannot found my library, i must to check second way. Second way is system path a "/sys/lib/". |
49 | ; If I cannot found my library, i must to check second way. Second way is system path a "/sys/lib/". |
50 | ; If we cannot load library, we must show the error message: |
50 | ; If we cannot load library, we must show the error message: |
51 | ; "I'm sorry,the programm cannot found system library box_lib.obj." |
51 | ; "I'm sorry,the programm cannot found system library box_lib.obj." |
52 | ; "The find was make on 2 ways: /sys/lib/ and current dirrectory." |
52 | ; "The find was make on 2 ways: /sys/lib/ and current dirrectory." |
53 | ; |
53 | ; |
54 | ;--------------------------------------------------------------------- |
54 | ;--------------------------------------------------------------------- |
55 | ; How can I use it? |
55 | ; How can I use it? |
56 | ;--------------------------------------------------------------------- |
56 | ;--------------------------------------------------------------------- |
57 | ;-Example using single load library |
57 | ;-Example using single load library |
58 | ;-universal load library/librarys |
58 | ;-universal load library/librarys |
59 | ;load_library library_name__, cur_dir_path__, library_path__, system_path__, \ |
59 | ;load_library library_name__, cur_dir_path__, library_path__, system_path__, \ |
60 | ;err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__ |
60 | ;err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__ |
61 | ;-if return code =-1 then exit, else normally work |
61 | ;-if return code =-1 then exit, else normally work |
62 | ; cmp eax,-1 |
62 | ; cmp eax,-1 |
63 | ; jz exit |
63 | ; jz exit |
64 | ;- Well, if you get |
64 | ;- Well, if you get |
65 | ; |
65 | ; |
66 | ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
66 | ;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> |
67 | ;DATA ¤ ë¥ |
67 | ;DATA ¤ ë¥ |
68 | ;ᥣ¤ ᮡ«î¤ âì ¯®á«¥¤®¢ ⥫ì®áâì ¢ ¨¬¥¨. |
68 | ;ᥣ¤ ᮡ«î¤ âì ¯®á«¥¤®¢ ⥫ì®áâì ¢ ¨¬¥¨. |
69 | ;system_path__ db '/sys/lib/' |
69 | ;system_path__ db '/sys/lib/' |
70 | ;library_name__ db 'box_lib.obj',0 |
70 | ;library_name__ db 'box_lib.obj',0 |
71 | ; ᫨ ¥áâì ¦¥« ¨¥ à §ê¥¤¨¨âì, ⮠㦮 ¨á¯®«ì§®¢ âì á«¥¤ãîé¨î ª®áâàãªæ¨î |
71 | ; ᫨ ¥áâì ¦¥« ¨¥ à §ê¥¤¨¨âì, ⮠㦮 ¨á¯®«ì§®¢ âì á«¥¤ãîé¨î ª®áâàãªæ¨î |
72 | ;system_path__ db '/sys/lib/box_lib.obj',0 |
72 | ;system_path__ db '/sys/lib/box_lib.obj',0 |
73 | ;... «î¡ ï ¯®á«¥¤®¢ ⥫ì®áâì ¤àã£¨å ª®¬ ¤ ¨ ®¯à¥¤¥«¥¨©. |
73 | ;... «î¡ ï ¯®á«¥¤®¢ ⥫ì®áâì ¤àã£¨å ª®¬ ¤ ¨ ®¯à¥¤¥«¥¨©. |
74 | ;library_name__ db 'box_lib.obj',0 |
74 | ;library_name__ db 'box_lib.obj',0 |
75 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
75 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
76 | 76 | ||
77 | ;err_message_found_lib__ db 'Sorry I cannot found library box_lib.obj',0 |
77 | ;err_message_found_lib__ db 'Sorry I cannot found library box_lib.obj',0 |
78 | ;head_f_i__: |
78 | ;head_f_i__: |
79 | ;head_f_l__ db 'System error',0 |
79 | ;head_f_l__ db 'System error',0 |
80 | ;err_message_import__ db 'Error on load import library box_lib.obj',0 |
80 | ;err_message_import__ db 'Error on load import library box_lib.obj',0 |
81 | 81 | ||
82 | ;myimport: |
82 | ;myimport: |
83 | ; |
83 | ; |
84 | ;edit_box_draw dd aEdit_box_draw |
84 | ;edit_box_draw dd aEdit_box_draw |
85 | ;edit_box_key dd aEdit_box_key |
85 | ;edit_box_key dd aEdit_box_key |
86 | ;edit_box_mouse dd aEdit_box_mouse |
86 | ;edit_box_mouse dd aEdit_box_mouse |
87 | ;version_ed dd aVersion_ed |
87 | ;version_ed dd aVersion_ed |
88 | ; dd 0,0 |
88 | ; dd 0,0 |
89 | ;aEdit_box_draw db 'edit_box',0 |
89 | ;aEdit_box_draw db 'edit_box',0 |
90 | ;aEdit_box_key db 'edit_box_key',0 |
90 | ;aEdit_box_key db 'edit_box_key',0 |
91 | ;aEdit_box_mouse db 'edit_box_mouse',0 |
91 | ;aEdit_box_mouse db 'edit_box_mouse',0 |
92 | ;aVersion_ed db 'version_ed',0 |
92 | ;aVersion_ed db 'version_ed',0 |
93 | 93 | ||
94 | 94 | ||
95 | 95 | ||
96 | macro @use_library |
96 | macro @use_library |
97 | { |
97 | { |
98 | local lp1 |
98 | local lp1 |
99 | local lp2 |
99 | local lp2 |
100 | local lp3 |
100 | local lp3 |
101 | local lp4 |
101 | local lp4 |
102 | local lp5 |
102 | local lp5 |
103 | local lp6 |
103 | local lp6 |
104 | local file_name |
104 | local file_name |
105 | 105 | ||
106 | library_fun_memory_alloc equ 0 ;¥ ¨á¯®«ì§®¢ âì ¢ ¬ ªà®á å ¯à®¢¥àªã äãªæ¨¨ 'lib_init' |
106 | library_fun_memory_alloc equ 0 ;¥ ¨á¯®«ì§®¢ âì ¢ ¬ ªà®á å ¯à®¢¥àªã äãªæ¨¨ 'lib_init' |
107 | 107 | ||
108 | align 4 |
108 | align 4 |
109 | arrea_xx dd 0 |
109 | arrea_xx dd 0 |
110 | file_name db '/rd/1/@notify',0 |
110 | file_name db '/sys/@notify',0 |
111 | 111 | ||
112 | align 4 |
112 | align 4 |
113 | run_notify_struct: |
113 | run_notify_struct: |
114 | .Function dd 7 |
114 | .Function dd 7 |
115 | .Position dd 0 |
115 | .Position dd 0 |
116 | .Flags dd ? |
116 | .Flags dd ? |
117 | .Count dd 0 |
117 | .Count dd 0 |
118 | .Buffer dd 0 |
118 | .Buffer dd 0 |
119 | db 0 |
119 | db 0 |
120 | .FileName dd file_name |
120 | .FileName dd file_name |
121 | 121 | ||
122 | @library_name equ dword [esp+16] |
122 | @library_name equ dword [esp+16] |
123 | @cur_dir_path equ dword [esp+12] |
123 | @cur_dir_path equ dword [esp+12] |
124 | @library_path equ dword [esp+8] |
124 | @library_path equ dword [esp+8] |
125 | @point_dir_name equ dword [esp+4] |
125 | @point_dir_name equ dword [esp+4] |
126 | 126 | ||
127 | ;description: |
127 | ;description: |
128 | ; £®â®¢¨¬ ⥪áâ ¤«ï ¯®ª § ç¥à¥§ @notify: |
128 | ; £®â®¢¨¬ ⥪áâ ¤«ï ¯®ª § ç¥à¥§ @notify: |
129 | ; 1) ¢ë¤¥«ï¥¬ ¯ ¬ïâì ¢ [arrea_xx] ® ¥ ¡®«ìè¥ ®¤®£® à § |
129 | ; 1) ¢ë¤¥«ï¥¬ ¯ ¬ïâì ¢ [arrea_xx] ® ¥ ¡®«ìè¥ ®¤®£® à § |
130 | ; 2) ª®¯¨à㥬 § £®«®¢®ª (¥á«¨ ¥áâì ¨¬ï äãªæ¨¨ â® ¤®¡ ¢«ï¥¬ ¥£® ª § £®«®¢ªã) ¨ ⥪áâ á®®¡é¥¨ï ¢ [arrea_xx] |
130 | ; 2) ª®¯¨à㥬 § £®«®¢®ª (¥á«¨ ¥áâì ¨¬ï äãªæ¨¨ â® ¤®¡ ¢«ï¥¬ ¥£® ª § £®«®¢ªã) ¨ ⥪áâ á®®¡é¥¨ï ¢ [arrea_xx] |
131 | ;input: |
131 | ;input: |
132 | ; ebp+8 - head message |
132 | ; ebp+8 - head message |
133 | ; ebp+12 - error message |
133 | ; ebp+12 - error message |
134 | ; ebp+16 - 0 ¨«¨ ¨¬ï äãªæ¨¨, ª®â®àãî ¥ 㤠«®áì íªá¯®àâ¨à®¢ âì |
134 | ; ebp+16 - 0 ¨«¨ ¨¬ï äãªæ¨¨, ª®â®àãî ¥ 㤠«®áì íªá¯®àâ¨à®¢ âì |
135 | ;output: |
135 | ;output: |
136 | ; eax = -1 |
136 | ; eax = -1 |
137 | align 4 |
137 | align 4 |
138 | l_lib_init_error_window: |
138 | l_lib_init_error_window: |
139 | push ebp |
139 | push ebp |
140 | mov ebp,esp |
140 | mov ebp,esp |
141 | cmp dword[arrea_xx],0 |
141 | cmp dword[arrea_xx],0 |
142 | jne .no_msg ;¥á«¨ à ìè¥ ¡ë«® ᮧ¤ ® ¤à㣮¥ á®®¡é¥¨¥ |
142 | jne .no_msg ;¥á«¨ à ìè¥ ¡ë«® ᮧ¤ ® ¤à㣮¥ á®®¡é¥¨¥ |
143 | pushad |
143 | pushad |
144 | 144 | ||
145 | mcall 68,11 |
145 | mcall 68,11 |
146 | mcall 68,12,4096 |
146 | mcall 68,12,4096 |
147 | mov [arrea_xx],eax |
147 | mov [arrea_xx],eax |
148 | 148 | ||
149 | mov edi,eax |
149 | mov edi,eax |
150 | mov esi,[ebp+8] |
150 | mov esi,[ebp+8] |
151 | align 4 |
151 | align 4 |
152 | @@: |
152 | @@: |
153 | movsb |
153 | movsb |
154 | cmp byte[esi],0 |
154 | cmp byte[esi],0 |
155 | jne @b |
155 | jne @b |
156 | mov word[edi],0xa0d |
156 | mov word[edi],0xa0d |
157 | add edi,2 |
157 | add edi,2 |
158 | 158 | ||
159 | ;¤®¡ ¢«ï¥¬ ¨¬ï äãªæ¨¨ ¢ § £®«®¢®ª |
159 | ;¤®¡ ¢«ï¥¬ ¨¬ï äãªæ¨¨ ¢ § £®«®¢®ª |
160 | mov esi,[ebp+16] |
160 | mov esi,[ebp+16] |
161 | or esi,esi |
161 | or esi,esi |
162 | jz .lp1 |
162 | jz .lp1 |
163 | mov word[edi-2],0x2020 |
163 | mov word[edi-2],0x2020 |
164 | @@: |
164 | @@: |
165 | movsb |
165 | movsb |
166 | cmp byte[esi],0 |
166 | cmp byte[esi],0 |
167 | jne @b |
167 | jne @b |
168 | mov word[edi],0xa0d |
168 | mov word[edi],0xa0d |
169 | add edi,2 |
169 | add edi,2 |
170 | .lp1: |
170 | .lp1: |
171 | 171 | ||
172 | mov esi,[ebp+12] |
172 | mov esi,[ebp+12] |
173 | align 4 |
173 | align 4 |
174 | @@: |
174 | @@: |
175 | movsb |
175 | movsb |
176 | cmp byte[esi],0 |
176 | cmp byte[esi],0 |
177 | jne @b |
177 | jne @b |
178 | mov byte[edi],0 |
178 | mov byte[edi],0 |
179 | popad |
179 | popad |
180 | .no_msg: |
180 | .no_msg: |
181 | or eax,-1 |
181 | or eax,-1 |
182 | pop ebp |
182 | pop ebp |
183 | ret 12 |
183 | ret 12 |
184 | 184 | ||
185 | align 4 |
185 | align 4 |
186 | @copy_path: |
186 | @copy_path: |
187 | mov esi,@cur_dir_path |
187 | mov esi,@cur_dir_path |
188 | mov edi,@library_path |
188 | mov edi,@library_path |
189 | xor eax,eax |
189 | xor eax,eax |
190 | cld |
190 | cld |
191 | align 4 |
191 | align 4 |
192 | .lp1: |
192 | .lp1: |
193 | lodsb |
193 | lodsb |
194 | stosb |
194 | stosb |
195 | test eax,eax |
195 | test eax,eax |
196 | jnz .lp1 |
196 | jnz .lp1 |
197 | mov esi,edi |
197 | mov esi,edi |
198 | dec esi ;¯¥à¥å®¤ ᨬ¢®« ª®æ áâப¨ @cur_dir_path |
198 | dec esi ;¯¥à¥å®¤ ᨬ¢®« ª®æ áâப¨ @cur_dir_path |
199 | std |
199 | std |
200 | align 4 |
200 | align 4 |
201 | .lp2: |
201 | .lp2: |
202 | lodsb |
202 | lodsb |
203 | cmp al,'/' |
203 | cmp al,'/' |
204 | jnz .lp2 |
204 | jnz .lp2 |
205 | mov edi,esi |
205 | mov edi,esi |
206 | add edi,2 |
206 | add edi,2 |
207 | cld |
207 | cld |
208 | mov esi,@point_dir_name |
208 | mov esi,@point_dir_name |
209 | test esi,esi |
209 | test esi,esi |
210 | jz .str_lp4 |
210 | jz .str_lp4 |
211 | 211 | ||
212 | ;¯à®¢¥àª ®â®á¨â¥«ìëå ¯ã⥩ c ¤¢ã¬ï â®çª ¬¨ '../' |
212 | ;¯à®¢¥àª ®â®á¨â¥«ìëå ¯ã⥩ c ¤¢ã¬ï â®çª ¬¨ '../' |
213 | cmp word[esi],'..' |
213 | cmp word[esi],'..' |
214 | jne .lp3 |
214 | jne .lp3 |
215 | dec edi ;¤«ï ¯¥à¥å®¤ '/' |
215 | dec edi ;¤«ï ¯¥à¥å®¤ '/' |
216 | .lp6: |
216 | .lp6: |
217 | add esi,3 ;¯à®¯ã᪠¥¬ ®¤® ¯®¤ï⨥ '../' |
217 | add esi,3 ;¯à®¯ã᪠¥¬ ®¤® ¯®¤ï⨥ '../' |
218 | .lp5: |
218 | .lp5: |
219 | dec edi ;¨¤¥¬ ¯® ¯ ¯ª ¬ |
219 | dec edi ;¨¤¥¬ ¯® ¯ ¯ª ¬ |
220 | cmp byte[edi],'/' |
220 | cmp byte[edi],'/' |
221 | jnz .lp5 |
221 | jnz .lp5 |
222 | cmp word[esi],'..' |
222 | cmp word[esi],'..' |
223 | je .lp6 |
223 | je .lp6 |
224 | inc edi ;¤«ï ¯¥à¥å®¤ '/' |
224 | inc edi ;¤«ï ¯¥à¥å®¤ '/' |
225 | 225 | ||
226 | ;ª®¯¨à®¢ ¨¥ ®â®á¨â¥«ì®£® ¯ã⨠|
226 | ;ª®¯¨à®¢ ¨¥ ®â®á¨â¥«ì®£® ¯ã⨠|
227 | align 4 |
227 | align 4 |
228 | .lp3: |
228 | .lp3: |
229 | lodsb |
229 | lodsb |
230 | stosb |
230 | stosb |
231 | test eax,eax |
231 | test eax,eax |
232 | jnz .lp3 |
232 | jnz .lp3 |
233 | dec edi |
233 | dec edi |
234 | .str_lp4: |
234 | .str_lp4: |
235 | mov esi,@library_name |
235 | mov esi,@library_name |
236 | align 4 |
236 | align 4 |
237 | .lp4: |
237 | .lp4: |
238 | lodsb |
238 | lodsb |
239 | stosb |
239 | stosb |
240 | test eax,eax |
240 | test eax,eax |
241 | jnz .lp4 |
241 | jnz .lp4 |
242 | ret |
242 | ret |
243 | } |
243 | } |
244 | ;--------------------------------------------------------------------- |
244 | ;--------------------------------------------------------------------- |
245 | 245 | ||
246 | macro @use_library_mem mem_alloc,mem_free,mem_realloc,dll_load |
246 | macro @use_library_mem mem_alloc,mem_free,mem_realloc,dll_load |
247 | { |
247 | { |
248 | @use_library |
248 | @use_library |
249 | library_fun_memory_alloc equ mem_alloc |
249 | library_fun_memory_alloc equ mem_alloc |
250 | library_fun_memory_free equ mem_free |
250 | library_fun_memory_free equ mem_free |
251 | library_fun_memory_realloc equ mem_realloc |
251 | library_fun_memory_realloc equ mem_realloc |
252 | library_fun_dll_load equ dll_load |
252 | library_fun_dll_load equ dll_load |
253 | } |
253 | } |
254 | 254 | ||
255 | macro sys_load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__,point_dir_name__ |
255 | macro sys_load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__,point_dir_name__ |
256 | { |
256 | { |
257 | local i_begin |
257 | local i_begin |
258 | local i_error |
258 | local i_error |
259 | local i_exit |
259 | local i_exit |
260 | 260 | ||
261 | mcall 68,19,system_path__ ; load of sys directory |
261 | mcall 68,19,system_path__ ; load of sys directory |
262 | test eax,eax |
262 | test eax,eax |
263 | jnz i_begin |
263 | jnz i_begin |
264 | 264 | ||
265 | if point_dir_name__ eq |
265 | if point_dir_name__ eq |
266 | copy_path library_name__, cur_dir_path__, library_path__,0 |
266 | copy_path library_name__, cur_dir_path__, library_path__,0 |
267 | else |
267 | else |
268 | ;the macros making way /current path a program/ + name system library |
268 | ;the macros making way /current path a program/ + name system library |
269 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
269 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
270 | end if |
270 | end if |
271 | mcall 68,19,library_path__ ; load of alternative |
271 | mcall 68,19,library_path__ ; load of alternative |
272 | test eax,eax |
272 | test eax,eax |
273 | jnz i_begin |
273 | jnz i_begin |
274 | push eax |
274 | push eax |
275 | push dword err_message_found_lib__ |
275 | push dword err_message_found_lib__ |
276 | push dword head_f_l__ |
276 | push dword head_f_l__ |
277 | jmp i_error |
277 | jmp i_error |
278 | align 4 |
278 | align 4 |
279 | i_begin: |
279 | i_begin: |
280 | import_boxlib myimport |
280 | import_boxlib myimport |
281 | test eax,eax |
281 | test eax,eax |
282 | jz i_exit |
282 | jz i_exit |
283 | push eax |
283 | push eax |
284 | push dword err_message_import__ |
284 | push dword err_message_import__ |
285 | push dword head_f_i__ |
285 | push dword head_f_i__ |
286 | i_error: |
286 | i_error: |
287 | call l_lib_init_error_window |
287 | call l_lib_init_error_window |
288 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
288 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
289 | i_exit: |
289 | i_exit: |
290 | } |
290 | } |
291 | ;--------------------------------------------------------------------- |
291 | ;--------------------------------------------------------------------- |
292 | 292 | ||
293 | macro load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__,point_dir_name__ |
293 | macro load_library library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, myimport, err_message_import__, head_f_i__,point_dir_name__ |
294 | { |
294 | { |
295 | local i_begin |
295 | local i_begin |
296 | local i_error |
296 | local i_error |
297 | local i_exit |
297 | local i_exit |
298 | 298 | ||
299 | if point_dir_name__ eq |
299 | if point_dir_name__ eq |
300 | copy_path library_name__, cur_dir_path__, library_path__,0 |
300 | copy_path library_name__, cur_dir_path__, library_path__,0 |
301 | else |
301 | else |
302 | ;the macros making way /current path a program/ + name system library |
302 | ;the macros making way /current path a program/ + name system library |
303 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
303 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
304 | end if |
304 | end if |
305 | mcall 68,19,library_path__ ; load of alternative |
305 | mcall 68,19,library_path__ ; load of alternative |
306 | test eax,eax |
306 | test eax,eax |
307 | jnz i_begin |
307 | jnz i_begin |
308 | 308 | ||
309 | mcall 68,19,system_path__ ; load of sys directory |
309 | mcall 68,19,system_path__ ; load of sys directory |
310 | test eax,eax |
310 | test eax,eax |
311 | jnz i_begin |
311 | jnz i_begin |
312 | push eax |
312 | push eax |
313 | push dword err_message_found_lib__ |
313 | push dword err_message_found_lib__ |
314 | push dword head_f_l__ |
314 | push dword head_f_l__ |
315 | jmp i_error |
315 | jmp i_error |
316 | align 4 |
316 | align 4 |
317 | i_begin: |
317 | i_begin: |
318 | import_boxlib myimport |
318 | import_boxlib myimport |
319 | test eax,eax |
319 | test eax,eax |
320 | jz i_exit |
320 | jz i_exit |
321 | push eax |
321 | push eax |
322 | push dword err_message_found_lib__ |
322 | push dword err_message_found_lib__ |
323 | push dword head_f_l__ |
323 | push dword head_f_l__ |
324 | i_error: |
324 | i_error: |
325 | call l_lib_init_error_window |
325 | call l_lib_init_error_window |
326 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
326 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
327 | i_exit: |
327 | i_exit: |
328 | ;--------------------------------------------------------------------- |
328 | ;--------------------------------------------------------------------- |
329 | } |
329 | } |
330 | 330 | ||
331 | ;description: |
331 | ;description: |
332 | ; ¬ ªà®á § £à㧪¨ ¡¨¡«¨®â¥ª ¨§ á¨á⥬®© ¯ ¯ª¨, ¥á«¨ ¡¨¡«¨®â¥ª ¥ ©¤¥ |
332 | ; ¬ ªà®á § £à㧪¨ ¡¨¡«¨®â¥ª ¨§ á¨á⥬®© ¯ ¯ª¨, ¥á«¨ ¡¨¡«¨®â¥ª ¥ ©¤¥ |
333 | ; ⮣¤ ¯®¨áª ¨¤¥â ¢ ⥪ã饩 ¯ ¯ª¥ á ¯à®£à ¬¬®© |
333 | ; ⮣¤ ¯®¨áª ¨¤¥â ¢ ⥪ã饩 ¯ ¯ª¥ á ¯à®£à ¬¬®© |
334 | macro sys_load_libraries _start,_end |
334 | macro sys_load_libraries _start,_end |
335 | { |
335 | { |
336 | local cycle0 |
336 | local cycle0 |
337 | local end_steep |
337 | local end_steep |
338 | local cycle0n |
338 | local cycle0n |
339 | local cycle1 |
339 | local cycle1 |
340 | local cycle1n |
340 | local cycle1n |
341 | local cycle1e |
341 | local cycle1e |
342 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
342 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
343 | library_name__ equ [ebp] |
343 | library_name__ equ [ebp] |
344 | cur_dir_path__ equ [ebp+4] |
344 | cur_dir_path__ equ [ebp+4] |
345 | library_path__ equ [ebp+8] |
345 | library_path__ equ [ebp+8] |
346 | system_path__ equ [ebp+12] |
346 | system_path__ equ [ebp+12] |
347 | err_message_found_lib__ equ [ebp+16] |
347 | err_message_found_lib__ equ [ebp+16] |
348 | head_f_l__ equ [ebp+20] |
348 | head_f_l__ equ [ebp+20] |
349 | my_import equ [ebp+24] |
349 | my_import equ [ebp+24] |
350 | err_message_import__ equ [ebp+28] |
350 | err_message_import__ equ [ebp+28] |
351 | head_f_i__ equ [ebp+32] |
351 | head_f_i__ equ [ebp+32] |
352 | point_dir_name__ equ [ebp+36] |
352 | point_dir_name__ equ [ebp+36] |
353 | adr_load_lib equ dword [ebp+40] |
353 | adr_load_lib equ dword [ebp+40] |
354 | status_lib equ dword [ebp+44] |
354 | status_lib equ dword [ebp+44] |
355 | 355 | ||
356 | mov ebp,_start |
356 | mov ebp,_start |
357 | mov ecx,(_end-_start)/ll_struc_size |
357 | mov ecx,(_end-_start)/ll_struc_size |
358 | align 4 |
358 | align 4 |
359 | cycle0: |
359 | cycle0: |
360 | push ecx |
360 | push ecx |
361 | mcall 68,19,system_path__ ; load of sys directory |
361 | mcall 68,19,system_path__ ; load of sys directory |
362 | test eax,eax |
362 | test eax,eax |
363 | jnz end_steep |
363 | jnz end_steep |
364 | 364 | ||
365 | ;the macros making way /current path a program/ + name system library |
365 | ;the macros making way /current path a program/ + name system library |
366 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
366 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
367 | 367 | ||
368 | mcall 68,19,library_path__ ; load of alternative |
368 | mcall 68,19,library_path__ ; load of alternative |
369 | test eax,eax |
369 | test eax,eax |
370 | jnz end_steep |
370 | jnz end_steep |
371 | or status_lib,1 ; status of code - enable error - not found library |
371 | or status_lib,1 ; status of code - enable error - not found library |
372 | 372 | ||
373 | push eax |
373 | push eax |
374 | push dword err_message_found_lib__ |
374 | push dword err_message_found_lib__ |
375 | push dword head_f_l__ |
375 | push dword head_f_l__ |
376 | call l_lib_init_error_window |
376 | call l_lib_init_error_window |
377 | jmp cycle0n |
377 | jmp cycle0n |
378 | 378 | ||
379 | align 4 |
379 | align 4 |
380 | end_steep: |
380 | end_steep: |
381 | mov adr_load_lib,eax ;save adr lib in memory |
381 | mov adr_load_lib,eax ;save adr lib in memory |
382 | import_boxlib my_import |
382 | import_boxlib my_import |
383 | test eax,eax |
383 | test eax,eax |
384 | jz cycle0n |
384 | jz cycle0n |
385 | or status_lib,2 ; status of code - enable error - import error |
385 | or status_lib,2 ; status of code - enable error - import error |
386 | push eax |
386 | push eax |
387 | push dword err_message_import__ |
387 | push dword err_message_import__ |
388 | push dword head_f_i__ |
388 | push dword head_f_i__ |
389 | call l_lib_init_error_window |
389 | call l_lib_init_error_window |
390 | cycle0n: |
390 | cycle0n: |
391 | pop ecx |
391 | pop ecx |
392 | add ebp,ll_struc_size |
392 | add ebp,ll_struc_size |
393 | dec ecx |
393 | dec ecx |
394 | jnz cycle0 |
394 | jnz cycle0 |
395 | 395 | ||
396 | ;¢ë¢®¤ á®®¡é¥¨ï ®¡ ®è¨¡ª¥ ¯à¨ § £à㧪¥ |
396 | ;¢ë¢®¤ á®®¡é¥¨ï ®¡ ®è¨¡ª¥ ¯à¨ § £à㧪¥ |
397 | mov ebp,_start |
397 | mov ebp,_start |
398 | mov ecx,(_end-_start)/ll_struc_size |
398 | mov ecx,(_end-_start)/ll_struc_size |
399 | align 4 |
399 | align 4 |
400 | cycle1: |
400 | cycle1: |
401 | mov eax,status_lib |
401 | mov eax,status_lib |
402 | test eax,eax |
402 | test eax,eax |
403 | jz cycle1n |
403 | jz cycle1n |
404 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
404 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
405 | mov eax,-1 |
405 | mov eax,-1 |
406 | jmp cycle1e |
406 | jmp cycle1e |
407 | align 4 |
407 | align 4 |
408 | cycle1n: |
408 | cycle1n: |
409 | add ebp,ll_struc_size |
409 | add ebp,ll_struc_size |
410 | dec ecx |
410 | dec ecx |
411 | jnz cycle1 |
411 | jnz cycle1 |
412 | cycle1e: |
412 | cycle1e: |
413 | } |
413 | } |
414 | 414 | ||
415 | ;description: |
415 | ;description: |
416 | ; ¬ ªà®á § £à㧪¨ ¡¨¡«¨®â¥ª ¨§ ⥪ã饩 ¯ ¯ª¨ á ¯à®£à ¬¬®©, ¥á«¨ ¡¨¡«¨®â¥ª ¥ ©¤¥ |
416 | ; ¬ ªà®á § £à㧪¨ ¡¨¡«¨®â¥ª ¨§ ⥪ã饩 ¯ ¯ª¨ á ¯à®£à ¬¬®©, ¥á«¨ ¡¨¡«¨®â¥ª ¥ ©¤¥ |
417 | ; ⮣¤ ¯®¨áª ¨¤¥â ¢ á¨á⥬®© ¯ ¯ª¥ |
417 | ; ⮣¤ ¯®¨áª ¨¤¥â ¢ á¨á⥬®© ¯ ¯ª¥ |
418 | macro load_libraries _start,_end |
418 | macro load_libraries _start,_end |
419 | { |
419 | { |
420 | local cycle0 |
420 | local cycle0 |
421 | local end_steep |
421 | local end_steep |
422 | local cycle0n |
422 | local cycle0n |
423 | local cycle1 |
423 | local cycle1 |
424 | local cycle1n |
424 | local cycle1n |
425 | local cycle1e |
425 | local cycle1e |
426 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
426 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
427 | library_name__ equ [ebp] |
427 | library_name__ equ [ebp] |
428 | cur_dir_path__ equ [ebp+4] |
428 | cur_dir_path__ equ [ebp+4] |
429 | library_path__ equ [ebp+8] |
429 | library_path__ equ [ebp+8] |
430 | system_path__ equ [ebp+12] |
430 | system_path__ equ [ebp+12] |
431 | err_message_found_lib__ equ [ebp+16] |
431 | err_message_found_lib__ equ [ebp+16] |
432 | head_f_l__ equ [ebp+20] |
432 | head_f_l__ equ [ebp+20] |
433 | my_import equ [ebp+24] |
433 | my_import equ [ebp+24] |
434 | err_message_import__ equ [ebp+28] |
434 | err_message_import__ equ [ebp+28] |
435 | head_f_i__ equ [ebp+32] |
435 | head_f_i__ equ [ebp+32] |
436 | point_dir_name__ equ [ebp+36] |
436 | point_dir_name__ equ [ebp+36] |
437 | adr_load_lib equ dword [ebp+40] |
437 | adr_load_lib equ dword [ebp+40] |
438 | status_lib equ dword [ebp+44] |
438 | status_lib equ dword [ebp+44] |
439 | 439 | ||
440 | mov ebp,_start |
440 | mov ebp,_start |
441 | mov ecx,(_end-_start)/ll_struc_size |
441 | mov ecx,(_end-_start)/ll_struc_size |
442 | align 4 |
442 | align 4 |
443 | cycle0: |
443 | cycle0: |
444 | push ecx |
444 | push ecx |
445 | 445 | ||
446 | ;the macros making way /current path a program/ + name system library |
446 | ;the macros making way /current path a program/ + name system library |
447 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
447 | copy_path library_name__, cur_dir_path__, library_path__,point_dir_name__ |
448 | 448 | ||
449 | mcall 68,19,library_path__ ; load of alternative |
449 | mcall 68,19,library_path__ ; load of alternative |
450 | test eax,eax |
450 | test eax,eax |
451 | jnz end_steep |
451 | jnz end_steep |
452 | 452 | ||
453 | mcall 68,19,system_path__ ; load of sys directory |
453 | mcall 68,19,system_path__ ; load of sys directory |
454 | test eax,eax |
454 | test eax,eax |
455 | jnz end_steep |
455 | jnz end_steep |
456 | or status_lib,1 ; status of code - enable error - not found library |
456 | or status_lib,1 ; status of code - enable error - not found library |
457 | 457 | ||
458 | push eax |
458 | push eax |
459 | push dword err_message_found_lib__ |
459 | push dword err_message_found_lib__ |
460 | push dword head_f_l__ |
460 | push dword head_f_l__ |
461 | call l_lib_init_error_window |
461 | call l_lib_init_error_window |
462 | jmp cycle0n |
462 | jmp cycle0n |
463 | 463 | ||
464 | align 4 |
464 | align 4 |
465 | end_steep: |
465 | end_steep: |
466 | mov adr_load_lib,eax ;save adr lib in memory |
466 | mov adr_load_lib,eax ;save adr lib in memory |
467 | import_boxlib my_import |
467 | import_boxlib my_import |
468 | test eax,eax |
468 | test eax,eax |
469 | jz cycle0n |
469 | jz cycle0n |
470 | or status_lib,2 ; status of code - enable error - import error |
470 | or status_lib,2 ; status of code - enable error - import error |
471 | push eax |
471 | push eax |
472 | push dword err_message_import__ |
472 | push dword err_message_import__ |
473 | push dword head_f_i__ |
473 | push dword head_f_i__ |
474 | call l_lib_init_error_window |
474 | call l_lib_init_error_window |
475 | cycle0n: |
475 | cycle0n: |
476 | pop ecx |
476 | pop ecx |
477 | add ebp,ll_struc_size |
477 | add ebp,ll_struc_size |
478 | dec ecx |
478 | dec ecx |
479 | jnz cycle0 |
479 | jnz cycle0 |
480 | 480 | ||
481 | ;¢ë¢®¤ á®®¡é¥¨ï ®¡ ®è¨¡ª¥ ¯à¨ § £à㧪¥ |
481 | ;¢ë¢®¤ á®®¡é¥¨ï ®¡ ®è¨¡ª¥ ¯à¨ § £à㧪¥ |
482 | mov ebp,_start |
482 | mov ebp,_start |
483 | mov ecx,(_end-_start)/ll_struc_size |
483 | mov ecx,(_end-_start)/ll_struc_size |
484 | align 4 |
484 | align 4 |
485 | cycle1: |
485 | cycle1: |
486 | mov eax,status_lib |
486 | mov eax,status_lib |
487 | test eax,eax |
487 | test eax,eax |
488 | jz cycle1n |
488 | jz cycle1n |
489 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
489 | notify_window_run [arrea_xx] ; ᮧ¤ ¥¬ ®ª® @notify |
490 | mov eax,-1 |
490 | mov eax,-1 |
491 | jmp cycle1e |
491 | jmp cycle1e |
492 | align 4 |
492 | align 4 |
493 | cycle1n: |
493 | cycle1n: |
494 | add ebp,ll_struc_size |
494 | add ebp,ll_struc_size |
495 | dec ecx |
495 | dec ecx |
496 | jnz cycle1 |
496 | jnz cycle1 |
497 | cycle1e: |
497 | cycle1e: |
498 | } |
498 | } |
499 | 499 | ||
500 | 500 | ||
501 | macro copy_path lib_name,dir_path,lib_path,point_dir_name |
501 | macro copy_path lib_name,dir_path,lib_path,point_dir_name |
502 | { |
502 | { |
503 | pushad ;save all registers |
503 | pushad ;save all registers |
504 | push dword lib_name |
504 | push dword lib_name |
505 | push dword dir_path |
505 | push dword dir_path |
506 | push dword lib_path |
506 | push dword lib_path |
507 | push dword point_dir_name |
507 | push dword point_dir_name |
508 | call @copy_path |
508 | call @copy_path |
509 | 509 | ||
510 | add esp,16 |
510 | add esp,16 |
511 | ;notify_window_run lib_path ;unblok for test load path |
511 | ;notify_window_run lib_path ;unblok for test load path |
512 | popad ;restore all registers |
512 | popad ;restore all registers |
513 | } |
513 | } |
514 | 514 | ||
515 | ; ¢ª«îç ¥¬ ¯®ª § á®®¡é¥¨ï ç¥à¥§ @notify: |
515 | ; ¢ª«îç ¥¬ ¯®ª § á®®¡é¥¨ï ç¥à¥§ @notify: |
516 | macro notify_window_run message |
516 | macro notify_window_run message |
517 | { |
517 | { |
518 | push eax ebx |
518 | push eax ebx |
519 | mov eax,message ;¯ à ¬¥âàë ¤«ï ª®¬ ¤®© áâப¨ |
519 | mov eax,message ;¯ à ¬¥âàë ¤«ï ª®¬ ¤®© áâப¨ |
520 | mov [run_notify_struct.Flags],eax |
520 | mov [run_notify_struct.Flags],eax |
521 | mov eax,70 ;run @notify |
521 | mov eax,70 ;run @notify |
522 | mov ebx,run_notify_struct |
522 | mov ebx,run_notify_struct |
523 | int 0x40 |
523 | int 0x40 |
524 | pop ebx eax |
524 | pop ebx eax |
525 | } |
525 | } |
526 | 526 | ||
527 | 527 | ||
528 | ;input: |
528 | ;input: |
529 | ; eax - ¤à¥á ¡¨¡«¨®â¥ª¨ ¢ ¯ ¬ï⨠|
529 | ; eax - ¤à¥á ¡¨¡«¨®â¥ª¨ ¢ ¯ ¬ï⨠|
530 | ; myimport - ¨¬¯®àâ¨àã¥¬ë¥ äãªæ¨¨ |
530 | ; myimport - ¨¬¯®àâ¨àã¥¬ë¥ äãªæ¨¨ |
531 | ;output: |
531 | ;output: |
532 | ; eax - ¥á«¨ ã¤ ç® â® 0 ¨«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ ª®â®àãî ¥ 㤠«®áì § £à㧨âì |
532 | ; eax - ¥á«¨ ã¤ ç® â® 0 ¨«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ ª®â®àãî ¥ 㤠«®áì § £à㧨âì |
533 | macro import_boxlib myimport |
533 | macro import_boxlib myimport |
534 | { |
534 | { |
535 | local import_loop |
535 | local import_loop |
536 | local import_find |
536 | local import_find |
537 | local lp |
537 | local lp |
538 | local import_find_next |
538 | local import_find_next |
539 | local import_found |
539 | local import_found |
540 | local import_done |
540 | local import_done |
541 | local exit |
541 | local exit |
542 | local import_not_found |
542 | local import_not_found |
543 | ; initialize import |
543 | ; initialize import |
544 | 544 | ||
545 | mov edx, eax |
545 | mov edx, eax |
546 | mov esi,myimport |
546 | mov esi,myimport |
547 | import_loop: |
547 | import_loop: |
548 | lodsd ;mov eax,dword[esi] ;add esi,4 ;¯®«ãç ¥¬ ¢ eax 㪠§ â¥«ì ¨¬ï ¨¬¯®àâ¨à㥬®© äãªæ¨¨ |
548 | lodsd ;mov eax,dword[esi] ;add esi,4 ;¯®«ãç ¥¬ ¢ eax 㪠§ â¥«ì ¨¬ï ¨¬¯®àâ¨à㥬®© äãªæ¨¨ |
549 | test eax, eax |
549 | test eax, eax |
550 | jz import_done ;¥á«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ = 0 (¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥) |
550 | jz import_done ;¥á«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ = 0 (¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥) |
551 | push edx ;á®åà 塞 ç «® ¡¨¡«¨®â¥çëå 㪠§ ⥫¥© äãªæ¨¨ |
551 | push edx ;á®åà 塞 ç «® ¡¨¡«¨®â¥çëå 㪠§ ⥫¥© äãªæ¨¨ |
552 | import_find: |
552 | import_find: |
553 | mov ebx, [edx] |
553 | mov ebx, [edx] |
554 | test ebx, ebx |
554 | test ebx, ebx |
555 | jz import_not_found ;¥á«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ = 0 (¢ ¡¨¡«¨®â¥ª¥) |
555 | jz import_not_found ;¥á«¨ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ = 0 (¢ ¡¨¡«¨®â¥ª¥) |
556 | push eax ;eax - 㪠§ â¥«ì ¨¬ï íªá¯®àâ¨à㥬®© äãªæ¨¨ (¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥) |
556 | push eax ;eax - 㪠§ â¥«ì ¨¬ï íªá¯®àâ¨à㥬®© äãªæ¨¨ (¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥) |
557 | lp: |
557 | lp: |
558 | mov cl, [eax] |
558 | mov cl, [eax] |
559 | cmp cl, [ebx] ;áà ¢¨¢ ¥¬ ¨¬¥ äãªæ¨© ¢ ¡¨¡«¨®â¥ª¥ ¨ ¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥ |
559 | cmp cl, [ebx] ;áà ¢¨¢ ¥¬ ¨¬¥ äãªæ¨© ¢ ¡¨¡«¨®â¥ª¥ ¨ ¢ ¯®«ì§®¢ ⥫ì᪮© ¯à®£à ¬¬¥ |
560 | jnz import_find_next ;¥á«¨ §¢ ¨ï ¥ ᮢ¯ «¨ |
560 | jnz import_find_next ;¥á«¨ §¢ ¨ï ¥ ᮢ¯ «¨ |
561 | test cl, cl |
561 | test cl, cl |
562 | jz import_found ;¥á«¨ §¢ ¨ï ᮢ¯ «¨, ¨ 㦥 ª®¥æ áâப¨ (cl=0) |
562 | jz import_found ;¥á«¨ §¢ ¨ï ᮢ¯ «¨, ¨ 㦥 ª®¥æ áâப¨ (cl=0) |
563 | inc eax |
563 | inc eax |
564 | inc ebx |
564 | inc ebx |
565 | jmp lp |
565 | jmp lp |
566 | import_find_next: |
566 | import_find_next: |
567 | pop eax |
567 | pop eax |
568 | add edx, 8 ;8 = 4 ¡ ©â 㪠§ â¥«ì §¢ ¨¥ ¨ 4 ¡ ©â 㪠§ ⥫ì äãªæ¨î |
568 | add edx, 8 ;8 = 4 ¡ ©â 㪠§ â¥«ì §¢ ¨¥ ¨ 4 ¡ ©â 㪠§ ⥫ì äãªæ¨î |
569 | jmp import_find |
569 | jmp import_find |
570 | import_found: |
570 | import_found: |
571 | pop ebx ;¢®áâ ¢«¨¢ ¥¬ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ (ª®â®àë© ¡ë« ¢ eax) ¨ ®á¢®¡®¦¤ ¥¬ á⥪ |
571 | pop ebx ;¢®áâ ¢«¨¢ ¥¬ 㪠§ â¥«ì ¨¬ï äãªæ¨¨ (ª®â®àë© ¡ë« ¢ eax) ¨ ®á¢®¡®¦¤ ¥¬ á⥪ |
572 | mov eax, [edx+4] ;eax = 㪠§ ⥫ì äãªæ¨î (¢ ¡¨¡«¨®â¥ª¥) |
572 | mov eax, [edx+4] ;eax = 㪠§ ⥫ì äãªæ¨î (¢ ¡¨¡«¨®â¥ª¥) |
573 | mov [esi-4], eax ;ª®¯¨à㥬 㪠§ ⥫ì ( äãªæ¨î) ¢ ¯à®£à ¬¬ã, -4 áâ ¢¨¬ ¯®â®¬ã çâ® esi ¡ë«® ᤢ¨ãâ® ª®¬ ¤®© lodsd |
573 | mov [esi-4], eax ;ª®¯¨à㥬 㪠§ ⥫ì ( äãªæ¨î) ¢ ¯à®£à ¬¬ã, -4 áâ ¢¨¬ ¯®â®¬ã çâ® esi ¡ë«® ᤢ¨ãâ® ª®¬ ¤®© lodsd |
574 | pop edx ;ãáâ ¢«¨¢ ¥¬ edx ç «® ¡¨¡«¨®â¥çëå äãªæ¨© |
574 | pop edx ;ãáâ ¢«¨¢ ¥¬ edx ç «® ¡¨¡«¨®â¥çëå äãªæ¨© |
575 | ;--- ¯à®¢¥à塞 ᮢ¯ ¤ ¥â «¨ ¨¬ï íªá¯®àâ¨à®¢ ®© äãªæ¨¨ á 'lib_init' |
575 | ;--- ¯à®¢¥à塞 ᮢ¯ ¤ ¥â «¨ ¨¬ï íªá¯®àâ¨à®¢ ®© äãªæ¨¨ á 'lib_init' |
576 | if library_fun_memory_alloc eq 0 |
576 | if library_fun_memory_alloc eq 0 |
577 | else |
577 | else |
578 | cmp dword[ebx],'lib_' |
578 | cmp dword[ebx],'lib_' |
579 | jne import_loop |
579 | jne import_loop |
580 | cmp dword[ebx+4],'init' |
580 | cmp dword[ebx+4],'init' |
581 | jne import_loop |
581 | jne import_loop |
582 | ;--- ¥á«¨ ¨¬ï äãªæ¨¨ ᮢ¯ «® á 'lib_init' ¯®¯ ¤ ¥¬ áî¤ |
582 | ;--- ¥á«¨ ¨¬ï äãªæ¨¨ ᮢ¯ «® á 'lib_init' ¯®¯ ¤ ¥¬ áî¤ |
583 | ;¯®¤ª«î票¥ äãªæ¨© ¤«ï à ¡®âë á ¯ ¬ïâìî |
583 | ;¯®¤ª«î票¥ äãªæ¨© ¤«ï à ¡®âë á ¯ ¬ïâìî |
584 | ;push eax |
584 | ;push eax |
585 | ;call dll.Init |
585 | ;call dll.Init |
586 | pushad |
586 | pushad |
587 | mov esi,eax |
587 | mov esi,eax |
588 | mov eax,library_fun_memory_alloc |
588 | mov eax,library_fun_memory_alloc |
589 | mov ebx,library_fun_memory_free |
589 | mov ebx,library_fun_memory_free |
590 | mov ecx,library_fun_memory_realloc |
590 | mov ecx,library_fun_memory_realloc |
591 | mov edx,library_fun_dll_load |
591 | mov edx,library_fun_dll_load |
592 | call dword esi |
592 | call dword esi |
593 | popad |
593 | popad |
594 | end if |
594 | end if |
595 | jmp import_loop |
595 | jmp import_loop |
596 | import_not_found: |
596 | import_not_found: |
597 | add esp,4 |
597 | add esp,4 |
598 | jmp exit |
598 | jmp exit |
599 | import_done: |
599 | import_done: |
600 | xor eax,eax ;=0 ¢á¥ § £à㧨«®áì ã¤ ç® |
600 | xor eax,eax ;=0 ¢á¥ § £à㧨«®áì ã¤ ç® |
601 | exit: |
601 | exit: |
602 | } |
602 | } |
603 | ;--------------------------------------------------------------------- |
603 | ;--------------------------------------------------------------------- |
604 | 604 | ||
605 | ll_struc_size = 48;($-library_name__) ; constant size of struct |
605 | ll_struc_size = 48;($-library_name__) ; constant size of struct |
606 | struc l_libs library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, my_import, err_message_import__, head_f_i__,point_dir_name; struct for loading libraries |
606 | struc l_libs library_name__, cur_dir_path__, library_path__, system_path__, err_message_found_lib__, head_f_l__, my_import, err_message_import__, head_f_i__,point_dir_name; struct for loading libraries |
607 | { |
607 | { |
608 | .library_name__ dd library_name__ ; ¨¬ï § £à㦠¥¬®© ¡¨¡«¨®â¥ª¨ |
608 | .library_name__ dd library_name__ ; ¨¬ï § £à㦠¥¬®© ¡¨¡«¨®â¥ª¨ |
609 | .cur_dir_path__ dd cur_dir_path__ ; 㪠§ â¥«ì ¡ãä¥à ¢ ª®â®à®¬ ᮤ¥à¦¨âìáï ¯ãâì ®â ªã¤ ¡ë« § ¯ãé¥ ¯à®£à ¬¬ |
609 | .cur_dir_path__ dd cur_dir_path__ ; 㪠§ â¥«ì ¡ãä¥à ¢ ª®â®à®¬ ᮤ¥à¦¨âìáï ¯ãâì ®â ªã¤ ¡ë« § ¯ãé¥ ¯à®£à ¬¬ |
610 | 610 | ||
611 | .library_path__ dd library_path__ ; 㪠§ â¥«ì ¡ãä¥à ¢ ª®â®à®¬ ¡ã¤¥â á®ä®à¨¬¨à®¢ ¯ãâì ª ¡¨¡«¨®â¥ª¨, ¥á«¨ 㦮 ¢ëç¨á«¨âì ¯ãâì ¤® «¨¡ë á ¬¥áâ § ¯ã᪠¯à®£à ¬¬ë, ®¡ëç® ã¦®, ¢ á«ãç ïå, ¥á«¨ «¨¡ à ᯮ«®¦¥ ¢ ⮩ ¦¥ ¯ ¯ª¥ |
611 | .library_path__ dd library_path__ ; 㪠§ â¥«ì ¡ãä¥à ¢ ª®â®à®¬ ¡ã¤¥â á®ä®à¨¬¨à®¢ ¯ãâì ª ¡¨¡«¨®â¥ª¨, ¥á«¨ 㦮 ¢ëç¨á«¨âì ¯ãâì ¤® «¨¡ë á ¬¥áâ § ¯ã᪠¯à®£à ¬¬ë, ®¡ëç® ã¦®, ¢ á«ãç ïå, ¥á«¨ «¨¡ à ᯮ«®¦¥ ¢ ⮩ ¦¥ ¯ ¯ª¥ |
612 | .complete_path dd system_path__ ; ¯ãâì ª®â®àë© ç¥âª® ᮤ¥à¦¨â ¯ãâì |
612 | .complete_path dd system_path__ ; ¯ãâì ª®â®àë© ç¥âª® ᮤ¥à¦¨â ¯ãâì |
613 | 613 | ||
614 | .err_message_found_lib__ dd err_message_found_lib__ |
614 | .err_message_found_lib__ dd err_message_found_lib__ |
615 | .head_f_l__ dd head_f_l__ |
615 | .head_f_l__ dd head_f_l__ |
616 | .my_import dd my_import |
616 | .my_import dd my_import |
617 | .err_message_import__ dd err_message_import__ |
617 | .err_message_import__ dd err_message_import__ |
618 | .head_f_i__ dd head_f_i__ |
618 | .head_f_i__ dd head_f_i__ |
619 | if point_dir_name eq |
619 | if point_dir_name eq |
620 | .point_dir_name__ dd 0 |
620 | .point_dir_name__ dd 0 |
621 | else |
621 | else |
622 | .point_dir_name__ dd point_dir_name ; ¨¬ï ¢«®¦¥®© ¤¨à४â®à¨¨ ¢ ªâ®à®© åà ïâìáï ¯®¤£à㦠¥¬ë¥ ¬®¤ã«¨. |
622 | .point_dir_name__ dd point_dir_name ; ¨¬ï ¢«®¦¥®© ¤¨à४â®à¨¨ ¢ ªâ®à®© åà ïâìáï ¯®¤£à㦠¥¬ë¥ ¬®¤ã«¨. |
623 | end if |
623 | end if |
624 | .adr_load_lib dd 0 |
624 | .adr_load_lib dd 0 |
625 | .status_lib dd 0 ;status of load library |
625 | .status_lib dd 0 ;status of load library |
626 | ; |
626 | ; |
627 | } |
627 | } |