🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #16069

Re: Retardo en juego

#16069
From: batsman
Date: Wed, 10 May 2000 00:00
95 lines
4191 bytes
-----BEGIN PGP SIGNED MESSAGE-----


    >>>> El 08 May 2000 14:00:40 +0200, iLogik
    >>>> aporre� su teclado, y logr� este curioso efecto:

>>>>>> "batsman" == batsman  <batsman@simpsons.for.ever> writes:
>
>    batsman> Pero s� que tienes acceso a la interrupci�n 0x80, para
>    batsman> hacer las llamadas al sistema "a mano".
>
>Pues no lo sabia... yo crei que protegia todas sin excepcion, seguro
>que no es por llamada al sistema?

Es que cuando haces una llamada al sistema, al final se acaba usando la
interrupci�n 0x80 para pasar al modo n�cleo.

Comprobaci�n
============

Cogemos el siguiente programa:

#include <unistd.h>

int main(int argc, char *argv[])
{
	printf("Mi PID es %d\n", getpid());
}

lo compilamos est�ticamente con
[/tmp]$ gcc -static -o tst tst.c
[/tmp]$ ./tst
Mi PID es 1099

Hacemos un objdump --disassemble

Entre otras cosas, tenemos

08048140 <main>:
8048140:       55              pushl  %ebp
8048141:       89 e5           movl   %esp,%ebp
8048143:       e8 18 49 00 00  call   804ca60 <__getpid>
8048148:       89 c0           movl   %eax,%eax
804814a:       50              pushl  %eax
804814b:       68 6c 94 05 08  pushl  $0x805946c
8048150:       e8 5b 04 00 00  call   80485b0 <_IO_printf>
8048155:       83 c4 08        addl   $0x8,%esp
8048158:       89 ec           movl   %ebp,%esp
804815a:       5d              popl   %ebp
804815b:       c3              ret
804815c:       90              nop
804815d:       90              nop
804815e:       90              nop
804815f:       90              nop
	       
Y la funci�n getpid, que es la que nos interesa:

0804ca60 <__getpid>:
804ca60:       b8 14 00 00 00  movl   $0x14,%eax
804ca65:       cd 80           int    $0x80
			       ^^^^^^^^^^^^^
Como ves, llama a la interrupci�n 0x80, pasando el n�mero de llamada al
sistema 0x14=20 en eax..

804ca67:       3d 01 f0 ff ff  cmpl   $0xfffff001,%eax
804ca6c:       0f 83 fe 01 00  jae    804cc70 <__syscall_error>
804ca71:       00
804ca72:       c3              ret
804ca73:       90              nop

Este programa se ejecuta sin privilegios particulares y tiene acceso a la
interrupci�n 0x80 para pasar al modo kernel...

- -- 
              _           _                             
             | |__   __ _| |_ ___ _ __ ___   __ _ _ __  
             | '_ \ / _` | __/ __| '_ ` _ \ / _` | '_ \ 
             | |_) | (_| | |_\__ \ | | | | | (_| | | | |
             |_.__/ \__,_|\__|___/_| |_| |_|\__,_|_| |_|

             Real email: batsman dot geo at yahoo dot com

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv
Comment: Public key via email: send mail with Subject: [PGPKEY]

iQEVAwUBORm0Qr0Y27yr0iefAQEXKwf8Dp+qv3fcMpz19AdJO1X5aLFZT9CVndAQ
l0AYgEgZ+Kc/81uEGTMOr4EIcSwCrlfF4yQrR7Qd0fSJhhF61EFDhCU0UxWF+AAm
5E+Cam+ByyE5rScOo3gJxu4nkzIzLpYgULg72Dc0dxPmJjQ/geZvNZ47DWnA9DE4
WanYbWwdpAxTQlpSf8Jz008zckon402uFaxr+1x/rnPZhCxFcQxzAOZkRANuVdXQ
5e3Ld98zt57M0E/j59whz8h0urkaXijqu1RRJ7GUDiasRhiU8QhORNhwinMkJOY2
RwQbfSnQ0A2Sk2iRgdCcWyANLR7FUHuF7vH2L/vLwN9NapSvKvC2Iw==
=g3Kf
-----END PGP SIGNATURE-----
Technical Details
Message-ID: <78ccf8.ps.ln@simpsons4ever>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <8e4sen$4n3$1@talia.mad.ttd.net> <3906FE47.6CB90517@lcc.uma.es> <t3p9e8.dg.ln@debian> <c8ice8.b8.ln@simpsons4ever> <fmcfe8.0v.ln@debian> <390E8907.9088231B@barpimo.com> <87hfcghy0d.fsf@chaos.rpm.org> <h061f8.ik.ln@simpsons4ever> <8766sp9rpz.fsf@chaos.rpm.org>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,38f52171fe384988
X-Google-Attributes: gidf86c8,public
From: batsman@simpsons.for.ever (batsman)
Subject: Re: Retardo en juego
Date: 2000/05/10
Message-ID: <78ccf8.ps.ln@simpsons4ever>
X-Deja-AN: 621732405
Content-Transfer-Encoding: 8bit
References: <8e4sen$4n3$1@talia.mad.ttd.net> <3906FE47.6CB90517@lcc.uma.es> <t3p9e8.dg.ln@debian> <c8ice8.b8.ln@simpsons4ever> <fmcfe8.0v.ln@debian> <390E8907.9088231B@barpimo.com> <87hfcghy0d.fsf@chaos.rpm.org> <h061f8.ik.ln@simpsons4ever> <8766sp9rpz.fsf@chaos.rpm.org>
Content-Type: text/plain; charset=iso-8859-1
X-Complaints-To: abuse@news.wanadoo.es
X-Trace: m2newsread.uni2.es 957992177 62.36.16.174 (Wed, 10 May 2000 22:56:17 MET DST)
Organization: Wanadoo Usenet News - Visita http://www.wanadoo.es/
Mime-Version: 1.0
User-Agent: slrn/0.9.5.3 (UNIX)
Reply-To: see_signature-mira_firma
NNTP-Posting-Date: Wed, 10 May 2000 22:56:17 MET DST
Newsgroups: es.comp.os.linux.programacion