forked from KolibriOS/kolibrios
535 lines
14 KiB
Plaintext
535 lines
14 KiB
Plaintext
|
; The macros for load any library/libraries:
|
|||
|
; Copyright (c) 2009, <Lrz>
|
|||
|
; All rights reserved.
|
|||
|
|
|||
|
|
|||
|
|
|||
|
macro @use_library mem_alloc,mem_free,mem_realloc,dll_load
|
|||
|
{
|
|||
|
local lp1
|
|||
|
local lp2
|
|||
|
local lp3
|
|||
|
local lp4
|
|||
|
local lp5
|
|||
|
local lp6
|
|||
|
local file_name
|
|||
|
local l_lib_m1
|
|||
|
local l_lib_m2
|
|||
|
local l_lib_m3
|
|||
|
local l_lib_m4
|
|||
|
|
|||
|
library_fun_memory_alloc equ mem_alloc
|
|||
|
library_fun_memory_free equ mem_free
|
|||
|
library_fun_memory_realloc equ mem_realloc
|
|||
|
library_fun_dll_load equ dll_load
|
|||
|
|
|||
|
align 4
|
|||
|
arrea_xx dd 0
|
|||
|
file_name db '/sys/@notify',0
|
|||
|
|
|||
|
if lang eq ru
|
|||
|
l_lib_m1 db '"<22><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20>訡<EFBFBD><E8A8A1>',13,10,'<27><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> ',39,0
|
|||
|
l_lib_m2 db '"<22><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20>訡<EFBFBD><E8A8A1>',13,10,'<27>訡<EFBFBD><E8A8A1> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> ',39,0
|
|||
|
l_lib_m3 db 39,13,10,'<27><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>㭪<EFBFBD><E3ADAA><EFBFBD> ',39,0
|
|||
|
l_lib_m4 db 39,'" -tE',0
|
|||
|
else
|
|||
|
l_lib_m1 db '"System error',13,10,'Sorry I cannot found library ',39,0
|
|||
|
l_lib_m2 db '"System error',13,10,'Error on load import library ',39,0
|
|||
|
l_lib_m3 db 39,13,10,'cannot found function ',39,0
|
|||
|
l_lib_m4 db 39,'" -tE',0
|
|||
|
end if
|
|||
|
|
|||
|
align 4
|
|||
|
run_notify_struct:
|
|||
|
.Function dd 7
|
|||
|
.Position dd 0
|
|||
|
.Flags dd ?
|
|||
|
.Count dd 0
|
|||
|
.Buffer dd 0
|
|||
|
db 0
|
|||
|
.FileName dd file_name
|
|||
|
|
|||
|
@library_name equ dword [esp+16]
|
|||
|
@cur_dir_path equ dword [esp+12]
|
|||
|
@library_path equ dword [esp+8]
|
|||
|
@point_dir_name equ dword [esp+4]
|
|||
|
|
|||
|
;description:
|
|||
|
; <20><>⮢<EFBFBD><E2AEA2> ⥪<><E2A5AA> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>१ @notify:
|
|||
|
; 1) <20>뤥<EFBFBD>塞 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> [arrea_xx] <20><> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ࠧ<>
|
|||
|
; 2) <20><><EFBFBD><EFBFBD><EFBFBD>㥬 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> (<28> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20>㭪樨 <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 <20><><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>) <20> ⥪<><E2A5AA> ᮮ<>饭<EFBFBD><E9A5AD> <20> [arrea_xx]
|
|||
|
;input:
|
|||
|
; ebp+8 - library name
|
|||
|
; ebp+12 - 0 <20><><EFBFBD> <20><><EFBFBD> <20>㭪樨, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><E0AEA2><EFBFBD>
|
|||
|
;output:
|
|||
|
; eax = -1
|
|||
|
align 4
|
|||
|
l_lib_init_error_window:
|
|||
|
push ebp
|
|||
|
mov ebp,esp
|
|||
|
cmp dword[arrea_xx],0
|
|||
|
jne .no_msg ;<3B> ࠭<><E0A0AD><EFBFBD> <20>뫮 ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><>㣮<EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD>
|
|||
|
pushad
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_HEAP_INIT
|
|||
|
mcall SF_SYS_MISC,SSF_MEM_ALLOC,4096
|
|||
|
mov [arrea_xx],eax
|
|||
|
|
|||
|
mov edi,eax
|
|||
|
mov esi,l_lib_m2 ;ᮮ<>饭<EFBFBD><E9A5AD> <20> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD> <20>㭪<EFBFBD><E3ADAA><EFBFBD>
|
|||
|
cmp dword[ebp+12],0
|
|||
|
je @f
|
|||
|
mov esi,l_lib_m1 ;ᮮ<>饭<EFBFBD><E9A5AD> <20> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧨<EFBFBD><E3A7A8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>
|
|||
|
align 4
|
|||
|
@@:
|
|||
|
movsb
|
|||
|
cmp byte[esi],0
|
|||
|
jne @b
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>
|
|||
|
mov esi,[ebp+8]
|
|||
|
align 4
|
|||
|
@@:
|
|||
|
movsb
|
|||
|
cmp byte[esi],0
|
|||
|
jne @b
|
|||
|
|
|||
|
cmp dword[ebp+12],0
|
|||
|
je .lp1
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 <20><>।<EFBFBD><E0A5A4><EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD>
|
|||
|
mov esi,l_lib_m3
|
|||
|
align 4
|
|||
|
@@:
|
|||
|
movsb
|
|||
|
cmp byte[esi],0
|
|||
|
jne @b
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 <20><><EFBFBD> <20>㭪樨
|
|||
|
mov esi,[ebp+12]
|
|||
|
align 4
|
|||
|
@@:
|
|||
|
movsb
|
|||
|
cmp byte[esi],0
|
|||
|
jne @b
|
|||
|
|
|||
|
.lp1: ;ᮮ<>饭<EFBFBD><E9A5AD> <20> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧨<EFBFBD><E3A7A8> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>塞 <20><><EFBFBD><EFBFBD><EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD>
|
|||
|
mov esi,l_lib_m4
|
|||
|
align 4
|
|||
|
@@:
|
|||
|
movsb
|
|||
|
cmp byte[esi],0
|
|||
|
jne @b
|
|||
|
mov byte[edi],0
|
|||
|
|
|||
|
popad
|
|||
|
.no_msg:
|
|||
|
or eax,-1
|
|||
|
pop ebp
|
|||
|
ret 8
|
|||
|
|
|||
|
align 4
|
|||
|
@copy_path:
|
|||
|
mov esi,@cur_dir_path
|
|||
|
mov edi,@library_path
|
|||
|
xor eax,eax
|
|||
|
cld
|
|||
|
align 4
|
|||
|
.lp1:
|
|||
|
lodsb
|
|||
|
stosb
|
|||
|
test eax,eax
|
|||
|
jnz .lp1
|
|||
|
mov esi,edi
|
|||
|
dec esi ;<3B><><EFBFBD><EFBFBD>室 <20><> ᨬ<><E1A8AC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20><>ப<EFBFBD> @cur_dir_path
|
|||
|
std
|
|||
|
align 4
|
|||
|
.lp2:
|
|||
|
lodsb
|
|||
|
cmp al,'/'
|
|||
|
jnz .lp2
|
|||
|
mov edi,esi
|
|||
|
add edi,2
|
|||
|
cld
|
|||
|
mov esi,@point_dir_name
|
|||
|
test esi,esi
|
|||
|
jz .str_lp4
|
|||
|
|
|||
|
;<3B><EFBFBD>ઠ <20>⭮<EFBFBD><E2ADAE>⥫<EFBFBD><E2A5AB><EFBFBD><EFBFBD> <20><>⥩ c <20><><EFBFBD><EFBFBD><EFBFBD> <20><>窠<EFBFBD><E7AAA0> '../'
|
|||
|
cmp word[esi],'..'
|
|||
|
jne .lp3
|
|||
|
dec edi ;<3B><><EFBFBD> <20><><EFBFBD><EFBFBD>室<EFBFBD> <20><> '/'
|
|||
|
.lp6:
|
|||
|
add esi,3 ;<3B>ய<EFBFBD>᪠<EFBFBD><E1AAA0> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>⨥ '../'
|
|||
|
.lp5:
|
|||
|
dec edi ;<3B><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
cmp byte[edi],'/'
|
|||
|
jnz .lp5
|
|||
|
cmp word[esi],'..'
|
|||
|
je .lp6
|
|||
|
inc edi ;<3B><><EFBFBD> <20><><EFBFBD><EFBFBD>室<EFBFBD> <20><> '/'
|
|||
|
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><E0AEA2><EFBFBD><EFBFBD> <20>⭮<EFBFBD><E2ADAE>⥫쭮<E2A5AB><ECADAE> <20><><EFBFBD><EFBFBD>
|
|||
|
align 4
|
|||
|
.lp3:
|
|||
|
lodsb
|
|||
|
stosb
|
|||
|
test eax,eax
|
|||
|
jnz .lp3
|
|||
|
dec edi
|
|||
|
.str_lp4:
|
|||
|
mov esi,@library_name
|
|||
|
align 4
|
|||
|
.lp4:
|
|||
|
lodsb
|
|||
|
stosb
|
|||
|
test eax,eax
|
|||
|
jnz .lp4
|
|||
|
ret
|
|||
|
}
|
|||
|
;---------------------------------------------------------------------
|
|||
|
|
|||
|
macro sys_load_library library_name__, library_path__, system_path__, myimport, point_dir_name__
|
|||
|
{
|
|||
|
local i_begin
|
|||
|
local i_error
|
|||
|
local i_exit
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,system_path__ ; load of sys directory
|
|||
|
test eax,eax
|
|||
|
jnz i_begin
|
|||
|
|
|||
|
if point_dir_name__ eq
|
|||
|
copy_path library_name__, [32], library_path__,0
|
|||
|
else
|
|||
|
;the macros making way /current path a program/ + name system library
|
|||
|
copy_path library_name__, [32], library_path__,point_dir_name__
|
|||
|
end if
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,library_path__ ; load of alternative
|
|||
|
test eax,eax
|
|||
|
jnz i_begin
|
|||
|
jmp i_error
|
|||
|
align 4
|
|||
|
i_begin:
|
|||
|
import_boxlib myimport
|
|||
|
test eax,eax
|
|||
|
jz i_exit
|
|||
|
i_error:
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
notify_window_run [arrea_xx] ; ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> @notify
|
|||
|
i_exit:
|
|||
|
}
|
|||
|
;---------------------------------------------------------------------
|
|||
|
|
|||
|
macro load_library library_name__, library_path__, system_path__, myimport, point_dir_name__
|
|||
|
{
|
|||
|
local i_begin
|
|||
|
local i_error
|
|||
|
local i_exit
|
|||
|
|
|||
|
if point_dir_name__ eq
|
|||
|
copy_path library_name__, [32], library_path__,0
|
|||
|
else
|
|||
|
;the macros making way /current path a program/ + name system library
|
|||
|
copy_path library_name__, [32], library_path__,point_dir_name__
|
|||
|
end if
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,library_path__ ; load of alternative
|
|||
|
test eax,eax
|
|||
|
jnz i_begin
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,system_path__ ; load of sys directory
|
|||
|
test eax,eax
|
|||
|
jnz i_begin
|
|||
|
jmp i_error
|
|||
|
align 4
|
|||
|
i_begin:
|
|||
|
import_boxlib myimport
|
|||
|
test eax,eax
|
|||
|
jz i_exit
|
|||
|
i_error:
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
notify_window_run [arrea_xx] ; ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> @notify
|
|||
|
i_exit:
|
|||
|
;---------------------------------------------------------------------
|
|||
|
}
|
|||
|
|
|||
|
;description:
|
|||
|
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧪<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪ <20><> <20><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
; ⮣<><E2AEA3> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> ⥪<>饩 <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20>ணࠬ<E0AEA3><E0A0AC><EFBFBD>
|
|||
|
macro sys_load_libraries _start,_end
|
|||
|
{
|
|||
|
local cycle0
|
|||
|
local end_steep
|
|||
|
local cycle0n
|
|||
|
local cycle1
|
|||
|
local cycle1n
|
|||
|
local cycle1e
|
|||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|||
|
library_name__ equ [ebp]
|
|||
|
library_path__ equ [ebp+4]
|
|||
|
system_path__ equ [ebp+8]
|
|||
|
my_import equ [ebp+12]
|
|||
|
point_dir_name__ equ [ebp+16]
|
|||
|
adr_load_lib equ dword [ebp+20]
|
|||
|
status_lib equ dword [ebp+24]
|
|||
|
|
|||
|
mov ebp,_start
|
|||
|
mov ecx,(_end-_start)/ll_struc_size
|
|||
|
align 4
|
|||
|
cycle0:
|
|||
|
push ecx
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,system_path__ ; load of sys directory
|
|||
|
test eax,eax
|
|||
|
jnz end_steep
|
|||
|
|
|||
|
;the macros making way /current path a program/ + name system library
|
|||
|
copy_path library_name__, [32], library_path__,point_dir_name__
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,library_path__ ; load of alternative
|
|||
|
test eax,eax
|
|||
|
jnz end_steep
|
|||
|
or status_lib,1 ; status of code - enable error - not found library
|
|||
|
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
jmp cycle0n
|
|||
|
|
|||
|
align 4
|
|||
|
end_steep:
|
|||
|
mov adr_load_lib,eax ;save adr lib in memory
|
|||
|
import_boxlib my_import
|
|||
|
test eax,eax
|
|||
|
jz cycle0n
|
|||
|
or status_lib,2 ; status of code - enable error - import error
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
cycle0n:
|
|||
|
pop ecx
|
|||
|
add ebp,ll_struc_size
|
|||
|
dec ecx
|
|||
|
jnz cycle0
|
|||
|
|
|||
|
;<3B>뢮<EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD> <20><> <20>訡<EFBFBD><E8A8A1> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>㧪<EFBFBD>
|
|||
|
mov ebp,_start
|
|||
|
mov ecx,(_end-_start)/ll_struc_size
|
|||
|
align 4
|
|||
|
cycle1:
|
|||
|
mov eax,status_lib
|
|||
|
test eax,eax
|
|||
|
jz cycle1n
|
|||
|
notify_window_run [arrea_xx] ; ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> @notify
|
|||
|
mov eax,-1
|
|||
|
jmp cycle1e
|
|||
|
align 4
|
|||
|
cycle1n:
|
|||
|
add ebp,ll_struc_size
|
|||
|
dec ecx
|
|||
|
jnz cycle1
|
|||
|
cycle1e:
|
|||
|
}
|
|||
|
|
|||
|
;description:
|
|||
|
; <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧪<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪ <20><> ⥪<>饩 <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20>ணࠬ<E0AEA3><E0A0AC><EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
; ⮣<><E2AEA3> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD>⥬<EFBFBD><E2A5AC><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
macro load_libraries _start,_end
|
|||
|
{
|
|||
|
local cycle0
|
|||
|
local end_steep
|
|||
|
local cycle0n
|
|||
|
local cycle1
|
|||
|
local cycle1n
|
|||
|
local cycle1e
|
|||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|||
|
library_name__ equ [ebp]
|
|||
|
library_path__ equ [ebp+4]
|
|||
|
system_path__ equ [ebp+8]
|
|||
|
my_import equ [ebp+12]
|
|||
|
point_dir_name__ equ [ebp+16]
|
|||
|
adr_load_lib equ dword [ebp+20]
|
|||
|
status_lib equ dword [ebp+24]
|
|||
|
|
|||
|
mov ebp,_start
|
|||
|
mov ecx,(_end-_start)/ll_struc_size
|
|||
|
align 4
|
|||
|
cycle0:
|
|||
|
push ecx
|
|||
|
|
|||
|
;the macros making way /current path a program/ + name system library
|
|||
|
copy_path library_name__, [32], library_path__,point_dir_name__
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,library_path__ ; load of alternative
|
|||
|
test eax,eax
|
|||
|
jnz end_steep
|
|||
|
|
|||
|
mcall SF_SYS_MISC,SSF_LOAD_DLL,system_path__ ; load of sys directory
|
|||
|
test eax,eax
|
|||
|
jnz end_steep
|
|||
|
or status_lib,1 ; status of code - enable error - not found library
|
|||
|
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
jmp cycle0n
|
|||
|
|
|||
|
align 4
|
|||
|
end_steep:
|
|||
|
mov adr_load_lib,eax ;save adr lib in memory
|
|||
|
import_boxlib my_import
|
|||
|
test eax,eax
|
|||
|
jz cycle0n
|
|||
|
or status_lib,2 ; status of code - enable error - import error
|
|||
|
push eax
|
|||
|
push dword library_name__
|
|||
|
call l_lib_init_error_window
|
|||
|
cycle0n:
|
|||
|
pop ecx
|
|||
|
add ebp,ll_struc_size
|
|||
|
dec ecx
|
|||
|
jnz cycle0
|
|||
|
|
|||
|
;<3B>뢮<EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD> <20><> <20>訡<EFBFBD><E8A8A1> <20><><EFBFBD> <20><><EFBFBD><EFBFBD>㧪<EFBFBD>
|
|||
|
mov ebp,_start
|
|||
|
mov ecx,(_end-_start)/ll_struc_size
|
|||
|
align 4
|
|||
|
cycle1:
|
|||
|
mov eax,status_lib
|
|||
|
test eax,eax
|
|||
|
jz cycle1n
|
|||
|
notify_window_run [arrea_xx] ; ᮧ<><E1AEA7><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> @notify
|
|||
|
mov eax,-1
|
|||
|
jmp cycle1e
|
|||
|
align 4
|
|||
|
cycle1n:
|
|||
|
add ebp,ll_struc_size
|
|||
|
dec ecx
|
|||
|
jnz cycle1
|
|||
|
cycle1e:
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
macro copy_path lib_name,dir_path,lib_path,point_dir_name
|
|||
|
{
|
|||
|
pushad ;save all registers
|
|||
|
push dword lib_name
|
|||
|
push dword dir_path
|
|||
|
push dword lib_path
|
|||
|
push dword point_dir_name
|
|||
|
call @copy_path
|
|||
|
|
|||
|
add esp,16
|
|||
|
;notify_window_run lib_path ;unblok for test load path
|
|||
|
popad ;restore all registers
|
|||
|
}
|
|||
|
|
|||
|
; <20><><EFBFBD><EFBFBD>砥<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> ᮮ<>饭<EFBFBD><E9A5AD> <20><>१ @notify:
|
|||
|
macro notify_window_run message
|
|||
|
{
|
|||
|
push eax ebx
|
|||
|
mov eax,message ;<3B><>ࠬ<EFBFBD><E0A0AC><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>ப<EFBFBD>
|
|||
|
mov [run_notify_struct.Flags],eax
|
|||
|
mcall SF_FILE,run_notify_struct
|
|||
|
pop ebx eax
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
;input:
|
|||
|
; eax - <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
; myimport - <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㥬<EFBFBD><E3A5AC> <20>㭪樨
|
|||
|
;output:
|
|||
|
; eax - <20> 㤠筮 <20><> 0 <20><><EFBFBD> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20>㭪樨 <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> 㤠<><E3A4A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>㧨<EFBFBD><E3A7A8>
|
|||
|
macro import_boxlib myimport
|
|||
|
{
|
|||
|
local import_loop
|
|||
|
local import_find
|
|||
|
local lp
|
|||
|
local import_find_next
|
|||
|
local import_found
|
|||
|
local import_done
|
|||
|
local exit
|
|||
|
local import_not_found
|
|||
|
; initialize import
|
|||
|
|
|||
|
mov edx, eax
|
|||
|
mov esi,myimport
|
|||
|
import_loop:
|
|||
|
lodsd ;mov eax,dword[esi] ;add esi,4 ;<3B><><EFBFBD><EFBFBD>砥<EFBFBD> <20> eax 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>㥬<EFBFBD><E3A5AC> <20>㭪樨
|
|||
|
test eax, eax
|
|||
|
jz import_done ;<3B> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20>㭪樨 = 0 (<28> <20><><EFBFBD>짮<EFBFBD><ECA7AE>⥫<EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC>)
|
|||
|
push edx ;<3B><><EFBFBD>࠭塞 <20><>砫<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 㪠<><E3AAA0>⥫<EFBFBD><E2A5AB> <20><> <20>㭪樨
|
|||
|
import_find:
|
|||
|
mov ebx, [edx]
|
|||
|
test ebx, ebx
|
|||
|
jz import_not_found ;<3B> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20>㭪樨 = 0 (<28> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>)
|
|||
|
push eax ;eax - 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20><>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD>㥬<EFBFBD><E3A5AC> <20>㭪樨 (<28> <20><><EFBFBD>짮<EFBFBD><ECA7AE>⥫<EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC>)
|
|||
|
lp:
|
|||
|
mov cl, [eax]
|
|||
|
cmp cl, [ebx] ;<3B>ࠢ<EFBFBD><E0A0A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> <20>㭪権 <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD> <20> <20> <20><><EFBFBD>짮<EFBFBD><ECA7AE>⥫<EFBFBD><EFBFBD> <20>ணࠬ<E0AEA3><E0A0AC>
|
|||
|
jnz import_find_next ;<3B> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> ᮢ<><E1AEA2><EFBFBD><EFBFBD>
|
|||
|
test cl, cl
|
|||
|
jz import_found ;<3B> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ᮢ<><E1AEA2><EFBFBD><EFBFBD>, <20> 㦥 <20><><EFBFBD><EFBFBD><EFBFBD> <20><>ப<EFBFBD> (cl=0)
|
|||
|
inc eax
|
|||
|
inc ebx
|
|||
|
jmp lp
|
|||
|
import_find_next:
|
|||
|
pop eax
|
|||
|
add edx, 8 ;8 = 4 <20><><EFBFBD><EFBFBD><EFBFBD> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> 4 <20><><EFBFBD><EFBFBD><EFBFBD> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20>㭪<EFBFBD><E3ADAA><EFBFBD>
|
|||
|
jmp import_find
|
|||
|
import_found:
|
|||
|
pop ebx ;<3B><><EFBFBD>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD> <20>㭪樨 (<28><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD> <20> eax) <20> <20><EFBFBD><E1A2AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>⥪
|
|||
|
mov eax, [edx+4] ;eax = 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20>㭪<EFBFBD><E3ADAA><EFBFBD> (<28> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>)
|
|||
|
mov [esi-4], eax ;<3B><><EFBFBD><EFBFBD><EFBFBD>㥬 㪠<><E3AAA0>⥫<EFBFBD> (<28><> <20>㭪<EFBFBD><E3ADAA><EFBFBD>) <20> <20>ணࠬ<E0AEA3><E0A0AC>, -4 <20>⠢<EFBFBD><E2A0A2> <20><>⮬<EFBFBD> <20><><EFBFBD> esi <20>뫮 ᤢ<><E1A4A2><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> lodsd
|
|||
|
pop edx ;<3B><>⠭<EFBFBD><E2A0AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> edx <20><> <20><>砫<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>㭪権
|
|||
|
;--- <20><EFBFBD><E0AEA2>塞 ᮢ<><E1AEA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD> <20><>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><E0AEA2><EFBFBD><EFBFBD><EFBFBD> <20>㭪樨 <20> 'lib_init'
|
|||
|
if library_fun_memory_alloc eq
|
|||
|
else
|
|||
|
cmp dword[ebx],'lib_'
|
|||
|
jne import_loop
|
|||
|
cmp dword[ebx+4],'init'
|
|||
|
jne import_loop
|
|||
|
;cmp byte[ebx+8],0
|
|||
|
;jne import_loop
|
|||
|
;--- <20> <20><><EFBFBD> <20>㭪樨 ᮢ<><E1AEA2><EFBFBD><EFBFBD> <20> 'lib_init' <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20>
|
|||
|
;<3B><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>祭<EFBFBD><E7A5AD> <20>㭪権 <20><><EFBFBD> ࠡ<><E0A0A1><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
;push eax
|
|||
|
;call dll.Init
|
|||
|
pushad
|
|||
|
mov esi,eax
|
|||
|
mov eax,library_fun_memory_alloc
|
|||
|
mov ebx,library_fun_memory_free
|
|||
|
mov ecx,library_fun_memory_realloc
|
|||
|
mov edx,library_fun_dll_load
|
|||
|
call dword esi
|
|||
|
popad
|
|||
|
end if
|
|||
|
jmp import_loop
|
|||
|
import_not_found:
|
|||
|
add esp,4
|
|||
|
jmp exit
|
|||
|
import_done:
|
|||
|
xor eax,eax ;=0 <20><><EFBFBD> <20><><EFBFBD><EFBFBD>㧨<EFBFBD><E3A7A8><EFBFBD><EFBFBD> 㤠筮
|
|||
|
exit:
|
|||
|
}
|
|||
|
;---------------------------------------------------------------------
|
|||
|
|
|||
|
ll_struc_size = 28;($-library_name__) ; constant size of struct
|
|||
|
struc l_libs library_name__, library_path__, system_path__, my_import, point_dir_name; struct for loading libraries
|
|||
|
{
|
|||
|
.library_name__ dd library_name__ ; <20><><EFBFBD> <20><><EFBFBD><EFBFBD>㦠<EFBFBD><E3A6A0><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>
|
|||
|
|
|||
|
.library_path__ dd library_path__ ; 㪠<><E3AAA0>⥫<EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD> <20>㤥<EFBFBD> <20><><EFBFBD><EFBFBD>ਬ<EFBFBD><EFBFBD><E0AEA2> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>⥪<EFBFBD>, <20> <20>㦭<EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><E1ABA8> <20><><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>᪠ <20>ணࠬ<E0AEA3><E0A0AC>, <20><><EFBFBD>筮 <20>㦭<EFBFBD>, <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20> <20><><EFBFBD><EFBFBD> <20><>ᯮ<EFBFBD><E1AFAE><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> ⮩ <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
.complete_path dd system_path__ ; <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><>⪮ ᮤ<>ন<EFBFBD> <20><><EFBFBD><EFBFBD>
|
|||
|
.my_import dd my_import
|
|||
|
if point_dir_name eq
|
|||
|
.point_dir_name__ dd 0
|
|||
|
else
|
|||
|
.point_dir_name__ dd point_dir_name ; <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>४<EFBFBD><E0A5AA>ਨ <20> <20><><EFBFBD>ன <20>࠭<EFBFBD><E0A0AD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>㦠<EFBFBD><E3A6A0><EFBFBD><EFBFBD> <20><><EFBFBD>㫨.
|
|||
|
end if
|
|||
|
.adr_load_lib dd 0
|
|||
|
.status_lib dd 0 ;status of load library
|
|||
|
;
|
|||
|
}
|