![]() |
file name from remote proc |
Post Reply
|
Page 12> |
| Author | |
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Topic: file name from remote procPosted: 11 May 2006 at 8:14am |
|
I want to obtain file name of file locked by remote process. I used NtQuerySystemInformation to get handles and then I use this function to filter only Files and to obtain file name. Something is wrong and I can't figure out what:
Everything here works fine until obvious comment line. Also, for some reason, NTSTATUS code returned by NtQueryInformationFile is some large negative value, so I can't see why it isn't working. I hope someobody can help me see the problem, or at least to help me retrieve valid NTSTATUS code. thx. |
|
![]() |
|
EP_X0FF
Senior Member
Joined: 08 March 2006 Location: Russian Federation Online Status: Offline Posts: 4753 |
Quote Reply
Posted: 11 May 2006 at 8:18am |
![]() |
|
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Posted: 11 May 2006 at 8:37am |
|
I was already !
The error about return type was trivial: long rc = NtQueryInformationFile(h, &status ... long rc -> DWORD rc error reported is: Invalid Handle. Now, that is strange, since the same handle was valid for NTQueryObject... |
|
![]() |
|
EP_X0FF
Senior Member
Joined: 08 March 2006 Location: Russian Federation Online Status: Offline Posts: 4753 |
Quote Reply
Posted: 11 May 2006 at 8:39am |
|
OpenProcess flags?
DuplicateHandle flags? |
|
![]() |
|
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Posted: 11 May 2006 at 8:46am |
|
then after fixing handle problem:
The specified request is nota valid operation for the target device |
|
![]() |
|
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Posted: 11 May 2006 at 8:47am |
|
This is how I declared those functions:
Edited by majkinetor - 11 May 2006 at 8:49am |
|
![]() |
|
EP_X0FF
Senior Member
Joined: 08 March 2006 Location: Russian Federation Online Status: Offline Posts: 4753 |
Quote Reply
Posted: 11 May 2006 at 8:50am |
|
Grant more privilegies to OpenProcess? Why not use NtQueryObject - Object Name Information class?
|
|
![]() |
|
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Posted: 11 May 2006 at 11:41am |
|
Thank you EP_X0FF.
I switched to NtQO function and everything is ok up to the part where it hangs for long period of time. I have to open thread to execute this function and kill it after some short time. I have to ask for opinion here if you have time: Since I am trying to create Total Commander so called content plugin this needs to be fast, because it will be called for each file in the directory. The plugin is supouse to return information about file's lock status and to return string containing names of applications which hold the lock. I am caching information on the first file (I create a snapshot of all open files in the system) and look into cache on all other subsequent files. Therefore, above procedure will be executed only once, but it still have to be fast to alow TC to function normaly (lets say, everything up to 2 seconds should be fine). I am concerned here how big impact on procedure speed will have creating new thread for every file handle in the system (on my system, currently > 1000) thx |
|
![]() |
|
EP_X0FF
Senior Member
Joined: 08 March 2006 Location: Russian Federation Online Status: Offline Posts: 4753 |
Quote Reply
Posted: 11 May 2006 at 11:55am |
|
Yes it will decrease performance. Each thread will decrease performance and your plugin will works very slow and probably use more memory. As you know NtQueryObjects sometimes hungs. It happens when it trying to get name of NamedPipe object. So for this reason I think you are creating new threads. But in forum-thread "Enumerate opened files" we have not get solution for this "hung" problem. It is known that under Ring0 (Kernel Mode) everything works fine (look on Process Explorer). But for this solution you need to create driver and this I think is too much for some simple program as "tc plugin". Hope this small information on bad english
will help you.
Regards. |
|
|
Ring0 - the source of inspiration
|
|
![]() |
|
majkinetor
Groupie
Joined: 17 April 2006 Location: Yugoslavia Online Status: Offline Posts: 42 |
Quote Reply
Posted: 12 May 2006 at 3:19am |
|
I don't know what is going on here, since when my console application that I am using for test hang, I can not delete it for very long period of time (it is up for more then 20 minutes now...). TaskInfo & Proc Exp can not kill it also.
You are right, that is too big project for simple plugin, it already took me much time to come to this stage. Anyway you were of great help and I thank you for that. Your english is fine by me.
|
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |