Subversion Repositories Kolibri OS

Rev

Rev 3545 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;                                                                 ;;
  3. ;; Copyright (C) KolibriOS team 2010-2013. All rights reserved.    ;;
  4. ;; Distributed under terms of the GNU General Public License       ;;
  5. ;;                                                                 ;;
  6. ;;  socketdbg.asm - socket debug utility for KolibriOS             ;;
  7. ;;                                                                 ;;
  8. ;;  Written by hidnplayr@kolibrios.org                             ;;
  9. ;;                                                                 ;;
  10. ;;          GNU GENERAL PUBLIC LICENSE                             ;;
  11. ;;             Version 2, June 1991                                ;;
  12. ;;                                                                 ;;
  13. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  14.  
  15. format binary as ""
  16.  
  17. use32
  18. ; standard header
  19.         db      'MENUET01'      ; signature
  20.         dd      1               ; header version
  21.         dd      start           ; entry point
  22.         dd      i_end           ; initialized size
  23.         dd      mem             ; required memory
  24.         dd      mem             ; stack pointer
  25.         dd      0               ; parameters
  26.         dd      0               ; path
  27.  
  28. ; useful includes
  29. include '../../macros.inc'
  30. purge mov,add,sub
  31. include '../../proc32.inc'
  32. include '../../dll.inc'
  33. include '../../struct.inc'
  34.  
  35. include 'socket.inc'
  36.  
  37. ; entry point
  38. start:
  39.         mcall   40, 0                   ; we dont want any events
  40. ; load libraries
  41.         stdcall dll.Load, @IMPORT
  42.         test    eax, eax
  43.         jnz     exit
  44. ; initialize console
  45.         push    1
  46.         call    [con_start]
  47.         push    title
  48.         push    -1
  49.         push    -1
  50.         push    -1
  51.         push    -1
  52.         call    [con_init]
  53. ; main loop
  54. main:
  55.         mcall   75, 255, 0, socket_list ; get current socket list
  56.  
  57.         call    [con_cls]
  58.  
  59.         mov     esi, socket_list
  60.   .loop:
  61.         lodsd
  62.         test    eax, eax
  63.         jz      .done
  64.  
  65.         mov     ecx, eax
  66.         mcall   75, 255, , socket_buf
  67.  
  68.         pushd   [socket_buf + SOCKET.state]
  69.         pushd   [socket_buf + SOCKET.PID]
  70.         pushd   [socket_buf + SOCKET.Number]
  71.         push    str_sock
  72.         call    [con_printf]
  73.         add     esp, 4
  74.  
  75.         jmp     .loop
  76.  
  77.   .done:
  78.  
  79.         mcall   23, 50
  80.  
  81.         jmp     main
  82.  
  83.  
  84.         push    0
  85.         call    [con_exit]
  86. exit:
  87.         mcall   -1
  88.  
  89. ; data
  90. title           db 'Socket debugger', 0
  91.  
  92. str_sock        db 'Socket=%d PID=%d state=%d', 10, 0
  93.  
  94. ; import
  95. align 4
  96. @IMPORT:
  97.  
  98. library console, 'console.obj'
  99.  
  100. import  console,        \
  101.         con_start,      'START',        \
  102.         con_init,       'con_init',     \
  103.         con_cls,        'con_cls',      \
  104.         con_exit,       'con_exit',     \
  105.         con_printf,     'con_printf'
  106. i_end:
  107.  
  108. socket_list     rd 4096
  109. socket_buf      rd 4096
  110.  
  111. align   4
  112. rb      4096    ; stack
  113. mem:
  114.