UnicodeTest/LockedTest

Discuss and announce Total Commander plugins, addons and other useful tools here, both their usage and their development.

Moderators: white, Hacker, petermad, Stefan2

User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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.
Habemus majkam!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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.
Habemus majkam!
User avatar
SanskritFritz
Power Member
Power Member
Posts: 3693
Joined: 2003-07-24, 09:25 UTC
Location: Budapest, Hungary

Post by *SanskritFritz »

Call handle.exe without params and redirect output to some file
Or capture the STDOUT?
I switched to Linux, bye and thanks for all the fish!
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

What about this procedure. Not very cool but it will be fast.
Good idea. But when I need to refresh this list from plugin?
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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 !
Habemus majkam!
User avatar
Alextp
Power Member
Power Member
Posts: 2321
Joined: 2004-08-16, 22:35 UTC
Location: Russian Federation
Contact:

Post by *Alextp »

You should take snapshot of the system every time TC sends request to your plugin but only once (for the first file).
I don't understand: "every time" or "once"?
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?
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
Let's wait.
User avatar
frenky
Senior Member
Senior Member
Posts: 250
Joined: 2005-07-30, 19:36 UTC

Post by *frenky »

majkinetor ! wrote:What are you talking about ? What stdout ? This is not some batch script !
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.

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.
User avatar
SQUIRE
Senior Member
Senior Member
Posts: 373
Joined: 2005-06-16, 18:07 UTC

Post by *SQUIRE »

majkinator ! wrote: I send e-mails today to Mark Rusinovich and the other gay from WinInternals
ROFLMAO! You're never going to get an answer majki, you're going to get a lawsuit! :D
User avatar
frenky
Senior Member
Senior Member
Posts: 250
Joined: 2005-07-30, 19:36 UTC

Post by *frenky »

:lol:
Ambiguity succeeds where honesty dares not venture.
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

majkinetor wrote:What are you talking about ? What stdout ? This is not some batch script !
I donot know what was I thinking... sorry.




Alex
I will see what I can do... I must check TC content plugin spec. I currently can't answer the last question....
Habemus majkam!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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
My replay:
  • 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!
KevinMo
Member
Member
Posts: 104
Joined: 2005-03-27, 01:37 UTC

Post by *KevinMo »

A little request / suggestion:
Would you mind to add another column which uses only one letter or several letters to indicate the information?
I mean, for example, A=ANSI, U=Unicode, P=Partial Unicode, X=Invalid.
Regards,
Kevin
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

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:
  • onRefreshStart()
    Called before first request
  • onRefreshEnd()
    Called after TC have finished displaying/searching.
This is 4 minutes work for you ghisler... Just put 1st func before FileNext loop and 2nd after.... and thats it.
Habemus majkam!
User avatar
majkinetor !
Power Member
Power Member
Posts: 1580
Joined: 2006-01-18, 07:56 UTC
Contact:

Post by *majkinetor ! »

Anyway this is the procedure for now:
  • 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]
You can also make one extra field: Time in which U can store time of the systemshot that was used to obtain info and C-T value, just to have this information when analyzing locks. Like this:
  • [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!
User avatar
frenky
Senior Member
Senior Member
Posts: 250
Joined: 2005-07-30, 19:36 UTC

Post by *frenky »

2KevinMo
I do not think this would be enough.
E.g. Unicode can be UTF-8 or UTF-16... If such difference would be implemented. ASCII can be 7 or 8 bit etc..
Ambiguity succeeds where honesty dares not venture.
Post Reply