Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Interrupts in Win2000 1

Status
Not open for further replies.

shanlon

Technical User
Dec 4, 2000
24
0
0
IE
I'm trying to use various interrupts in Win2000 (using Borland C 4.51). The interrupts are int25/int26(absolute disk read/write). However i can't use them because I get a protection error.. ok.. i now realise that Windows will not allow me to use these ints because of something called protected mode. Is there a way around this???

I'm trying to read/write to a FAT32 formatted 10Gb hard disk.. i only want access to the master boot record and the fat tables (+ anything in between).
I presume NT will give the same error(s) as Win2000 because '2000 is built on NT technology.

I have no trouble using interrupt 21, function 440Dh, minor code 60h to read a parameter table from the disk.. why doesn't this give an error also?? .. is it because this int usage is not harmful??

Any help would be appreciated.
 
Here is a little code snippet from MSDN VC++ that I tested on a Windows 2000 box. I get no errors and it appears to successfully read/write using the INT25/26 calls. It was originally written to read/write from/to the floppy, however I changed it to access one of my hard drives and it seemed to do what it said. Maybe you can use something from this code to get your app to work.

//code

#include <stdio.h>
#include <dos.h>
#include <malloc.h>

/***** WARNING!!!!! ******/
/* If you change the following line so that DRIVE_G is assigned a 2 or
above, you could destroy data on your hard drive. This test program
segment was written to read and write from the floppy disk A:
*/
#define DRIVE_G 6 /* 0=A, 1=B, 2=C, etc. */
#define ONE_SECTOR 1
#define ABS_WRITE 38 /* Decimal value of int call */
#define ABS_READ 37 /* Decimal value of int call */
unsigned int far *out; /* Pointer to Data to be output
*/
unsigned int far *input; /* Pointer to Data Transfer Area
*/
unsigned int output; /* Data to be output */
union REGS inregs, outregs;
struct SREGS segregs;
void main(void) {
out = &amp;output;
input = (unsigned int far *) malloc(1024 * sizeof(unsigned int));
*out = 11;
inregs.h.al = DRIVE_G; /* Write to drive G */
inregs.x.cx = ONE_SECTOR; /* Write one sector only */
inregs.x.dx = 3; /* Logical sector 3 */
segregs.ds = FP_SEG(out); /* Get Seg address of output */
inregs.x.bx = FP_OFF(out); /* Get Offset of output */
outregs.x.ax = 0; /* No error */
int86x (ABS_WRITE, &amp;inregs, &amp;outregs, &amp;segregs);

inregs.h.al = DRIVE_G; /* Read to drive G */
inregs.x.cx = ONE_SECTOR; /* Read one sector only */
inregs.x.dx = 3; /* Logical sector 3 */
segregs.ds = FP_SEG(input); /* Get Seg address of buffer */
inregs.x.bx = FP_OFF(input); /* Get Offset of buffer */
outregs.x.ax = 0; /* No error */
int86x (ABS_READ, &amp;inregs, &amp;outregs, &amp;segregs);
printf (&quot;%u was read from drive G: \n&quot;, *input);
}

Doug
dxd_2000@yahoo.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top