Re: in C how to store a value on a given memory address



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
.



Relevant Pages

  • Re: Can anyone explain PHP slowing down please ?
    ... Thanks for the comments david - I've run this on both windows and linux ... now and the linux system I ran through apache - I get the same results on ... I dont cause it to - but if thats how it works? ... I have discovered a windows loss of 2Mb of system memory for every run - ...
    (comp.lang.php)
  • RE: service pack 2 and time errors
    ... > Windows firewall, that could explain your other issues as ... send the report i am informed that i dont have service pack 2 and should get ... i do know i need more memory so im not worried about them. ...
    (microsoft.public.windowsxp.general)
  • Re: Excluding Process from getting paged,...
    ... paged to the pagefile on a windows xp system? ... I dont want to disable the pagefile, ... If you have lots of available memory, then your process won't get paged ...
    (microsoft.public.win32.programmer.kernel)
  • Virtual Memory
    ... just let windows manage it. ... with 1 gig of memory u dont ... >Memeory Change set Initial Size and Maximum Size to 3000 ... >should say 4000 and when I go back to Virtual Memory ...
    (microsoft.public.windowsxp.customize)
  • RE: Virtual memory
    ... You can configure virtual memory in windows xp and thereby improve the ... How to set performance options in Windows XP ... if you have background programs such as printing or disk ... It is also known as the paging file. ...
    (microsoft.public.windowsxp.perform_maintain)