views:

43

answers:

3

Hello,

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?

+1  A: 

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...

tommieb75
@tommieb75: but i can hook only my application not target, this is good way but if i would be can do DLL injection on all applications working on system then i will hook CreateFile is good method.
Svisstack
@svisstack - easyhook works by injection..and is global hooking...
tommieb75
+1  A: 

Use the backup API if you have sufficient privilege. Otherwise, note that these flags exist for a reason. If someone disabled sharing, it's disabled.

You want to call BackupRead, and MSDN notes the following:

a backup application must have access to the system-level access control settings, the ACCESS_SYSTEM_SECURITY flag must be specified in the dwDesiredAccess parameter value passed to CreateFile.value passed to CreateFile.

parameter value passed to CreateFile.

bmargulies
@bmargulies: what you mean backup API?
Svisstack
@bmargulies In some libraries when you open the file, sharing is disabled under the hood and the programmer doesn't even know if shareing is enabled or disabled. So your comment about "for a reason" isn ot applicable.
Eugene Mayevski 'EldoS Corp
@Eug well, ok, there's only so much I can recommend to people stuck with the output of idiots. (e.g. libraries that forbid sharing for no good reason).
bmargulies
+1  A: 

One of the options is to use our RawDisk product, which lets you bypass system security restrictions and open files, which have been opened exclusively or the ones for which you don't have access rights. Note, that installing RawDisk itself requires admin rights, so RawDisk can't be used for intrusion to other's computer.

Another option is to use backup API, i.e. above mentioned BackupRead() Windows API function. Doing google search for BackupAPI will give you not just description of this function, but also several comments from users about what's involved in using this backup API

Eugene Mayevski 'EldoS Corp