5d420261fb
git-svn-id: svn://kolibrios.org@7389 a494cfbc-eb01-0410-851d-a64ba20cac60
379 lines
9.3 KiB
NASM
379 lines
9.3 KiB
NASM
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; Hot Angles ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
; Compile with FASM
|
|
; Version 0.1: Sep 18, 2018
|
|
|
|
; Copyright (c) 2018, Efremenkov Sergey aka TheOnlyMirage
|
|
; 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.
|
|
|
|
; THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
|
; INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
|
|
; PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
|
; HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
; OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
; --------------------------------------------------------------------------------------
|
|
|
|
format binary as "" ;"kex"
|
|
use32
|
|
org 0x0 ; áàçîâûé àäðåñ ðàçìåùåíèÿ êîäà, âñåãäà 0x0
|
|
|
|
UNLOCKd = 0
|
|
LOCKd = 1
|
|
|
|
; çàãîëîâîê
|
|
db 'MENUET01' ;ìàãè÷åñêèé èäåíòèôèêàòîð
|
|
dd 0x01 ;âåðñèÿ
|
|
dd START_DEBUG ;àäðåñ òî÷êè ñòàðòà ïðîãðàììû
|
|
dd I_END ;àäðåñ êîíöà, ïî ôàêòó ðàçìåð ôàéëà ïðîãðàììû
|
|
dd 0x100000 ;òðåáóåìîå êîë-âî ïàìÿòè äëÿ çàãðóçêè ïðîãðàììû
|
|
dd 0x7fff0 ;íà÷àëüíîå çíà÷åíèå ðåãèñòðà esp - àäðåñ êîíöà îáëàñòè ñòýêà òàê êàê ñòýê ðàñòåò â ñòîðîíó ìåíüøèõ àäðåñîâ
|
|
dd 0, 0 ;àäðåñ ñòðîêè ïàðàìåòðîâ è àäðåñ ñòðîêè ïóòè èñïîëíÿåìîãî ôàéëà
|
|
|
|
|
|
include '../../macros.inc'
|
|
|
|
START_DEBUG:
|
|
call copyKill ;ïðîñòåéøàÿ çàùèòà îò ïîâòîðíîãî çàïóñêà
|
|
mcall 68, 11 ;èíèöèàëèçàöèÿ êó÷è
|
|
call loadConfig ;çàãðóæàåì êîíôèãóðàöèþ ïðèëîæåíèÿ
|
|
mov ebx, 00000100000000000000000000100000b ;ïîäïèñûâàåìñÿ íà èíòåðåñíûå íàì ñîáûòèÿ
|
|
mcall 40
|
|
|
|
START:
|
|
mov eax, 10 ; function 10 : wait until event
|
|
mcall ; event type is returned in eax
|
|
|
|
cmp eax, 6 ;îáðàáîòêà ïåðåìåùåíèé è íàæàòèÿ ìûøè
|
|
je mouse
|
|
|
|
jmp START
|
|
|
|
mouse:
|
|
;îñíîâíîé öèêë ïðîãðàììû
|
|
call get_mouse_pos ;ïîëó÷àåì òåêóùèå êîîðäèíàòû ìûøè
|
|
|
|
cmp eax, 0 ;ëåâûé âåðõíèé óãîë
|
|
jne @f
|
|
; -- çäåñü âûçûâàåì ñîîòâ. âûçîâ äëÿ ëåâîãî âåðõíåãî óãëà (X=0, Y=0)
|
|
push ecx
|
|
mov ecx, 0
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp START ;finish
|
|
@@:
|
|
call get_screen_size ;èíà÷å îáíîâëÿåì ðàçìåðû ýêðàíà
|
|
|
|
cmp ax, word[screen.height] ;Ymouse = Yscreen ?
|
|
je Ytrue
|
|
;åñëè Y íå ðàâíû, òî íàñ èíòåðåñóåò Y=0 è X=ScreenWidth (ïðàâûé âåðõíèé óãîë)
|
|
|
|
cmp ax, 0
|
|
jne unlockend
|
|
shr eax, 16
|
|
cmp ax, word[screen.width]
|
|
jne unlockend
|
|
; -- çäåñü âûçûâàåì äëÿ ïðàâîãî âåðõåíåãî óãëà
|
|
push ecx
|
|
mov ecx, 2
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp START
|
|
Ytrue:
|
|
;åñëè Y ðàâíû, òî íàñ èíòåðåñóåò X=0 (ëåâûé íèæíèé óãîë) èëè X=ScreenWidth (ïðàâûé íèæíèé)
|
|
shr eax, 16
|
|
cmp ax, 0
|
|
jne @f
|
|
; -- X=0, Y = Height (ëåâûé íèæíèé óãîë)
|
|
push ecx
|
|
mov ecx, 1
|
|
call run_command
|
|
pop ecx
|
|
jmp START
|
|
@@:
|
|
cmp ax, word[screen.width]
|
|
jne unlockend
|
|
; -- (ïðàâûé íèæíèé óãîë)
|
|
push ecx
|
|
mov ecx, 3
|
|
call run_command
|
|
pop ecx
|
|
|
|
jmp START
|
|
|
|
unlockend:
|
|
mov byte[state], UNLOCKd
|
|
jmp START
|
|
|
|
|
|
;ñòðóêòóðêà äàííûõ äëÿ õðàíåíèÿ ïàðàìåòðîâ ýêðàíà
|
|
screen:
|
|
.width dw 0
|
|
.height dw 0
|
|
;ïîëó÷èòü ðàçìåð ýêðàíà
|
|
get_screen_size:
|
|
push eax
|
|
mcall 14
|
|
;òåïåðü â eax = [xsize]*65536 + [ysize]
|
|
;mov dword[screen], eax
|
|
mov word[screen.height], ax
|
|
shr eax, 16
|
|
mov word[screen.width], ax
|
|
pop eax
|
|
ret
|
|
|
|
|
|
;ïîëó÷èòü ïîçèöèþ ìûøè
|
|
get_mouse_pos:
|
|
;push eax
|
|
push ebx
|
|
mcall 37, 0
|
|
pop ebx
|
|
;pop eax
|
|
ret
|
|
|
|
|
|
;çàïóñê ïðèëîæåíèÿ: ecx - àêòèâíûé óãîë: lu=0, ld=1, ru=2, rd=3
|
|
run_command:
|
|
cmp byte[state], UNLOCKd
|
|
jne run_command.end
|
|
|
|
push eax
|
|
push ebx
|
|
push ecx
|
|
|
|
|
|
cmp ecx, 0
|
|
jne @f
|
|
mov eax, dword[newData.lu] ;testData.lu
|
|
mov dword[struct70.path_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 1
|
|
jne @f
|
|
mov eax, dword[newData.ld]
|
|
mov dword[struct70.path_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 2
|
|
jne @f
|
|
mov eax, dword[newData.ru]
|
|
mov dword[struct70.path_adr], eax
|
|
jmp .end_set_path
|
|
@@:
|
|
cmp ecx, 3
|
|
jne .end_set_path
|
|
mov eax, dword[newData.rd]
|
|
mov dword[struct70.path_adr], eax
|
|
jmp .end_set_path
|
|
.end_set_path:
|
|
|
|
;ïàðàìåòðû
|
|
;mov dword[struct.adr],
|
|
|
|
;ýòîò êîä çàìåíèòü - åñëè àäðåñ 0, òî íè÷åãî íå äåëàòü
|
|
cmp dword[struct70.path_adr], 0
|
|
jne .next
|
|
mov eax, testData.ld ;
|
|
mov dword[struct70.path_adr], eax
|
|
.next:
|
|
;êîíåö êîäà äëÿ çàìåíû
|
|
|
|
mcall 70, struct70
|
|
mov byte[state], LOCKd
|
|
|
|
pop ecx
|
|
pop ebx
|
|
pop eax
|
|
.end:
|
|
ret
|
|
|
|
struct70: ;Ôîðìàò èíôîðìàöèîííîé ñòðóêòóðû
|
|
.func dd 7 ; íîìåð ïîäôóíêöèè
|
|
.mask dd 0
|
|
.param_adr dd 0 ; óêàçàòåëü íà ASCIIZ-ñòðîêó ñ ïàðàìåòðàìè
|
|
.other dd 0, 0
|
|
.path db 0 ; "/rd/1/TINYPAD",0 ; ïóòü
|
|
.path_adr dd 0 ;testData.lu ;0
|
|
|
|
|
|
state: db 0 ; 0=unlock, 1=lock
|
|
|
|
testData:
|
|
.lu db '/rd/1/SHELL', 0
|
|
.ld db '/rd/1/RUN', 0
|
|
.ru db "/rd/1/TINYPAD", 0
|
|
.rd db '/rd/1/File Managers/EOLITE', 0
|
|
|
|
newData: ;òàáëè÷êà àäðåñîâ êîìàíäíûõ ñòðîê
|
|
.lu dd 0
|
|
.ld dd 0
|
|
.ru dd 0
|
|
.rd dd 0
|
|
newDataEnd:
|
|
|
|
;èìÿ êîíôèãóðàöèîííîãî ôàéëà
|
|
fileName: db 'SETTINGS/HOTANGLES.CFG', 0 ;'ha.cfg', 0
|
|
|
|
loadConfig:
|
|
push eax
|
|
push ebx
|
|
push ecx
|
|
push edx
|
|
mcall 68, 27, fileName ;çàãðóæàåì êîíôèãóðàöèîííûé ôàéë â ÎÇÓ
|
|
cmp eax, 0
|
|
je loadConfig.exit ;åñëè ôàéëà êîíôèãóðàöèè íåò, òî çàâåðøàåì ðàáîòó ïðèëîæåíèÿ
|
|
;èíà÷å äàííûå çàãðóæåíû â ÎÇÓ, ðàçìåð â edx
|
|
cmp edx, 0 ;åñëè ôàéë ïóñò, â í¸ì íåò äàííûõ, òî çàâåðøàåì ðàáîòó
|
|
je loadConfig.exit
|
|
|
|
add edx, eax ;èíà÷å êëàä¸ì â edx - àäðåñ êîíöà ôàéëà
|
|
|
|
cmp byte[eax], 121 ;'y' ;åñëè ïàðàìåòð àêòèâíîñòè ïðèëîæåíèÿ èìååò ñòàòóñ: íå àêòèâíî
|
|
jne loadConfig.exit ;òî çàâåðøàåì ðàáîòó ïðèëîæåíèÿ
|
|
|
|
push edi
|
|
push esi
|
|
; ñîõðàíÿåì â edi óêàçàòåëü íà íà÷àëî òàáëèöû àäðåñîâ íàøèõ êîìàíä
|
|
mov edi, newData
|
|
; ñîõðàíÿåì àäðåñà ñòðîê è äîáàâëÿåì 0 â êîíöå
|
|
mov esi, eax
|
|
.block:
|
|
inc esi
|
|
cmp byte[esi], 10 ;åñëè î÷åðåäíîé êîä ñèìâîëà 10 èëè 13, òî ïðîïóñêàåì ñèìâîëû
|
|
je loadConfig.propusk ;äî ïåðâîãî îòëè÷íîãî îò íèõ
|
|
cmp byte[esi], 13
|
|
je loadConfig.propusk
|
|
|
|
; ñèìâîë îòëè÷åí îò ïåðåíîñà ñòðîêè è âîçâðàòà êàðåòêè - çàïîìèíàåì åãî
|
|
mov dword[edi], esi
|
|
add edi, 4
|
|
|
|
;èä¸ì äî êîíöà ýòîé ñòðîêè: ïîêà íå âñòðåòèì î÷åðåäíîé 10, 13, 0 èëè file end
|
|
.while:
|
|
inc esi
|
|
cmp esi, edx ;òóò áóäåò ïðîáëåìà - òê ôàéë çàêîí÷èëñÿ, à íóëÿ íå áûëî !!! èñïðàâèòü
|
|
jae loadConfig.fileend
|
|
cmp byte[esi], 10
|
|
je loadConfig.ura
|
|
cmp byte[esi], 0
|
|
je loadConfig.ura
|
|
cmp byte[esi], 13
|
|
jne loadConfig.while
|
|
.ura:
|
|
mov byte[esi], 0
|
|
|
|
cmp edi, newDataEnd ;newData.end ;åñëè âñÿ òàáëèöà àäðåñîâ çàïîëíåíà, òî âûõîäèì èç öèêëà
|
|
jb loadConfig.block
|
|
.fileend:
|
|
|
|
pop esi
|
|
pop edi
|
|
|
|
jmp loadConfig.end
|
|
|
|
.propusk:
|
|
mov byte[esi], 0
|
|
jmp loadConfig.block
|
|
.exit:
|
|
pop edx
|
|
pop ecx
|
|
pop ebx
|
|
pop eax
|
|
mcall -1 ;çàêðûòü ýòó ïðîãðàììó
|
|
.end:
|
|
pop edx
|
|
pop ecx
|
|
pop ebx
|
|
pop eax
|
|
ret
|
|
|
|
|
|
|
|
|
|
;Âûíåñòè êîä íèæå â îòäåëüíûé îáùèé ìîäóëü
|
|
selfName db '@HOTANGLES',0
|
|
selfNameSize = 10 ;äî 11 byte
|
|
;
|
|
compareBytes:
|
|
push edi esi ecx ebx
|
|
mov eax, 0 ;xor eax, eax
|
|
mov ecx, selfNameSize ;max ðàçìåð ñòðîê 11
|
|
@@:
|
|
mov bl, byte[edi]
|
|
cmp bl, byte[esi]
|
|
jne compareBytes.no
|
|
inc edi
|
|
inc esi
|
|
cmp ecx, 0
|
|
je @f
|
|
dec ecx
|
|
jmp @b
|
|
.no:
|
|
mov eax, 1
|
|
@@:
|
|
pop ebx ecx esi edi
|
|
ret
|
|
;
|
|
slotMax dd 0
|
|
selfPID dd 0
|
|
buf db 1024 dup(0)
|
|
copyKill:
|
|
push eax ebx ecx esi edi
|
|
|
|
;ñïåðâà ïðî÷ò¸ì ñâîþ èíôîðìàöèþ
|
|
mcall 9, buf, -1
|
|
mov eax, dword[buf+30]
|
|
mov dword[selfPID], eax
|
|
|
|
;óêàçàòåëè, êîòîðûå íèêîãäà íå ìåíÿþòñÿ:
|
|
mov esi, selfName ;ïåðâàÿ ñòðîêà - èìÿ òåêóùåãî ïðèëîæåíèÿ
|
|
mov edi, buf ;âòîðàÿ ñòðîêà - èìÿ òåêóùåãî ñëîòà
|
|
add edi, 10
|
|
|
|
mov ecx, 1
|
|
@@:
|
|
mcall 9, buf, ecx
|
|
mov dword[slotMax], eax
|
|
|
|
;åñëè ýòî ìû ñàìè, òî ïðîïóñêàåì ïðîâåðêó
|
|
mov eax, dword[buf+30]
|
|
cmp eax, dword[selfPID]
|
|
je copyKill.propusk
|
|
|
|
call compareBytes ;ñðàâíèâàåì 11 áàéò ñòðîê, ðåçóëüòàò â eax
|
|
|
|
cmp eax, 0
|
|
je copyKill.selfKill
|
|
|
|
.propusk:
|
|
inc ecx
|
|
cmp ecx, dword[slotMax]
|
|
ja @f
|
|
jmp @b
|
|
|
|
.selfKill:
|
|
pop edi esi ecx ebx eax
|
|
mcall -1
|
|
ret
|
|
@@:
|
|
pop edi esi ecx ebx eax
|
|
ret
|
|
|
|
|
|
|
|
I_END:
|