Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How we access any memory address of windows using c++.

my real and simple question is that, how we change something in the window using c++

Exmaple: how we change computer time using c++ language.

Please tell me about this .
Posted
Updated 7-Jul-14 14:57pm
v2

The physical memory of a computer cannot be directly adressed or read or written in a modern OS. This used to be possible some 20-30 years ago, but since then memory managers were introduced, which map the physical addresses to virtual addresses. That is why you can run 10 applications that each allocate 1GB of memory on a system that only has 2 GB of memory available!

What you have in mind therefore requires an entirely different approach. The operating system offers many libraries with functions that give you access to all kind of information. For instance you can query the current time using the C Time library[^]. Setting the system time is also possible, but it depends on the OS what function to use. E.g. for Windows you can use SetSystemTime()[^]

More generally, whatever you wish to query or change in the system, just google for it, and you will find a multitude of references to system libraries and functions, often with example code on how to use them.
 
Share this answer
 
If you use &SomeFunctionName you get its address. You can then read that content (you will be reading the bytes of the code that's at that address).
Unfortunately, by the memory protection you can't simply write there, but that's on purpose.

But what do you really want to ask? I think that simply reading the bytes inside a given memory address is not what you want to do. So, what do you really want?

If you want to read "any address", it is enough to fill a pointer (char *, for example) with something like 0xAA00120 or anything you see fit.
Ex:
C++
char *address = (char *)0xAA00120
char c = address[0]; // this reads the address 0xAA00120... 
// it will probably cause an exception if this is not a valid address, though.
 
Share this answer
 
Comments
Stefan_Lang 8-Jul-14 3:05am    
Actually I doubt this will work for anything beyond reading system function code: Memory addresses are virtual, and the address space of each application is separate from all others. It is impossible to read data from the address space of another application, no matter what address you use.

Likewise, system functions and data are in a separate address space, although libs that are linked to your application may indeed have their function pointers mapped to the applications' address space.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900