Subversion Repositories Kolibri OS

Rev

Rev 5881 | Rev 8083 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

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