Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

383
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!