Subversion Repositories Kolibri OS

Rev

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

  1.  
  2.  
  3. SC_OK   = 0
  4. SC_EXIT = 1
  5. SC_PUTC = 2
  6. SC_PUTS = 3
  7. SC_GETC = 4
  8. SC_GETS = 5
  9. SC_CLS  = 6
  10.  
  11. SHM_WRITE =  0x01
  12. SHM_OPEN_ALWAYS = 0x04
  13.  
  14. ;============================
  15.  
  16. align 4
  17. sc_name    rb 64
  18. sc_pid     dd 0
  19. sc_buffer  dd 0
  20. sc_process dd 0
  21.  
  22. ;============================
  23.  
  24. align 4
  25. _sc_pid2name:
  26.  
  27.  push esp
  28.  push ebx
  29.  
  30.  xor ecx, ecx
  31.  mov eax, [sc_pid]
  32.  mov ebx, 10
  33. @@:
  34.  xor edx, edx
  35.  div ebx
  36.  push edx
  37.  inc ecx
  38.  test eax, eax
  39.  jnz @b
  40.  
  41. mov edi, sc_name
  42.  
  43. @@:
  44.  pop eax
  45.  add al, '0'
  46.  stosb
  47.  loop @b
  48.  
  49.  
  50.  mov al, '-'
  51.  stosb
  52.  mov al, 'S'
  53.  stosb
  54.  mov al, 'H'
  55.  stosb
  56.  mov al, 'E'
  57.  stosb
  58.  mov al, 'L'
  59.  stosb
  60.  mov al, 'L'
  61.  stosb
  62.  mov al,  0
  63.  stosb
  64.  
  65.  
  66.  pop ebx
  67.  pop esp
  68.  
  69.  ret
  70.  
  71. ;============================
  72.  
  73. align 4
  74. ; void __stdcall sc_init();
  75. _sc_init:
  76.  
  77.  push esp
  78.  push ebx
  79.  
  80.  mov eax, 68
  81.  mov ebx, 11
  82.  int 0x40
  83.  
  84.  mov eax, 68 ; ¢ë¤¥«¨âì ¯ ¬ïâì
  85.  mov ebx, 12
  86.  mov ecx, 1024
  87.  int 0x40
  88.  
  89.  mov [sc_process], eax
  90.  
  91.  mov eax, 9 ; ¯®«ãç¨âì ¨­ä®à¬ æ¨î ® ⥪ã饬 ¯à®æ¥áá¥
  92.  mov ebx, [sc_process]
  93.  mov ecx, -1
  94.  int 0x40
  95.  
  96.  mov dword eax, [ebx+30] ; ¯®«ãç ¥¬ PID ⥪饣® ¯à®æ¥áá 
  97.  mov [sc_pid], eax
  98.  
  99.  mov eax, 68 ; ®á¢®¡®¤¨âì ¯ ¬ïâì
  100.  mov ebx, 13
  101.  mov ecx, [sc_process]
  102.  int 0x40
  103.  
  104.  call _sc_pid2name
  105.  
  106.  mov eax, 68 ; ®âªàëâì ¨¬¥­®¢ ­­ãî ®¡« áâì
  107.  mov ebx, 22
  108.  mov dword ecx, sc_name
  109.  mov edx, 4096
  110.  mov esi, SHM_OPEN_ALWAYS or SHM_WRITE
  111.  int 0x40
  112.  
  113.  mov [sc_buffer], eax
  114.  
  115.  pop ebx
  116.  pop esp
  117.  
  118.  ret
  119.  
  120. ;============================
  121.  
  122. align 4
  123. ; void __stdcall sc_puts(char *str);
  124. _sc_puts:
  125.  
  126.  push esp
  127.  push ebx
  128.  
  129.  mov esi, [esp+12]
  130.  mov edi, [sc_buffer]
  131.  mov al, SC_PUTS
  132.  stosb
  133.  
  134. @@:
  135.  lodsb
  136.  stosb
  137.  test al, al
  138.  jnz @b
  139.  
  140.  mov ebx, [sc_buffer]
  141.  
  142. @@:
  143.  mov byte dl, [ebx]
  144.  test dl, dl
  145.  jz @f
  146.  push ebx
  147.  mov eax, 5
  148.  mov ebx, 5
  149.  int 0x40
  150.  pop ebx
  151.  jmp @b
  152.  
  153. @@:
  154.  
  155.  pop ebx
  156.  pop esp
  157.  ret 4
  158.  
  159. ;============================
  160.  
  161. align 4
  162. ; void __stdcall sc_exit();
  163. _sc_exit:
  164.  push ebx
  165.  push esp
  166.  
  167.  mov ebx, [sc_buffer]
  168.  mov byte [ebx], SC_EXIT
  169.  
  170. @@:
  171.  mov byte dl, [ebx]
  172.  test dl, dl
  173.  jz @f
  174.  push ebx
  175.  mov eax, 5
  176.  mov ebx, 5
  177.  int 0x40
  178.  pop ebx
  179.  jmp @b
  180.  
  181. @@:
  182.  mov eax, 68 ;§ ªàëâì ¨¬¥­®¢ ­­ãî ®¡« áâì
  183.  mov ebx, 23
  184.  mov dword ecx, sc_name
  185.  int 0x40
  186.  
  187.  pop esp
  188.  pop ebx
  189.  ret
  190.  
  191.  
  192. ;============================
  193.  
  194. align 4
  195. ; void __stdcall sc_gets(char *str);
  196. _sc_gets:
  197.  
  198.  push esp
  199.  push ebx
  200.  
  201.  mov edi, [esp+12]
  202.  
  203.  mov ebx, [sc_buffer]
  204.  mov byte [ebx], SC_GETS
  205.  
  206. @@:
  207.  mov byte dl, [ebx]
  208.  test dl, dl
  209.  jz @f
  210.  push ebx
  211.  mov eax, 5
  212.  mov ebx, 5
  213.  int 0x40
  214.  pop ebx
  215.  jmp @b
  216.  
  217. @@:
  218.  
  219.  
  220.  mov esi, [sc_buffer]
  221.  inc esi
  222.  
  223. @@:
  224.  lodsb
  225.  stosb
  226.  test al, al
  227.  jnz @b
  228.  
  229.  pop ebx
  230.  pop esp
  231.  ret 4
  232.  
  233. ;============================
  234.  
  235.