Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have used a code which hooks ZwQueryDirectryFile in ssdt and whenever this function is called, my function, NewZwQueryDirectryFile, is executed. I need to know the full pathes of the files in the opened directory but I only get the names. Is there any way I can get the full path of the files in the direcory?
I can not use functions like GetFileNameFromHandle which are included in windows.h because I am writing a driver and including "windows.h" casues me a lot of trouble.

P.S.
I am trying to write an anti-virus.

Thank you.
Posted

You can try to use ZwQueryInformationFile (using FileNameInformation class) with directory handle passed to ZwQueryDirectryFile
 
Share this answer
 
If including Windows.h creates a problem for you, then use those functions without including Windows.h

Just call LoadLibrary and then GetProcAddress to load up the function and then call it, that'd be the simplest solution, like shown below...

C#
typedef DWORD (CALLBACK* LP_GFPNBH)(HANDLE, LPTSTR, DWORD, DWORD);
HMODULE hModule = ::LoadLibrary("Kernel32.dll");
LP_GFPNBH func = (LP_GFPNBH)::GetProcAddress(hModule, "GetFinalPathNameByHandle");

// Calling function:
func(...parameters...);
 
Share this answer
 
v4

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900