UnicodeTest/LockedTest
Moderators: Hacker, petermad, Stefan2, white
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
NtUnlockFile or UnlockFile
UnLockFile().
Description. Unlocks a file specified by a filehandle
Since I didn't use it, it is possible that Win allows just to unlock files locked by your proccess.. in that case you will have to use dll injection....
This is of course, just what I found today.... maybe more info in the future.... I send several mails today so let us hope for the answer.
UnLockFile().
Description. Unlocks a file specified by a filehandle
Since I didn't use it, it is possible that Win allows just to unlock files locked by your proccess.. in that case you will have to use dll injection....
This is of course, just what I found today.... maybe more info in the future.... I send several mails today so let us hope for the answer.
Habemus majkam!
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
What about this procedure. Not very cool but it will be fast.
1. Call handle.exe without params and redirect output to some file. It will list all locked files on the system. U do that on first-file-call from TC.
2. When TC asks for info you search txt file and find the record of application name.
1. Call handle.exe without params and redirect output to some file. It will list all locked files on the system. U do that on first-file-call from TC.
2. When TC asks for info you search txt file and find the record of application name.
Habemus majkam!
- SanskritFritz
- Power Member
- Posts: 3693
- Joined: 2003-07-24, 09:25 UTC
- Location: Budapest, Hungary
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
You should take snapshot of the system every time TC sends request to your plugin but only once (for the first file).
After that you scan this txt file and search for all other posible files selected.
You can go with this for the moment until we find some faster procedure... consider this as workaround. I send e-mails today to Mark Rusinovich and the other gay from WinInternals to share some info about internals of handle.exe. I hope they will answer... I don't know why they shouldn't since they have source code available for most of their apps. You should also use Memory Mapped Files to open handle.exe so to be fast on possible subsequent calls.
2 Sans
What are you talking about ? What stdout ? This is not some batch script !
After that you scan this txt file and search for all other posible files selected.
You can go with this for the moment until we find some faster procedure... consider this as workaround. I send e-mails today to Mark Rusinovich and the other gay from WinInternals to share some info about internals of handle.exe. I hope they will answer... I don't know why they shouldn't since they have source code available for most of their apps. You should also use Memory Mapped Files to open handle.exe so to be fast on possible subsequent calls.
2 Sans
What are you talking about ? What stdout ? This is not some batch script !
Habemus majkam!
I don't understand: "every time" or "once"?You should take snapshot of the system every time TC sends request to your plugin but only once (for the first file).
Look, TC may work for a long time, e.g. 1 hour, so this info (list built for the first call) will not be actual at the end of work time. So when I need to refresh list?
Let's wait.You can go with this for the moment until we find some faster procedure... consider this as workaround. I send e-mails today to Mark Rusinovich and the other
STDOUT is more of a Unix terminology. It means standard output, or in a case of handle.exe what you see as an output in the command prompt.majkinetor ! wrote:What are you talking about ? What stdout ? This is not some batch script !
When you type "handle.exe > fajl.ext" this will redirect STDOUT to file. Almost the same way you can redirect STDIN.
[edit]
And so to make things clear, you CAN'T restrict terminology of STDIN/OUT to batch. What SanskritFritz suggested is almost exactly what you sugest but without file.
This would be directly written to mem. So even better than your way.
Ambiguity succeeds where honesty dares not venture.
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
This is the replay I got from author of Unlocker:
- Hello Miodrag,
Thanks for the information.
There is nothing at the moment that would allow to dosuch thing, but I could include a command line optionfor one of the next releases so that to create a textfile with the list of processes locking the file orfolder.
unlocker pathtounlock -O logfile.txt
Would this be fine for you guys?
Thanks,
Cedrick
- Hello there Cedrick
>>unlocker pathtounlock -O logfile.txt
We already have solution like this, console app made by SysInternals named handle.exe which provides such text file. Unfortunately, this is very hard to connect with current TC content plugin model since we don't know when to refresh this list... U have details about this procedure on our forum post.
Is there any possibility to encapsulate mentioned functionality in a dll ?
Some function that will return string containing name of the app that locked the file ? Or its handle ?
Maybe some short notes about procedure, in few words? I can currently think of just one solution -
1. we know how to find if file is locked. If it is, go to 2
2. iterate all runing processes and search for the file handle among its opened files.
This will be very slow of course, especialy with large selections or directories.
Miodrag
Habemus majkam!
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
The main problem here is that content plugin model doesn't have refresh mechanism... and some basic functions most of plug implementations have.
That is, there is no INIT event or PRE/POST events or usual things all good models have ....
GHSILER should change this.
for instance:
That is, there is no INIT event or PRE/POST events or usual things all good models have ....
GHSILER should change this.
for instance:
- onRefreshStart()
Called before first request
- onRefreshEnd()
Called after TC have finished displaying/searching.
Habemus majkam!
- majkinetor !
- Power Member
- Posts: 1580
- Joined: 2006-01-18, 07:56 UTC
- Contact:
Anyway this is the procedure for now:
You can do systemshot either yourself, or via handle.exe.
I prefer the first solution it will be much faster and it is easy to implement.
C-T>val is effort to catch "the first call" so choosing correct time is of importance. If we set 1000ms you can be sure that when you execute 2. and C-T>val TC has started "new session".
AND GHISLER... FIND THOSE 4 MINUTES... YOU SEE HOW THINGS CAN GET UGLY.
- 1. When dll is first called do systemshot of all open files on the system. Iterate through all open apps and get opened modules into some string. Save the time of this screenshot, T
2. TC calls for the next file. Current time is C. Val is some user conifgurable value like 5 minutes.- [face=courier]if (C-T>val) do systemshot
else search the sysemshot record[/face]
- [face=courier]if (C-T>val) do systemshot
- [face=courier]name ext lock time path
somefile txt Notepad 12:48 + 1230ms c:\windows\notepad.exe[/face]
You can do systemshot either yourself, or via handle.exe.
I prefer the first solution it will be much faster and it is easy to implement.
C-T>val is effort to catch "the first call" so choosing correct time is of importance. If we set 1000ms you can be sure that when you execute 2. and C-T>val TC has started "new session".
AND GHISLER... FIND THOSE 4 MINUTES... YOU SEE HOW THINGS CAN GET UGLY.
Last edited by majkinetor ! on 2006-02-01, 09:57 UTC, edited 2 times in total.
Habemus majkam!