Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

385
Vistas
replacing one processes esp value with other , to get a local variable

I am trying to copy a current running process esp value to another processes esp, running on another terminal.

I am getting a segmentation fault.

But I can't figure out the reason correctly as I am using inline assembly.

p1.c

int main()
{
    int a=5;
    int b =8;
    unsigned int esp =0;
    asm("mov %%esp,%0":"=r"(esp)::);
    printf("esp:[%x] \n",esp);
    while(1);
}

P2.c

int main()
{
    int a=5;
    int espoth=0;
    asm("mov 0xbfda8008,%%esp"::);
}

First I ran p1.c which gave me 0xbfda8008 current stack pointer. Then I used it in p2.c which gave me Segmentation fault.

I am just writing a value into esp. Why am I getting this fault ? Need a little hint... ;-(

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

This will not work as expected. The memory for each process is isolated from the other processes, and the memory-map each process sees is virtual. So even if two processes both might have memory available at the same address, it does not mean that the actual physical memory is the same.

This is what separates "modern" operating systems and hardware from the "old" ones. You can search about "mmu", "memory protection unit" and "virtual memory" on your favorite search engine.

Your idea would work if playing in good old MS-DOS for instance that did not use the MMU (unless playing with protected mode programs using for instance DOS4GW, GO32-V2)

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda