![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
I am not a programmer. however, I wish to know
how to take contents from my pc's memory and place into a variable. I have slapped together something that looked promising but I just get some error like "....c++ forbids the comparison of pointer and integers" could some one explain how i can grab byte from anywhere in pc memory. no code required just conceptual explanation. I attempted to use a pointer to point to some byte in memory and copy the byte value to a variable. is this the right approach? |
|
|
|
|
|
#2 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
Modern operating systems don't allow unfettered access to computer memory from user-mode programs --- in fact, they are deliberately designed to prevent such access.
|
|
|
|
|
|
#3 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
You response is difficult to accept. i presume you are refering to the x86 protected mode.
|
|
|
|
|
|
#4 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
You finding it unacceptable doesn't change the answer. No, I wasn't referring to x86 protected mode, I was talking generically. However, modern operating systems (windows NT, linux, solaris, BSD, etc) that run on x86 architecture do, AFAIK, make use of protected mode.
|
|
|
|
|
|
#5 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
ROFL! I found if difficult to accept, when she said, "No", but I still didn't get any.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
|
|
#6 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
could I use some thing like:
int *memory_location,memory_value; memory_location=0x00000000; &(memory_value)=memory_location; i.e. intialize a pointer and pass the pointers' value as address to a varible and then using the variable as normal byte int. |
|
|
|
|
|
#7 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
I assume you mean;
int *memory_location,memory_value; memory_location= (int *)0x00000000; memory_value= *memory_location; In practice, on a modern OS, this code might actually tell you what data is available at some specified zero address. However, on those same systems, that specified zero address will be part of the address space for the process that is executing your program, which is different from actual physical memory on your machine. As I said, a design goal of a modern OS is to keep a running program from directly accessing physical memory. |
|
|
|
|
|
#8 |
|
Newbie
Join Date: Apr 2006
Posts: 11
Rep Power: 0
![]() |
ahh! I see. mmmm...
|
|
|
|
|
|
#9 |
|
Programming Guru
![]() Join Date: Jun 2005
Location: Adelaide, South Australia
Posts: 1,221
Rep Power: 5
![]() |
No you don't. You are assuming I have given you the solution you want. What I have given you is a bit of code that you think will give you what you want, and it won't. Even worse, it could corrupt your system. I suppose having to reinstall your OS might be a way to get the message across to you.
|
|
|
|
|
|
#10 |
|
Resident Grouch
![]() ![]() ![]() ![]() ![]() ![]() Join Date: Jun 2005
Posts: 6,453
Rep Power: 10
![]() |
Let me put it like this: on a primitive machine, or working at a primitive level, you may do whatever you wish, including trash the machine. By trash, I even include physical damage, as well as just causing the machine to go belly-up out in the weeds. On a typical, modern machine, you are presumed to be one of a half-scad of users. If you were allowed to do what you desire, nothing would prevent you from accessing and messing with another's app. You might trash it entirely. You might just mess with the answers it gives. Would you want me doing that to your program, if you're computing the critical mass of a radioactive material, and are going to test the results your very own lowly, expendable, self? I'm thinnking, "NOT!". If you are entirely serious, you need to get under the hood and learn how things work. In the meantime, please wear bright red if you are working in the local hospital when I suddenly need to get an appendectomy. I'd rather choose to die my own way.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code. Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|