我正在尝试对 USB 闪存驱动器执行直接数据读取和写入作为 Windows 上的物理驱动器(如果重要,则为 10)。我正在使用 Python 来做到这一点。
我遵循了以下讨论:
使用 python 和 windows 获得对原始设备的写入访问权限
我遇到了kcstrom在那个问题中遇到的同样问题。我得到一个
Traceback (most recent call last):
File "C:\script.py", line 49, in <module>
disk.write(data)
IOError: [Errno 9] Bad file descriptor
Run Code Online (Sandbox Code Playgroud)
阅读和寻找工作应有尽有,读取的数据是正确的。
到目前为止我所知道的:
重现错误:(警告:此代码可能损坏物理驱动器,仅当您知道自己在做什么时才运行)
SOME_OFFSET = 123123
SOME_SIZE = 100
# replace L with the drive letter
disk = open('\\\\.\\L:','r+b')
# or use: (replace N with the drive number)
# disk = …Run Code Online (Sandbox Code Playgroud) 我知道在linux中它就像/ dev/sda一样简单但在Windows中如何打开磁盘并开始在低级别读取数据?
在python我尝试过:
f = open("K:", "r")
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IOError: [Errno 13] Permission denied: 'K:'
Run Code Online (Sandbox Code Playgroud)
即使是管理员,我也会收到此错误.