-
October 26th, 2009, 06:00 PM
#1
How do I read the value of an address?
I am trying to read the value of memory address using c++.
For example, how can I read the value contained in "00B12318"?
I have tried:
Help with Code Tags
int value;
00B12318 = &value;
cout << value;
But sadly it doesnt work.
Please help! THank you
-
October 26th, 2009, 06:02 PM
#2
Re: How do I read the value of an address?
I am trying to read the value of memory address using c++.
For example, how can I read the value contained in "00B12318"?
I have tried:
int value;
00B12318 = &value;
cout << value;
But sadly it doesnt work.
Please help! THank you
Sorry I dont know how to edit my thread.
-
October 26th, 2009, 07:18 PM
#3
Re: How do I read the value of an address?
Code:
int *value;
value = 0x00B12318;
cout << *value;
Is that what you are trying to do? I don't see why you would want to print out the value of a static memory address.
-
October 26th, 2009, 07:33 PM
#4
Re: How do I read the value of an address?
Originally Posted by Poopynoob
I am trying to read the value of memory address using c++.
For example, how can I read the value contained in "00B12318"?
I have tried:
Help with Code Tags
int value;
00B12318 = &value;
cout << value;
But sadly it doesnt work.
Please help! THank you
That doesn't make sense. You
declare an int but don't assign it a value.
You have this undermined type variable named 00B12318 which isn't a legal C++ variable name, then you assign it the address of your previously defined int.
Then you output the int that you never initialized.
What are you trying to do?
If you want to read the value of a memory address
Code:
int value = 23;
int* pValue = &value;
cout << *pValue;
-
October 27th, 2009, 07:51 AM
#5
Re: How do I read the value of an address?
Originally Posted by GCDEF
What are you trying to do?
If you want to read the value of a memory address
Code:
int value = 23;
int* pValue = &value;
cout << *pValue;
I am a beginner at C++. The "&" operator means "address of" and so hence my pathetic attempt.
I am still not understanding the code. Please explain further with the memory address: 00B12318
Thank you
Last edited by Poopynoob; October 27th, 2009 at 08:05 AM.
-
October 27th, 2009, 07:54 AM
#6
Re: How do I read the value of an address?
Attempt at what? You haven't been very clear on what it is you are trying to accomplish.
-
October 27th, 2009, 09:19 AM
#7
Re: How do I read the value of an address?
Originally Posted by Poopynoob
I am a beginner at C++. The "&" operator means "address of" and so hence my pathetic attempt.
I am still not understanding the code. Please explain further with the memory address: 00B12318
Thank you
You'd have to know what pointed to do know how to interpret it. If you know it's an int
Code:
int* pInt = "0x00B12318";
int nInt = *pInt;
I don't know why you'd ever want to dereference a hardwired address though. Again, what are you trying to do?
-
October 27th, 2009, 09:26 AM
#8
Re: How do I read the value of an address?
Originally Posted by Poopynoob
I am a beginner at C++. The "&" operator means "address of" and so hence my pathetic attempt.
I am still not understanding the code.
Code:
#include <iostream>
using namespace std;
int main()
{
int value = 23;
int* pValue = &value;
cout << *pValue;
}
Which line of the code above do you not understand?
Please explain further with the memory address: 00B12318
What is special to you about memory address 00B12318? The only time you want to manipulate an exact memory address is either you're developing for some hardware device (a driver), or you're trying to hack something at that address.
Regards,
Paul McKenzie
-
October 27th, 2009, 02:40 PM
#9
Re: How do I read the value of an address?
@hoxsiew: As the title says, I am trying to READ the value contained in a memory address, in this case it would be "00B12318". I would rather not reveal what I am trying to accomplish.
@GCDEF: int* pInt = "0x00B12318";
int nInt = *pInt; is not working for me either. (error C2440: 'initializing' : cannot convert from 'const char [11]' to 'int *), of course if I remove the quotes around 0x00B12318 then there would be another error. (cannot convert from 'int' to 'int *')
@Paul: I do not get what the 23 is.
NOTE: 00B12318 is a String (series of letters)
Thanks for all the help guys but it does not solve my problem.
Last edited by Poopynoob; October 27th, 2009 at 02:54 PM.
-
October 27th, 2009, 02:56 PM
#10
Re: How do I read the value of an address?
Originally Posted by Poopynoob
I would rather not reveal what I am trying to accomplish.
Why not? It sounds suspicious to me as to why you want to know what is at a hard-coded address.
Regards,
Paul McKenzie
-
October 27th, 2009, 03:00 PM
#11
Re: How do I read the value of an address?
Originally Posted by Poopynoob
@hoxsiew: As the title says, I am trying to READ the value contained in a memory address
You were told in post #3 how to do it. Did you read it?
Code:
int *value;
value = 0x00B12318;
cout << *value; // *value is the data at that address
Regards,
Paul McKenzie
-
October 27th, 2009, 03:03 PM
#12
Re: How do I read the value of an address?
Originally Posted by Poopynoob
I would rather not reveal what I am trying to accomplish.
Thanks for all the help guys but it does not solve my problem.
Then you probably shouldn't expect any more help.
-
October 27th, 2009, 05:00 PM
#13
Re: How do I read the value of an address?
Alright, I am doing this for a school project. Trying to get a good mark. :P (Although it is not nessesary, nevertheless I might need it later in programming)
@Paul: It gives this error: error C2440: '=' : cannot convert from 'int' to 'int *' when I use the code : int *value;
value = 0x00B12318;
cout << *value; // *value is the data at that address
Thanks for all the help! Appreciate it
-
October 27th, 2009, 05:02 PM
#14
Re: How do I read the value of an address?
You cannot access memory directly. You can do that only using a pointer variable.
Some explanations...
A line like:
v = e;
is an assignment. The '=' sign is the assignment operator. The 'v' must be an l-value and the 'e' must be an r-value.
You can find more about l-values and r-values at http://msdn.microsoft.com/en-us/library/bkbs2cds.aspx
Simply, in your line:
00B12318 = &value;
the 00B12318 is not an l-value, so your line will cause a syntax error.
To do it properly you should use the way suggested by jnmacd (I will use more suggestive variable names):
int* PointerToInt; // declare a pointer to a memory area used to store an integer
PointerToInt = 0x00B12318; // assign the address 0x00B12318 to that pointer
cout << *PointerToInt; // Show the content of the memory address pointed by PointerToInt
Important to know:
If you access memory addresses allocated to your application, that code will work. If you attempt to access memory addresses from the memory space allocated to other applications, the code will fail.
Normally, an application is denied access to the memory used by other applications. There are three reasons for that. The first is to protect the memory of an application from being spoiled by other applications. The second is the security, to prevent one application to spy on another. The third is easy memory management.
There are some special techniques to access the memory allocated to another application, (like dll injection) but frankly, at the level of your knowledge, at this time , you should focus your attention on understanding more basic tasks.
My guess is that you attempt to hack something, that's why you don't want to talk about your intentions. To me it sounds ok, trying that is an excellent way to learn programming. But be aware that the ideas you're trying to use are far from being new. Usually serious programmers will use sophisticated techniques to protect their software, so you will encounter many nasty suprises. Don't expect that you'll find what you're looking for just from readind the memory.
-
October 27th, 2009, 05:11 PM
#15
Re: How do I read the value of an address?
Originally Posted by Poopynoob
Alright, I am doing this for a school project. Trying to get a good mark. :P
I would be very surprised to find out that a technique commonly used for cheating at games would be assigned as a school project. Would you care to name the school and the instructor? I would be happy to write to him/her and explain why this is not a proper assignment for someone just learning to program.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|