Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

DeviceIoControl DFP_RECEICE_DRIVE_DATA (ID_CMD) on Win95/98

3 views
Skip to first unread message

Marcel Rasche

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
Hello,

I use the DeviceIoControl to send the DFP_GET_VERSION and the
DFP_RECEICE_DRIVE_DATA (ID_CMD) command.
It works fine with WinNT, but on Win95/98 I have a problem.
I have read the Microsoft SMART IOCTL API Specification (1999) and he
write for Win95
"Under Windows95,the name of the executable is Smartvsd.vxd."

I have test with "vwin32" and with "smartvsd". But if call
DeviceIoControl with DFP_RECEICE_DRIVE_DATA (ID_CMD) than
return in the struct DRIVERSTATUS bDriverError=4 and bIDEStatus=0.
(ERROR 4 is INVALID BUFFER).

Thanks for help

Best regards
Marcel


####################################################################

typedef struct _GETVERSIONINPARAMS {
UCHAR bVersion; // Binary driver version.
UCHAR bRevision; // Binary driver revision.
UCHAR bReserved; // Not used.
UCHAR bIDEDeviceMap; // Bit map of IDE devices.
ULONG fCapabilities; // Bit mask of driver capabilities.
ULONG dwReserved[4]; // For future use.
} GETVERSIONINPARAMS, *PGETVERSIONINPARAMS, *LPGETVERSIONINPARAMS;

typedef struct _IDEREGS {
UCHAR bFeaturesReg; // Used for specifying SMART
"commands".
UCHAR bSectorCountReg; // IDE sector count register
UCHAR bSectorNumberReg; // IDE sector number register
UCHAR bCylLowReg; // IDE low order cylinder value
UCHAR bCylHighReg; // IDE high order cylinder value
UCHAR bDriveHeadReg; // IDE drive/head register
UCHAR bCommandReg; // Actual IDE command.
UCHAR bReserved; // reserved for future
use. Must be zero.
} IDEREGS, *PIDEREGS, *LPIDEREGS;

typedef struct _SENDCMDINPARAMS {
ULONG cBufferSize; // Buffer size in bytes
IDEREGS irDriveRegs; // Structure with drive register
values.
UCHAR bDriveNumber; // Physical drive number to send
command to (0,1,2,3).
UCHAR bReserved[3]; // Reserved for future expansion.
ULONG dwReserved[4]; // For future use.
UCHAR bBuffer[1]; // Input buffer.
} SENDCMDINPARAMS, *PSENDCMDINPARAMS, *LPSENDCMDINPARAMS;

typedef struct _DRIVERSTATUS {
UCHAR bDriverError; // Error code from driver, or 0 if no
error.
UCHAR bIDEError; // Contents of IDE Error register. Only
valid
when bDriverError, is SMART_IDE_ERROR.
UCHAR bReserved[2]; // Reserved for future expansion.
ULONG dwReserved[2]; // Reserved for future expansion.
} DRIVERSTATUS, *PDRIVERSTATUS, *LPDRIVERSTATUS;

typedef struct _SENDCMDOUTPARAMS {
ULONG cBufferSize; // Size of bBuffer in bytes
DRIVERSTATUS DriverStatus; // Driver status structure.
UCHAR bBuffer[1024]; // Buffer of arbitrary
length in which to store the data read from
the
// drive.
} SENDCMDOUTPARAMS, *PSENDCMDOUTPARAMS, *LPSENDCMDOUTPARAMS;

#define DFP_GET_VERSION 0x74080
#define DFP_SEND_DRIVE_COMMAND 0x7c084
#define DFP_RECEICE_DRIVE_DATA 0x7c088

#define ATAPI_ID_CMD 0xA1 // Returns ID sector for ATAPI.
#define ID_CMD 0xEC // Returns ID sector for ATA.

bool GetDriveIdentifyNT(bool winNT)
{
HANDLE hHandle;
char device[100];
WORD identify[257];
DWORD byteReturn;
GETVERSIONINPARAMS outParmas;
SENDCMDOUTPARAMS out;
SENDCMDINPARAMS inp;

if(WINNT) // NT
strcpy(device,"\\\\.\\PhysicalDrive0");
else
strcpy(device,"\\\\.\\smartvsd");

hHandle=CreateFile(device,GENERIC_READ,FILE_SHARE_READ,NULL,
OPEN_EXISTING,FILE_FLAG_NO_BUFFERING |
FILE_FLAG_OVERLAPPED,NULL);

byteReturn=0;
if(DeviceIoControl(hHandle,DFP_GET_VERSION,NULL,0,
&outParmas,sizeof(GETVERSIONINPARAMS),&byteReturn,NULL))
{
UCHAR comid=0;
if(outParmas.fCapabilities & 1) // IDE IDENTIFY CMD 0xce
comid=ID_CMD;
else if(outParmas.fCapabilities & 2) // ATAPI IDENTIFY CMD 0xa1
comid=ATAPI_ID_CMD;
if(comid != 0)
{
inp.cBufferSize=1;
inp.bBuffer[0]=comid;
inp.bDriveNumber=0; // 0,1,2,3
inp.irDriveRegs.bFeaturesReg=0;
inp.irDriveRegs.bSectorCountReg=1;
inp.irDriveRegs.bSectorNumberReg=1;
inp.irDriveRegs.bCylLowReg=0;
inp.irDriveRegs.bFeaturesReg=0;
inp.irDriveRegs.bCylHighReg=0;
inp.irDriveRegs.bDriveHeadReg=0;
inp.irDriveRegs.bCommandReg=comid;
out.cBufferSize=1024;
byteReturn=0;
if(DeviceIoControl(hHandle,DFP_RECEICE_DRIVE_DATA,

&inp,sizeof(SENDCMDINPARAMS),&out,sizeof(SENDCMDOUTPARAMS),&byteReturn,NULL))
{

}
}
}

if(!hHandle)
return FALSE;

CloseHandle(hHandle);
return TRUE;
}

Karen Hazzah

unread,
May 21, 1999, 3:00:00 AM5/21/99
to
In article , Marcel says...

>
>I have test with "vwin32" and with "smartvsd". But if call
>DeviceIoControl with DFP_RECEICE_DRIVE_DATA (ID_CMD) than
>return in the struct DRIVERSTATUS bDriverError=4 and bIDEStatus=0.
>(ERROR 4 is INVALID BUFFER).

SMARTVSD requires the size of the output buffer to be

sizeof(SENDCMDOUTPARAMS) - 1


Marcel Rasche

unread,
May 27, 1999, 3:00:00 AM5/27/99
to
Hello,

Karen Hazzah wrote:
>
> In article , Marcel says...
> >

> >I have test with "vwin32" and with "smartvsd". But if call
> >DeviceIoControl with DFP_RECEICE_DRIVE_DATA (ID_CMD) than
> >return in the struct DRIVERSTATUS bDriverError=4 and bIDEStatus=0.
> >(ERROR 4 is INVALID BUFFER).
>

> SMARTVSD requires the size of the output buffer to be
>
> sizeof(SENDCMDOUTPARAMS) - 1

thanks for the information, but if set sizeof(SENDCMDOUTPARAMS) - 1 than
return also DRIVERSTATUS bDriverError=4.

0 new messages