i've become crazy for over a mounth to read mbr under win95, created dll's 32 and 16 bit, qt thunking and so on...

and was so easy ??? damned me.

Posted on 2003-04-10 12:20:36 by Bit7
Posted on 2003-04-10 12:44:01 by david
You'd better disable interrupts when you access the hard drive... What if there's a thread switch in the middle of the programming of the hard drive, and the new thread accesses it? Or, it could be that the hard drive is already carrying out an operation. Use the IOS services instead
Posted on 2003-04-10 13:13:53 by Sephiroth3
First, as I said it is a hack, second , I never had a problem with it :grin:
...In ring0 I dont think you would have a problem with any of what you mention, or am I wrong?
Posted on 2003-04-10 13:49:38 by david
You might not have suffered problems from it, but accessing your HD like that under an operating system is like playing with fire. If you want to play with IDE programming, fine - do it from a boot sector or own little kernel.

If you just need raw access, use thunking like bit7 said, VXD with IOS services (am I right?) like sephiroth said, or CreateFile with the special names on NT.
Posted on 2003-04-10 13:56:20 by f0dder
Yes, fodder and Sephiroth3, and it doesn't matter if I did knew about those methods too,
but 'RealVampire' wanted an example of accesing the harddrive with I/O ports. :grin:
I think is a perfect short lean example source code of how to do it. And I said it was a hack,
and that it is not a serious way of doing stuff. At the same time I have to admit it never failed me.

Anyways, I think you're over-reacting, pls calm down guys.
Posted on 2003-04-10 14:22:04 by david
with something that could theoretically end up trashing data, I don't think this is overreacting. In a single-tasking environment where you have full control over everything, it's not too bad to do this.

I guess that it _should_ be safe even in a multitasking environment, perhaps even without CLI, as the OS harddrive stuff might run with interrupts disabled - not sure which effect (u)DMA has on this though.

You just don't do direct hardware access from a real OS.
Posted on 2003-04-10 14:45:07 by f0dder
just courious .. is IDT address table writable also in NT / 2K... ? i don't think...
Posted on 2003-04-10 15:31:36 by Bit7
It's not.
Posted on 2003-04-10 15:34:46 by david
ok, to make myself a bit clear and avoid misunderstanding.
I'm not, as such, saying you shouldn't mess around and poke at stuff. I am, however, suggesting you should do it "safely", and not mess around too much before you have a general idea of how stuff works (or at least have most of the basic prerequisite knowledge to have a general idea what you're doing). This is to keep you from crashing your computer, losing data, etc.

Programming your harddrive with port I/O is a quite dangerous thing to do. One little slip, and you risk mayhem. If you really feel like playing with it, do yourself a favour, and write a small bootsector to put on a floppy, and do the reading there. It will make sure there's no other software interfering, so there's less risk of serious crashes.

If you play around with ring0 (especially the hacky way of entering), be very careful - it takes so little to crash your system, and the consequences of doing that while in ring0 could be filesystem corruption. Always run sync.exe from sysinternals.com before executing ring0 code, and take great care. And do NOT call any ring3 (like win32 APIs) from ring0.

Play safe, have fun.
Posted on 2003-04-10 16:10:36 by f0dder
Yeah, I've change my mind. I'll experimented it on Blank Diskette. Its too dangerous done it on HDD. Anyway, If I did not OnLine for a long time, I failed. Please check my profile see home address and get here, maybe you can find my dying message ( before Im suicide ). :grin:
Posted on 2003-04-10 19:14:12 by realvampire
you could also take a look at http://bochs.sourceforge.net/ for real safe experimentation with stuff like this.
Posted on 2003-04-11 01:49:06 by f0dder