|
本帖最后由 527104427 于 2024-5-28 11:53 编辑
VendorId 怎么是一个括号?
我用API写了一段代码,经测试,win7大部分有VendorId,而win10大部分没有VendorId:
这是win7的:
这是win10的:
测试代码:
- //https://learn.microsoft.com/zh-cn/windows/win32/fileio/disk-management-control-codes
- //https://learn.microsoft.com/zh-cn/windows/win32/api/winioctl/ni-winioctl-ioctl_storage_query_property
- //https://learn.microsoft.com/zh-cn/windows/win32/api/winioctl/ns-winioctl-storage_property_query
- //https://blog.csdn.net/lengye7/article/details/122953234
- set^ EnviMode=1
- set^ ForceLocal=1
- set$ nl=0d 0a
- envi PartitionInformation=
- //set disk=\\?\STORAGE#Volume#{bd7e99c2-72f8-11ed-b079-806e6f6e6963}#0000000000100000#{7f108a28-9833-4b3b-b780-2c6b5fa5c062} //检索设备接口路径
- //set disk=\\?\scsi#disk&ven_st2000dm&prod_001-1ch164#4&15828421&0&030000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} //检索设备接口路径
- //set disk=\\?\scsi#disk&ven_samsung&prod_ssd_850_evo_500g#4&15828421&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b} //检索设备接口路径
- //set disk=\\.\Volume{e1d1e74e-4d47-11ed-aa55-806e6f6e6963} //检索卷
- //set disk=\\.\HarddiskVolume2 //检索 MS-DOS 设备
- set disk=\\.\PhysicalDrive0 //检索磁盘
- //set disk=\\.\Harddisk0Partition1 //检索分区
- //set disk=\\.\GLOBALROOT\device\Harddisk0\Partition1 //检索分区
- //set disk=\\.\C: //检索 C 盘
- set generic_read=0x80000000
- set file_share_read=0x00000001
- set file_share_write=0x00000002
- calc dwShareMode=%file_share_read% | %file_share_write%
- set open_existing=3
- set file_attribute_normal=0x00000080
- call $--qd --ret:h Kernel32.dll,CreateFileW,$%disk%,#%generic_read%,#%dwShareMode%,#0,#%open_existing%,#%file_attribute_normal%,#0 //如果函数成功,则返回值是指定文件、设备、命名管道或邮件槽的打开句柄。如果函数失败,则返回值为 INVALID_HANDLE_VALUE (-1)。 要获得更多的错误信息,请调用 GetLastError。
- ifex $%h%<>-1,
- {
- set ioctl_storage_base=0x0000002d
- set Function=0x0500
- set method_buffered=0
- set file_any_access=0
- calc ioctl_storage_query_property=shl(%ioctl_storage_base%,16) | shl(%file_any_access%,14) | shl(%Function%,2) | %method_buffered% //0x2D1400
- set nInBufferSize=0xC //结构体 storage_property_query 的长度
- set$# lpInBuffer=*%nInBufferSize% 0
- set-long PropertyId=0 //由 storage_property_id 枚举的 StorageDeviceProperty 值,指示调用方是请求设备描述符、适配器描述符、写入缓存属性、设备唯一 ID (DUID) ,还是设备 SCSI 重要产品数据 (VPD) 页中提供的设备标识符。
- set-long QueryType=0 //由 storage_query_type 枚举的 PropertyStandardQuery 值,要查询类型的标志
- set-long AdditionalParameters=0 //包含可用于检索特定查询的其他参数的字节数组
- set-copy lpInBuffer=PropertyId;0;4;0
- set-copy lpInBuffer=QueryType;0;4;4
- set-copy lpInBuffer=AdditionalParameters;0;4;(4 + 4)
- ifex $%::bX64%<3, set lpdword=4! set lpdword=8 //%&::bX64%=0, PECMD32+Win32 //%&::bX64%=1, PECMD32+WIN64 //%&::bX64%=3, PECMD64+WIN64
- calc nOutBufferSize=0x28 + 1K //结构体 storage_device_descriptor 的长度
- set$# lpOutBuffer=*%nOutBufferSize% 0
- set$# lpBytesReturned=*%lpdword% 0 //LPDWORD 实际就是DWORD类型,int
- call $--qd --ret:RetDeviceIoControl Kernel32.dll,DeviceIoControl,#%h%,#%ioctl_storage_query_property%,*lpInBuffer,#%nInBufferSize%,*lpOutBuffer,#%nOutBufferSize%,*lpBytesReturned,#0 //如果操作成功完成,则返回值为非零 (TRUE) 。如果操作失败或挂起,则返回值为零。 要获得更多的错误信息,请调用 GetLastError。
- call $--qd --bool --ret:RetCloseHandle Kernel32.dll,CloseHandle,#%h% //如果函数成功,则返回值为非零值。如果函数失败,则返回值为零。若要获取扩展的错误信息,请调用 GetLastError。如果应用程序在调试器下运行,则函数在收到无效的句柄值或伪句柄值时将引发异常。如果关闭句柄两次,或者对 FindFirstFile 函数返回的句柄调用 CloseHandle,而不是调用 FindClose 函数,则可能会发生这种情况。
- ifex $%RetDeviceIoControl%<>0,
- {
- //结构体 storage_device_descriptor
- set?int lpOutBuffer=Version:0
- set?int lpOutBuffer=Size:4
- set?char lpOutBuffer=DeviceType:(4 + 4)
- set?char lpOutBuffer=DeviceTypeModifier:(4 + 4 + 1)
- set?char lpOutBuffer=RemovableMedia:(4 + 4 + 1 + 1)
- set?char lpOutBuffer=CommandQueueing:(4 + 4 + 1 + 1 + 1)
- set?int lpOutBuffer=VendorIdOffset:(4 + 4 + 1 + 1 + 1 + 1)
- set?int lpOutBuffer=ProductIdOffset:(4 + 4 + 1 + 1 + 1 + 1 + 4)
- set?int lpOutBuffer=ProductRevisionOffset:(4 + 4 + 1 + 1 + 1 + 1 + 4 + 4)
- set?int lpOutBuffer=SerialNumberOffset:(4 + 4 + 1 + 1 + 1 + 1 + 4 + 4 + 4)
- set?int lpOutBuffer=BusType:(4 + 4 + 1 + 1 + 1 + 1 + 4 + 4 + 4 + 4)
- set?int lpOutBuffer=RawPropertiesLength:(4 + 4 + 1 + 1 + 1 + 1 + 4 + 4 + 4 + 4 + 4)
- call GetBusType BusType
- call GetStr VendorId %VendorIdOffset%
- call GetStr ProductId %ProductIdOffset%
- call GetStr ProductRevision %ProductRevisionOffset%
- call GetStr SerialNumber %SerialNumberOffset%
- set PartitionInformation=
- \%nl%Version: %Version%
- \%nl%Size: %Size% //%lpOutBuffer?long:4% //%lpOutBuffer?int:4% 这个表示法有问题,把int当成char了
- \%nl%DeviceType: %DeviceType%
- \%nl%DeviceTypeModifier: %DeviceTypeModifier%
- \%nl%RemovableMedia: %RemovableMedia%
- \%nl%CommandQueueing: %CommandQueueing%
- \%nl%VendorIdOffset: %VendorIdOffset%
- \%nl%ProductIdOffset: %ProductIdOffset%
- \%nl%ProductRevisionOffset: %ProductRevisionOffset%
- \%nl%SerialNumberOffset: %SerialNumberOffset%
- \%nl%BusType: %BusType%
- \%nl%RawPropertiesLength: %RawPropertiesLength%
- \%nl%VendorId: %VendorId%
- \%nl%ProductId: %ProductId%
- \%nl%ProductRevision: %ProductRevision%
- \%nl%SerialNumber: %SerialNumber%
- }
- }
- find *=PartitionInformation, mess=+icon6. 检索失败!@错误#ok*3000! mess. %PartitionInformation%
- exit
- _sub GetStr
- envi szId=
- ifex $%~2>0,
- {
- set-make lpHex=&lpOutBuffer@%~2;*(%Size% - %~2)
- code **ansi,lpHex,**uni,szId
- }
- set-ret %~1=%szId%
- _end
- _sub GetBusType
- ^ifex $%%%~1%%=0x00, team set-ret< %~1= (BusTypeUnknown) (Unknown)| exit //未知总线类型。
- ^ifex $%%%~1%%=0x01, team set-ret< %~1= (BusTypeScsi) (SCSI)| exit //SCSI 总线。
- ^ifex $%%%~1%%=0x02, team set-ret< %~1= (BusTypeAtapi) (ATAPI)| exit //ATAPI 总线。
- ^ifex $%%%~1%%=0x03, team set-ret< %~1= (BusTypeAta) (ATA)| exit //ATA 总线。
- ^ifex $%%%~1%%=0x04, team set-ret< %~1= (BusType1394) (1394)| exit //IEEE-1394 总线。
- ^ifex $%%%~1%%=0x05, team set-ret< %~1= (BusTypeSsa) (SSA)| exit //SSA 总线。
- ^ifex $%%%~1%%=0x06, team set-ret< %~1= (BusTypeFibre) (Fibre Channel)| exit //光纤通道总线。
- ^ifex $%%%~1%%=0x07, team set-ret< %~1= (BusTypeUsb) (USB)| exit //USB 总线。
- ^ifex $%%%~1%%=0x08, team set-ret< %~1= (BusTypeRAID) (RAID)| exit //RAID 总线。
- ^ifex $%%%~1%%=0x09, team set-ret< %~1= (BusTypeiScsi) (iSCSI)| exit
- ^ifex $%%%~1%%=0x0A, team set-ret< %~1= (BusTypeSas) (SAS)| exit //串行附加的 SCSI (SAS) 总线。Windows Server 2003: 在 Windows Server 2003 SP1 之前不支持此功能。
- ^ifex $%%%~1%%=0x0B, team set-ret< %~1= (BusTypeSata) (SATA)| exit //SATA 总线。Windows Server 2003: 在 Windows Server 2003 SP1 之前不支持此功能。
- ^ifex $%%%~1%%=0x0C, team set-ret< %~1= (BusTypeSd) (SD)| exit
- ^ifex $%%%~1%%=0x0D, team set-ret< %~1= (BusTypeMmc) (MMC)| exit
- ^ifex $%%%~1%%=0x0E, team set-ret< %~1= (BusTypeVirtual) (Virtual)| exit
- ^ifex $%%%~1%%=0x0F, team set-ret< %~1= (BusTypeFileBackedVirtual) (File Backed Virtual)| exit
- ^ifex $%%%~1%%=0x10, team set-ret< %~1= (BusTypeSpaces) (Storage Spaces)| exit
- ^ifex $%%%~1%%=0x11, team set-ret< %~1= (BusTypeNvme) (Nvme)| exit
- ^ifex $%%%~1%%=0x12, team set-ret< %~1= (BusTypeSCM) (SCM)| exit
- ^ifex $%%%~1%%=0x13, team set-ret< %~1= (BusTypeUfs) (Ufs)| exit
- ^ifex $%%%~1%%=0x14, team set-ret< %~1= (BusTypeMax) (MAX)| exit
- ^ifex $%%%~1%%=0x7F, team set-ret< %~1= (BusTypeMaxReserved) (Microsoft Reserved)| exit
- _end
复制代码
|
|