Subversion Repositories Kolibri OS

Rev

Rev 4480 | Rev 4673 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4480 Rev 4672
Line 4... Line 4...
4
;   See f63
4
;   See f63
5
;
5
;
6
;   Compile with FASM for Menuet
6
;   Compile with FASM for Menuet
7
;
7
;
8
WRITE_LOG  equ 1
8
WRITE_LOG    equ 1
9
 
9
P_LEN		 equ 11
10
include 'lang.inc'
10
include 'lang.inc'
Line 11... Line 11...
11
 
11
 
12
   use32
12
   use32
13
   org	  0x0
13
   org	  0x0
Line 23... Line 23...
23
purge newline
23
purge newline
24
MAXSTRINGS = 16
24
MAXSTRINGS = 16
25
TMP = 80*(MAXSTRINGS+1)
25
TMP = 80*(MAXSTRINGS+1)
26
;------------------------------------------------------------------------------
26
;------------------------------------------------------------------------------
27
START:				; start of execution
27
START:				; start of execution
-
 
28
 
-
 
29
	call CheckUnique
-
 
30
 
28
	mov	edi,filename
31
	mov	edi,filename
29
	cmp	[edi],byte 0
32
	cmp	[edi],byte 0
30
	jnz	param
33
	jnz	param
31
	mov	esi,default_filename
34
	mov	esi,default_filename
32
@@:
35
@@:
Line 309... Line 312...
309
	jz	.out
312
	jz	.out
310
	stc
313
	stc
311
.out:
314
.out:
312
	pop      ebx
315
	pop      ebx
313
	ret
316
	ret
-
 
317
 
-
 
318
;-------------------------------------------------
-
 
319
;********************************************
-
 
320
;*  input:  esi = pointer to string         *
-
 
321
;*          edi = pointer to string         *
-
 
322
;*          ecx = data length               *
-
 
323
;********************************************
-
 
324
StrCmp:
-
 
325
	repe cmpsb
-
 
326
	ja .a_greater_b
-
 
327
	jb .a_less_b
-
 
328
.equal:
-
 
329
	mov eax, 0
-
 
330
	jmp .end
-
 
331
.a_less_b:
-
 
332
	mov eax, 1
-
 
333
	jmp .end
-
 
334
.a_greater_b:
-
 
335
	mov eax, -1
-
 
336
.end:
-
 
337
	ret
-
 
338
 
-
 
339
;-------------------------------------------------
-
 
340
;********************************************
-
 
341
;*  input:  edi = pointer to string         *
-
 
342
;*          ecx = data length			    *
-
 
343
;********************************************
-
 
344
; 'a' - 'A' = 32 -> 'A'|32 = 'a'
-
 
345
ToLower:
-
 
346
	xor eax, eax
-
 
347
.cycle:
-
 
348
	or byte[edi+eax], 32
-
 
349
	inc eax
-
 
350
	loop .cycle
-
 
351
.end:
-
 
352
	ret
-
 
353
 
-
 
354
 
-
 
355
;-------------------------------------------------
-
 
356
CheckUnique:
-
 
357
;get info on current thread, save pid/tid
-
 
358
;look for another process with same name and different pid/tid
-
 
359
;if found, close self
-
 
360
;else continue normally
-
 
361
 
-
 
362
.get_thread_info:
-
 
363
	mov ebx, procinfo
-
 
364
	mov ecx, -1
-
 
365
	mcall 9
-
 
366
.get_pid:
-
 
367
; check_buffer
-
 
368
	mov [process_count], eax
-
 
369
	mov eax, [ebx+process_information.PID]
-
 
370
	mov [pid_tid], eax
-
 
371
	mov ecx, 2
-
 
372
 
-
 
373
.check_threads:
-
 
374
	cmp ecx, [process_count]
-
 
375
	ja .leave_check
-
 
376
	mov eax, 9
-
 
377
	mcall
-
 
378
 
-
 
379
.check_slot_free:
-
 
380
	cmp dword [ebx+process_information.slot_state], 9
-
 
381
	je .next_thread
-
 
382
 
-
 
383
.check_pid:
-
 
384
	mov eax, [pid_tid]
-
 
385
	cmp [ebx+process_information.PID], eax
-
 
386
	je .next_thread
-
 
387
 
-
 
388
.get_proc_name:
-
 
389
	lea edi, [ebx+process_information.process_name]
-
 
390
	push ecx
-
 
391
	mov ecx, my_name_size-1
-
 
392
.lower_case:
-
 
393
	call ToLower
-
 
394
	lea esi, [my_name]
-
 
395
 
-
 
396
	mov ecx, my_name_size
-
 
397
	call StrCmp
-
 
398
 
-
 
399
	pop ecx
-
 
400
 
-
 
401
	cmp eax, 0
-
 
402
	je .close_program
-
 
403
 
-
 
404
.next_thread:
-
 
405
	inc ecx
-
 
406
	jmp .check_threads
-
 
407
 
-
 
408
.close_program:
-
 
409
	mov eax, -1
-
 
410
	mcall
-
 
411
 
-
 
412
.leave_check:
-
 
413
	ret
-
 
414
 
-
 
415
 
-
 
416
 
314
;--------------------------------------------------
417
;--------------------------------------------------
315
InfoStructure:
418
InfoStructure:
316
	dd 0x0	; subfunction number
419
	dd 0x0	; subfunction number
317
	dd 0x0	; position in the file in bytes
420
	dd 0x0	; position in the file in bytes
318
	dd 0x0	; upper part of the position address
421
	dd 0x0	; upper part of the position address
Line 341... Line 444...
341
 title	db 'General debug & message board',0
444
 title	db 'General debug & message board',0
342
end if
445
end if
343
krnl_cnt	dd 0
446
krnl_cnt	dd 0
344
vmode		dd 1
447
vmode		dd 1
345
targ		dd text2
448
targ		dd text2
-
 
449
 
-
 
450
my_name 	   db 'board',0
-
 
451
my_name_size   = $-my_name
-
 
452
process_count  dd 0x0
-
 
453
pid_tid		   dd 0x0
346
;------------------------------------------------------------------------------
454
;------------------------------------------------------------------------------
347
I_END:
455
I_END:
348
;------------------------------------------------------------------------------
456
;------------------------------------------------------------------------------
349
offs	dd ?
457
offs	dd ?
350
flag	rb 1
458
flag	rb 1