-
September 26th, 2009, 04:23 AM
#1
[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.
-
September 26th, 2009, 06:14 AM
#2
Re: Retrieve filename from HANDLE
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?
-
September 26th, 2009, 08:13 AM
#3
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.
-
September 26th, 2009, 08:23 AM
#4
Re: Retrieve filename from HANDLE
Ovidiu,
Ajay already wrote that he "cannot disclose 'how' ..." he is "getting this HANDLE".
And I agree with you that this "how" could help...
Victor Nijegorodov
-
September 26th, 2009, 09:26 AM
#5
Re: Retrieve filename from HANDLE
Originally Posted by VictorN
Ovidiu,
Ajay already wrote that he " cannot disclose 'how' ..." he is " getting this HANDLE".
Oh, sorry! Is a special question/quiz for Chuck Norris, isn't it?
Last edited by ovidiucucu; September 26th, 2009 at 09:35 AM.
-
September 26th, 2009, 10:26 AM
#6
Re: Retrieve filename from HANDLE
Originally Posted by ovidiucucu
Oh, sorry! Is a special question/quiz for Chuck Norris, isn't it?
LOL!
Ajay! How have you resolved this handle/filename problem?
Victor Nijegorodov
-
September 26th, 2009, 10:29 AM
#7
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.
-
September 26th, 2009, 10:39 AM
#8
Re: [RESOLVED] Retrieve filename from HANDLE
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.
Victor Nijegorodov
-
September 26th, 2009, 10:42 AM
#9
Re: [RESOLVED] Retrieve filename from HANDLE
-
September 26th, 2009, 11:50 AM
#10
Re: [RESOLVED] Retrieve filename from HANDLE
Okay, Ajay! I'm looking forward for the article. It seems to be an interesting one.
-
September 26th, 2009, 11:53 AM
#11
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.
-
September 27th, 2009, 04:02 PM
#12
Re: [RESOLVED] Retrieve filename from HANDLE
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.
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. )
Best regards,
Igor
-
September 27th, 2009, 04:57 PM
#13
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:
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!
-
September 28th, 2009, 12:11 PM
#14
Re: [RESOLVED] Retrieve filename from HANDLE
Because it's an undocumented function. Not mentioned anywhere in MSDN. I found it under undocumented.ntinternals.net.
Oh, really?
NtQueryInformationFile
ZwQueryInformationFile
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.
Best regards,
Igor
-
September 28th, 2009, 01:48 PM
#15
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|