Thread: Writing to a specific virtural address???

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    1

    Writing to a specific virtural address???

    Hello all,

    Question: Is there a way to write to a specific virtural address space (or even better, a specific physical address space).

    I am running Solaris 9 (which I know they won't let me write to physical address space directly - because I can only execute program in USER space). So my best best is to write a known value to a known virtural address space.

    If you are wondering why, it is because I am writing a memory checker. I have the physical page I want locked. Now, I am just not sure how to write to it directly.

    -Tony

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Something like this
    Code:
    int *ptr=(int *)0x00; //point to address 0x00
    *ptr=1;//set it to 1
    Of course that example will crash.
    Last edited by Quantum1024; 05-09-2005 at 05:23 PM.

  3. #3
    .
    Join Date
    Nov 2003
    Posts
    307
    If you want to read/write memory that is not part of your process you have to be in kernel mode. Debuggers do this routinely.

    Code:
    /usr/proc/bin/pmap -x <pid>
    will show the physical addresses a process has on Solaris

    I don't know enough Solaris to really help, but the source for the GNU debugger
    is here:

    http://www.gnu.org/software/gdb/gdb.html

    If your version of Solaris supports the ptrace library <sys/ptrace.h>
    then you have a leg up.
    Last edited by jim mcnamara; 05-10-2005 at 04:03 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    > I have the physical page I want locked.
    My guess is whatever routine you called to get that returned an equivalent virtual address.

    Say
    unsigned char *myVirtualAddress = someOsPageLockingFunction( myPhysicalPage );

    myVirtualAddress[0] is therefore the first location of that page.

    Or if you feel like exercising your root powers, try looking at /dev/mem or something.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. import address table (IAT)
    By George2 in forum C++ Programming
    Replies: 5
    Last Post: 02-20-2008, 08:01 AM
  2. help! fifo read problem
    By judoman in forum C Programming
    Replies: 1
    Last Post: 08-16-2004, 09:19 AM
  3. Im so lost at . .
    By hermit in forum C Programming
    Replies: 18
    Last Post: 05-15-2002, 01:26 AM
  4. doubly linked lists
    By cworld in forum C++ Programming
    Replies: 2
    Last Post: 04-21-2002, 09:33 AM
  5. Writing to Specific Locations
    By Spex in forum C Programming
    Replies: 5
    Last Post: 02-14-2002, 10:08 PM