From: "Keonwoo Kim" Newsgroups: comp.os.msdos.djgpp Subject: Please Help! Logical Disk Access Date: Mon, 21 Jul 2003 23:34:30 +0900 Organization: Hanaro Telecom Lines: 128 Message-ID: NNTP-Posting-Host: 218.39.244.178 X-Trace: news.hananet.net 1058800228 27653 218.39.244.178 (21 Jul 2003 15:10:28 GMT) X-Complaints-To: newsadmin AT hanaro DOT com NNTP-Posting-Date: Mon, 21 Jul 2003 15:10:28 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com I want to read logical sector. so I used DOS interrupt services, int 25, int 25/cx=FFFFh, int 21/ax=7305h,cx=FFFFh It works well under MSDOS-CWSDPMI. but It die under Windows 98. what is problem? I just call __dpmi_int( 0x21, ®s ). but I don't know why it die. if this is bug of windows, how can I read logical sector? please help. #include #include #include #include #define SECTOR_SIZE 0x200 #pragma pack(1) struct SectorPacket { int sector; short num; short offset; short seg; }; #pragma pack() static int CallInt25( __dpmi_regs *regs ) { /* pushw %bp; int $0x25; popw %bp; popw %bp; retf */ static char buff[] = { 0x55, 0xCD, 0x25, 0x5D, 0x5D, 0xCB }; int nSeg, nSel; nSeg = __dpmi_allocate_dos_memory( 1, &nSel ); /* 16 bytes */ if ( nSeg == 0 ) { regs->x.flags |= 1; return 0; } dosmemput(buff, sizeof(buff), nSeg*16 ); regs->x.ss = __dpmi_int_ss; regs->x.sp = __dpmi_int_sp; regs->x.cs = nSeg; regs->x.ip = 0; if ( __dpmi_simulate_real_mode_procedure_retf( regs ) != 0 ) regs->x.flags |= 1; __dpmi_free_dos_memory( nSel ); return !(regs->x.flags & 1); } int main( int argc, char** argv ) { int sector = 1; // first logical sector int drive = 2; // drive c: int i; __dpmi_regs regs; struct SectorPacket packet; char buff[SECTOR_SIZE]; packet.sector = sector; packet.num = 1; packet.seg = __tb >> 4; packet.offset = __tb & 0x0F; printf ("read logical sector 1 in drive C:\n"); if ( sector < 0x10000 ) { printf("try int 25..."); regs.x.ax = drive; regs.x.cx = 1; regs.x.dx = sector; regs.x.ds = __tb >> 4; regs.x.bx = __tb & 0x0F; CallInt25( ®s ); // it can access when disk size < 32M } if ( regs.x.flags & 1) { printf("fail\n"); printf("try int 25/cx=ffff..."); // copy disk read packet to transfer buffer dosmemput( &packet, sizeof(packet), __tb + SECTOR_SIZE ); regs.x.ax = drive; regs.x.cx = 0xFFFF; regs.x.ds = __tb >> 4; regs.x.bx = ( __tb & 0x0F ) + SECTOR_SIZE; // 'struct sector'ÀÇ »çº» regs.x.dx = 0; CallInt25( ®s ); // it can access when disk size >= 32M and < 2048M ( fat16 ) if ( regs.x.flags & 1 ) { printf("fail\n"); printf("try int21/ax=7305/cx=ffff..."); // copy disk read packet to transfer buffer dosmemput( &packet, sizeof(packet), __tb + SECTOR_SIZE ); regs.x.ax = 0x7305; regs.x.cx = 0xFFFF; regs.x.dx = drive + 1; regs.x.si = 0; // read mode regs.x.ds = __tb >> 4; regs.x.bx = ( __tb & 0x0F ) + SECTOR_SIZE; // 'struct sector'ÀÇ »çº» __dpmi_int( 0x21, ®s ); // it can access fat32 <-- damn, dead in win 98 if ( regs.x.ax == 0x7300 ) regs.x.flags |= 1; } } if ( regs.x.flags & 1) { printf("fail\n"); } else { dosmemget( __tb, SECTOR_SIZE, buff ); printf("success\n"); for( i = 0; i < 16; i++ ) printf("%02x ", buff[i] ); printf("\n"); } return 0; }