[FileLocksmith.Interop] Enhance File Path Resolution with GetFinalPathNameByHandle #31385
Labels
Help Wanted
We encourage anyone to jump in on these and submit a PR.
Idea-Enhancement
New feature or request on an existing product
Product-File Locksmith
Refers to the File Locksmith utility
Description of the new feature / enhancement
Context
In the current implementation of the FileLocksmith module NtdllExtensions::path_to_kernel_name is utilized to translate NT-style paths to a more conventional, drive-based format.
This translation is necessary after fetching file paths using the
NtDll.NtQuerySystemInformation
function.While this manual approach is functional, Windows API offers a more robust and potentially less error-prone method for achieving the same goal: GetFinalPathNameByHandleW. This function, given a file handle, returns the full drive-based path of the file, including handling various path nuances and edge cases automatically.
Proposal
Replace the current manual method implemented in
path_to_kernel_name
withGetFinalPathNameByHandleW
Scenario when this would be used?
Convert the NT device object path to the path with the drive letter.
Supporting information
Reference implementation in pseudo C#
The text was updated successfully, but these errors were encountered: