[RESOLVED] Retrieve filename from HANDLE
I got the HANDLE to a file, and I need to find the filename associated.
- GetFileInformationByHandle returns other information about file, but not filename.
- I don't want to use NtQueryInformationFile
- Cannot use CFile(HANDLE), CFile::GetFileName, since it needs open file-handle. I just have file-handle (no open file).
- This is not appealing me:
http://msdn.microsoft.com/en-us/libr...89(VS.85).aspx
For now, I cannot disclose "how" I am getting this HANDLE. :cool:
Re: Retrieve filename from HANDLE
Quote:
Originally Posted by
Ajay Vijay
I got the HANDLE to a file, and I need to find the filename associated. [...]
One question: how did you get the HANDLE to that file?
Re: Retrieve filename from HANDLE
I already mentioned, that I cannot tell how I got the handle (at least for now!).
Thus, for now I've used the MSDN's code to retrieve the filename.
Re: Retrieve filename from HANDLE
Ovidiu,
Ajay already wrote that he "cannot disclose 'how' ..." he is "getting this HANDLE". :sick:
And I agree with you that this "how" could help... :rolleyes:
Re: Retrieve filename from HANDLE
Quote:
Originally Posted by
VictorN
Ovidiu,
Ajay already wrote that he "cannot disclose 'how' ..." he is "getting this HANDLE". :sick:
Oh, sorry! Is a special question/quiz for Chuck Norris, isn't it? :D
Re: Retrieve filename from HANDLE
Quote:
Originally Posted by
ovidiucucu
Oh, sorry! Is a special question/quiz for
Chuck Norris, isn't it? :D
LOL! :D:thumb:
Ajay! How have you resolved this handle/filename problem?
Re: [RESOLVED] Retrieve filename from HANDLE
Well, right now I am using this approach: http://msdn.microsoft.com/en-us/libr...89(VS.85).aspx
Okay, I am going to write an article for CodeGuru.com, and for that I needed to find out name of file, associated with handle. But I want to keep the topic private to myself, till I write and submit for posting.
Re: [RESOLVED] Retrieve filename from HANDLE
Quote:
Originally Posted by
Ajay Vijay
Well, right now I am using this approach:
http://msdn.microsoft.com/en-us/libr...89(VS.85).aspx
Okay, I am going to write an article for CodeGuru.com, and for that I needed to find out name of file, associated with handle. But I want to keep the topic private to myself, till I write and submit for posting.
Well, We'll wait for your article...
BTW, the link you provided is wrong. :sick:
Re: [RESOLVED] Retrieve filename from HANDLE
Quote:
Originally Posted by
VictorN
BTW, the link you provided is wrong. :sick:
I just copied and pasted from the link in the first post. Please navigate from the link in first post.
I am wondering, why I need tell the same thing twice? :o:confused:
Re: [RESOLVED] Retrieve filename from HANDLE
Okay, Ajay! I'm looking forward for the article. It seems to be an interesting one. ;)
Re: [RESOLVED] Retrieve filename from HANDLE
One thing! I've not written a single word for the article as of now. May take few days to finish.
The article (on multithreading), that I've already submitted for posting isn't the one I am working on. ;)
Re: [RESOLVED] Retrieve filename from HANDLE
Quote:
Originally Posted by
Ajay Vijay
I got the HANDLE to a file, and
I need to find the filename associated.
- I don't want to use NtQueryInformationFile
Sounds... like not very reasonable. Afraid you have no other choice. I wouldn't be surprised if I found out that GetMappedFileName uses NtQueryInformationFile internally. :cool:
Besides, I'd like to hear about the reason of such a dislike to a very basic API. (Please, don't tell me it's just because the approach is not a brand new one. :D)
Re: [RESOLVED] Retrieve filename from HANDLE
Because it's an undocumented function. Not mentioned anywhere in MSDN. I found it under undocumented.ntinternals.net. Further to that, other similar APIs (like NtQueryInformationProcess), says something in MSDN:
Quote:
Originally Posted by MSDN
[NtQueryInformationProcess may be altered or unavailable in future versions of Windows. Applications should use the alternate functions listed in this topic.]
I am still a user-mode programmer, I cannot think of these APIs till I start with kernel-mode programming! ;)
Re: [RESOLVED] Retrieve filename from HANDLE
Quote:
Because it's an undocumented function. Not mentioned anywhere in MSDN. I found it under undocumented.ntinternals.net.
Oh, really?
NtQueryInformationFile
ZwQueryInformationFile
Quote:
I am still a user-mode programmer, I cannot think of these APIs till I start with kernel-mode programming!
That's too bad. I am a user-mode programmer too, and I never stop thinking of the NtXxxx functions, as they are legal portals from user mode to kernel mode. :D
Re: [RESOLVED] Retrieve filename from HANDLE
The APIs were in Kernel-Mode Driver Architecture group, and I would not use it for the sake of article. :cool:;)