Subversion Repositories Kolibri OS

Rev

Rev 8088 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8088 Rev 8219
Line 1... Line -...
1
;13.03.2013 - use @notify
-
 
2
;08.06.2010 - new macros @use_library_mem
-
 
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.
-
 
5
; The macros for load any library/libraries:
1
; The macros for load any library/libraries:
6
; Copyright (c) 2009, 
2
; Copyright (c) 2009, 
7
; All rights reserved.
3
; All rights reserved.
8
;
4
;
9
; Redistribution and use in source and binary forms, with or without
5
; Redistribution and use in source and binary forms, with or without
Line 91... Line 87...
91
;aEdit_box_mouse db 'edit_box_mouse',0
87
;aEdit_box_mouse db 'edit_box_mouse',0
92
;aVersion_ed     db 'version_ed',0
88
;aVersion_ed     db 'version_ed',0
Line 93... Line 89...
93
 
89
 
94
 
90
 
95
 
91
 
96
macro @use_library
92
macro @use_library mem_alloc,mem_free,mem_realloc,dll_load
97
{
93
{
98
local lp1
94
local lp1
99
local lp2
95
local lp2
100
local lp3
96
local lp3
101
local lp4
97
local lp4
Line -... Line 98...
-
 
98
local lp5
-
 
99
local lp6
102
local lp5
100
local file_name
-
 
101
 
Line 103... Line 102...
103
local lp6
102
library_fun_memory_alloc equ mem_alloc
104
local file_name
103
library_fun_memory_free equ mem_free
105
 
104
library_fun_memory_realloc equ mem_realloc
Line 243... Line 242...
243
}
242
}
244
;---------------------------------------------------------------------
243
;---------------------------------------------------------------------
Line 245... Line 244...
245
 
244
 
246
macro @use_library_mem mem_alloc,mem_free,mem_realloc,dll_load
245
macro @use_library_mem mem_alloc,mem_free,mem_realloc,dll_load
247
{
-
 
248
@use_library
-
 
249
library_fun_memory_alloc equ mem_alloc
-
 
250
library_fun_memory_free equ mem_free
246
{
251
library_fun_memory_realloc equ mem_realloc
-
 
252
library_fun_dll_load equ dll_load
247
@use_library mem_alloc,mem_free,mem_realloc,dll_load
Line 253... Line 248...
253
}
248
}
254
 
249
 
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__
250
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__
Line 261... Line 256...
261
	mcall	68,19,system_path__   ; load of sys directory
256
	mcall	68,19,system_path__   ; load of sys directory
262
	test	eax,eax
257
	test	eax,eax
263
	jnz		i_begin
258
	jnz		i_begin
Line 264... Line 259...
264
 
259
 
265
if point_dir_name__ eq
260
if point_dir_name__ eq
266
		copy_path   library_name__, cur_dir_path__, library_path__,0
261
		copy_path   library_name__, [32], library_path__,0
267
else
262
else
268
		;the macros making way /current path a program/ + name system library
263
		;the macros making way /current path a program/ + name system library
269
		copy_path   library_name__, cur_dir_path__, library_path__,point_dir_name__
264
		copy_path   library_name__, [32], library_path__,point_dir_name__
270
end if
265
end if
271
		mcall	68,19,library_path__ ; load of alternative
266
		mcall	68,19,library_path__ ; load of alternative
272
		test	eax,eax
267
		test	eax,eax
273
		jnz		i_begin
268
		jnz		i_begin
Line 295... Line 290...
295
local i_begin
290
local i_begin
296
local i_error
291
local i_error
297
local i_exit
292
local i_exit
Line 298... Line 293...
298
 
293
 
299
if point_dir_name__ eq
294
if point_dir_name__ eq
300
		copy_path   library_name__, cur_dir_path__, library_path__,0
295
		copy_path   library_name__, [32], library_path__,0
301
else
296
else
302
		;the macros making way /current path a program/ + name system library
297
		;the macros making way /current path a program/ + name system library
303
		copy_path   library_name__, cur_dir_path__, library_path__,point_dir_name__
298
		copy_path   library_name__, [32], library_path__,point_dir_name__
304
end if
299
end if
305
		mcall	68,19,library_path__ ; load of alternative
300
		mcall	68,19,library_path__ ; load of alternative
306
		test	eax,eax
301
		test	eax,eax
Line 339... Line 334...
339
local cycle1
334
local cycle1
340
local cycle1n
335
local cycle1n
341
local cycle1e
336
local cycle1e
342
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
337
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
343
library_name__            equ [ebp]
338
library_name__            equ [ebp]
344
cur_dir_path__            equ [ebp+4]
-
 
345
library_path__            equ [ebp+8]
339
library_path__            equ [ebp+4]
346
system_path__             equ [ebp+12]
340
system_path__             equ [ebp+8]
347
err_message_found_lib__   equ [ebp+16]   
341
err_message_found_lib__   equ [ebp+12]   
348
head_f_l__                equ [ebp+20]
342
head_f_l__                equ [ebp+16]
349
my_import                 equ [ebp+24] 
343
my_import                 equ [ebp+20] 
350
err_message_import__      equ [ebp+28]
344
err_message_import__      equ [ebp+24]
351
head_f_i__                equ [ebp+32]
345
head_f_i__                equ [ebp+28]
352
point_dir_name__          equ [ebp+36]
346
point_dir_name__          equ [ebp+32]
353
adr_load_lib              equ dword [ebp+40]
347
adr_load_lib              equ dword [ebp+36]
354
status_lib                equ dword [ebp+44]
348
status_lib                equ dword [ebp+40]
Line 355... Line 349...
355
 
349
 
356
	mov	ebp,_start
350
	mov	ebp,_start
357
	mov	ecx,(_end-_start)/ll_struc_size
351
	mov	ecx,(_end-_start)/ll_struc_size
358
align 4
352
align 4
Line 361... Line 355...
361
        mcall   68,19,system_path__   ; load of sys directory
355
        mcall   68,19,system_path__   ; load of sys directory
362
        test    eax,eax
356
        test    eax,eax
363
        jnz     end_steep 
357
        jnz     end_steep 
Line 364... Line 358...
364
 
358
 
365
        ;the macros making way /current path a program/ + name system library
359
        ;the macros making way /current path a program/ + name system library
Line 366... Line 360...
366
		copy_path  library_name__, cur_dir_path__, library_path__,point_dir_name__
360
		copy_path  library_name__, [32], library_path__,point_dir_name__
367
        
361
        
368
        mcall   68,19,library_path__ ; load of alternative
362
        mcall   68,19,library_path__ ; load of alternative
369
        test    eax,eax
363
        test    eax,eax
Line 423... Line 417...
423
local cycle1
417
local cycle1
424
local cycle1n
418
local cycle1n
425
local cycle1e
419
local cycle1e
426
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
420
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
427
library_name__            equ [ebp]
421
library_name__            equ [ebp]
428
cur_dir_path__            equ [ebp+4]
-
 
429
library_path__            equ [ebp+8]
422
library_path__            equ [ebp+4]
430
system_path__             equ [ebp+12]
423
system_path__             equ [ebp+8]
431
err_message_found_lib__   equ [ebp+16]   
424
err_message_found_lib__   equ [ebp+12]   
432
head_f_l__                equ [ebp+20]
425
head_f_l__                equ [ebp+16]
433
my_import                 equ [ebp+24] 
426
my_import                 equ [ebp+20] 
434
err_message_import__      equ [ebp+28]
427
err_message_import__      equ [ebp+24]
435
head_f_i__                equ [ebp+32]
428
head_f_i__                equ [ebp+28]
436
point_dir_name__          equ [ebp+36]
429
point_dir_name__          equ [ebp+32]
437
adr_load_lib              equ dword [ebp+40]
430
adr_load_lib              equ dword [ebp+36]
438
status_lib                equ dword [ebp+44]
431
status_lib                equ dword [ebp+40]
Line 439... Line 432...
439
 
432
 
440
	mov	ebp,_start
433
	mov	ebp,_start
441
	mov	ecx,(_end-_start)/ll_struc_size
434
	mov	ecx,(_end-_start)/ll_struc_size
442
align 4
435
align 4
443
	cycle0:
436
	cycle0:
Line 444... Line 437...
444
		push	ecx
437
		push	ecx
445
 
438
 
Line 446... Line 439...
446
		;the macros making way /current path a program/ + name system library
439
		;the macros making way /current path a program/ + name system library
447
		copy_path    library_name__, cur_dir_path__, library_path__,point_dir_name__
440
		copy_path    library_name__, [32], library_path__,point_dir_name__
448
 
441
 
Line 571... Line 564...
571
        pop     ebx ;¢®áâ ­ ¢«¨¢ ¥¬ 㪠§ â¥«ì ­  ¨¬ï ä㭪樨 (ª®â®àë© ¡ë« ¢ eax) ¨ ®á¢®¡®¦¤ ¥¬ á⥪
564
        pop     ebx ;¢®áâ ­ ¢«¨¢ ¥¬ 㪠§ â¥«ì ­  ¨¬ï ä㭪樨 (ª®â®àë© ¡ë« ¢ eax) ¨ ®á¢®¡®¦¤ ¥¬ á⥪
572
        mov     eax, [edx+4] ;eax = 㪠§ â¥«ì ­  äã­ªæ¨î (¢ ¡¨¡«¨®â¥ª¥)
565
        mov     eax, [edx+4] ;eax = 㪠§ â¥«ì ­  äã­ªæ¨î (¢ ¡¨¡«¨®â¥ª¥)
573
        mov     [esi-4], eax ;ª®¯¨à㥬 㪠§ â¥«ì (­  äã­ªæ¨î) ¢ ¯à®£à ¬¬ã, -4 áâ ¢¨¬ ¯®â®¬ã çâ® esi ¡ë«® ᤢ¨­ãâ® ª®¬ ­¤®© lodsd
566
        mov     [esi-4], eax ;ª®¯¨à㥬 㪠§ â¥«ì (­  äã­ªæ¨î) ¢ ¯à®£à ¬¬ã, -4 áâ ¢¨¬ ¯®â®¬ã çâ® esi ¡ë«® ᤢ¨­ãâ® ª®¬ ­¤®© lodsd
574
        pop     edx ;ãáâ ­ ¢«¨¢ ¥¬ edx ­  ­ ç «® ¡¨¡«¨®â¥ç­ëå ä㭪権
567
        pop     edx ;ãáâ ­ ¢«¨¢ ¥¬ edx ­  ­ ç «® ¡¨¡«¨®â¥ç­ëå ä㭪権
575
;--- ¯à®¢¥à塞 ᮢ¯ ¤ ¥â «¨ ¨¬ï íªá¯®àâ¨à®¢ ­­®© ä㭪樨 á 'lib_init'
568
;--- ¯à®¢¥à塞 ᮢ¯ ¤ ¥â «¨ ¨¬ï íªá¯®àâ¨à®¢ ­­®© ä㭪樨 á 'lib_init'
576
if library_fun_memory_alloc eq 0
569
if library_fun_memory_alloc eq
577
else
570
else
578
		cmp dword[ebx],'lib_'
571
		cmp dword[ebx],'lib_'
579
		jne		import_loop
572
		jne		import_loop
580
		cmp dword[ebx+4],'init'
573
		cmp dword[ebx+4],'init'
581
		jne		import_loop
574
		jne		import_loop
Line 600... Line 593...
600
        xor     eax,eax ;=0 ¢á¥ § £à㧨«®áì 㤠筮
593
        xor     eax,eax ;=0 ¢á¥ § £à㧨«®áì 㤠筮
601
exit:
594
exit:
602
} 
595
} 
603
;---------------------------------------------------------------------
596
;---------------------------------------------------------------------
Line 604... Line 597...
604
 
597
 
605
ll_struc_size = 48;($-library_name__)    ; constant   size of struct
598
ll_struc_size = 44;($-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
599
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
{        
600
{        
608
.library_name__           dd library_name__        ; ¨¬ï § £à㦠¥¬®© ¡¨¡«¨®â¥ª¨
-
 
Line 609... Line 601...
609
.cur_dir_path__           dd cur_dir_path__        ; 㪠§ â¥«ì ­  ¡ãä¥à ¢ ª®â®à®¬ ᮤ¥à¦¨âìáï ¯ãâì ®â ªã¤  ¡ë«  § ¯ã饭  ¯à®£à ¬¬ 
601
.library_name__           dd library_name__        ; ¨¬ï § £à㦠¥¬®© ¡¨¡«¨®â¥ª¨
610
                        
602
                        
Line 611... Line 603...
611
.library_path__           dd library_path__        ; 㪠§ â¥«ì ­  ¡ãä¥à ¢ ª®â®à®¬ ¡ã¤¥â á®ä®à¨¬¨à®¢ ­ ¯ãâì ª ¡¨¡«¨®â¥ª¨, ¥á«¨ ­ã¦­® ¢ëç¨á«¨âì ¯ãâì ¤® «¨¡ë á ¬¥áâ  § ¯ã᪠ ¯à®£à ¬¬ë, ®¡ëç­® ­ã¦­®, ¢ á«ãç ïå, ¥á«¨ «¨¡  à á¯®«®¦¥­  ¢ ⮩ ¦¥ ¯ ¯ª¥
603
.library_path__           dd library_path__        ; 㪠§ â¥«ì ­  ¡ãä¥à ¢ ª®â®à®¬ ¡ã¤¥â á®ä®à¨¬¨à®¢ ­ ¯ãâì ª ¡¨¡«¨®â¥ª¨, ¥á«¨ ­ã¦­® ¢ëç¨á«¨âì ¯ãâì ¤® «¨¡ë á ¬¥áâ  § ¯ã᪠ ¯à®£à ¬¬ë, ®¡ëç­® ­ã¦­®, ¢ á«ãç ïå, ¥á«¨ «¨¡  à á¯®«®¦¥­  ¢ ⮩ ¦¥ ¯ ¯ª¥