Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

394
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda