Programmatically find a Windows hard link target

I recently played a lot, manipulating reprocessing points programmatically, and something annoyed me for a while. Because Windows hard links are not reprocessing points, such as links or symbolic links, they cannot be accessed the same way. Creating a new one is simple enough, but I still have to figure out how to read the goal of one. Since extensions, such as the Hard Shell Shell Extension , have property sheets displaying this information, I assume this can be done, but I could not find documentation on how. (I noticed that the shell extension does not indicate which file is the real thing on hard links, though)

I found this answer explaining how to count file links, but unfortunately I still adhere to the permission.

+1
source share
2 answers

Hard link information is stored in attributes $FILE_NAMEusing the POSIX name. Each of these attributes refers to a file that can reference the source file. A file without any hardlink may also be named POSIX. In other words, a hardlinked file always has multiple POSIX names. The attribute field DirectoryFileReferenceNumberindicates the index of the MFT record, which is the record of the folder containing the file.

Here is a guide to extracting all the goals of a file, regardless of whether it is connected to a hard link or not.

FSCTL_GET_NTFS_FILE_RECORD , NTFS $FILE_NAME.

$FILE_NAME FSCTL_GET_NTFS_FILE_RECORD , , DirectoryFileReferenceNumber MFT . , . , C:\MyData\Myfiles\MyDocument.txt, - MyFiles. DirectoryFileReferenceNumber , 0x5, . , C:\MyDocument.txt.

, , , , Name $FILE_NAME. NameType POSIX, . LFN LFN DOS8.3. DirectoryFileReferenceNumber, . DirectoryFileReferenceNumber , 0x5, , .

. - $FILE_NAME, NameType POSIX. , . , , . GetFileAttributes, .

+2

++, Windows, MIT. , , , , , .

0

All Articles