mirror of
https://github.com/KolibriOS/kolibrios.git
synced 2024-12-28 09:19:41 +03:00
4c444c11c9
in file 'load_lib.mac' git-svn-id: svn://kolibrios.org@1488 a494cfbc-eb01-0410-851d-a64ba20cac60
401 lines
18 KiB
Plaintext
401 lines
18 KiB
Plaintext
Ðóêîâîäñòâî ïðîãðàììèñòà ïî èñïîëüçîâàíèþ ìàêðîñîâ äëÿ óíèâåðñàëüíîé çàãðóçêè áèáëèîòåêè/áèáëèîòåê
|
|
îò 6 èþëÿ 2009ã.
|
|
|
|
Copyright (c) 2009, <Lrz>
|
|
All rights reserved.
|
|
|
|
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
Neither the name of the <organization> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
|
|
THIS SOFTWARE IS PROVIDED BY Alexey Teplov aka <Lrz> ''AS IS'' AND ANY
|
|
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE MPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL <copyright holder> BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
*****************************************************************************Èçìåíåíèÿ:
|
|
|
|
Äîðàáîòàí ìàêðîñ, óáðàíû îãðàíè÷åíèÿ ïðè åãî èñïîëüçîâàíèè. Âûâîä ñîîáùåíèé îá îøèáêàõ ïðîèçâîäèòüñÿ â îòäåëüíîì ïîòîêå. Ïðè ïàêåòíîé îáðàáîòêå çàãðóçêè áèáëèîòåê, â íà÷àëå ôîðìèðóåòñÿ âñå ñîîáùåíèÿ îò áèáëèîòåê, êîòîðûå çàãðóæåíû ñ îøèáêàìè, è çàòåì ïðîèçâåäåí âûâîä íà ýêðàí îòäåëüíûì ïîòîêîì ñî âñåì ñïèñêîì îøèáîê.Ââåäåíèå:
|
|
|
|
 ïîñëåäíåå âðåìÿ íàìåòèëàñü òåíäåíöèÿ â ïåðåíîñå îñíîâíûõ, áàçîâûõ áëîêîâ (êîìïîíåíòîâ) â áèáëèîòåêè. Äëÿ ðàçðàáîò÷èêà ýòî ÿâëÿåòñÿ î÷åíü óäîáíî, ò.ê. ñðîêè ðàçðàáîòêè ïðîãðàììû çíà÷èòåëüíî ñîêðàùàþòñÿ. Ìàêðîñ load_lib.mac ðàçðàáàòûâàëñÿ êàê óíèâåðñàëüíûé äëÿ çàãðóçêè ëþáîãî êîëè÷åñòâà áèáëèîòåê. Îñîáåííîñòüþ åãî ÿâëÿåòñÿ òî, ÷òî åñëè áèáëèîòåêà íå ìîæåò áûòü íàéäåíà ïî óêàçàííîìó ïóòè, èëè ñóùåñòâóåò îøèáêà ïðè èìïîðòå, òî òîãäà, ôîðìèðóåòñÿ ñîîáùåíèå è âûâîäèòüñÿ â îêíå èíôîðìàöèÿ îá îøèáêå. Ïîèñê áèáëèîòåêè ïðîèñõîäèò ïî 2-ì íàïðàâëåíèÿì.  òåêóùåé ïàïêå, îòêóäà ñòàðòîâàëà ïðîãðàììà è â ñèñòåìíîé ïàïêå (ïî óêàçàííîìó ïóòè + íàçâàíèå áèáëèîòåêè).
|
|
Ñòðóêòóðà ìàêðîñîâ:
|
|
|
|
Ôàéë load_lib.mac ñîñòîèò èç 5 îñíîâíûõ ìàêðîñîâ.
|
|
Äëÿ çàãðóçêè îäíîé áèáëèîòåêè ñóùåñòâóþò ìàêðîñû ïåðâîé ãðóïïû, íàçîâåì, åå ãðóïïà À. Äëÿ çàãðóçêè îò 2-õ è áîëåå áèáëèîòåê ñîçäàíû ìàêðîñû ãðóïïû B. Íàçâàíèå ýòèõ ìàêðîñîâ:
|
|
|
|
A:
|
|
sys_load_library
|
|
load_library
|
|
B:
|
|
sys_load_libraries
|
|
load_libraries
|
|
|
|
Äëÿ ìàêðîñîâ ãðóïïû À íåîáõîäèìî â êà÷åñòâå ïàðàìåòðîâ óêàçàòü ñëåäóþùèå îïöèè:
|
|
library_name, cur_dir_path, library_path, system_path, err_message_found_lib, head_f_l, myimport, err_message_import, head_f_i . Ñèíòàêñè÷åñêè ïðàâèëüíî èñïîëüçîâàòü ñëåäóþùèþ çàïèñü äëÿ ïðàâèëüíîãî ðàçâîðà÷èâàíèÿ ìàêðîñà:
|
|
|
|
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
|
|
|
|
èëè
|
|
|
|
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
|
|
|
|
Ðàçíèöà ìåæäó ýòèìè äâóìÿ ìàêðîñàìè òîëüêî â ïîðÿäêå ïðîâåðêè ïóòè ê áèáëèîòåêå.
|
|
sys_load_library - â ïåðâóþ î÷åðåäü ïðîâåðÿåòñÿ çíà÷åíèå óêàçàííîå â system_path, ò.å. íà ýòîì ìåñòå ãäå íàõîäèòñÿ system_path äîëæåí áûòü ïîìåùåí àäðåñ çàïèñè.
|
|
|
|
Âñåãäà ñîáëþäàòü ïîñëåäîâàòåëüíîñòü â èìåíè.
|
|
system_path db '/sys/lib/'
|
|
library_name db 'box_lib.obj',0 ; òàêàÿ çàïèñü ñäåëàíà èç ýêîíîìèè ìåñòà
|
|
|
|
Åñëè åñòü æåëàíèå ðàçúåäèíèòü, òî íóæíî èñïîëüçîâàòü ñëåäóþùóþ êîíñòðóêöèþ
|
|
system_path db '/sys/lib/box_lib.obj',0
|
|
... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
|
|
library_name db 'box_lib.obj',0
|
|
|
|
|
|
À load_library - â ïåðâóþ î÷åðåäü ïðîâåðÿåò òåêóùóþ ïàïêó, ò.å. èñïîëüçóåò ýòîò ïóòü äëÿ ïîèñêà áèáëèîòåêè.
|
|
|
|
library_name - èìÿ áèáëèîòåêè îáû÷íî â äàííûõ îïðåäåëÿåòñÿ êàê
|
|
library_name db 'box_lib.obj',0
|
|
|
|
Èíîãäà, âîçíèêàåò íåîáõîäèìîñòü çàãðóçêè áèáëèîòåêè ñ ïàïêè, êîòîðàÿ íàõîäèòüñÿ íèæå óðîâíåì äèðåêòîðèè, ñ êîòîðîé áûëà çàïóùåíà ïðîãðàììà. Äîïóñòèì, ñëåäóþùåå:
|
|
|
|
|
|
Íåîáõîäèìàÿ íàì áèáëèîòåêà ðàñïîëîæåíà â ïàïêå ff2, äëÿ òîãî, ÷òî áû ìàêðîñ çàãðóçèë áèáëèîòåêó èç ýòîé ïàïêè, íàì íóæíî ñäåëàòü ñëåäóþùåå:
|
|
|
|
Îáðàùàþ âíèìàíèå, ÷òî êîðîòêàÿ çàïèñü â ýòîì ñëó÷àå íåâîçìîæíà, è íóæíî îïðåäåëèòü ñëåäóþùèå ïóòè ïîëíîñòüþ.
|
|
system_path db '/sys/lib/tread_lib.obj',0
|
|
;... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
|
|
library_name db 'ff2/tread_lib.obj',0
|
|
- èìåííî òàêîå îïðåäåëåíèå èìåíè, ïîçâîëèò äèíàìè÷åñêè ñôîðìèðîâàòü ïóòü äî íàøåé áèáèëîòåêè.
|
|
|
|
cur_dir_path - ïåðâîíà÷àëüíî äîëæåí áûòü îïðåäåëåí â çàãîëîâêå ïðîãðàììû, êàê:
|
|
|
|
use32 ; òðàíñëÿòîð, èñïîëüçóþùèé 32 ðàçðÿäíûõ êîìàíäû
|
|
org 0x0 ; áàçîâûé àäðåñ êîäà, âñåãäà 0x0
|
|
db 'MENUET01' ; èäåíòèôèêàòîð èñïîëíÿåìîãî ôàéëà (8 áàéò)
|
|
dd 0x1 ; âåðñèÿ ôîðìàòà çàãîëîâêà èñïîëíÿåìîãî ôàéëà
|
|
dd start ; àäðåñ, íà êîòîðûé ñèñòåìà ïåðåäà¸ò óïðàâëåíèå
|
|
; ïîñëå çàãðóçêè ïðèëîæåíèÿ â ïàìÿòü
|
|
dd i_end ; ðàçìåð ïðèëîæåíèÿ
|
|
dd mem ; Îáúåì èñïîëüçóåìîé ïàìÿòè, äëÿ ñòåêà îòâåäåì 0õ100 áàéò è âûðîâíèì íà ãðíèöó 4 áàéòà
|
|
dd mem ; ðàñïîëîæèì ïîçèöèþ ñòåêà â îáëàñòè ïàìÿòè, ñðàçó çà òåëîì ïðîãðàììû. Âåðøèíà ñòåêà â äèàïàçîíå ïàìÿòè, óêàçàííîì âûøå
|
|
dd 0x0 ; óêàçàòåëü íà ñòðîêó ñ ïàðàìåòðàìè.
|
|
dd cur_dir_path ; óêàçàòåëü íà àäðåñ, êóäà ïîìåùàåòñÿ ñòðîêà, ñîäåðæàùàÿ ïóòü äî ïðîãðàììû â ìîìåíò çàïóñêà.
|
|
à çàòåì â ñåêöèè DATA ïðîãðàììû
|
|
|
|
cur_dir_path rb 4096 ; çíà÷åíèå 4096 ìîæåò áûòü è ìåíüøå, íî äîëæíî âìåùàòü ïîëíîñòüþ ïóòü äî áèáëèîòåêè. Ò.å. ýòî áóôåð, â êîòîðîì ôîðìèðóåòñÿ ïóòü ïðè çàïóñêå ïðîãðàììû.
|
|
|
|
library_path - íà÷àëî áóôåðà, â êîòîðîì áóäåò ñôîðìèðîâàí ïóòü ïîëó÷åííûé ïðè çàïóñêå ïðîãðàììû ñ èìåíåì áèáëèîòåêè.
|
|
library_path rb 4096
|
|
|
|
system_path - ïóòü äî áèáëèîòåêè ñ èìåíåì áèáëèîòåêè. Ïðåäïîëàãàåì, ÷òî, òóò óêàçàí ïîëíûé ïóòü äî áèáëèîòåêè.
|
|
Âñåãäà ñîáëþäàòü ïîñëåäîâàòåëüíîñòü â èìåíè.
|
|
system_path db '/sys/lib/'
|
|
library_name db 'box_lib.obj',0 ; òàêàÿ çàïèñü ñäåëàíà èç ýêîíîìèè ìåñòà
|
|
|
|
Åñëè åñòü æåëàíèå ðàçúåäèíèòü, òî íóæíî èñïîëüçîâàòü ñëåäóþùóþ êîíñòðóêöèþ
|
|
system_path db '/sys/lib/box_lib.obj',0
|
|
... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
|
|
library_name db 'box_lib.obj',0
|
|
|
|
err_message_found_lib - ñòðîêà, êîòîðàÿ áóäåò â ñôîðìèðîâàííîì îêíå, åñëè áèáëèîòåêà íå áóäåò íàéäåíà.
|
|
|
|
err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0
|
|
|
|
head_f_l - çàãîëîâîê îêíà, ïðè âîçíèêíîâåíèè îøèáêè - áèáëèîòåêà íå íàéäåíà.
|
|
head_f_l db 'System error',0
|
|
|
|
myimport - óêàçàòåëü íà èìïîðò ôóíêöèé èç áèáëèîòåêè.
|
|
myimport:
|
|
|
|
edit_box_draw dd aEdit_box_draw
|
|
edit_box_key dd aEdit_box_key
|
|
edit_box_mouse dd aEdit_box_mouse
|
|
version_ed dd aVersion_ed
|
|
|
|
check_box_draw dd aCheck_box_draw
|
|
check_box_mouse dd aCheck_box_mouse
|
|
version_ch dd aVersion_ch
|
|
|
|
option_box_draw dd aOption_box_draw
|
|
option_box_mouse dd aOption_box_mouse
|
|
version_op dd aVersion_op
|
|
|
|
dd 0
|
|
dd 0
|
|
|
|
aEdit_box_draw db 'edit_box',0
|
|
aEdit_box_key db 'edit_box_key',0
|
|
aEdit_box_mouse db 'edit_box_mouse',0
|
|
aVersion_ed db 'version_ed',0
|
|
|
|
aCheck_box_draw db 'check_box_draw',0
|
|
aCheck_box_mouse db 'check_box_mouse',0
|
|
aVersion_ch db 'version_ch',0
|
|
|
|
aOption_box_draw db 'option_box_draw',0
|
|
aOption_box_mouse db 'option_box_mouse',0
|
|
aVersion_op db 'version_op',0
|
|
|
|
err_message_import - ñòðîêà, êîòîðàÿ áóäåò â ñôîðìèðîâàííîì îêíå, åñëè ïðè èìïîðòå ôóíêöèé ïðîèçîøëà îøèáêà.
|
|
|
|
err_message_import db 'Error on load import library box_lib.obj',0
|
|
|
|
head_f_i - çàãîëîâîê îêíà, ïðè âîçíèêíîâåíèè îøèáêè - îøèáêà èìïîðòà ôóíêöèé.
|
|
head_f_i db 'System error',0
|
|
|
|
Ïîñëå òîãî, êàê ìàêðîñ áóäåò ðàñêðûò è îòðàáîòàåò ñâîþ ÷àñòü êîäà, ìîæíî óçíàòü îá óñïåøíîñòè èëè íå óñïåøíîñòè çàãðóçêè, èìïîðòå áèáëèîòåêè.  ðåãèñòðå åax ôîðìèðóåòñÿ 0 ïðè óñïåøíîé çàãðóçêå è èìïîðòå, èëè -1, åñëè íà ëþáîì èç ýòèõ ýòàïîâ âîçíèêëà îøèáêà. Ïðè âîçíèêíîâåíèè îøèáêè ðåêîìåíäóåòñÿ çàâåðøèòü âûïîëíåíèå ïðîãðàììû.
|
|
cmp eax,-1
|
|
jz exit
|
|
|
|
Ãðóïïà ìàêðîñîâ B
|
|
|
|
Îñíîâíûì îòëè÷èåì ìàêðîñîâ ãðóïïû À, îò ãðóïïû B ÿâëÿåòñÿ áëî÷íàÿ (ïàêåòíàÿ) îáðàáîòêà çàãðóçêè áîëüøîãî êîëè÷åñòâå áèáëèîòåê. Òàê æå, áîëüøå èíôîðìàöèè ìîæíî ïîëó÷èòü ïîñëå îáðàáîòêè ïàêåòà. Òàê, ïðè ïàêåòíîé îáðàáîòêå ïîëó÷àåì êîä âîçâðàòà, êîòîðûé ñîäåðæèò 2 òèïà êîäîâ îøèáîê:
|
|
Íå íàøëè ëèáó
|
|
Íå ñìîãëè èìïîðòèðîâàòü ôóíêöèè.
|
|
|
|
B:
|
|
sys_load_libraries
|
|
load_libraries
|
|
|
|
Äëÿ ìàêðîñîâ ãðóïïû B íåîáõîäèìî â êà÷åñòâå ïàðàìåòðîâ óêàçàòü ñëåäóþùèå îïöèè:
|
|
íà÷àëî áëîêà äàííûõ ñòðóêòóð è êîíåö load_libraries l_libs_start,end_l_libs, ãäå
|
|
|
|
l_libs_start:
|
|
library01 l_libs boxlib_name, path, file_name, system_dir, \
|
|
er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
|
|
|
|
library02 l_libs plugin_BMP_name, path, file_name, system_dir1,\
|
|
er_message_found_lib2, ihead_f_l, myimport, er_message_import2, ihead_f_i
|
|
end_l_libs:
|
|
|
|
Âîò òàêàÿ çàïèñü
|
|
library01 l_libs boxlib_name, path, file_name, system_dir, \
|
|
er_message_found_lib, ihead_f_l, myimport, er_message_import, ihead_f_i
|
|
ðàñêðûâàåòñÿ â ñëåäóþùåå:
|
|
|
|
.library_name dd library_name
|
|
.cur_dir_path dd cur_dir_path
|
|
.library_path dd library_path
|
|
.system_path dd system_path
|
|
.err_message_found_lib dd err_message_found_lib
|
|
.head_f_l dd head_f_l
|
|
.my_import dd my_import
|
|
.err_message_import dd err_message_import
|
|
.head_f_i dd head_f_i
|
|
;âûøå ïîëíîñòüþ ñîîòâåòñòâóåò çíà÷åíèÿì äëÿ ïàðàìåòðîâ ãðóïïû ìàêðîñîâ À.
|
|
.adr_load_lib dd 0x0 ; àäðåñ çàãðóæåííîé áèáëèîòåêè
|
|
.status_lib dd 0x0 ;status of load library - ñòàòóñ êîäû ìîãóò ïðèíèìàòü çíà÷åíèå 0 - óñïåøíî, 0õ1 - îøèáêà ïîèñêà áèáëèîòåêè, 0õ2 - îøèáêà èìïîðòà ôóíêöèé.
|
|
|
|
Åñëè íóæíî óçíàòü ïðîãðàììå, êàê çàãðóçèëàñü áèáëèîòåêà, èñïîëüçóåì ñëåäóþùóþ ïðîâåðêó:
|
|
|
|
;ïðîâåðêà íà ñêîëüêî óäà÷íî çàãðóçèëàñü íàøà áèáëèîòåêà
|
|
mov ebp,library01 - ìåòêà ñòðóêòóðû
|
|
cmp dword [ebp+ll_struc_size-4],0 ; òóò ïðîâåðÿåì êîä ñòàòóñà âîçâðàòà
|
|
jnz exit ;åñëè íå 0, òî óõîäèì.
|
|
|
|
|
|
;ïîëó÷åíèå àäðåñà çàãðóæåííîé áèáëèîòåêè
|
|
mov ebp,library01 - ìåòêà ñòðóêòóðû
|
|
cmp dword [ebp+ll_struc_size-4],0 ; òóò ïðîâåðÿåì êîä ñòàòóñà âîçâðàòà
|
|
jnz exit ;åñëè íå 0, òî óõîäèì.
|
|
mov ebp, dword [ebp+ll_struc_size-8] - â ebp àäðåñ íà÷àëà.
|
|
|
|
Ìàêîðîñ @use_library
|
|
|
|
Ýòîò ìàêðîñ ïðåäñòàâëÿåò âûçûâàåìûå ïðîöåäóðû, êîòîðûå èñïîëüçóþòñÿ äëÿ ðàáîòû ãðóïï ìàêðîñîâ À è B. Äàííûé ìàêðîñ ðàñïîëàãàåòñÿ â ñåêöèè äàòà. Èñïîëüçîâàíèå äàííîãî ìàêðîñà íóæíî äëÿ çàãðóçêè áèáëèîòåê íî åãî ìîæíî çàìåíÿòü íà @use_library_mem.
|
|
|
|
|
|
Ìàêîðîñ @use_library_mem mem_alloc,mem_free,mem_realloc,dll_load
|
|
|
|
Ýòîò ìàêðîñ èñïîëüçóåò ìàêðîñ @use_library, íî â îòëè÷èå îò íåãî îí ïîçâîëÿåò äëÿ ôóíêöèé ñ èìåíàìè 'lib_init' çàäàâàòü 4 ïàðàìåòðà.  äàíûõ ïàðàìåòðàõ ìîãóò áûòü óêàçàòåëè íà ôóíêöèè äëÿ ðàáîòû ñ ïàìÿòüþ, êîòîðûå ìîãóò áûòü íóæíû äëÿ èñïîëüçîâàíèÿ âíóòðè áèáëèîòåêè.
|
|
|
|
|
|
Êàê ÿ ìîãó èñïîëüçîâàòü ìàêðîñ çàãðóçêè áèáëèîòåêè/áèáëèîòåê â ñâîåé ïðîãðàììå?
|
|
|
|
Îáùèé øàáëîí äëÿ èñïîëüçîâàíèÿ áèáëèîòåêè òàêîé:
|
|
|
|
use32 ; òðàíñëÿòîð, èñïîëüçóþùèé 32 ðàçðÿäíûõ êîìàíäû
|
|
org 0x0 ; áàçîâûé àäðåñ êîäà, âñåãäà 0x0
|
|
db 'MENUET01' ; èäåíòèôèêàòîð èñïîëíÿåìîãî ôàéëà (8 áàéò)
|
|
dd 0x1 ; âåðñèÿ ôîðìàòà çàãîëîâêà èñïîëíÿåìîãî ôàéëà
|
|
dd start ; àäðåñ, íà êîòîðûé ñèñòåìà ïåðåäà¸ò óïðàâëåíèå
|
|
; ïîñëå çàãðóçêè ïðèëîæåíèÿ â ïàìÿòü
|
|
dd i_end ; ðàçìåð ïðèëîæåíèÿ
|
|
dd mem ; Îáúåì èñïîëüçóåìîé ïàìÿòè, äëÿ ñòåêà îòâåäåì 0õ100 áàéò è âûðîâíèì íà ãðíèöó 4 áàéòà
|
|
dd mem ; ðàñïîëîæèì ïîçèöèþ ñòåêà â îáëàñòè ïàìÿòè, ñðàçó çà òåëîì ïðîãðàììû. Âåðøèíà ñòåêà â äèàïàçîíå ïàìÿòè, óêàçàííîì âûøå
|
|
dd 0x0 ; óêàçàòåëü íà ñòðîêó ñ ïàðàìåòðàìè.
|
|
dd cur_dir_path
|
|
include 'macros.inc'
|
|
include 'box_lib.mac'
|
|
include 'load_lib.mac'
|
|
@use_library ;use load lib macros
|
|
start:
|
|
;universal load library/librarys
|
|
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
|
|
;if return code =-1 then exit, else nornary work
|
|
cmp eax,-1
|
|
jz exit
|
|
mcall 40,0x27 ;óñòàíîâèòü ìàñêó äëÿ îæèäàåìûõ ñîáûòèé
|
|
red_win:
|
|
call draw_window ;ïåðâîíà÷àëüíî íåîáõîäèìî íàðèñîâàòü îêíî
|
|
align 4
|
|
still: ;îñíîâíîé îáðàáîò÷èê
|
|
mcall 10 ;Îæèäàòü ñîáûòèÿ
|
|
dec eax
|
|
jz red_win
|
|
dec eax
|
|
jz key
|
|
dec eax
|
|
jz button
|
|
|
|
push dword edit1
|
|
call [edit_box_mouse]
|
|
|
|
push dword edit2
|
|
call [edit_box_mouse]
|
|
|
|
push dword check1
|
|
call [check_box_mouse]
|
|
|
|
push dword check2
|
|
call [check_box_mouse]
|
|
|
|
push dword Option_boxs
|
|
call [option_box_mouse]
|
|
|
|
push dword Option_boxs2
|
|
call [option_box_mouse]
|
|
|
|
jmp still ;åñëè íè÷åãî èç ïåðå÷èñëåííîãî òî ñíîâà â öèêë
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
button:
|
|
mcall 17 ;ïîëó÷èòü èäåíòèôèêàòîð íàæàòîé êëàâèøè
|
|
test ah,ah ;åñëè â ah 0, òî ïåðåéòè íà îáðàáîò÷èê ñîáûòèé still
|
|
jz still
|
|
exit: mcall -1
|
|
key:
|
|
mcall 2 ;çàãðóçèì çíà÷åíèå 2 â ðåãèñòîð eax è ïîëó÷èì êîä íàæàòîé êëàâèøè
|
|
|
|
push dword edit1
|
|
call [edit_box_key]
|
|
|
|
push dword edit2
|
|
call [edit_box_key]
|
|
|
|
jmp still
|
|
|
|
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
align 4
|
|
draw_window: ;ðèñîâàíèå îêíà ïðèëîæåíèÿ
|
|
mcall 12,1
|
|
mcall 0,(50*65536+390),(30*65536+200),0x33AABBCC,0x805080DD,hed
|
|
|
|
push dword edit1
|
|
call [edit_box_draw]
|
|
|
|
push dword edit2
|
|
call [edit_box_draw]
|
|
|
|
push dword check1
|
|
call [check_box_draw]
|
|
|
|
push dword check2
|
|
call [check_box_draw]
|
|
|
|
push dword Option_boxs
|
|
call [option_box_draw]
|
|
|
|
push dword Option_boxs2
|
|
call [option_box_draw]
|
|
|
|
mcall 12,2
|
|
ret
|
|
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
|
|
;DATA äàííûå
|
|
;Âñåãäà ñîáëþäàòü ïîñëåäîâàòåëüíîñòü â èìåíè.
|
|
system_path db '/sys/lib/'
|
|
library_name db 'box_lib.obj',0
|
|
; Åñëè åñòü æåëàíèå ðàçúåäèíèòü, òî íóæíî èñïîëüçîâàòü ñëåäóþùèþ êîíñòðóêöèþ
|
|
;system_path db '/sys/lib/box_lib.obj',0
|
|
;... ëþáàÿ ïîñëåäîâàòåëüíîñòü äðóãèõ êîìàíä è îïðåäåëåíèé.
|
|
;library_name db 'box_lib.obj',0
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
|
|
err_message_found_lib db 'Sorry I cannot load library box_lib.obj',0
|
|
head_f_i:
|
|
head_f_l db 'System error',0
|
|
err_message_import db 'Error on load import library box_lib.obj',0
|
|
|
|
myimport:
|
|
|
|
edit_box_draw dd aEdit_box_draw
|
|
edit_box_key dd aEdit_box_key
|
|
edit_box_mouse dd aEdit_box_mouse
|
|
version_ed dd aVersion_ed
|
|
|
|
check_box_draw dd aCheck_box_draw
|
|
check_box_mouse dd aCheck_box_mouse
|
|
version_ch dd aVersion_ch
|
|
|
|
option_box_draw dd aOption_box_draw
|
|
option_box_mouse dd aOption_box_mouse
|
|
version_op dd aVersion_op
|
|
|
|
dd 0
|
|
dd 0
|
|
|
|
aEdit_box_draw db 'edit_box',0
|
|
aEdit_box_key db 'edit_box_key',0
|
|
aEdit_box_mouse db 'edit_box_mouse',0
|
|
aVersion_ed db 'version_ed',0
|
|
|
|
aCheck_box_draw db 'check_box_draw',0
|
|
aCheck_box_mouse db 'check_box_mouse',0
|
|
aVersion_ch db 'version_ch',0
|
|
|
|
aOption_box_draw db 'option_box_draw',0
|
|
aOption_box_mouse db 'option_box_mouse',0
|
|
aVersion_op db 'version_op',0
|
|
|
|
|
|
|
|
|
|
check1 check_box 10,45,6,12,0x80AABBCC,0,0,check_text,14,ch_flag_en
|
|
check2 check_box 10,60,6,12,0x80AABBCC,0,0,check_text2,15
|
|
|
|
edit1 edit_box 350,3,5,0xffffff,0x6f9480,0,0xAABBCC,0,308,hed,ed_focus,hed_end-hed-1,hed_end-hed-1
|
|
edit2 edit_box 350,3,25,0xffffff,0x6a9480,0,0,0,99,ed_buffer,ed_figure_only
|
|
|
|
op1 option_box option_group1,10,90,6,12,0xffffff,0,0,op_text.1,op_text.e1-op_text.1
|
|
op2 option_box option_group1,10,105,6,12,0xFFFFFF,0,0,op_text.2,op_text.e2-op_text.2
|
|
op3 option_box option_group1,10,120,6,12,0xffffff,0,0,op_text.3,op_text.e3-op_text.3
|
|
op11 option_box option_group2,120,90,6,12,0xffffff,0,0,op_text.1,op_text.e1-op_text.1
|
|
op12 option_box option_group2,120,105,6,12,0xffffff,0,0,op_text.2,op_text.e2-op_text.2
|
|
op13 option_box option_group2,120,120,6,12,0xffffff,0,0,op_text.3,op_text.e3-op_text.3
|
|
|
|
option_group1 dd op1 ;óêàçàòåëè, îíè îòîáðàæàþòñÿ ïî óìîë÷àíèþ, êîãäà âûâîäèòñÿ
|
|
option_group2 dd op12 ;ïðèëîæåíèå
|
|
Option_boxs dd op1,op2,op3,0
|
|
Option_boxs2 dd op11,op12,op13,0
|
|
hed db 'BOXs load from lib <Lrz> date 27.04.2009',0
|
|
hed_end:
|
|
rb 256
|
|
check_text db 'First checkbox'
|
|
check_text2 db 'Second checkbox'
|
|
op_text: ; Ñîïðîâîæäàþùèé òåêñò äëÿ ÷åê áîêñîâ
|
|
.1 db 'Option_Box #1'
|
|
.e1:
|
|
.2 db 'Option_Box #2'
|
|
.e2:
|
|
.3 db 'Option_Box #3'
|
|
.e3:
|
|
ed_buffer rb 100
|
|
;-----------------------
|
|
;sc system_colors
|
|
p_info process_information
|
|
cur_dir_path rb 4096
|
|
library_path rb 4096
|
|
i_end:
|
|
rb 1024
|
|
mem: |