利用USB分析仪捕捉了Windows Vista读取Lexar Firefly 1GB的过程。
灰色部分是非必须的操作。
- USB标准枚举过程: Set_Address,
Get_Device_Descriptor, Get_Configuration_Descriptor
Interface 0: | Class=8 | [USB Mass Storage Device] |
| SubClass=6 | [SCSI Transparent] |
| Protocol=0x50 | [Bulk Only Transport] |
Endpoints: | IN=0x81 | OUT=0x02 |
- Mass Storage Class Request: Get Max
LUN 返回 0
- MassStorageBulk CBW:
返回36字节数据,Media Type/Vendor ID/Product ID/Product
Revision
- MassStorageBulk CBW: SCSI
ReadFormatCapabilities
返回12字节描述符:0x1e3bff个扇区,扇区长度为512字节
- MassStorageBulk CBW: SCSI
Inquiry
与3.不同之处是EVPD=1,Page=0x80,即获取Unit serial
number
未返回任何数据,命令状态返回Passed
- MassStorageBulk CBW:
Byte | Value | Meaning |
0~3 | 55
53 42 43 | CBW
Signature |
4~7 | 30
5A 88 87 | CBW
Tag |
8~11 | 24
00 00 00 | CBW
DataTransferLength |
12 | 80 | CBW
Flags |
13 | 00 | CBW
LUN |
14 | 0A | CBW
Length |
15~24 | 25
00 00 00 00 00 00 00 00 00
| CBW
CommandBlock: |
返回8字节描述符:00 1E 3B
FF 00 00 02 00, 最大LBA=0x1E3BFF,扇区长度为512字节
然后返回13字节命令状态
Byte | Value | Meaning |
0~3 | 55
53 42 53 | CSW
Signature |
4~7 | 30
5A 88 87 | CSW
Tag |
8~11 | 00
00 00 00 | CSW
DataResidue |
12 | 00 | CSW
Status: Command Passed |
- MassStorageBulk CBW:
LBA=0, 传输长度=1,即读取512字节MBR数据
头446字节为引导代码,然后是分区表,只有一个分区
00 01
01 00 0B F9 20 F9 20 00 00 00 E0 3B 1E 00
系统类型是
FAT32,不可引导,首扇区为32,总扇区数0x1E3BE0
- MassStorageBulk CBW: SCSI
Mode Sense: Page 0x1C
- MassStorageBulk CBW: SCSI
Mode Sense: Page 0x08
返回的CSW的状态码为1【failed】
MassStorageBulk CBW: SCSI
Request Sense
返回sense key=5 (Illegal Request)
Windows又重复了两遍如上操作,以失败告终
- MassStorageBulk CBW: SCSI Test
Unit Ready, 第一次CSW返回1,
Request Sense返回Sense
Key=6(Attention),重试后成功
- MassStorageBulk CBW:
LBA=0x20, 传输长度=8,即读取Boot
Sector内容
保留扇区数=0x20,FAT数量=2,FAT大小=0x78C,每簇有8个扇区,
根目录开始于簇2,簇2开始扇区数=0x20+0x20+0x78c*2=0xF58
- MassStorageBulk CBW:
顺序读取了整个FAT到内存
- MassStorageBulk CBW:
LBA=0xF58, 传输长度=8, 即读取根目录内容
其中对应test.xml的32字节为
54 45 53 54 20 20 20 20 58 4D
4C 20 18 44 00 5B
97 39 90 3A 03 00 15 5B 97 39 FF 0C 36 0E 00
00
文件长度为0x0E36,起始地址为0x30CFF,
LBA=0xF58+8*(0x30CFF-2)=0x187740
FAT地址为0x40+0x30CFF>>7=0x659,
扇区内偏移为0x30CFF%128=127
FAT内容为0x0FFFFFFF,即这为最后一个簇
- MassStorageBulk CBW:
LBA=0x187740, 传输长度=8, 即读取test.xml内容
阅读(867) | 评论(0) | 转发(0) |