Please Help! Logical Disk Access

Please Help! Logical Disk Access

Post by Keonwoo Ki » Tue, 22 Jul 2003 23:34:30



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;

Quote:};

#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);

Quote:}

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'?
??o?
        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'?
??o?
            __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;

Quote:}

 
 
 

Please Help! Logical Disk Access

Post by Keonwoo Ki » Wed, 23 Jul 2003 11:18:29


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;
Quote:};

#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.


Quote:> 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'?
> ??o?
>         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'?
> ??o?
>             __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;
> }


 
 
 

Please Help! Logical Disk Access

Post by Eli Zaretski » Wed, 23 Jul 2003 22:00:12



> Newsgroups: comp.os.msdos.djgpp
> Date: Tue, 22 Jul 2003 11:18:29 +0900

> hi. I could know what is matter.
> under Windows 98, DPMI server assume the address is linear.

It's not the DPMI server that assumes this, it's the DOS extender
built into Windows. Plain DOS doesn't have a DOS extender, thus the
difference.

The problem is that you issue INT 25h as a real-mode procedure.
Instead, I think it's much easier to use __dpmi_int to invoke 25h.
Why didn't you do that in the first place?

Quote:> my program should work under msdos and windows. so
> i should know vandor of dpmi server which it use.
> --- how can i know this?

I don't think your program needs to know that, if you change the code
as mentioned above. But anyhow, the function __dpmi_get_capabilities,
if supported by the DPMI server, returns the vendor ID. Alternatively,
simply detect Windows (using Int 2Fh, AX=17xx) and assume the DPMI is
the one bundled with Windows.
 
 
 

Please Help! Logical Disk Access

Post by Eli Zaretski » Wed, 23 Jul 2003 22:34:37



> Newsgroups: comp.os.msdos.djgpp
> Date: Tue, 22 Jul 2003 11:18:29 +0900

> 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.

Btw, it might help if you post the full crash messages printed when
your program crashes, both under DOS/CWSDPMI and Windows 98. The info
printed there might give some useful hint.
 
 
 

1. Can't access logical drive *** HELP ***

I have a PB SX/20 running DOS 5.0 and Windows 3.1.  I have
one hard drive (internal) that has two partitions (C and D).
Over the weekend I re-installed DOS 5.0 on my hard drive
because of some corrupted DOS files.  Before I re-installed
DOS I was able to access the data on my "C" and "D" drives.
After the DOS install I have be unable to access drive "D".

Before I ran the install, I saved the config.sys and autoexec.bat
files.  So I am currently using the config.sys and autoexec.bat
files that were in place before the install.

When I try to access drive "D" I receive the following message:

             Invalid Media type reading drive D
             Abort, Retry, Fail?

The following is the output from "fdisk":

    Current fixed disk drive: 1

    Partition  Status  Type             Volume Label   Mbutes  System    Usage
    c: 1            A      PRI DOS        MS-DOS_5      225        FAT16       69%
       2                     EXT DOS                               100                          31%

    Drv Volume Lable  Mbytes  System              Usage
    D:                           100       UNKNOWN     100%

Can anyone tell me how/if I can gain access to my data on drive "D"?

Thanks in advance........

Scott

2. Fatal Exception OE on Win98

3. Lost logical drive, please help

4. Webmap in WebExplorer

5. Delphi 2. & Stored Procedures

6. NEAD HELP PLEASE HELP ME PLEASE PLEASE

7. Forwarding without an open relay

8. Trapping DOS access to logical drive B:

9. Please, Please PLEASE help me with DIff and/or Uniq!

10. lan access to/from W95 - help please!

11. Partitioning and resizing logical disk drives

12. Disk partitions and Logical format