C programming question
taavi-LbuTpDkqzNzXI80/IeQp7B2eb7JE58TQ at public.gmane.org
Sat Dec 20 04:56:06 UTC 2003
On Fri, Dec 19, 2003 at 06:08:04PM -0500, Sergey Kuznetsov wrote:
> In this case you can't reach the physical memory. Intel processors ( and
> other CPU as well ) protects the access to the real physical memory.
> Only kernel have access to it.
> You can do it only thru the kernel space as a driver module, or thru the
> /proc/kcore, but this is file in format of core file, you should know how to
> handle and read it.
"Physical memory" is an interesting topic when talking about CPUs with
MMUs (memory management units). x86 CPUs since the 286 iirc have
To read the actual first few hundred bytes of physical, you will probably
want to go through DOS, or write your own bootable program and eschew with
an OS entirely.
The Linux kernel does have the ability to map bits of real physical memory
into the standard protected mode address space, though. I just don't
know how to do it. Much simpler from DOS. ;)
Note that doing something like:
char *memory = 0x0202;
will let you access memory at address 0x0202, relative to the program
as it runs. In DOS, this is actually the 0x0202 byte in real, physical
memory(*). In Linux, it'll be whatever's in 0x00000202 as seen by that
process. Even in the kernel, it'll be 0x00000202 as seen by the kernel.
The MMU can dynamically map physical and logical memory addresses by
making use of a TLB (translation lookaside buffer). Because the kernel
has to deal with physical devices which are memory mapped, however,
it is possible using existing interfaces. You'd want to explore
some of the driver and "real mode" memory interfaces, I think.
No, it's never as simple as you thought. ;)
(*) Of course, you'd want to be sure that you were accessing offset
0x0202 from segment 0x0000. DOS and all other intel real-mode applications
have the concept of a "near" and a "far" pointer, the former being 16-bit,
and the latter being 24-bit (the middle 8 bits of segment and offset
overlap). See, it's NEVER as simple as you thought. ;)
Hackers (the movie) n.
A notable bomb from 1995. Should have been titled "Crackers", because
cracking is what the movie was about. It's understandable that they didn't
however; titles redolent of snack food are probably a tough sell in
--From the Jargon File 4.1.2
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy