Sometimes it is useful to use a web browser like Netscape as the user interface to a program. One of the reasons is that there is no need to implement a complex graphical user interface in the program itself, especially if the program must run in environments with different user interfaces.
Web browsers can be used as graphical user interface front-ends, provided the program can generate HTML pages, and that there is some way for the browser to communicate with the program.
Another advantage is that the program can run on a remote workstation, and the browser can run on a PC connected on the network, or viceversa. This is useful in case of very complex decompilation tasks, that require more computational power than available on the user's system.
Starting from version 1.4, REC can act as a generator of HTML pages.
In this mode (enabled by the +html option), REC reads commands from its standard input, and produces an HTML page with the result of the command.
A running example of this mode is available from the on-line example server page.
|CGI server setup|
To allow REC to communicate with a web browser, a CGI script is required to act as a proxy server to keep the session alive. The required setup is shown in the following figure:
In this setup, the web browser sends a request to the HTTP server. The HTTP server starts the CGI script, which extracts the command from the request, passes the command to the REC process, receives the HTML page generated by REC, adds some additional information and passes it back to the browser, which renders the page.
This approach requires that the user be able to run CGI scripts on the server system. This is not always possible, or it may require some assistance from your system administrator.
If you are using a Linux system, you can mimic the setup I use on my system. First of all, you must run the HTTP server, which is invoked with the 'httpd' command (you probably must be root to run this command).
The next step is to setup the CGI script. I wrote my own CGI program using one of the publicly available CGI libraries. You can download this program and compile it on your system by typing make. Once you have the cgirec executable, you must make it available to the HTTP server. On my Linux system, the server looks in the /home/cg/cgi-bin/ for the cgirec executable. If you have a different setup, you can created a symbolic link to the location where you compiled the executable. For example:ln -s /home/cg/cgi-bin/cgirec /var/lib/httpd/cgi-bin/cgirecThen, you must write a configuration file for cgirec. This configuration file will tell cgirec where to find the executable to decompile. Again, you can create a symbolic link to make the configuration file visible from cgirec. You can look at the file /tmp/proxy.trace for helpful trace messages. A configuration file looks like this:dir=/home/cg/recserv/ cpu=i386,ex386 cpu=ppc,exppc cpu=mc68k,ex68k
The dir= line identifies the root directory containing the files to be decompiled.
The cpu= lines identify different sessions. The first word is the argument passed from the browser to cgirec. The argument is used to select the name of the directory (the word after the comma ',' sign) that contains the program to decompile. cgirec will then change to that directory (for example /home/cg/recserv/ex386) and start a decompile session by executing the commandrec +html exampleThis means that the program to decompile must be called example and that an executable called rec must be present in that directory. Of course you can use symbolic links to point to the location where the real executables reside.
Of course you are free to change the sources of cgirec.c to adapt it to your particular environment (a port to Windows 95/NT would be particularly appreciated. Any volunteer :-)
Multiple sessions can be executed in the same directory. cgirec maintains different communication channels to each session. A session is automatically terminated if the server has not received a command in the last 20 minutes.
Copyright © 1998 - 2000 Backer Street Software -- All right reserved.
Last revised on 6 Mar. 1999
REC Home Page | REC User Manual