📄 ideioctl.h
字号:
//**********************************************************************
//
// Filename: ideioctl.h
//
// Description: User I/O Control calls for the
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
// ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
// PARTICULAR PURPOSE.
//
// Use of this source code is subject to the terms of the Cirrus end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to
// use this source code. For a copy of the EULA, please see the
// LICENSE.RTF on your install media.
//
// Copyright(c) Cirrus Logic Corporation 2002, All Rights Reserved
//
//**********************************************************************
#ifndef _H_IDECTRL
#define _H_IDECTRL
#include <diskio.h>
#define IOCTL_DISK_USER_GET_DRIVE_STATS IOCTL_DISK_USER(0)
#define IOCTL_DISK_USER_GET_DRIVE_IDENTIFY IOCTL_DISK_USER(1)
#define IOCTL_DISK_USER_SET_TRANSFER_MODE IOCTL_DISK_USER(2)
typedef struct
{
ULONG ulDmaTotalRead;
ULONG ulDmaTotalWrite;
ULONG ulDmaNoError;
ULONG ulDmaOtherError;
ULONG ulDmaWriteBug1;
ULONG ulDmaWriteBug2;
ULONG ulDmaReadBug1;
} DmaStatistics;
typedef struct
{
ULONG ulSize;
BOOL bDmaEnabled;
BOOL bDmaReadEnabled;
BOOL bDmaWriteEnabled;
ULONG ulDmaMode;
DmaStatistics DmaStats;
} UserDriveStatistics;
typedef struct
{
BOOL fUDMAEnable;
ULONG ulBestUDmaModeReg;
} UserUdmaSettings;
//****************************************************************************
// IdeGetDriveStatistics
//****************************************************************************
// Gets the Drive statistics.
//
// strDrive - DSK1: or DSK2:
//
// return nozero - Success
// 0 - Failure
//
__inline BOOL IdeGetDriveStatistics (WCHAR * strDrive, UserDriveStatistics *pDriveStats)
{
HANDLE hFile;
BOOL bRet = 0;
ULONG ulBytesReturned;
hFile = CreateFile
(
strDrive,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
if(hFile)
{
bRet = DeviceIoControl
(
hFile,
IOCTL_DISK_USER_GET_DRIVE_STATS,
NULL,
0,
(void *)pDriveStats,
sizeof(UserDriveStatistics),
&ulBytesReturned,
NULL
);
CloseHandle(hFile);
if(ulBytesReturned != sizeof(UserDriveStatistics))
{
bRet = 0;
}
}
return bRet;
}
//****************************************************************************
// IdeGetIdentifyData
//****************************************************************************
// Gets the Identification information off of the Hard Drive.
//
// strDrive - DSK1: or DSK2:
// pIdentifyData - Drive Information. See atapi2.h.
//
// return nozero - Success
// 0 - Failure
__inline BOOL IdeGetIdentifyData(WCHAR *strDrive, IDENTIFY_DATA *pIdentifyData)
{
HANDLE hFile;
BOOL bRet = 0;
ULONG ulBytesReturned;
hFile = CreateFile
(
strDrive,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
if(hFile)
{
bRet = DeviceIoControl
(
hFile,
IOCTL_DISK_USER_GET_DRIVE_IDENTIFY,
NULL,
0,
(void *)pIdentifyData,
sizeof(IDENTIFY_DATA),
&ulBytesReturned,
NULL
);
CloseHandle(hFile);
if(ulBytesReturned != sizeof(IDENTIFY_DATA))
{
bRet = 0;
}
}
return bRet;
}
//****************************************************************************
// IdeSetTransferMode
//****************************************************************************
// This function Enables/Disables UDMA mode if the drives supports it.
// This is exactly like changing the IDE registry settings.
//
// "UDMAEnable"=dword:1
// "BestUDMAMode"=dword:2
//
__inline BOOL IdeSetTransferMode(WCHAR *strDrive, UserUdmaSettings *pSettings)
{
HANDLE hFile;
BOOL bRet = 0;
ULONG ulBytesReturned;
hFile = CreateFile
(
strDrive,
GENERIC_READ | GENERIC_WRITE,
0,
NULL,
OPEN_EXISTING,
0,
NULL
);
if(hFile)
{
bRet = DeviceIoControl
(
hFile,
IOCTL_DISK_USER_SET_TRANSFER_MODE,
(void *)pSettings,
sizeof(UserUdmaSettings),
NULL,
0,
&ulBytesReturned,
NULL
);
CloseHandle(hFile);
}
return bRet;
}
#endif // _H_IDECTRL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -