How to modify EIP's tracee forked procee?
You're not modifying the EIP, you're adding something to the value of the instruction at EIP, and probably resulting in a bad address reference. To change EIP, use PTRACE_SETREGS
wait(NULL);
ptrace(PTRACE_GETREGS, child,NULL, ®s);
printf("\n EIP @ 0x %#lx\n",regs.eip);
regs.eip += ???;
ptrace(PTRACE_SETREGS, child, NULL, ®s);
ptrace(PTRACE_CONT, child, NULL, NULL);
After forking, are global variables shared?
No and yes.
No, they are not shared in any way which is visible to the programmer; the processes can modify their own copies of the variables independently and they will change without any noticable effect on the other process(es) which are fork() parents, siblings or descendents.
But yes, the OS actually does share the pages initially, because fork implements copy-on-write which means that provided none of the processes modifies the pages, they are shared. This is, however, an optimisation which can be ignored.
If you wanted to have shared variables, put them in an anonymous shared mapping (see mmap()) in which case they really will get shared, with all the caveats which come with that.
Related Topics
How to Make .Gitignore Configurable Based on Environment Variables
How Provide Nested Mount of Overlayfs
How to Prevent an X Window from Receiving User Input
Batch Remove Substring from Filename with Special Characters in Bash
Automating Killall Then Killall Level 9
Rust Linux Version Glibc Not Found - Compile for Different Glibc/Libc6 Version
How Does Gdb Start an Assembly Compiled Program and Step One Line at a Time
Is Ethernet Checksum Exposed via Af_Packet
How to Print the Nth (5Th) Line of Every File Preceded by the Filename Using Any Linux Tool
Sed: Matching on 2 Patterns on the Same Line
Wget: Unsupported Scheme on Non-Http Url
Difference Between Source and ./ Execution of Linux Scripts
Comparison of Cat Pipe Awk Operation to Awk Command on a File
Jupyter Lab - Suppress Console Output
Executable Object Files and Virtual Memory
Start Docker-Compose Automatically on Ec2 Startup
How to Fix Numpy Dependencies Path on a Python 3.7.3 Script on Linux Frozen with Cx_Freeze 6.0B1