delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2003/07/21/23:51:18

From: "Keonwoo Kim" <sosaria AT freechal DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Please Help! Logical Disk Access
Date: Tue, 22 Jul 2003 11:18:29 +0900
Organization: Hanaro Telecom
Lines: 165
Message-ID: <bfi928$idk$1@news.hananet.net>
References: <bfgvp4$r05$1 AT news DOT hananet DOT net>
NNTP-Posting-Host: 218.39.244.178
X-Trace: news.hananet.net 1058842504 18868 218.39.244.178 (22 Jul 2003 02:55:04 GMT)
X-Complaints-To: newsadmin AT hanaro DOT com
NNTP-Posting-Date: Tue, 22 Jul 2003 02:55:04 +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

hi. I could know what is matter.
under Windows 98, DPMI server assume the address is linear.
so...
#pragma pack(1)
struct  SectorPacket {
    int sector;
    short num;
//    short offset;
//    short seg;
    int buffer;
};
#pragma pack()
        :
        :
    packet.sector = sector;
    packet.num = 1;
//    packet.seg = __tb >> 4;
//    packet.offset = __tb & 0x0F;
    packet.buffer = __tb;

if change like this, it works ok under windows 98
but crash under msdos-cwsdpmi...

i don't know what is right. but it seems CWSDPMI is right way.
my program should work under msdos and windows. so
i should know vandor of dpmi server which it use.
--- how can i know this?

thanks.


"Keonwoo Kim" <sosaria AT freechal DOT com> wrote in message
news:bfgvp4$r05$1 AT news DOT hananet DOT net...
> 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, &regs ). but I don't know
why
> it die.
> if this is bug of windows, how can I read logical sector?
> please help.
>
>
> #include <dpmi.h>
> #include <go32.h>
> #include <sys/farptr.h>
> #include <stdio.h>
>
>
> #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( &regs );         // 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( &regs );         // 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, &regs );              // 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;
> }
>
>


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019