通过FRN直接得到文件路径, 纠正或者说补强网络上盛传的一段代码
前言:
1. NTFS的设计者希望我们在数据库里建立表结构来映射FRN和文件地址. 但是是有办法直接通过FRN和盘符拿到完整的路径
2. 方法通过调用内核API:NtCreatefile和NtQueryInformationFile. 会用这两个函数
不再赘述内核API的调用方法和局限
这里是参考的文献地址
http://univasity.iteye.com/blog/860847
http://hi.baidu.com/znjcx/blog/item/5b6ded43382d13189213c65b.html
直接给我的测试代码吧, 放在console application下. 还么整理就贴上来了,有兴趣的朋友可以改写.
#include "stdafx.h"
#include <windows.h>
#include <iostream>
typedef enum _FILE_INFORMATION_CLASS
{
// end_wdm
FileDirectoryInformation = 1,
FileFullDirectoryInformation, // 2
FileBothDirectoryInformation, // 3
FileBasicInformation, // 4 wdm
FileStandardInformation, // 5 wdm
FileInternalInformation, // 6
FileEaInformation, // 7
FileAccessInformation, // 8
FileNameInformation, // 9
FileRenameInformation, // 10
FileLinkInformation, // 11
FileNamesInformation, // 12
FileDispositionInformation, // 13
FilePositionInformation, // 14 wdm
FileFullEaInformation, // 15
FileModeInformation, // 16
FileAlignmentInformation, // 17
FileAllInformation, // 18
FileAllocationInformation, // 19
FileEndOfFileInformation, // 20 wdm
FileAlternateNameInformation, // 21
FileStreamInformation, // 22
FilePipeInformation, // 23
FilePipeLocalInformati