win32file.createFile “The System cannot find the specified path”

廉价感情. 提交于 2021-02-08 09:16:14

问题


I'm using win32file.CreateFile() to open up "file" that I see in process explorer. The file in question is (as seen in proc explorer's handles and dlls view) : "\Device\ccSet_{}"

Q1. Can anyone shed light on what is \Device\<file name> . I believe these are obviously not files stored on the hard-disks somewhere. Unless I am wrong, what are they ?

Q2. When I try to use the path AS IS, in win32file.CreateFile() , it gives me an error "The system cannot find the specified path or file". Where am I going wrong.

Q3. Given an address of the above file object (again from proc explorer), can I read the file without specifying the path ?

the single line of code I am using is :

>>> win32file.CreateFile("Device\<filename>",w
in32con.GENERIC_READ|win32con.GENERIC_WRITE,win32con.FILE_SHARE_READ|win32con.FI
LE_SHARE_WRITE,None,win32con.OPEN_EXISTING,0,0)

回答1:


  1. The \Device\XXX names are the internal Windows NT device names.
  2. The \\.\ prefix will access the Win32 device namespace instead of the Win32 file namespace. For instance, to open COM10, you would need to use \\.\COM10.
  3. The handle is only valid inside the process that opened it.


来源:https://stackoverflow.com/questions/11621671/win32file-createfile-the-system-cannot-find-the-specified-path

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