![]() |
how do you get a list of open file handles?
I know of some programs that do this, such as SysInternals' Handle.exe or ProcessExplorer.
But I am trying to do it in my own code, and I don't know what I should be looking for. One thing I found was to maybe use the ROT (Running Objects Table), but I don't see enough information. Another possiblity is to get a list of handles for each process, but the closest I find is HandleCount: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdiagnosticsprocessmemberstopic.asp and that is just the number of handles, no way to access the Handles themselves and find what process has them open. I would like to look at the process handle table directly, but apparently you have to inject a device driver to do this, which is more complicated than I'd like it to be. It would be a big help if someone could help me with disassembling this: http://www.sysinternals.com/Utilities/Handle.html or this: http://www.microsoft.com/windows2000/techinfo/reskit/tools/existing/oh-o.asp So I could have some idea of what they are doing, namely what system calls they're making. But I have never done any disassembly before and I am confused about how to handle this. |
well i read some thing about some one asking the same question some where :)
it was also describing the difference between ms oh.exe and sysinternals handle i think one is usermode completely and other uses r0 procedures aka uses a driver though i cannot find that article now ( i think you have to browse throug holy_fathers forum i think thats where i read about it but i am not sure ) but you can use the undocumented NtQuerySystemInformation() with info class 16 here is a code that was posted on osronline by Prasad Dabak long time back that you can try out i dont have link i only have this code and referance but google should fetch you the original thread Code:
Hello, |
Memory Hacking Software comes with a FileWatcher DLL plug-in that monitors all file activity in the target process.
The plug-in itself comes inside the regular download of Memory Hacking Software. The source for the plug-in is also on the site, which means you can modify it to do anything else you need it to do. Instructions on how to use the DLL are included in the package. Load the target process in debug mode to make sure you catch ALL file activity, from the very start of the application��s life. Again, the source is there to be extended into whatever you need it to do. Have fun�� h??p://www.memoryhacking.com L. Spiro |
for Windows 95/98 sample:
Code:
// OpenFiles.cpp (Windows 95/98 Only!) |
�ne little addition to JuneMouse's answer:
given code enumerates _all_ handles, not just open file handles. The way to determine witch of them are _file_ handles is to check ObjectType member of HandleInfo structure. ObjectType value for file type is different for different OS'es and, so, it must be detected dynamically. It could be done, for example, by searching known file handle. |
| All times are GMT +8. The time now is 16:38. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX