Click here to Skip to main content
14,930,722 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to copy a file that is being used by "System" process[pid:4]
I iterated all the handles for this process and duplicated the handle for the file i required. now when i am reading the file using this handle it says "access denied"
is there any way to change the "share mode" using this duplicate handle so that I can read it?
Posted

Nope (as far as I know): that would be a security treat.
   
Comments
Sergey Alexandrovich Kryukov 24-Mar-11 15:40pm
   
I think your right. Shared more is granted, not grabbed. My 5.
--SA
mbue 24-Mar-11 15:47pm
   
Indeed! - sometimes there is a reason to open a file exclusive.
Regards.
CPallini is right. If the handle is not inheritable (which is the default), you can't use it from another process.

If you know the name of the file, you can try to open it with CreateFile and use FILE_SHARE_READ | FILE_SHARE_WRITE flags.

If you don't know the name of the file, you can try to get it from its handle there:
http://msdn.microsoft.com/en-us/library/aa366789(v=vs.85).aspx[^]
   
Comments
Sergey Alexandrovich Kryukov 24-Mar-11 15:41pm
   
I agree, too. Good Answer, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900