in reply to Blending perl and C (two approaches)
You could try opening a pipe to the perl executable and feeding it the decrypted program line by line. Once you close the pipe, perl will compile and run the code you feed it and it will never have existed as a file anywhere. This trivial example works for me on Win32, and only uses POSIX calls:
#include <stdio.h> #include <stdlib.h> char* prog = "\ #! perl\n\ use strict;\n\ $\\ = qq[\\n]; \n\ $|=1;\n\ print qq[hello world];\n\ print for 1 .. 10;\n\ "; char* cmd = "/perl/bin/perl.exe"; int main( void ) { FILE* pipe; if( !( pipe = _popen( cmd, "wt" ) ) ) { fprintf( stderr, "Failed to create pipe\n" ); exit( -1 ); } fprintf( pipe, prog ); close( pipe ); flushall(); return 0; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Blending perl and C (two approaches)
by Anonymous Monk on Oct 29, 2007 at 06:14 UTC | |
by BrowserUk (Patriarch) on Oct 29, 2007 at 06:48 UTC | |
by holandes777 (Scribe) on Oct 31, 2007 at 14:36 UTC |