Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. reading a memory address using c++

reading a memory address using c++

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancequestion
5 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tervalor
    wrote on last edited by
    #1

    How do you read the value from a memory address using c++ ? do you use pointer or something ?

    A H 2 Replies Last reply
    0
    • T tervalor

      How do you read the value from a memory address using c++ ? do you use pointer or something ?

      A Offline
      A Offline
      Anonymous
      wrote on last edited by
      #2

      What u want exactly? If u looking for actual memory address of your volatile memory then I dont think memory address is shown by your pointer is the actual one. Also u can manipuate data of the memory address of current process in windows at least. If you want actual physical memory address u please look for some windows memory management book.

      1 Reply Last reply
      0
      • T tervalor

        How do you read the value from a memory address using c++ ? do you use pointer or something ?

        H Offline
        H Offline
        humps
        wrote on last edited by
        #3

        You can use the * operator. But you have to tell C++ what sort of data to expect at the address, so it knows what type of variable to create, e.g.: int memoryAddressValue = *((int *)memoryAddress); if you know an int is at the address (which occupies 4 bytes, so this call reads the address and the next 3 addresses). Memory addresses are just bytes or data, so their meaning is open to interpretation ! This call casts the address to a pointer to an integer - (int*)memoryAddress - and then reads the value from memory - * operator. Note: if the process doesn't have access to the address (which usually means the address is not the address of one of its variables on the stack, or is not part of the heap space defined by calling new/malloc etc) then expect an access violation exception. Thanks, Neil Humphreys.

        T 1 Reply Last reply
        0
        • H humps

          You can use the * operator. But you have to tell C++ what sort of data to expect at the address, so it knows what type of variable to create, e.g.: int memoryAddressValue = *((int *)memoryAddress); if you know an int is at the address (which occupies 4 bytes, so this call reads the address and the next 3 addresses). Memory addresses are just bytes or data, so their meaning is open to interpretation ! This call casts the address to a pointer to an integer - (int*)memoryAddress - and then reads the value from memory - * operator. Note: if the process doesn't have access to the address (which usually means the address is not the address of one of its variables on the stack, or is not part of the heap space defined by calling new/malloc etc) then expect an access violation exception. Thanks, Neil Humphreys.

          T Offline
          T Offline
          tervalor
          wrote on last edited by
          #4

          thanks for the swift reply humps. I could understand your explaination better than any of those websites out there. Well you know the websites nowadays are providing more junks per piece of useful information. well i think i understand what you mean, and that exactly is what i am trying to do. I am trying to get a vaule from the address of another application. I suppose those address are not part of the heap space defined by my source code. So what am are the alternative now ? * define my source code to include those address ? well i am super confused stucked now i been bombing the internet all night with no avail... No last plea anyone could be kind enough to offer some help to write the souce code in c++ to get the value of a WORD from a memory address finder application -- memware -- the address is 12C71560 and probably 0x12C71560 in c++ ? well fragment of codes or even a clue as to which command would be kind enough.

          G 1 Reply Last reply
          0
          • T tervalor

            thanks for the swift reply humps. I could understand your explaination better than any of those websites out there. Well you know the websites nowadays are providing more junks per piece of useful information. well i think i understand what you mean, and that exactly is what i am trying to do. I am trying to get a vaule from the address of another application. I suppose those address are not part of the heap space defined by my source code. So what am are the alternative now ? * define my source code to include those address ? well i am super confused stucked now i been bombing the internet all night with no avail... No last plea anyone could be kind enough to offer some help to write the souce code in c++ to get the value of a WORD from a memory address finder application -- memware -- the address is 12C71560 and probably 0x12C71560 in c++ ? well fragment of codes or even a clue as to which command would be kind enough.

            G Offline
            G Offline
            Gary R Wheeler
            wrote on last edited by
            #5

            Modern operating systems are designed to prevent exactly the type of access you are attempting. As a rule, each process runs in its own address space, and cannot access the address space of other processes. For example, suppose you have a variable in process A whose address is 12C71560. That address has meaning only inside process A. That same address inside process B only refers to memory that may or may not be allocated to process B. If you are looking to establish communication between two processes, try here[^]. The topic you are looking for is inter-process communication.


            Software Zen: delete this;

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups