分享

Windows 机密:跟踪快捷方式

 看见就非常 2012-08-31
Windows ConfidentialTracking Shortcuts
Raymond Chen


If the target of a shortcut moves, the Windows shell will try to find the new location; this is known as "resolving" the shortcut.But what algorithm does the shell use to find that target?
The answer: It depends.

Windows 95
When shortcuts were introduced in Windows 95, file systems did not have a lot of smarts associated with object tracking.The Windows 95 shell uses a simple searching algorithm to find the lost shortcut destination: When a shortcut is created, various properties of the target of the shortcut are recorded in the shortcut file itself—properties such as the file name, file size, creation time and the last-modified time, as well as information about the drive containing the file.
These properties are updated periodically when the shortcut is used, and when the target of the shortcut goes missing, the shell starts searching for a file with as many properties as possible in common with the intended target file.When it finds a file that looks similar enough to the original target, it declares the target as having been found.
Different properties have varying importance, but creation time has the greatest weight, because that property tends to remain attached to a file even after it has been modified and even renamed.File system tunneling helps keep this information associated with the file, even when programs unwittingly operate in a manner that would normally destroy the information.
The search starts in the directory that was the file's last known location.But even locating the starting point can take a bit of work if the drive has changed; for example, if the shortcut target was on a network drive mapped to drive "O" but is now mapped to drive "P."
After searching the last-known directory, the search descends into subdirectories; then expands outward to the parent directory and sibling directories; then moves to the grandparent directory, aunts, uncles and cousins—pretty much every relative known to mankind.If the search continues for two minutes with no luck, the effort is abandoned (even if not all candidate directories have been searched).

The NT Way
The Windows NT file system folks looked at the Windows 95 shortcut resolution algorithm and scoffed. "We can do better than that: We're object-oriented!" Each NTFS object has an object identifier; a shortcut with a target that's on an NTFS volume also records the object identifier of the shortcut target, as well as the object identifier of the drive itself.
When it comes time to resolve the shortcut, the shell asks the Distributed Link Tracking Service to look for the original object.On a domain, this can produce surprising results, like finding the file even when the drive has been taken out of one computer and installed into another one.
There are a number of ways administrators can affect the algorithm the shell chooses to use.If you enable the Do not track Shell shortcuts during roaming (LinkResolveIgnoreLinkInfo) policy, the shell will not try to locate the original drive.If the shortcut target was on a network drive, the shell will not try to locate the original network resource when determining the starting location for the Windows 95-style search.It will just assume the drive letter is correct; if it isn't, well, what happens, happens.
This policy was created for environments which have a pool of identical network resources, where the load is distributed by having a login script connect the "O" drive (for example) to a different server depending on the user.Even though two users are connecting to two physically different servers, they are logically identical.If you set this policy, a shortcut to O:\program.exe will run the program currently on drive "O," even if drive "O" is not connected to the same network resource as when the shortcut was created.
There are also a pair of policies that let you disable the two object-location algorithms once the starting point has been determined: the Do not use the tracking-based method when resolving shell shortcuts (NoResolveTrack) policy disables the fancy NTFS object-tracking algorithm; the Do not use the search-based method when resolving shell shortcuts (NoResolveSearch) policy disables the low-tech Windows 95 search algorithm.
Repairing broken shortcuts is one of those thankless jobs of the shell: People don't even realize that they're relying on the feature until it stops working.

Raymond Chen's Web site, The Old New Thing, and identically titled book (Addison-Wesley 2007) deal with Windows history and Win32 programming.He sometimes encodes information by translating it into German (poorly).

Windows 机密跟踪快捷方式
Raymond Chen


如果目标的快捷方式移动在 Windows 外壳程序将尝试查找新的位置 ;这称为"解析"该快捷方式。但外壳程序查找该目标会使用哪种算法呢?
答案是:这要视情况而定。

Windows 95
当在 Windows 95 中引入的快捷方式时,文件系统不具有大量与跟踪的对象关联的智能。Windows 95 外壳程序使用一个简单的搜索算法中查找丢失的快捷方式目标:在创建快捷方式时的快捷方式的目标的各种属性都记录在快捷方式文件本身) 属性,如鏂囦欢鍚、 文件大小、 创建时间和在上次修改的时间,以及有关驱动器包含该文件的信息。
定期使用快捷方式,和快捷方式的目标是缺少更新这些属性,外壳程序启动尽可能与预期的目标文件中搜索具有多个属性的文件。当找到类似足够原始目标的文件时,它声明发现具有作为目标。
不同的属性具有不同的重要性但创建时间,最大权值,因为该属性往往会保持连接到一个文件,即使它有被修改,即使重命名。文件系统的隧道操作有助于此程序无意通常会破坏信息的方式运行,即使与文件,相关联的信息。
搜索开始在该文件的上次已知的位置的目录中。但如果该驱动器已更改 ; 甚至定位起始点会花费的工作例如如果快捷方式目标在网络驱动器上映射到驱动器"O"但现在被映射到驱动器"P."
按降序后搜索上次已知目录,搜索排列到子目录中 ;然后向外扩展到父目录和同级目录 ;然后移动到祖父目录、 aunts、 uncles cousins — — 几乎已知人类的每个多相对。如果搜索继续与未能提供有用的两分钟,努力被放弃 (即使不是所有的候选目录已被搜索)。

NT 方式
在 Windows NT 文件系统人员查看 Windows 95 的快捷方式解析算法和 scoffed。"我们可以更好的执行操作:我们是面向对象的 !"NTFS 的每个对象具有一个对象的标识符 ;快捷方式,在 NTFS 卷上的目标还记录的该快捷方式目标对象标识符,以及驱动器本身的对象标识符。
若要解决该快捷方式的时间时,外壳程序会询问分布式链接跟踪服务以查找原始对象。加入某个域,这可能会产生类似于查找文件,即使已经采取的一台计算机并安装到另一个驱动器的意外结果。
有许多的管理员可能会影响外壳程序选择使用该算法的方法。如果启用不在漫游 (LinkResolveIgnoreLinkInfo) 策略的过程中跟踪外壳程序快捷方式,外壳程序将不尝试找到原始的驱动器。濡傛灉鍦 ㄦ 缃戠粶椹卞姩鍣 ㄤ 笂快捷方式目标,外壳程序不会找到原始的网络资源时确定 Windows 95 的样式的搜索起始位置。它只是将假定该驱动器号是正确的 ;如果不是,还,发生什么情况发生。
此策略是为创建具有的相同网络的资源池的负载分布通过登录脚本 (例如) 连接到不同的服务器根据用户的"O"驱动器的环境的。即使两个用户连接到两个不同的服务器,他们是逻辑上相同的。如果设置了该策略将 O:\program.exe 快捷方式将上运行程序当前驱动器"O,"即使驱动器"O"未连接到作为相同的网络资源,创建快捷方式时。
还有一对的策略,可以禁用在两个对象的位置算法,已确定的起始点后的:该操作不使用基于跟踪的方法解析外壳程序快捷方式 (NoResolveTrack) 策略禁用别致的 NTFS 对象的跟踪算法 ;该操作不使用基于搜索的方法解析外壳程序快捷方式 (NoResolveSearch) 策略禁用 low-tech Windows 95 搜索算法。
修复断开的快捷方式是外壳程序的那些 thankless 作业:用户没有甚至意识到它们依赖功能停止工作之前。

Raymond Chen 网站、 的旧的新内容 和具有相同标题的简介册 (Addison-Wesley 2007) Windows 历史记录和 Win32 编程处理。他有时信息通过对进行编码 (差) 将其翻译成德语。

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多