![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to assign virtual address?. | veeru_jarugula | UNIX for Dummies Questions & Answers | 1 | 08-17-2007 01:30 AM |
| address of pointer | Poison Ivy | High Level Programming | 19 | 08-16-2006 04:04 AM |
| The best partitioning schem for a 250GB Sata hard drive & a 75GB SCSI hard drive | sirbijan | Filesystems, Disks and Memory | 0 | 04-05-2006 11:19 AM |
| Trying to copy old hard drive to new hard drive. | shorty | UNIX for Dummies Questions & Answers | 4 | 01-30-2006 02:47 PM |
| Virtual IP address | kanejm | IP Networking | 2 | 01-13-2006 10:21 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
A Pointer to non-Virtual Address, and All of my Hard drive
How do I get a pointer to any 32 bit address on my hard drive, in which I then could read that memory or write to that memory address?
And, while the subject is on, how do get a 32 bit pointer in RAM also, in which I can do the same? I'm using C and Objective-C with gcc on an iBook G4. A small example in C would be greatly appreciated. |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
What you want to do is direct physical I/O. It is completely hardware/kernel depdendant. You will probably have to write a kernel mode module, since user mode I/O does not have access to an address on a disk. You do realize you can trash your whole filesystem by writing something in the wrong place.
You'll have to get information on your kernel's source, and actually create a system call to do what you want, if one doesn't already exist. |
|
#3
|
|||
|
|||
|
When you say get information on your kernel's source, does that mean the C code will be different from platform to platform?
I asking, because I'm really after a C code example to get me going. I'm assuming the code example has got to be pretty simple. Psuedocode: Code:
Get a pointer to an address; Write this value to such an address; |
|
#4
|
|||
|
|||
|
Yes - the kernel source is different from distro to distro and has lots of hardware dependencies for things like endianess.
Some points -- 1. OS X is open source, I believe. That means either you already have or can download kernel source. 2. kernel code is not always super-simple, but there may be an existing physical I/O function you can work with. If there is you can make a minor change and allow the function to be exported from the kernel to user space. Then you can call it from C. 3. If there is no function you can use, then you will have to create one. In any event, you will have to learn something about the kernel. I just googled for 'linux kernel programming' and got a load of white papers, turtorials, and books. You will have to do some reading. PS: sometimes you can directly access the BIOS on your box. I'm not an OS X person, but be sure to research BIOS access - sometimes it's possible from a simple 3 line ASM call embedded in C. |
|
#5
|
|||
|
|||
|
Hey thanks. I've began a turotial on loading and unloading kexts in the kernel. I'll see how far that takes me.
|
|
#6
|
|||
|
|||
|
<deleted message>
Last edited by xcoder66; 12-15-2005 at 11:00 PM. |
|
#7
|
|||
|
|||
|
I don't know if you can do it with pointers, but on some UNIX systems you can get access to physical memory via /dev/mem.
[edit] Actually, if you can mmap it, you can get pointers to these things. Find out what device under /dev your hard drive is, and mmap-ing it will map a region of virtual memory into your memory which will act like this area of space on the device you've mapped. It's a very elegant way to access things. See 'man mmap'. Last edited by Corona688; 12-18-2005 at 12:46 PM. |
|||
| Google The UNIX and Linux Forums |