Search code examples
windowssecuritywinapireadfilefile-sharing

How to read data using ReadFile when file has disabled sharing on read


I have a problem, i have a file who opened other process and this process defined in CreateFile non file sharing, then i have other application and i want read data from this file in same time, but how to do.

I can't change file sharing in first application. I can reach computer administrator right's, i can do changes in system, but probably "code" solution will be better for this problem if this can be done by code.

Can anyone help me?


Solution

  • How about using EasyHook and hook in the API to the CreateFile routine, in effect, your code will intercept the API and possibly change the dwShareMode parameter to make it FILE_SHARE_READ bitwise or FILE_SHARE_WRITE i.e. (FILE_SHARE_READ|FILE_SHARE_WRITE) and call the original hook to allow the CreateFile to work normally...