📄 在win9x-nt下获取硬盘物理序列号.mht
字号:
=
InParams;<BR> =
//=20
Now, get the ID sector for all IDE devices in the=20
=
system.<BR> &n=
bsp; //=20
If the device is ATAPI use the IDE_ATAPI_IDENTIFY=20
=
command,<BR> &=
nbsp; //=20
otherwise use the IDE_ATA_IDENTIFY=20
=
command<BR> &n=
bsp; //=20
=
=BE=DF=CC=E5=CB=F9=B5=C3=BD=E1=B9=FB=C7=EB=B2=CE=BF=BC=CD=B7=CE=C4=BC=FE=D6=
=D0=B5=C4=CB=B5=C3=F7<BR> =
btIDCmd=20
=3D (gvopVersionParams.bIDEDeviceMap >> nDrive & =
0x10)=20
=
?<BR> &n=
bsp; &nb=
sp;IDE_ATAPI_IDENTIFY=20
:=20
=
IDE_ATA_IDENTIFY;<BR> &nbs=
p; ZeroMemory(&InParams,=20
=
sizeof(SENDCMDINPARAMS));<BR> &n=
bsp; ZeroMemory(btIDOutCmd=
,=20
=
sizeof(btIDOutCmd));<BR><BR> &nb=
sp; if(DoIdentify(hPhysica=
lDriveIOCTL,<BR> &nb=
sp; &=
;InParams,=20
=
(PSENDCMDOUTPARAMS)btIDOutCmd,<BR> &nb=
sp; &nbs=
p; (BYTE)btIDCmd,=20
(BYTE)nDrive,=20
=
&dwBytesReturned))<BR>  =
; {<BR> &=
nbsp; &n=
bsp; DWORD=20
=
dwDiskData[256];<BR>  =
; USHORT=
=20
*pIDSector; //=20
=
=B6=D4=D3=A6=BD=E1=B9=B9IDSECTOR=A3=AC=BC=FB=CD=B7=CE=C4=BC=FE<BR> &=
nbsp; &n=
bsp; char=20
=
szSerialNumber[21];<BR> &n=
bsp; cha=
r=20
=
szModelNumber[41];<BR><BR>  =
; =
pIDSector=20
=3D=20
=
(USHORT*)((SENDCMDOUTPARAMS*)btIDOutCmd)->bBuffer;<BR> &nbs=
p;  =
; for(int=20
i=3D0; i < 256;=20
=
i++)<BR>  =
; =
dwDiskData[i]=20
=3D=20
=
pIDSector[i];<BR> &n=
bsp; //=20
=
=C8=A1=CF=B5=C1=D0=BA=C5<BR> &nb=
sp; &nbs=
p;ZeroMemory(szSerialNumber,=20
=
sizeof(szSerialNumber));<BR> &nb=
sp; &nbs=
p;strcpy(szSerialNumber,=20
ConvertToString(dwDiskData, 10,=20
=
19));<BR><BR> =
//=20
=
=C8=A1=C4=A3=D0=CD=BA=C5<BR> &nb=
sp; &nbs=
p;ZeroMemory(szModelNumber,=20
=
sizeof(szModelNumber));<BR> &nbs=
p;  =
;strcpy(szModelNumber,=20
ConvertToString(dwDiskData, 27,=20
=
46));<BR><BR> =
pSerList->=
Add(szSerialNumber);<BR> &=
nbsp; pM=
odeList->Add(szModelNumber);<BR> &n=
bsp; }<BR> &nbs=
p; }<BR> =
CloseHa=
ndle=20
=
(hPhysicalDriveIOCTL);<BR>  =
;}<BR> }<BR>}<BR>//-------------------------------=
--------------------------------------------<BR>//=20
DoIdentify<BR>bool __fastcall DoIdentify(HANDLE =
hPhysicalDriveIOCTL,=20
PSENDCMDINPARAMS=20
=
pSCIP,<BR> &nb=
sp; PSENDCMDOUTPARAMS=20
pSCOP, BYTE btIDCmd, BYTE=20
=
btDriveNum,<BR> &nbs=
p; PDWORD=20
pdwBytesReturned)<BR>{<BR> // Set up =
data=20
structures for IDENTIFY=20
command.<BR> pSCIP->cBufferSize =
=3D=20
=
IDENTIFY_BUFFER_SIZE;<BR> pSCIP->irDriveRegs.bF=
eaturesReg=20
=3D=20
=
0;<BR> pSCIP->irDriveRegs.bSectorCountReg =
=3D=20
=
1;<BR> pSCIP->irDriveRegs.bSectorNumberReg=20
=3D=20
=
1;<BR> pSCIP->irDriveRegs.bCylLowReg  =
;=3D=20
=
0;<BR> pSCIP->irDriveRegs.bCylHighReg =3D=20
0;<BR><BR> // Compute the drive=20
=
number.=A3=A8=D6=F7=C5=CC=BA=CD=B4=D3=C5=CC=CB=F9=B6=D4=D3=A6=B5=C4=D6=B5=
=CA=C7=B2=BB=D2=BB=D1=F9=B5=C4=A3=A9<BR> pSCIP->=
;irDriveRegs.bDriveHeadReg=20
=3D (btDriveNum & 1) ? 0xB0 :=20
0xA0;<BR><BR> // The command can =
either be=20
IDE identify or ATAPI=20
=
identify.<BR> pSCIP->irDriveRegs.bCommandReg=20
=3D =
btIDCmd;<BR> pSCIP->bDriveNumber =3D=20
btDriveNum;<BR> pSCIP->cBufferSize =
=3D=20
IDENTIFY_BUFFER_SIZE;<BR><BR> return=20
DeviceIoControl(hPhysicalDriveIOCTL,=20
=
DFP_RCV_DRIVE_DATA,<BR> &n=
bsp; (LPVOID)pSCIP,<BR> &nb=
sp; sizeof(SENDCMDINPARAMS)=20
-=20
=
1,<BR> (=
LPVOID)pSCOP,<BR> &n=
bsp; sizeof(SENDCMDOUTPARAMS)=20
+ IDENTIFY_BUFFER_SIZE -=20
=
1,<BR> p=
dwBytesReturned,=20
=
NULL);<BR>}<BR>//--------------------------------------------------------=
-------------------<BR>//=20
Windows 95/98/ME=20
=
=B4=FA=C2=EB<BR>//-------------------------------------------------------=
--------------------<BR>//=20
ReadPhysicalDriveOnW9X<BR>void __fastcall=20
ReadPhysicalDriveOnW9X(TStrings *pSerList, TStrings=20
*pModeList)<BR>{<BR> WORD=20
=
wOutData[256];<BR> SetPriorityClass(GetCurrentProc=
ess(),=20
REALTIME_PRIORITY_CLASS);<BR><BR> //=20
=
=BE=AD=B9=FD=B2=E2=CA=D4=A3=AC=B7=A2=CF=D6=B5=DA=D2=BB=B4=CE=B5=F7=D3=C3=B6=
=F8=C7=D2Drive >=3D=20
=
2=CA=B1=BB=E1=D4=DARing0=B4=FA=C2=EB=D6=D0=B3=F6=CF=D6=B4=ED=CE=F3=A3=AC=B5=
=BC=D6=C2=C0=B6=C6=C1=A1=A3<BR> // =
=BE=AD=B9=FDN=A3=A8N >=20
=
15=A3=A9=B4=CE=B5=C4=C0=B6=C6=C1=BA=F3=C8=D4=D5=D2=B2=BB=B5=BD=D4=AD=D2=F2=
=A3=BA=A3=A8=A3=AC=B2=BB=B5=C3=B2=BB=D4=DA=D5=E2=C0=EF=D4=F6=BC=D3=D2=BB=B6=
=CE=CE=DE=D3=C3=B4=FA=C2=EB=D2=D4<BR> //=20
=
=B1=DC=C3=E2=C0=B6=C6=C1=B5=C4=B3=F6=CF=D6=A1=A3=A3=A8=C6=DA=B4=FD=B8=DF=C8=
=CB=C4=DC=D6=B8=B3=F6=D4=AD=D2=F2=A3=A9<BR> for(in=
t nDrive =3D 0;=20
nDrive < 8;=20
=
nDrive++)<BR> {<BR> &=
nbsp; WORD=20
=
dwBaseAddress;<BR> BYTE=20
=
btMasterSlave; //=20
Master Or=20
=
Slave<BR> bool=20
=
bIsIDEExist;<BR> bool=20
=
IsDiskExist;<BR><BR> switc=
h(nDrive=20
/=20
=
2)<BR> {<BR> &n=
bsp; case=20
0: dwBaseAddress =3D 0x01F0;=20
=
break;<BR> &nb=
sp; case=20
1: dwBaseAddress =3D 0x0170;=20
=
break;<BR> &nb=
sp; case=20
2: dwBaseAddress =3D 0x01E8;=20
=
break;<BR> &nb=
sp; case=20
3: dwBaseAddress =3D 0x0168;=20
=
break;<BR> }<BR><BR> =
btMasterSlave=20
=3D (BYTE)(((nDrive % 2) =3D=3D 0) ? 0xA0 :=20
=
0xB0);<BR><BR> //=20
=
=BD=F8=C8=EBRing0<BR> Read=
PhysicalDriveOnW9X_Ring0(true,=20
dwBaseAddress,=20
=
btMasterSlave,<BR> &=
nbsp; bIsIDEExist,=20
IsDiskExist,=20
=
wOutData);<BR> }<BR><BR> //=
=20
=BF=AA=CA=BC=B6=C1=C8=A1<BR> for(int =
nDrive =3D 0; nDrive < 8;=20
=
nDrive++)<BR> {<BR> &=
nbsp; WORD=20
=
dwBaseAddress;<BR> BYTE=20
=
btMasterSlave; //=20
Master Or=20
=
Slave<BR> bool=20
=
bIsIDEExist;<BR> bool=20
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -