我想将设备路径转换为文件路径。
我想通过进程id获取进程名,所以我用的是这段代码
PsLookupProcessByProcessId(processId,&pEProcess);
ObOpenObjectByPointer(pEProcess,
OBJ_KERNEL_HANDLE,
NULL,
0,
NULL,
KernelMode,
&hProcess);
ObDereferenceObject (pEProcess);
nts = ZwQueryInformationProcess (hProcess,27,0,0,&ulSize);
但它给出的路径为 \Device\hardDiskVolume1\windows\system32\taskmgr.exe
但我希望将其作为普通文件名C:\windows\system32\taskmgr.exe
最佳答案
Dr. Dobb's(Jim Conyngham 的 NT Handle-to-Path Conversion)中有一篇文章描述了从句柄获取 DOS 路径名的方法:参见 listing的 GetFileNameFromHandleNT()
。
在您的情况下,由于您已经拥有设备路径,因此您不需要执行 handle-to-memory-map-to-get-device-path 工作的代码的初始部分。
关于windows - 从 NT/设备名称获取文件路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3636081/