Files
KOS_qrcodes/programs/system/shell/shell.inc
T
Albom 4ed6be1119 Shell v0.6. See History.txt.
git-svn-id: svn://kolibrios.org@3245 a494cfbc-eb01-0410-851d-a64ba20cac60
2013-02-16 11:25:37 +00:00

235 lines
2.7 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
SC_OK = 0
SC_EXIT = 1
SC_PUTC = 2
SC_PUTS = 3
SC_GETC = 4
SC_GETS = 5
SC_CLS = 6
SHM_WRITE = 0x01
SHM_OPEN_ALWAYS = 0x04
;============================
align 4
sc_name rb 64
sc_pid dd 0
sc_buffer dd 0
sc_process dd 0
;============================
align 4
_sc_pid2name:
push esp
push ebx
xor ecx, ecx
mov eax, [sc_pid]
mov ebx, 10
@@:
xor edx, edx
div ebx
push edx
inc ecx
test eax, eax
jnz @b
mov edi, sc_name
@@:
pop eax
add al, '0'
stosb
loop @b
mov al, '-'
stosb
mov al, 'S'
stosb
mov al, 'H'
stosb
mov al, 'E'
stosb
mov al, 'L'
stosb
mov al, 'L'
stosb
mov al, 0
stosb
pop ebx
pop esp
ret
;============================
align 4
; void __stdcall sc_init();
_sc_init:
push esp
push ebx
mov eax, 68
mov ebx, 11
int 0x40
mov eax, 68 ; ¢ë¤¥«¨âì ¯ ¬ïâì
mov ebx, 12
mov ecx, 1024
int 0x40
mov [sc_process], eax
mov eax, 9 ; ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ⥪ã饬 ¯à®æ¥áá¥
mov ebx, [sc_process]
mov ecx, -1
int 0x40
mov dword eax, [ebx+30] ; ¯®«ãç ¥¬ PID ⥪饣® ¯à®æ¥áá 
mov [sc_pid], eax
mov eax, 68 ; ®á¢®¡®¤¨âì ¯ ¬ïâì
mov ebx, 13
mov ecx, [sc_process]
int 0x40
call _sc_pid2name
mov eax, 68 ; ®âªàëâì ¨¬¥­®¢ ­­ãî ®¡« áâì
mov ebx, 22
mov dword ecx, sc_name
mov edx, 4096
mov esi, SHM_OPEN_ALWAYS or SHM_WRITE
int 0x40
mov [sc_buffer], eax
pop ebx
pop esp
ret
;============================
align 4
; void __stdcall sc_puts(char *str);
_sc_puts:
push esp
push ebx
mov esi, [esp+12]
mov edi, [sc_buffer]
mov al, SC_PUTS
stosb
@@:
lodsb
stosb
test al, al
jnz @b
mov ebx, [sc_buffer]
@@:
mov byte dl, [ebx]
test dl, dl
jz @f
push ebx
mov eax, 5
mov ebx, 5
int 0x40
pop ebx
jmp @b
@@:
pop ebx
pop esp
ret 4
;============================
align 4
; void __stdcall sc_exit();
_sc_exit:
push ebx
push esp
mov ebx, [sc_buffer]
mov byte [ebx], SC_EXIT
@@:
mov byte dl, [ebx]
test dl, dl
jz @f
push ebx
mov eax, 5
mov ebx, 5
int 0x40
pop ebx
jmp @b
@@:
mov eax, 68 ;§ ªàëâì ¨¬¥­®¢ ­­ãî ®¡« áâì
mov ebx, 23
mov dword ecx, sc_name
int 0x40
pop esp
pop ebx
ret
;============================
align 4
; void __stdcall sc_gets(char *str);
_sc_gets:
push esp
push ebx
mov edi, [esp+12]
mov ebx, [sc_buffer]
mov byte [ebx], SC_GETS
@@:
mov byte dl, [ebx]
test dl, dl
jz @f
push ebx
mov eax, 5
mov ebx, 5
int 0x40
pop ebx
jmp @b
@@:
mov esi, [sc_buffer]
inc esi
@@:
lodsb
stosb
test al, al
jnz @b
pop ebx
pop esp
ret 4
;============================