0

Actually, I am working on QNX. Somepoint in the kernel space when one process want to send a message to another process and these both processes are blocked, I can get the values of stack pointer and frame pointer for each process.

Next, I want to access the stack of each process but my problem is that these values (sp and fp) are virtual addresses which are valid in user processes. How could I read words from these user addresses in kernel space?

moorara
  • 3,897
  • 10
  • 47
  • 60
  • Are you trying to get these addresses just so you can pass messages around? Read about QNX IPC if so. http://www.qnx.com/developers/docs/6.4.0/neutrino/sys_arch/ipc.html – kmort Nov 20 '13 at 15:14

1 Answers1

1

Unless you are a kernel developer employed by QNX your code never runs in "kernel space." Only the kernel and process 1 (which QNX calls "proc" and pidin displays as procnto or procnto-instr) run in "kernel space," none of which you are able to modify.

If you want to debug the processes then you can connect to them using gdb and inspect the contents of their memories. You can do this without knowing the physical address of the memory pointed to by the virtual sp.

If you want to read memory from another program then you can do:

fd = open("/proc/PID/as", O_RDONLY);
lseek(fd, virtual_address_to_read, SEEK_SET);
read(fd, buffer, cnt_bytes_to_read);

QNX documents this at the following location: http://www.qnx.com/developers/docs/6.5.0_sp1/index.jsp?topic=%2Fcom.qnx.doc.neutrino_prog%2Fprocess.html&cp=13_7_3_4_1&anchor=Address_space

maverick
  • 436
  • 2
  • 10