Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PermissionError: [WinError 32] The process cannot access the file because it is being used by another process #76

Open
chankruze opened this issue Sep 1, 2021 · 0 comments

Comments

@chankruze
Copy link

While decrypting Realme X (RMX1901_11_F.02) firmware, I encountered below error:

D:\lab\REALME>python oppo_ozip_decrypt\ozipdecrypt.py RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
ozipdecrypt 1.31 (c) B.Kerler 2017-2021
"There is no item named 'oppo_metadata' in the archive"
Detected mode 2....
Finding key...  RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
Unknown mode2, boot.img wasn't encrypted
Extracting...  RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
Traceback (most recent call last):
  File "D:\lab\REALME\oppo_ozip_decrypt\ozipdecrypt.py", line 258, in main
    if zo.extract('oppo_metadata', outpath):
  File "C:\Users\chankruze\AppData\Local\Programs\Python\Python39\lib\zipfile.py", line 1616, in extract
    return self._extract_member(member, path, pwd)
  File "C:\Users\chankruze\AppData\Local\Programs\Python\Python39\lib\zipfile.py", line 1655, in _extract_member
    member = self.getinfo(member)
  File "C:\Users\chankruze\AppData\Local\Programs\Python\Python39\lib\zipfile.py", line 1429, in getinfo
    raise KeyError(
KeyError: "There is no item named 'oppo_metadata' in the archive"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\lab\REALME\oppo_ozip_decrypt\ozipdecrypt.py", line 317, in <module>
    sys.exit(main(args.filename))
  File "D:\lab\REALME\oppo_ozip_decrypt\ozipdecrypt.py", line 265, in main
    return mode2(filename)
  File "D:\lab\REALME\oppo_ozip_decrypt\ozipdecrypt.py", line 208, in mode2
    os.remove(os.path.join(temp,"out"))
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'D:\\lab\\REALME\\temp\\out'

Then I commented out line no 208 as shown below:
image

After that it worked.

D:\lab\REALME>python oppo_ozip_decrypt\ozipdecrypt.py RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
ozipdecrypt 1.31 (c) B.Kerler 2017-2021
"There is no item named 'oppo_metadata' in the archive"
Detected mode 2....
Finding key...  RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
Unknown mode2, boot.img wasn't encrypted
Extracting...  RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.ozip
DONE... file decrypted to: D:\lab\REALME\RMX1901EX_11_OTA_10200270_all_236N4HwASEdD.zip

I believe that with open can be improved (It was very late in the morning so I had no patience to look the code). Another suggestion is to use snake case naming scheme if possible, it looks like more like C code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant