470,862 Members | 1,708 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,862 developers. It's quick & easy.

access memory

hi, this might b getting a bit too...low level but how can i check to see if
a certain memory address holds a charge?
--
-iwdu15
Mar 2 '06 #1
3 1101

"iwdu15" wrote:
hi, this might b getting a bit too...low level but how can i check to see if
a certain memory address holds a charge?
--


Are you talking about virtual address (i.e. in a process context) or
physical memory?
physical addresses can only be used in kernel space. The easiest solution is
to use a kernel debugger like WinDbg.

If you want to know the value at a virtual memory address in a process you
can also use a debugger, or do something like:

size_t the_address = 0x123456;
long * ptr = (long*) the_address;
long the_value = *ptr;

of course, since there may not be anything at that virtual address, you have
to use structured exception handling (seh) to make it safe. otherwise you can
crash your program.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 2 '06 #2
sorry for not being clear...i mean like get the value of what stored at a
certain memory address....like if i give 0x123456, then it returns whats
stored at that address
--
-iwdu15
Mar 3 '06 #3
> sorry for not being clear...i mean like get the value of what stored at a
certain memory address....like if i give 0x123456, then it returns whats
stored at that address


That is exactly what my example does:

size_t the_address = 0x123456; //specify a numerical value that
is to be used as an address
long * ptr = (long*) the_address; //declare a pointer that points
to the specified adress
long the_value = *ptr; //read the value that is
stored at that address.

or in shorthand:

long the_value = *(long *) 0x123456;

but you have to use SEH around this to catch possible access violations
because you don't know if you can access that address or not.
This also only works for virtual addresses. if you want to do this with
physical memory there is no choice but to write a kernel driver or use a
kernel debugger.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by James Brown | last post: by
5 posts views Thread by Benny Raymond | last post: by
14 posts views Thread by Greg Copeland | last post: by
10 posts views Thread by WannaKatana | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.