![]() |
|
#1
|
|||
|
|||
How to read particular memory location ?Hi members,
Now a days i was working on a program and i made a big move in it. Now the last stage is that i came up with a memory address and i wanna read the content at that particular address.I have previously asked about reading RAM yes this thread is just the end of my program. I have got the memory location and i simply made a "long int" variable and tried to read that memory location but error in program. Here is my source code. CPP / C++ / C Code:
I think that we can't assign a constant to a pointer. Am I right ? If yes then please tell me how can i read this particular memory location. With love REAL NAPSTER __________________
*Labor omnia consent*** Hardwork conquers all* |
|
#2
|
||||
|
||||
Re: How to read particular memory location ?I am afraid you can not access specific memory addresses, as your Operating system probably does not allow direct access to this resource. See for reference Direct memory access thread.
Best regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#3
|
|||
|
|||
Re: How to read particular memory location ?Oh my God it's a shock to me. I have been working on this project from a long time and when i reached my destiny, The OS sucks.
It's really bad to hear this news.Any more suggestions are welcomed.I really wanna do this at any cost.Please suggest something. with sadness REALNAPSTER __________________
*Labor omnia consent*** Hardwork conquers all* |
|
#4
|
||||
|
||||
Re: How to read particular memory location ?You can use DOS
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#5
|
|||
|
|||
Re: How to read particular memory location ?hi guys,
I used this code to read the memory addresses and i can read only a specific range. CPP / C++ / C Code:
minimum = 2281472 maximum = 2297852 Now i wanna know if i can read this region why i can't read the region that i want ? Actually i wanna read "address : 1613758136". Please tell me what the hell is happening beyond this specific region ? WALTP how can i use DOS to make it possible? please explain........... With happiness REALNAPSTER __________________
*Labor omnia consent*** Hardwork conquers all* |
|
#6
|
||||
|
||||
Re: How to read particular memory location ?Today's operating systems protect memory from being read by programs that don't 'own' the memory. Think virus. You write a program that plays around with memory from another program. What happens to that extremely important Word doc you haven't saved yet when a different program starts messing around with Word's memory? So the new O/S won't let you access any memory but your own.
As for DOS, search for a copy of it. You can load it on a system and there is no protection -- you can look at memory to your heart's content. But be sure to read up on installation and limitations. DOS cannot handle the huge memory and disks we have today. Quote:
__________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#7
|
|||
|
|||
Re: How to read particular memory location ?Quote:
First of all: when your "normal" C (or C++) program is loaded, the operating system gives it a certain region of memory to use for its variables and certain other stuff. If your program asks for memory (malloc(), for example), the operating system can give you some more. (Outside of the original region, probably). If you try to access some memory location outside of your allocated region(s), the program will bomb. That is, memory outside your program space is protected from your program. Can't read; can't write; can't do "squat". If you try to access some arbitrary address that "just happens" to be inside your allocated region (but was not given to explicitly by a variable declaration or other allocation process) the program may do something bad, or not. That's called "undefined behavior" and can give different results for different program runs, depending on what is actually happening with that memory location. Secondly: When the program gives you some memory (whether it is through a variable declaration or from malloc() or whatever), the value of the address that your program sees is not actually a physical address in real memory. If you think of connecting a logic analyzer to the physical address bus in such a way that you could actually track the physical memory accesses as your program runs, you would not see the same addresses as the program is using for its memory operations. Since I'm not sure why you want to access some memory location other than what your are given, I can't say whether your hopes and dreams can lead to something practical; I'm just saying that you can't do it with a "normal" C program by simply giving a pointer a value and then dereferencing it. You can try something like the following program to see what address values your program is using as it runs. I repeat: for "normal" users with Linux or Windows XP or other such systems, the addresses that this program tells you about are not actual physical memory addresses. Period. CPP / C++ / C Code:
For GNU gcc on my Windows XP machine: Code:
Since the value that I gave to the pointer just happened to fall close to the addresses of local variables (x, for example), the program apparently wasn't outside of its allowed region. Of course the value in that memory space is not meaningful, and if I tried to write to it, something bad could happen (or, maybe, not). The behavior is undefined, but, apparently not pathological (at least for reading). For Borland bcc32 on the same machine: Code:
In this case the arbitrary address that I gave to the pointer is not close to the (virtual) addresses that my program is allowed to use, and the program bombs. Regards, Dave |
|
#8
|
|||
|
|||
Re: How to read particular memory location ?i was wondering why not use assembly language with in c program , Because with assemble language the memory can explicatily altered. However i am not sure about how virtual memory would or memory map will look at this ..
|
|
#9
|
||||
|
||||
Re: How to read particular memory location ?Quote:
No it can't. Assembly has the same memory limitations as any other language. __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
|
#10
|
|||
|
|||
Re: How to read particular memory location ?Thanks for your comments on my problem. But i am still working on it to get something out from the OS.
I am using Windows XP and DAVE C++. Guys my exams are gonna start i will not be visiting the forum for some days. Anyways thanks for you help. REALNAPSTER __________________
*Labor omnia consent*** Hardwork conquers all* |
Recent GIDBlog
A Week in Kuwait by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Airport Log program using 3D linked List : problem reading from file | batrsau | C Programming Language | 11 | 29-Feb-2008 07:44 |
| Memory cannot be read? | dlare9 | C Programming Language | 3 | 16-Nov-2005 07:03 |
| Pointer Usage in C++: Beginner to Advanced | varunhome | C++ Forum | 0 | 19-Aug-2005 09:25 |
| [Tutorial] Pointers in C (Part II) | Stack Overflow | C Programming Language | 0 | 27-Apr-2005 17:36 |
| [Tutorial] Pointers in C (Part I) | Stack Overflow | C Programming Language | 1 | 08-Apr-2005 18:35 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The