madshi.net Forum Index madshi.net
high quality low level programming
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What kind of API do i hook to prevent from moving file ...

 
Post new topic   Reply to topic    madshi.net Forum Index -> madCodeHook
View previous topic :: View next topic  
Author Message
Rootmanager



Joined: 13 Jun 2008
Posts: 12

PostPosted: Fri Jun 13, 2008 10:01 am    Post subject: What kind of API do i hook to prevent from moving file ... Reply with quote

I want to prevent from deleing important file from user.
So i hook the DeleteFileA and DeleteFileW API.
It Works good When i trying to delete file in the ms explorer.

But When i tring to delete file with OS Recycle Bin active status.
My code does not work.
I think MS Windows does not use DeleteFileA/W API, When file move to Recyle Bin.
I know if i did not use Recyle Bin on the MS OS, My code will work.

But i want to trap file delete action , although file move to Recyle Bin.

Does anybody know What API should i hook ?

Please, Give me a idea.

Thanks.
Back to top
View user's profile Send private message
TiLT



Joined: 12 Jun 2008
Posts: 2

PostPosted: Sat Jun 14, 2008 4:13 am    Post subject: Reply with quote

Is it so hard to check the exports of ntdll?
Back to top
View user's profile Send private message
mikec



Joined: 16 Jul 2006
Posts: 166
Location: UK

PostPosted: Tue Jun 24, 2008 12:41 pm    Post subject: quick suggesition.. Reply with quote

What you're trying to do is difficult. I had the same problem ages ago and i worked on it for a month before coming up with a better solution.

I would suggest looking at the native API's instead of the Win32 ones. If i remember rightly, when i traced this, the system used NtDeleteFile but it also called NtQueryInformationFile and NtSetInformationFile in certain circumstances..

HTH

Mike
Back to top
View user's profile Send private message
Rootmanager



Joined: 13 Jun 2008
Posts: 12

PostPosted: Thu Jun 26, 2008 12:46 pm    Post subject: Reply with quote

Thank you. I'll try. very happy
Back to top
View user's profile Send private message
madshi
Site Admin


Joined: 21 Mar 2004
Posts: 5908

PostPosted: Thu Jul 03, 2008 8:43 pm    Post subject: Reply with quote

NtSetInformationFile sounds like the most promising API to me. It's used for both renaming/moving and deleting file, if I remember correctly.
Back to top
View user's profile Send private message Send e-mail
dcsoft



Joined: 11 Dec 2004
Posts: 353
Location: San Francisco Bay Area, CA USA

PostPosted: Sat Jul 12, 2008 6:14 pm    Post subject: Reply with quote

SHFileOperation() is used to recycle a file. I'm not sure there are any more API's that also do, so hooking an Nt() function as suggested may be more reliable.

-- David
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    madshi.net Forum Index -> madCodeHook All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group