Subversion Repositories Kolibri OS

Rev

Rev 3545 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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