Subversion Repositories Kolibri OS

Rev

Rev 5363 | Rev 9977 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5363 Rev 6502
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2
;;                                                              ;;
2
;;                                                              ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
3
;; Copyright (C) KolibriOS team 2004-2015. All rights reserved. ;;
4
;; Distributed under terms of the GNU General Public License    ;;
4
;; Distributed under terms of the GNU General Public License    ;;
5
;;                                                              ;;
5
;;                                                              ;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
7
 
-
 
8
;============================================================================
-
 
9
;
7
 
10
;   External kernel dependencies (libraries) loading
-
 
11
;
8
; External kernel dependencies (libraries) loading.
12
;============================================================================
9
; The code currently does not work, requires correcting dll.inc.
13
 
10
 
-
 
11
$Revision: 6502 $
14
$Revision: 5363 $
12
 
-
 
13
if 0
-
 
14
iglobal
-
 
15
tmp_file_name_size  dd  1
15
 
16
endg
-
 
17
 
-
 
18
uglobal
-
 
19
tmp_file_name_table dd  ?
-
 
20
s_libname   rb  64
16
if 0
21
def_val_1   db  ?
17
; The code currently does not work. Kill "if 0/end if" only after correcting
22
endg
18
; to current kernel (dll.inc).
23
 
19
macro library [name,fname]
24
macro library [name,fname]
20
{
25
{
21
  forward
26
  forward
22
    dd __#name#_library_table__,__#name#_library_name__
27
    dd __#name#_library_table__,__#name#_library_name__
23
  common
28
  common
24
    dd 0
29
    dd 0
25
  forward
30
  forward
26
    __#name#_library_name__ db fname,0
31
    __#name#_library_name__ db fname,0
27
}
32
}
28
 
33
 
29
macro import lname,[name,sname]
34
macro import lname,[name,sname]
30
{
35
{
31
  common
36
  common
32
    align 4
37
    align 4
33
    __#lname#_library_table__:
38
    __#lname#_library_table__:
34
  forward
39
  forward
35
    name dd __#name#_import_name__
40
    name dd __#name#_import_name__
36
  common
41
  common
37
    dd 0
42
    dd 0
38
  forward
43
  forward
39
    __#name#_import_name__ db sname,0
44
    __#name#_import_name__ db sname,0
40
}
45
}
41
 
46
 
42
macro export [name,sname]
47
macro export [name,sname]
43
{
48
{
44
align 4
49
align 4
45
  forward
50
  forward
46
    dd __#name#_export_name__,name
51
    dd __#name#_export_name__,name
47
  common
52
  common
48
    dd 0
53
    dd 0
49
  forward
54
  forward
50
    __#name#_export_name__ db sname,0
55
    __#name#_export_name__ db sname,0
51
}
56
}
52
 
57
 
53
 
58
 
54
 
59
 
55
align 4            ; loading library (use kernel functions)
60
align 4            ; loading library (use kernel functions)
56
proc load_k_library stdcall, file_name:dword
61
proc load_k_library stdcall, file_name:dword
57
           locals
62
           locals
58
             coff      dd ?
63
             coff      dd ?
59
             sym       dd ?
64
             sym       dd ?
60
             strings   dd ?
65
             strings   dd ?
61
             img_size  dd ?
66
             img_size  dd ?
62
             img_base  dd ?
67
             img_base  dd ?
63
             exports   dd ?
68
             exports   dd ?
64
           endl
69
           endl
65
 
70
 
66
        cli
71
        cli
67
 
72
 
68
        stdcall load_file, [file_name]
73
        stdcall load_file, [file_name]
69
        test    eax, eax
74
        test    eax, eax
70
        jz      .fail
75
        jz      .fail
71
 
76
 
72
        mov     [coff], eax
77
        mov     [coff], eax
73
        movzx   ecx, [eax+CFH.nSections]
78
        movzx   ecx, [eax+CFH.nSections]
74
        xor     ebx, ebx
79
        xor     ebx, ebx
75
 
80
 
76
        lea     edx, [eax+20]
81
        lea     edx, [eax+20]
77
@@:
82
@@:
78
        add     ebx, [edx+CFS.SizeOfRawData]
83
        add     ebx, [edx+CFS.SizeOfRawData]
79
        add     ebx, 15
84
        add     ebx, 15
80
        and     ebx, not 15
85
        and     ebx, not 15
81
        add     edx, COFF_SECTION_SIZE
86
        add     edx, COFF_SECTION_SIZE
82
        dec     ecx
87
        dec     ecx
83
        jnz     @B
88
        jnz     @B
84
        mov     [img_size], ebx
89
        mov     [img_size], ebx
85
 
90
 
86
        stdcall kernel_alloc, [img_size]
91
        stdcall kernel_alloc, [img_size]
87
 
92
 
88
        test    eax, eax
93
        test    eax, eax
89
        jz      .fail
94
        jz      .fail
90
        mov     [img_base], eax
95
        mov     [img_base], eax
91
 
96
 
92
        mov     edx, [coff]
97
        mov     edx, [coff]
93
        movzx   ebx, [edx+CFH.nSections]
98
        movzx   ebx, [edx+CFH.nSections]
94
        mov     edi, [img_base]
99
        mov     edi, [img_base]
95
        lea     eax, [edx+20]
100
        lea     eax, [edx+20]
96
@@:
101
@@:
97
        mov     [eax+CFS.VirtualAddress], edi
102
        mov     [eax+CFS.VirtualAddress], edi
98
        mov     esi, [eax+CFS.PtrRawData]
103
        mov     esi, [eax+CFS.PtrRawData]
99
        test    esi, esi
104
        test    esi, esi
100
        jnz     .copy
105
        jnz     .copy
101
        add     edi, [eax+CFS.SizeOfRawData]
106
        add     edi, [eax+CFS.SizeOfRawData]
102
        jmp     .next
107
        jmp     .next
103
.copy:
108
.copy:
104
        add     esi, edx
109
        add     esi, edx
105
        mov     ecx, [eax+CFS.SizeOfRawData]
110
        mov     ecx, [eax+CFS.SizeOfRawData]
106
        cld
111
        cld
107
        rep movsb
112
        rep movsb
108
.next:
113
.next:
109
        add     edi, 15
114
        add     edi, 15
110
        and     edi, not 15
115
        and     edi, not 15
111
        add     eax, COFF_SECTION_SIZE
116
        add     eax, COFF_SECTION_SIZE
112
        dec     ebx
117
        dec     ebx
113
        jnz     @B
118
        jnz     @B
114
 
119
 
115
        mov     ebx, [edx+CFH.pSymTable]
120
        mov     ebx, [edx+CFH.pSymTable]
116
        add     ebx, edx
121
        add     ebx, edx
117
        mov     [sym], ebx
122
        mov     [sym], ebx
118
        mov     ecx, [edx+CFH.nSymbols]
123
        mov     ecx, [edx+CFH.nSymbols]
119
        add     ecx, ecx
124
        add     ecx, ecx
120
        lea     ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
125
        lea     ecx, [ecx+ecx*8];ecx*=18 = nSymbols*CSYM_SIZE
121
        add     ecx, [sym]
126
        add     ecx, [sym]
122
        mov     [strings], ecx
127
        mov     [strings], ecx
123
 
128
 
124
        lea     eax, [edx+20]
129
        lea     eax, [edx+20]
125
 
130
 
126
        stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols], \
131
        stdcall fix_coff_symbols, eax, [sym], [edx+CFH.nSymbols], \
127
                [strings], dword 0
132
                [strings], dword 0
128
        test    eax, eax
133
        test    eax, eax
129
        jnz     @F
134
        jnz     @F
130
 
135
 
131
@@:
136
@@:
132
        mov     edx, [coff]
137
        mov     edx, [coff]
133
        movzx   ebx, [edx+CFH.nSections]
138
        movzx   ebx, [edx+CFH.nSections]
134
        mov     edi, 0
139
        mov     edi, 0
135
        lea     eax, [edx+20]
140
        lea     eax, [edx+20]
136
@@:
141
@@:
137
        add     [eax+CFS.VirtualAddress], edi ;patch user space offset
142
        add     [eax+CFS.VirtualAddress], edi ;patch user space offset
138
        add     eax, COFF_SECTION_SIZE
143
        add     eax, COFF_SECTION_SIZE
139
        dec     ebx
144
        dec     ebx
140
        jnz     @B
145
        jnz     @B
141
 
146
 
142
        add     edx, 20
147
        add     edx, 20
143
        stdcall fix_coff_relocs, [coff], edx, [sym]
148
        stdcall fix_coff_relocs, [coff], edx, [sym]
144
 
149
 
145
        mov     ebx, [coff]
150
        mov     ebx, [coff]
146
        stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szEXPORTS
151
        stdcall get_coff_sym, [sym], [ebx+CFH.nSymbols], szEXPORTS
147
        mov     [exports], eax
152
        mov     [exports], eax
148
 
153
 
149
        stdcall kernel_free, [coff]
154
        stdcall kernel_free, [coff]
150
 
155
 
151
        mov     eax, [exports]
156
        mov     eax, [exports]
152
        ret
157
        ret
153
.fail:
158
.fail:
154
        xor     eax, eax
159
        xor     eax, eax
155
        ret
160
        ret
156
endp
161
endp
157
 
162
 
158
 
163
 
159
proc dll.Load, import_table:dword
164
proc dll.Load, import_table:dword
160
        mov     esi, [import_table]
165
        mov     esi, [import_table]
161
  .next_lib:
166
  .next_lib:
162
        mov     edx, [esi]
167
        mov     edx, [esi]
163
        or      edx, edx
168
        or      edx, edx
164
        jz      .exit
169
        jz      .exit
165
        push    esi
170
        push    esi
166
 
171
 
167
        mov     edi, s_libname
172
        mov     edi, s_libname
168
 
173
 
169
        mov     al, '/'
174
        mov     al, '/'
170
        stosb
175
        stosb
171
        mov     esi, sysdir_path
176
        mov     esi, sysdir_path
172
            @@:
177
            @@:
173
        lodsb
178
        lodsb
174
        stosb
179
        stosb
175
        or      al, al
180
        or      al, al
176
        jnz     @b
181
        jnz     @b
177
        dec     edi
182
        dec     edi
178
        mov     [edi], dword '/lib'
183
        mov     [edi], dword '/lib'
179
        mov     [edi+4], byte '/'
184
        mov     [edi+4], byte '/'
180
        add     edi, 5
185
        add     edi, 5
181
        pop     esi
186
        pop     esi
182
        push    esi
187
        push    esi
183
        mov     esi, [esi+4]
188
        mov     esi, [esi+4]
184
            @@:
189
            @@:
185
        lodsb
190
        lodsb
186
        stosb
191
        stosb
187
        or      al, al
192
        or      al, al
188
        jnz     @b
193
        jnz     @b
189
 
194
 
190
        pushad
195
        pushad
191
        stdcall load_k_library, s_libname
196
        stdcall load_k_library, s_libname
192
        mov     [esp+28], eax
197
        mov     [esp+28], eax
193
        popad
198
        popad
194
        or      eax, eax
199
        or      eax, eax
195
        jz      .fail
200
        jz      .fail
196
        stdcall dll.Link, eax, edx
201
        stdcall dll.Link, eax, edx
197
        stdcall dll.Init, [eax+4]
202
        stdcall dll.Init, [eax+4]
198
        pop     esi
203
        pop     esi
199
        add     esi, 8
204
        add     esi, 8
200
        jmp     .next_lib
205
        jmp     .next_lib
201
  .exit:
206
  .exit:
202
        xor     eax, eax
207
        xor     eax, eax
203
        ret
208
        ret
204
  .fail:
209
  .fail:
205
        add     esp, 4
210
        add     esp, 4
206
        xor     eax, eax
211
        xor     eax, eax
207
        inc     eax
212
        inc     eax
208
        ret
213
        ret
209
endp
214
endp
210
 
215
 
211
proc dll.Link, exp:dword,imp:dword
216
proc dll.Link, exp:dword,imp:dword
212
        push    eax
217
        push    eax
213
        mov     esi, [imp]
218
        mov     esi, [imp]
214
        test    esi, esi
219
        test    esi, esi
215
        jz      .done
220
        jz      .done
216
  .next:
221
  .next:
217
        lodsd
222
        lodsd
218
        test    eax, eax
223
        test    eax, eax
219
        jz      .done
224
        jz      .done
220
        stdcall dll.GetProcAddress, [exp], eax
225
        stdcall dll.GetProcAddress, [exp], eax
221
        or      eax, eax
226
        or      eax, eax
222
        jz      @f
227
        jz      @f
223
        mov     [esi-4], eax
228
        mov     [esi-4], eax
224
        jmp     .next
229
        jmp     .next
225
            @@:
230
            @@:
226
        mov     dword[esp], 0
231
        mov     dword[esp], 0
227
  .done:
232
  .done:
228
        pop     eax
233
        pop     eax
229
        ret
234
        ret
230
endp
235
endp
231
 
236
 
232
proc dll.Init, dllentry:dword
237
proc dll.Init, dllentry:dword
233
        pushad
238
        pushad
234
        mov     eax, mem.Alloc
239
        mov     eax, mem.Alloc
235
        mov     ebx, mem.Free
240
        mov     ebx, mem.Free
236
        mov     ecx, mem.ReAlloc
241
        mov     ecx, mem.ReAlloc
237
        mov     edx, dll.Load
242
        mov     edx, dll.Load
238
        stdcall [dllentry]
243
        stdcall [dllentry]
239
        popad
244
        popad
240
        ret
245
        ret
241
endp
246
endp
242
 
247
 
243
proc dll.GetProcAddress, exp:dword,sz_name:dword
248
proc dll.GetProcAddress, exp:dword,sz_name:dword
244
        mov     edx, [exp]
249
        mov     edx, [exp]
245
  .next:
250
  .next:
246
        test    edx, edx
251
        test    edx, edx
247
        jz      .end
252
        jz      .end
248
        stdcall strncmp, [edx], [sz_name], dword -1
253
        stdcall strncmp, [edx], [sz_name], dword -1
249
        test    eax, eax
254
        test    eax, eax
250
        jz      .ok
255
        jz      .ok
251
        add     edx, 8
256
        add     edx, 8
252
        jmp     .next
257
        jmp     .next
253
  .ok:
258
  .ok:
254
        mov     eax, [edx+4]
259
        mov     eax, [edx+4]
255
  .end:
260
  .end:
256
        ret
261
        ret
257
endp
262
endp
258
 
263
 
259
;-----------------------------------------------------------------------------
264
;-----------------------------------------------------------------------------
260
proc mem.Alloc size ;/////////////////////////////////////////////////////////
265
proc mem.Alloc size ;/////////////////////////////////////////////////////////
261
;-----------------------------------------------------------------------------
266
;-----------------------------------------------------------------------------
262
        push    ebx ecx
267
        push    ebx ecx
263
;       mov     eax,[size]
268
;       mov     eax,[size]
264
;       lea     ecx,[eax+4+4095]
269
;       lea     ecx,[eax+4+4095]
265
;       and     ecx,not 4095
270
;       and     ecx,not 4095
266
;       stdcall kernel_alloc, ecx
271
;       stdcall kernel_alloc, ecx
267
;       add     ecx,-4
272
;       add     ecx,-4
268
;       mov     [eax],ecx
273
;       mov     [eax],ecx
269
;       add     eax,4
274
;       add     eax,4
270
 
275
 
271
        stdcall kernel_alloc, [size]
276
        stdcall kernel_alloc, [size]
272
 
277
 
273
        pop     ecx ebx
278
        pop     ecx ebx
274
        ret
279
        ret
275
endp
280
endp
276
 
281
 
277
;-----------------------------------------------------------------------------
282
;-----------------------------------------------------------------------------
278
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
283
proc mem.ReAlloc mptr,size;///////////////////////////////////////////////////
279
;-----------------------------------------------------------------------------
284
;-----------------------------------------------------------------------------
280
        push    ebx ecx esi edi eax
285
        push    ebx ecx esi edi eax
281
        mov     eax, [mptr]
286
        mov     eax, [mptr]
282
        mov     ebx, [size]
287
        mov     ebx, [size]
283
        or      eax, eax
288
        or      eax, eax
284
        jz      @f
289
        jz      @f
285
        lea     ecx, [ebx+4+4095]
290
        lea     ecx, [ebx+4+4095]
286
        and     ecx, not 4095
291
        and     ecx, not 4095
287
        add     ecx, -4
292
        add     ecx, -4
288
        cmp     ecx, [eax-4]
293
        cmp     ecx, [eax-4]
289
        je      .exit
294
        je      .exit
290
    @@:
295
    @@:
291
        mov     eax, ebx
296
        mov     eax, ebx
292
        call    mem.Alloc
297
        call    mem.Alloc
293
        xchg    eax, [esp]
298
        xchg    eax, [esp]
294
        or      eax, eax
299
        or      eax, eax
295
        jz      .exit
300
        jz      .exit
296
        mov     esi, eax
301
        mov     esi, eax
297
        xchg    eax, [esp]
302
        xchg    eax, [esp]
298
        mov     edi, eax
303
        mov     edi, eax
299
        mov     ecx, [esi-4]
304
        mov     ecx, [esi-4]
300
        cmp     ecx, [edi-4]
305
        cmp     ecx, [edi-4]
301
        jbe     @f
306
        jbe     @f
302
        mov     ecx, [edi-4]
307
        mov     ecx, [edi-4]
303
    @@:
308
    @@:
304
        add     ecx, 3
309
        add     ecx, 3
305
        shr     ecx, 2
310
        shr     ecx, 2
306
        cld
311
        cld
307
        rep movsd
312
        rep movsd
308
        xchg    eax, [esp]
313
        xchg    eax, [esp]
309
        call    mem.Free
314
        call    mem.Free
310
  .exit:
315
  .exit:
311
        pop     eax edi esi ecx ebx
316
        pop     eax edi esi ecx ebx
312
        ret
317
        ret
313
endp
318
endp
314
 
319
 
315
;-----------------------------------------------------------------------------
320
;-----------------------------------------------------------------------------
316
proc mem.Free mptr ;//////////////////////////////////////////////////////////
321
proc mem.Free mptr ;//////////////////////////////////////////////////////////
317
;-----------------------------------------------------------------------------
322
;-----------------------------------------------------------------------------
318
;       mov     eax,[mptr]
323
;       mov     eax,[mptr]
319
;       or      eax,eax
324
;       or      eax,eax
320
;       jz      @f
325
;       jz      @f
321
;       push    ebx ecx
326
;       push    ebx ecx
322
;       lea     ecx,[eax-4]
327
;       lea     ecx,[eax-4]
323
;       stdcall kernel_free, ecx
328
;       stdcall kernel_free, ecx
324
;       pop     ecx ebx
329
;       pop     ecx ebx
325
;    @@: ret
330
;    @@: ret
326
        stdcall kernel_free, [mptr]
331
        stdcall kernel_free, [mptr]
327
        ret
332
        ret
328
endp
333
endp
-
 
334
 
-
 
335
proc load_file_parse_table
-
 
336
        stdcall kernel_alloc, 0x1000
-
 
337
        mov     [tmp_file_name_table], eax
-
 
338
        mov     edi, eax
-
 
339
        mov     esi, sysdir_name
-
 
340
        mov     ecx, 128/4
-
 
341
        rep movsd
-
 
342
        invoke  ini.enum_keys, conf_fname, conf_path_sect, get_every_key
-
 
343
        mov     eax, [tmp_file_name_table]
-
 
344
        mov     [full_file_name_table], eax
-
 
345
        mov     eax, [tmp_file_name_size]
-
 
346
        mov     [full_file_name_table.size], eax
-
 
347
        ret
-
 
348
endp
-
 
349
 
-
 
350
proc get_every_key stdcall, f_name, sec_name, key_name
-
 
351
        mov     esi, [key_name]
-
 
352
        mov     ecx, esi
-
 
353
        cmp     byte [esi], '/'
-
 
354
        jnz     @f
-
 
355
        inc     esi
-
 
356
@@:
-
 
357
        mov     edi, [tmp_file_name_size]
-
 
358
        shl     edi, 7
-
 
359
        cmp     edi, 0x1000
-
 
360
        jae     .stop_parse
-
 
361
        add     edi, [tmp_file_name_table]
-
 
362
        lea     ebx, [edi+64]
-
 
363
@@:
-
 
364
        cmp     edi, ebx
-
 
365
        jae     .skip_this_key
-
 
366
        lodsb
-
 
367
        test    al, al
-
 
368
        jz      @f
-
 
369
        or      al, 20h
-
 
370
        stosb
-
 
371
        jmp     @b
329
 
372
 
-
 
373
.stop_parse:
-
 
374
        xor     eax, eax
-
 
375
        ret
-
 
376
 
-
 
377
@@:
-
 
378
        stosb
-
 
379
        invoke  ini.get_str, [f_name], [sec_name], ecx, ebx, 64, def_val_1
-
 
380
        cmp     byte [ebx], '/'
-
 
381
        jnz     @f
-
 
382
        lea     esi, [ebx+1]
-
 
383
        mov     edi, ebx
-
 
384
        mov     ecx, 63
-
 
385
        rep movsb
-
 
386
@@:
-
 
387
        push    ebp
-
 
388
        mov     ebp, [tmp_file_name_table]
-
 
389
        mov     ecx, [tmp_file_name_size]
-
 
390
        jecxz   .noreplace
-
 
391
        mov     eax, ecx
-
 
392
        dec     eax
-
 
393
        shl     eax, 7
-
 
394
        add     ebp, eax
-
 
395
.replace_loop:
-
 
396
        mov     edi, ebx
-
 
397
        mov     esi, ebp
-
 
398
@@:
-
 
399
        lodsb
-
 
400
        test    al, al
-
 
401
        jz      .doreplace
-
 
402
        mov     dl, [edi]
-
 
403
        inc     edi
-
 
404
        test    dl, dl
330
uglobal
405
        jz      .replace_loop_cont
-
 
406
        or      dl, 20h
-
 
407
        cmp     al, dl
-
 
408
        jz      @b
-
 
409
        jmp     .replace_loop_cont
-
 
410
 
-
 
411
.doreplace:
-
 
412
        cmp     byte [edi], 0
-
 
413
        jz      @f
-
 
414
        cmp     byte [edi], '/'
-
 
415
        jnz     .replace_loop_cont
-
 
416
@@:
-
 
417
        lea     esi, [ebp+64]
-
 
418
        call    .replace
-
 
419
        jc      .skip_this_key2
-
 
420
.replace_loop_cont:
-
 
421
        sub     ebp, 128
-
 
422
        loop    .replace_loop
-
 
423
.noreplace:
-
 
424
        pop     ebp
-
 
425
        inc     [tmp_file_name_size]
-
 
426
.skip_this_key:
-
 
427
        xor     eax, eax
-
 
428
        inc     eax
-
 
429
        ret
-
 
430
 
-
 
431
.skip_this_key2:
-
 
432
        pop     ebp
-
 
433
        jmp     .skip_this_key
-
 
434
endp
-
 
435
 
-
 
436
proc get_every_key.replace
-
 
437
; in: ebx->destination, esi->first part of name, edi->second part of name
-
 
438
; maximum length is 64 bytes
-
 
439
; out: CF=1 <=> overflow
-
 
440
        sub     esp, 64 ; allocate temporary buffer in stack
-
 
441
        push    esi
-
 
442
        lea     esi, [esp+4]    ; esi->tmp buffer
-
 
443
        xchg    esi, edi        ; edi->tmp buffer, esi->source
-
 
444
@@: ; save second part of name to temporary buffer
-
 
445
        lodsb
-
 
446
        stosb
-
 
447
        test    al, al
-
 
448
        jnz     @b
-
 
449
        pop     esi
-
 
450
        mov     edi, ebx
-
 
451
@@: ; copy first part of name to destination
-
 
452
        lodsb
-
 
453
        test    al, al
-
 
454
        jz      @f
-
 
455
        stosb
-
 
456
        jmp     @b
-
 
457
 
-
 
458
@@: ; restore second part of name from temporary buffer to destination
-
 
459
        lea     edx, [ebx+64]   ; limit of destination
-
 
460
        mov     esi, esp
-
 
461
@@:
-
 
462
        cmp     edi, edx
-
 
463
        jae     .overflow
-
 
464
        lodsb
-
 
465
        stosb
-
 
466
        test    al, al
-
 
467
        jnz     @b
-
 
468
        add     esp, 64 ; CF is cleared
-
 
469
        ret
-
 
470
 
-
 
471
.overflow:  ; name is too long
-
 
472
        add     esp, 64
-
 
473
        stc
331
s_libname  db 64 dup (0)
474
        ret
332
endg
475
endp
333
end if
476
end if