Hi.
Is there a way to write in a file that is in use ( on this way: ios::out | ios::binary | ios::trunc )?
Hi.
Is there a way to write in a file that is in use ( on this way: ios::out | ios::binary | ios::trunc )?
yes, unless the other program opened it in exclusive mode or "deny write" mode.
Is there an (easy) way to find that out and how can I change it on a way that it isn't on "deny write" mode?
Thanks Yuri.
try to open the file.Originally Posted by Yuri
You can't. The other program opened it like that for good reason -- it woesn't want anyone pulling the rug from under it. The other program may be in the process of writing to the file, so if you were to write to the same file you would really fu**k it up! The file would be nearly useless for anyone.Originally Posted by Yuri
Ok, the file is only in use for reading by another process, I foung something on MSDN, it's called Unlockfile
http://msdn.microsoft.com/library/de...unlockfile.asp could that help me with unlocking the file and make it writeable because I don't really understand it on MSDN.
As Ancient dragon said, you don't want to write to a locked file because it may be in use by another programme. It makes sense to me.
No it doesn't to me because I know the situation, I'll explain: The file I hook up in the process can after being loaded into the process deleted (I mean with deleted: it wont effect the process to crash) even when it's in use (what it always is) by that process after being loaded then you can delete (I mean with deleted: it wont effect the process to crash) the file with "ForceDel.exe" and the file is gone and then you can put the file that it replaces back, everyhting is then fine, the reason why the Process still use the file is because it is a protection against cheaters, the reason that I need to rewrite the file after being loaded in the process is because the file needs to be the same as the file it replaces, if the file isn't the same as the file it replaces then it will get a md5 mismatch and I get caught. That is why I want to 'Unlock' the file to make it writeable and to bypass the md5 tool.
Kill the other programs handle on the file, then it's possible.Originally Posted by bumfluff
Yeah, I was thinking about to kill the handle on that file but I can not kill the whole process because then the 'game' will stop running and that is not what I want... now I saw a program (procexp.exe) which is pretty usefull because if you select the 'game' then you will see (after a bit of scrolling) under "Type" that it is a File (we all knew that) and then the Path and FileName then I simple click with left mouse on that file which is running under the 'game' and press 'Close Handle' now everything is fine and I can rewrite or delete the file but the thing is:
I want to do (almost) the exact same thing, to close the handle on that file, nothing more because else the 'game' will get closed too. But I want it in my program and not to Alt + Tab out and etc. I know TerminateProcess but what to do if only want to close a certain file of the process (the 'game')?? Thanks Yuri.
Thanks but I already know that site and got the source.. the thing that I don't understand it, example: if I would use a part of his source and I want that it only deletes a certain file.. where do I need to put the "path\\filename" string?