Re: in C how to store a value on a given memory address
- From: Emmanuel Delahaye <emdel@xxxxxxxxxxxxxx>
- Date: Wed, 14 Dec 2005 21:38:05 +0100
Ashish a écrit :
i got the solution ..... i wrote this code in VC++ 5.0
int *p = (int *)0x100000UL; *p = 42;
I guess that your system is Windows. Some old versions could allow that, but dont that on a NT based Windows (20000, XP).
it compiles correctly but at runtime it is giving error as expression *p=42 cannot be evaluated .....
Big surprise !
i found that this code will be run only when the memory location is not reserved by OS and that it should be the part of memory segment (RAM) where variable is stored.... so i found that memory position and it works for me at address 0x0012ff92
On a 'Managed' system, the memory is virtual. The addresses are just arbitrary numbers having no relationship with the physical memory at all.
What you want to do is (was?) only possible on very small systems, based on very simple micro processors.
Nowadays, I work with Embedded Linux running on an MPC885 (a PowerPC Micro-controller), and trust me, there is no way out of the 'Modules' running in kernel mode that makes the address translation.
-- A+
Emmanuel Delahaye .
- Follow-Ups:
- References:
- in C how to store a value on a given memory address
- From: Ashish
- Re: in C how to store a value on a given memory address
- From: Richard Heathfield
- Re: in C how to store a value on a given memory address
- From: Ashish
- in C how to store a value on a given memory address
- Prev by Date: Re: in C how to store a value on a given memory address
- Next by Date: Re: integers to binary
- Previous by thread: Re: in C how to store a value on a given memory address
- Next by thread: OT: embedded linux [was Re: in C how to store a value on a given memory address]
- Index(es):
Relevant Pages
|