Reading from a file used by another process

For the application, I want to read the Google Chrome cache files. The problem is that Chrome works, files open and can be updated in the process.

So when i tried

data_1 = open("C:\Users\user\AppData\Local\Google\Chrome\User Data\Default\Cache\data_1")

He gave me

IOError: [Errno 13] Permission denied: 'C:\\Users\\user\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\Cache\\data_1' .

Since it says Permission denied ( EDIT: I have permission "full controll" on the file). I also tried it in a window with elevated cmd. The same thing is happening. It works great when Chrome is not working. I want something like this (FileShare on.net) .

I think Chrome will allow access to public access, because I saw this application running it.

Edit:

I think I'm wrong. As lulyon said, it seems Chrome is blocking the file. Because I tried this on vb.net, for example:

 Dim d As New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.Read) 

He says:

The process cannot access the file because it is being used by another process.

Initially, I thought that ChromeCacheView was copying the file to another location. So I took a deeper look using the process monitor. Check out this screenshot. Doesn’t this mean that both applications use the same files?

Process monitor: Chrome and ChromeCacheView

I don’t think there will be any understanding between them, since ChromeCacheView is a third-party application. So how is this possible?

+4
source share
1 answer

Probably chrome will prevent you from writing to the cache file that it uses. Try to make a copy of the cache file (with any tools (for example, the cp command) that you have), and perform replica I / O.

A possible explanation is that when chrome gets permission to read, write, and add access by simply opening a file with read permission, reading bytes with a search operation behind the scenes can ruin your own reading content, so it will be denied the OS .

To check read permissions, before you call the open function with default read access, use os.stat (file path) .st_mode; to find if you have read permission.

Only if it is confirmed that you do not have read permissions, could we go further to find out why chrome blocks your access to the cache file, but does not apply to ChromeCacheView.

+1
source

Source: https://habr.com/ru/post/1492436/


All Articles