Write in the running EXE file 
Author Message
 Write in the running EXE file

Hello all,

The problem is that I would like to write inside the exe file that I am
running in order to change the value at a specific address.
I try to open the exe file with Open then Seek the file to the specific
address and finally Put a new value in this address.
Is it possible to bypass the windows 95 file protection that don't allow me
to write to the file I am running.

Thanks in advance




Tue, 10 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Every OS that I've ever programmed in: DOS, Win 3.1, Win 95/NT, OS/2, Novell
Network, etc. will not allow a running executable file to be deleted or
written to, at least by default. I believe this is standard practice, and
I've never heard of a configuration to enable what you need. If the
executable is running only from your local client HD, rather than from the
network, then maybe an API function will allow this.

Eric


Quote:
>Hello all,

>The problem is that I would like to write inside the exe file that I am
>running in order to change the value at a specific address.
>I try to open the exe file with Open then Seek the file to the specific
>address and finally Put a new value in this address.
>Is it possible to bypass the windows 95 file protection that don't allow me
>to write to the file I am running.

>Thanks in advance





Tue, 10 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

It would be much better to have an ini file or save a value in the registry
but...

You can open the file as binary, which will allow you to read and write at
the same time.  This will also keep the file from being corrupted when it is
saved:

Dim mychar As String * 1
Open TempFile For Binary As #1
        Get #1, fileposition, mychar$
        Put #1, fileposition, mychar$
Close #1

where fileposition is the location to change


Quote:
>Hello all,

>The problem is that I would like to write inside the exe file that I am
>running in order to change the value at a specific address.
>I try to open the exe file with Open then Seek the file to the specific
>address and finally Put a new value in this address.
>Is it possible to bypass the windows 95 file protection that don't allow me
>to write to the file I am running.

>Thanks in advance





Tue, 10 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

While I don't think you CAN, I don't think you WANT to.

Better way to do it: Spawn a second process, wait for the first
process to die, modify the first EXE, spawn the first EXE again and
let the 2nd one die. Save some state when you exit the first exe and
it re-starts it can go back to where it "was".

Kevin



Quote:
>Hello all,

>The problem is that I would like to write inside the exe file that I am
>running in order to change the value at a specific address.
>I try to open the exe file with Open then Seek the file to the specific
>address and finally Put a new value in this address.
>Is it possible to bypass the windows 95 file protection that don't allow me
>to write to the file I am running.

>Thanks in advance





Tue, 10 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Did I mention that you don't WANT to modify EXEs? You would be much
better off just writing changing information to the registry (or the
old way, an INI file).

Kevin



Quote:
>Hello all,

>The problem is that I would like to write inside the exe file that I am
>running in order to change the value at a specific address.
>I try to open the exe file with Open then Seek the file to the specific
>address and finally Put a new value in this address.
>Is it possible to bypass the windows 95 file protection that don't allow me
>to write to the file I am running.

>Thanks in advance





Tue, 10 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Quote:

> Every OS that I've ever programmed in: DOS, Win 3.1, Win 95/NT, OS/2, Novell
> Network, etc. will not allow a running executable file to be deleted or
> written to, at least by default. I believe this is standard practice, and
> I've never heard of a configuration to enable what you need. If the
> executable is running only from your local client HD, rather than from the
> network, then maybe an API function will allow this.

> Eric


I was sucessful with that same crazy scheme, once upon a time in DOS. I
stored magic numbers
at the end of the .EXE that determined whether it would continue running
after a certain
number of uses. Worked pretty good, too... course there was no network
involved, and I
didn't realize at the time that it couldn't be done. :)
It was some of my favorite code... took a 'snapshot' of a database and
used that as a seed
for my little encryption routine. A user could read the generated number
to me and I could
give them another number that somehow had number of uses in it. Since
everybodies data was
different, so were the magic numbers. Well... back to work.


Fri, 13 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Quote:


>I was sucessful with that same crazy scheme, once upon a time in DOS. I
>stored magic numbers
>at the end of the .EXE that determined whether it would continue running
>after a certain
>number of uses. Worked pretty good, too... course there was no network
>involved, and I
>didn't realize at the time that it couldn't be done. :)

amazing what can be done when you don't know otherwise.  I once wrote
a couple of DXF files for use with AutoCAD (in dos 2.0) called:

fr 1.dxf
fr 2.dxf
fr 3.dxf

Notice the spaces?  Well, I wrote them with an app I had written in Turbo
Pascal and could neither use them in AutoCAD nor delete them till I
formatted the hard drive years later.



Fri, 13 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Oops!  This is for writing and reading an exe that is NOT running.  I don't
know that you can or would want to write to an exe that is running.

Quote:

>It would be much better to have an ini file or save a value in the registry
>but...

>You can open the file as binary, which will allow you to read and write at
>the same time.  This will also keep the file from being corrupted when it
is
>saved:

>Dim mychar As String * 1
>Open TempFile For Binary As #1
>        Get #1, fileposition, mychar$
>        Put #1, fileposition, mychar$
>Close #1

>where fileposition is the location to change



>>Hello all,

>>The problem is that I would like to write inside the exe file that I am
>>running in order to change the value at a specific address.
>>I try to open the exe file with Open then Seek the file to the specific
>>address and finally Put a new value in this address.
>>Is it possible to bypass the windows 95 file protection that don't allow
me
>>to write to the file I am running.

>>Thanks in advance





Fri, 13 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

Quote:

> > Every OS that I've ever programmed in: DOS, Win 3.1, Win 95/NT, OS/2, Novell
> > Network, etc. will not allow a running executable file to be deleted or
> > written to, at least by default. I believe this is standard practice, and
> > I've never heard of a configuration to enable what you need.

Not too useful, except for grins,
but spacecraft computer programs are routinely rewritten
while the extremely vital programs onboard continue to run.

I presume it's not trivial to do... ;)

- Matt



Fri, 13 Oct 2000 03:00:00 GMT  
 Write in the running EXE file

The same technique used to replace a DLL that is in use might work.
While you can't overwrite the existing DLL, you can rename it and
then copy in a new version with the same name. The next time it is
referenced, the new one is loaded.

A note of caution -  if you replace core system components on NT
that are not compatible with your service pack level, then you'll kick
yourself when you next restart your machine. If you are running the
NTFS file system, you can end up having to rebuild your machine.

Michael D. Long



Quote:
> Oops!  This is for writing and reading an exe that is NOT running.  I
don't
> know that you can or would want to write to an exe that is running.



Tue, 24 Oct 2000 03:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Write in the running EXE file

2. Write in the running EXE file

3. Writing to a running program's EXE file

4. Running setup.exe by writing code

5. VB4.0EE 32bit Error writing EXE w/Rmt Supt files

6. datareport seems to crash writing of exe file

7. System Error when writing a VB exe file

8. VB5 Crashes when writing the exe file

9. writing data to .exe file

10. Load A new Version of an Exe File From the same Exe file

11. Load A new Version of an Exe File From the same Exe file

12. Running a dos EXE file from Access'97

 

 
Powered by phpBB® Forum Software