问题描述
我正在尝试使用Giveio.sys驱动程序,该驱动程序需要先打开文件",然后才能访问受保护的内存.我正在看WinAVR/AVRdude中使用以下语法的C示例:
I'm trying to use the giveio.sys driver which requires a "file" to be opened before you can access protected memory. I'm looking at a C example from WinAVR/AVRdude that uses the syntax:
#define DRIVERNAME "\\\\.\\giveio"
HANDLE h = CreateFile(DRIVERNAME,
GENERIC_READ,
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
但是这似乎在Python中不起作用-对于这两种情况,我都只会收到指定的路径无效"错误
but this does not seem to work in Python - I just get a "The specified path is invalid" error, for both
f = os.open("\\\\.\\giveio", os.O_RDONLY)
和
f = os.open("//./giveio", os.O_RDONLY)
这为什么不做同样的事情?
Why doesn't this do the same thing?
已编辑,希望可以减少思想混乱(感谢Will).我确实通过AVRdude随附的批处理文件验证了设备驱动程序是否正在运行.
Edited to hopefully reduce confusion of ideas (thanks Will).I did verify that the device driver is running via the batch files that come with AVRdude.
进一步编辑以阐明SamB的赏金.
Further edited to clarify SamB's bounty.
推荐答案
解决方案:在python中,您必须使用win32file.CreateFile()而不是open().感谢大家告诉我我想做什么,这有助于我找到答案!
Solution: in python you have to use win32file.CreateFile() instead of open(). Thanks everyone for telling me what I was trying to do, it helped me find the answer!
这篇关于在Windows上的Python中打开设备的句柄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!