So now my ideal is to create a program which takes the interpreter name and the file (script) and create a compiled executable file, which can run standalone. There are several advantages of this program one thing is that this hepls the developers to hide the code of the scripts, what are the other advantages??....
To create this generic solution, I started thinking about this idea
STEP1:
o I'll create a dummy executable file compiled, with a placeholder for the script as follows
#include
static char buffer_space_for_script[MAX_SCRIPT_FILE_SIZE]="#Cheating perl hahaha...";
/*Driver program to launch the script, similar to piping except the program reads from static buffer and writes into the pipe.*/
int main(){
int fd[2], pid;
/*create a pipe all finer details avoided*/
pipe(fd);
dup2(1,fd[1]);
pid = fork()
........
if(pid==0){
dup2(0,fd[0]);
exec(perl/other interpreter);
.....
}
else{
write(1,buffer_space_for_script,MAX_SCRIPT_SIZE); /*write into stdout will be read by interpreter in the child*/
}
Now I wanted to compile this program and use 'hexdump -c a.out" find the seek location(byte in the physical file of the buffer_space_for_script and write the contents of the script file into the file a.out)....
I almost coded it but suddently realized that the major objective of this has been breached since hexdump -c will read out the ascii, thus a intelligent user can read the script using hexdump, even though we have created a compiled executable from the script.....
:(
No comments:
Post a Comment