Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27523 Discussions

Read open file and decompile fortran program

JNichols
New Contributor I
717 Views

I have an old Fortran file (exe) that writes to a text file.  The name of the text file is built in and I cannot change it.  I do not have the code. 

Once the file is open the program writes to it about 2000 times per second, and the program needs to run for days if not months.  

Is there anyway in Fortran to read or copy or something to get access to the data? whilst it is open and being written to?   I want to read it about as often as the writes? 

Can I decompile the exe file?  

0 Kudos
1 Solution
Steve_Lionel
Black Belt Retired Employee
696 Views

You can't decompile into anything useful.

As for accessing the file while it is being written, that depends on the options specified when the file was opened for writing. The default is no shared access, and the OS will block you.

View solution in original post

4 Replies
Steve_Lionel
Black Belt Retired Employee
697 Views

You can't decompile into anything useful.

As for accessing the file while it is being written, that depends on the options specified when the file was opened for writing. The default is no shared access, and the OS will block you.

GVautier
New Contributor II
676 Views

The name of the file is somewhere in the executable. With an hexadecimal editor, you can search for it and change the name to a more convenient (CON or NUL for example).The name can be duplicated in the executable and it's risky if the new name is longer than the previous.

jimdempseyatthecove
Black Belt
653 Views

Does the program use the Fortran .dll runtime library? If so, then you could be able to locate the dispatch table for the Fortran Open function and patch it (hook it)  to filter the arguments. Upon entry to the filter, when the name is noted as being that of the current output file, you can change the name... .AND. change the open mode to support shared access while being written. You could also add a filter for the WRITE for example to report count of I/O's (reading the file size does not necessarily show the correct information due to I/O buffering).

 

Jim Dempsey

JNichols
New Contributor I
643 Views

Thanks for the suggestions.  The code reads a serial port.  After reading Steve's note,  I realized the program reads to and from a serial port.  I found a port sniffer and noted the ASCII codes going to the port and the return values.  

I could write a short program to just do the parts I needed.  It has taken two days so I am happy.  

Biggest problem is the blasted device does not always follow its manual, a serial port should read the manual.  

The name of the interrupt code is the name of the company that made the device.  

Reply