Can't properly read the boot sector from a FAT32 USB drive on Android device

我只是一个虾纸丫 提交于 2019-12-12 02:35:19

问题


I'm trying to read the boot sector from a FAT32 drive on Android device, but I'm getting totally different data from what I expect.

This is the output I'm receiving with bulkTransfer on read endpoint on my Android device.

33C08ED0BC007C8EC08ED8BE007CBF00
06B90002FCF3A450681C06CBFBB90400
BDBE07807E00007C0B0F850E0183C510
...
656D000000637B9A5BE2B3D70000800F
30000BFEFFF4E0030000205CF8000000
00000000000000000000000000000000
00000000000000000000000000000000
000000000000000000000000000055AA

This is the boot sector dumped with hex viewer on my PC.

EB58904D53444F53352E300002081004
0200000000F800003F00FF00E0030000
205CF800F83D00000000000002000000
...
0000000000000000000000000D0A5573
75E4206479736B69206C756220696E6E
79206E6F986E696BFF0D0A4288A56420
6479736B75FF0D0A5A72657374617274
756A2C206E616369736B616AA563206B
6C617769737A0D0A00ACC9D6000055AA

The data I received on Android contains following message near the end: "Invalid partition table.Error loading operating system.Missing operating system".

Can anyone tell me what's wrong here? Is there any action I should perform before reading the boot sector?

As of now my code flow is as follows:

  1. Find desired USB device
  2. Get the permission to communicate with USB device
  3. Open connection do the device
  4. Execute "Test Unit Ready" command until successful response
  5. Execute "Read Capacity" command - this returns correct results
  6. Execute "Read 10" command to read first 512 bytes - this returns incorrect data

I will be thankful for any suggestions


回答1:


Which hex viewer?

Non-admin user on win cannot access the partition table on the physical device, so you usually get the first sector of the partition only. You can check this, it would contain the FAT32 string at offset 0x52. To read the real partition table, you need to access the pysical device with admin privileges.

On android, you read the partition table itself because you access the physical "disc" at a low level.



来源:https://stackoverflow.com/questions/29323088/cant-properly-read-the-boot-sector-from-a-fat32-usb-drive-on-android-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!