Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2004
    Location
    Scotland
    Posts
    17,702
    Tokens
    60,948
    Habbo
    Habbic

    Latest Awards:

    Default memory address c++

    is it possible given an address that using c++ you can find the value in that address?

    i know you can get pointers to get memory address of a variable, but is that possible?

  2. #2
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Yes you can but why do you want to do this? If the address is invalid or the OS does not want you to access that address then you're going to get an access violation on windows or segmentation violation on linux.

  3. #3
    Join Date
    Jul 2004
    Location
    Scotland
    Posts
    17,702
    Tokens
    60,948
    Habbo
    Habbic

    Latest Awards:

    Default

    Can you access any memory address on linux, or only ones used by that program?

    And it's for educational purposes, but i've never used C++ so before learning C++ need to know it's possible

  4. #4
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    If its for educational purposes then don't do it. Unless you're doing some embedded stuff then you'll find modern operating systems use virtual memory management so each process is going to have its own virtual address space. This means you can't access other process' memory directly (obvious security implications..).

    In Windows you can access memory from another process by using the ReadProcessMemory and WriteProcessMemory API functions. The application must be running as an administrator for this to work (technically, you need PROCESS_VM_READ and PROCESS_VM_WRITE repetitively for the process you're trying to access)

    Linux is a bit different. You can access physical memory by using /dev/mem and you'll find process memory mappings in /proc/<pid>/maps . However, depending on how the linux kernel was compiled and any other security measures in place you might find that access to /dev/mem is seriously restricted. For example you can deny userspace access (so that include userspace applications running as root) to all physical memory except peripherals.

    The only reason I could think of that you would need to access memory like this is if you were writing some debugging stuff, drivers/low level stuff or implementing some shady software (viruses or hacks/cheats for games) so I'm not sure what educational need this kind of thing serves

    Quote Originally Posted by scottish View Post
    Can you access any memory address on linux, or only ones used by that program?

    And it's for educational purposes, but i've never used C++ so before learning C++ need to know it's possible

  5. #5
    Join Date
    Jun 2005
    Location
    /dev/null
    Posts
    4,918
    Tokens
    126

    Latest Awards:

    Default

    Are you talking about accessing memory that hasn't been allocated by the program you're writing? If so then what Tomm has said applies. Otherwise just use the * operator to dereference a pointer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •