Is it possible to extract file HANDLE from Windows file descriptor or from FILE* ?
As an example, FILE* is implemeted on top of file descriptors, and in turn file descriptors are implemented (on Windows) on top of HANDLEs. A FD can be extracted from FILE* using documented fileno() function. Extracting HANDLE from FD might be more hacking or more documented ....
From what I have gathered from Wikipedia, a file descriptor is an index in a file descriptor table, which points to a file name in a file table, which in turn points to an inode in an inode table. File handle is a type of data structure that stores a file descriptor.
Microsoft/SysInternals Process Explorer - Go to Find > Find Handle or DLL. In the "Handle or DLL substring:" text box, type the path to the file (e.g. "C:\path\to\file. txt") and click "Search". All processes which have an open handle to that file should be listed.
The file handle is used to identify the file in many function calls. Each file handle and file object is generally unique to each process that opens a file—the only exceptions to this are when a file handle held by a process is duplicated, or when a child process inherits the file handles of the parent process.
File descriptors were first used in Unix, and are used by modern operating systems including Linux, macOS, and BSD. In Microsoft Windows, file descriptors are known as file handles.
Yes. See the _get_osfhandle
function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With