阅读:1927回复:5
SFILTER中SfGetObjectName得到的文件名的问题。
SFILTER中SfGetObjectName得到的文件名的格式是:
\\device\\harddiskVolume\\windows\\system32 感觉这个格式没有c:\\windows\\system32这样的格式舒服。 请高手指点一下,如何转换这个路径名称,谢谢! |
|
最新喜欢:![]() |
沙发#
发布于:2005-06-17 08:32
另外发现,SfGetObjectName对含汉字的文件名无法处理,2003 IFS自带的SFILTER就是这个效果。 自问自答: 为什么filespy只能获取英文得文件名, 中文的不行, 你们也是这样的么? 你怎么知道取不到中文名称,看看是不是Unicode的问题。 是unicode 问题,你需要转换. int ConvertFileNameWCHARToCHAR(PWCHAR pWChar, int nLen, PCHAR pChar) { UNICODE_STRING usFileName; ANSI_STRING asFileName; RtlInitUnicodeString(&usFileName, pWChar); asFileName.Length = 0; asFileName.MaximumLength = MAX_PATH; asFileName.Buffer = pChar; RtlUnicodeStringToAnsiString(&asFileName, &usFileName, FALSE); pChar[asFileName.Length] = 0; return asFileName.Length; } mbstowcs wcstombs |
|
板凳#
发布于:2005-06-16 08:42
filemon里那段注释的做法就是Sfilter用方法,用这个方法要考虑重入问题,很多地方不能用,比如在IRP_MJ_READ中。
取文件全路径可以用Filemon的方法,也可以用ifs自带filespy的方法 两者大同小异,都是自己发IRP去询问文件路径 |
|
地板#
发布于:2005-06-15 22:05
另外发现,SfGetObjectName对含汉字的文件名无法处理,2003 IFS自带的SFILTER就是这个效果。
|
|
地下室#
发布于:2005-06-15 20:28
FILEMON不稳定所以我才开始考虑SFILTER的,我现在心里都怕啊,始终不知道FILEMON哪里有问题,哪还敢用它里面的代码!
是否另有他法? FILEMON里面的这段注释倒挺有用: // // Ask the file system for the name of the file, which its required to be // able to provide for the Win32 filename query function. We could use the // undocumented ObQueryNameString, but then we\'d have to worry about // re-entrancy issues, since that call generates the IRP that we create // manually here. Since we send the IRP to the FSD below us, we don\'t need // to worry about seeing the IRP in our dispatch entry point. This can fail // in some cases, so we fall back on constructing the name ourselves if // we have to. // |
|
5楼#
发布于:2005-06-15 16:32
可以参考filemon的GetFullPathName函数,做的不错!
|
|