使用python和windows将原始字节写入磁盘

时间:2017-07-19 05:54:03

标签: python-2.7 disk

我跟着这个帖子: Writing raw data to physical disk (flash drive) fails with "Bad file descriptor" on windows - Python 并尝试在Windows上实施eriksun解决方案。我可以成功读取磁盘,并使用正确的数据(只有一个磁盘,我打开它

with open("\\\\.\\PhysicalDrive0", 'r+b') as disk:

但是,当我尝试写入时,按Enter键解锁后我收到错误

press enter to unlock the volume
Traceback (most recent call last):
  File "mbrwriter.py", line 113, in <module>
    input('press enter to unlock the volume')
  File "C:\python27\lib\contextlib.py", line 35, in __exit__
    self.gen.throw(type, value, traceback)
  File "mbrwriter.py", line 91, in lock_volume
    vol.flush()
IOError: [Errno 22] Invalid argument

可能是什么问题?

0 个答案:

没有答案