Subversion Repositories Kolibri OS

Rev

Rev 3245 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
3245 Albom 1
 
2
 
3
SC_PUTC = 2
4
SC_PUTS = 3
5
SC_GETC = 4
6
SC_GETS = 5
7
SC_CLS	= 6
8
SC_PID = 7
9
SC_PING = 8
8637 Kenshin 10
11
SHM_WRITE =  0x01
3245 Albom 12
 
13
14
;============================
15
 
16
align 4
17
 
18
sc_pid	   dd 0
19
sc_buffer  dd 0
20
sc_process dd 0
21
22
;============================
23
 
24
if used _sc_pid2name
25
 
8637 Kenshin 26
_sc_pid2name:
3245 Albom 27
28
 push esp
29
 
30
31
 xor ecx, ecx
32
 
33
 mov ebx, 10
34
@@:
35
 xor edx, edx
36
 div ebx
37
 push edx
38
 inc ecx
39
 test eax, eax
40
 jnz @b
41
42
mov edi, sc_name
43
 
44
@@:
45
 
46
 add al, '0'
47
 stosb
48
 loop @b
49
50
51
 
52
 
53
 mov al, 'S'
54
 stosb
55
 mov al, 'H'
56
 stosb
57
 mov al, 'E'
58
 stosb
59
 mov al, 'L'
60
 stosb
61
 mov al, 'L'
62
 stosb
63
 mov al,  0
64
 stosb
65
66
67
 
68
 
69
70
 ret
71
 
72
8637 Kenshin 73
;============================
3245 Albom 74
 
75
if used _sc_init
76
 
8637 Kenshin 77
; void __stdcall sc_init();
3245 Albom 78
_sc_init:
79
80
 push esp
81
 
82
83
 mov eax, 68
84
 
85
 int 0x40
86
87
 mov eax, 68 ; выделить память
88
 
89
 mov ecx, 1024
90
 int 0x40
91
92
 mov [sc_process], eax
93
 
94
 mov eax, 9 ; получить информацию о текущем процессе
95
 
96
 mov ecx, -1
97
 int 0x40
98
99
 mov dword eax, [ebx+30] ; получаем PID текщего процесса
100
 
101
102
 mov eax, 68 ; освободить память
103
 
104
 mov ecx, [sc_process]
105
 int 0x40
106
107
 call _sc_pid2name
108
 
109
 mov eax, 68 ; открыть именованную область
110
 
111
 mov dword ecx, sc_name
112
 mov edx, 4096
113
 mov esi, SHM_OPEN_ALWAYS or SHM_WRITE
114
 int 0x40
115
116
 mov [sc_buffer], eax
117
 
118
 pop ebx
119
 
120
121
 ret
122
 
123
8637 Kenshin 124
;============================
3245 Albom 125
 
126
if used _sc_puts
127
 
8637 Kenshin 128
; void __stdcall sc_puts(char *str);
3245 Albom 129
_sc_puts:
130
131
 push esp
132
 
133
134
 mov esi, [esp+12]
135
 
136
 mov al, SC_PUTS
137
 stosb
138
139
@@:
140
 
141
 stosb
142
 test al, al
143
 jnz @b
144
145
 mov ebx, [sc_buffer]
146
 
147
@@:
148
 
149
 test dl, dl
150
 jz @f
151
 push ebx
152
 mov eax, 5
153
 mov ebx, 5
154
 int 0x40
155
 pop ebx
156
 jmp @b
157
158
@@:
159
 
160
 pop ebx
161
 
162
 ret 4
163
end if
164
8637 Kenshin 165
;============================
3245 Albom 166
 
167
if used _sc_exit
168
 
8637 Kenshin 169
; void __stdcall sc_exit();
3245 Albom 170
_sc_exit:
171
 push ebx
172
 push esp
173
174
 mov ebx, [sc_buffer]
175
 
176
177
@@:
178
 
179
 test dl, dl
180
 jz @f
181
 push ebx
182
 mov eax, 5
183
 mov ebx, 5
184
 int 0x40
185
 pop ebx
186
 jmp @b
187
188
@@:
189
 
190
 mov ebx, 23
191
 mov dword ecx, sc_name
192
 int 0x40
193
194
 pop esp
195
 
196
 ret
197
end if
198
8637 Kenshin 199
3245 Albom 200
 
201
 
202
if used _sc_gets
203
 
8637 Kenshin 204
; void __stdcall sc_gets(char *str);
3245 Albom 205
_sc_gets:
206
207
 push esp
208
 
209
210
 mov edi, [esp+12]
211
 
212
 mov ebx, [sc_buffer]
213
 
214
215
@@:
216
 
217
 test dl, dl
218
 jz @f
219
 push ebx
220
 mov eax, 5
221
 mov ebx, 5
222
 int 0x40
223
 pop ebx
224
 jmp @b
225
226
@@:
227
 
228
229
 
230
 
231
232
@@:
233
 
234
 stosb
235
 test al, al
236
 jnz @b
237
238
 pop ebx
239
 
240
 ret 4
241
end if
242
8637 Kenshin 243
;============================
3245 Albom 244
 
245
if used _sc_pid
246
 
8637 Kenshin 247
;int __stdcall sc_pid (void);
248
	push	ebx ecx
249
250
	mov	ecx, [sc_buffer]
251
 
252
253
@@:
254
 
255
	mov	ebx, 5
256
	int	0x40
257
258
	cmp	byte [ecx], 0
259
 
260
	call	_sc_ping
261
	test	eax, eax
262
	jnz	.err
263
264
@@:
265
 
266
	pop	ecx ebx
267
	ret
268
269
.err:
270
 
271
	xor	eax, eax
272
	dec	eax
273
	ret
274
end if
275
276
;============================
277
 
278
if used _sc_ping
279
 
280
;int __stdcall sc_ping (void);
281
	push	ebx ecx
282
283
	mov	ecx, [sc_buffer]
284
 
285
286
	mov	eax, 5
287
 
288
	int	0x40
289
290
	xor	eax, eax
291
 
292
	je	@f
293
	dec	eax
294
295
@@:
296
 
297
	ret
298
end if
299