Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

access memory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
iwdu15 - 02 Mar 2006 03:57 GMT
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?
Signature

-iwdu15

Bruno van Dooren - 02 Mar 2006 08:50 GMT
> 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.

Signature

Kind regards,
   Bruno.
  bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"

iwdu15 - 03 Mar 2006 02:11 GMT
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
Signature

-iwdu15

Bruno van Dooren - 03 Mar 2006 07:57 GMT
> 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.

Signature

Kind regards,
   Bruno.
   bruno_nos_pam_van_dooren@hotmail.com
   Remove only "_nos_pam"


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.