Python ConfigParse Write Error


#1

Hello!

I’m creating a function hook using Python. But I’m having problems with an INI Write error.

This error occurs when my Python script is trying to write the INI that is currently being read by another program.

I’ve tried setting admin privilege for the script, but to no avail. There are never any errors when no other program accesses the INI while the Pyhon script writes to it.

It just doesn’t make sense, that other programs can’t read the file- as Python is writing to it. I’m sure there is a workaround- but I tried all I could with no success.
Any help would be much appreciated, thanks!


#2

It would make sense the file is checked out as long as another process has it open for writing. Not being able to write to a file that is open for reading only in another process could imply an inferior approach to opening the file in the first place. Is ‘with…as’ being implemented?


#3

@mtf: There are other coding languages- you can still read the file, while writing- and no lockout. I was speaking in that context.
I attached image of my code. What solution do you recommend?


#4

This is governed by your os, not python
It’s really hard to tell what you did, you’ve only posted the code of one program but you talk about two, you’ve posted a picture so it can’t be executed, and the code is coming from the middle of your program, it can’t be executed on its own


#5

@ionatan, The 2nd program is a reader- that never interacts with the Python script directly. It just reads info of the INI written by the Python script. Below is the full code of my function hook, using FRIDA library. The hook returns a value @ a memory address, when the function is called- then writes it to the INI. I’ll switch from INI to ComObj instead.
Full Image:


#6

That code doesn’t keep the file open, it reads one line and closes it.
You’re doing something other than what you’re saying, which is why the only way anyone can look at it is if you show how to reproduce it (without any other unrelated code, like frida)
and besides, that’s not even the same filename
my guess is you’ve got the file open in some text editor that locks the file while editing


#8

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.