Hi Monks:  
I am in need of conceptual help in blending C and perl.
 
I am trying to protect a perl program that is complied with perl2EXE using a key device. Here is the approach I am taking:
 
A C program is launched which interrogates a key.
If the key is valid the C program reads in an encrypted file.
The file is decrypted in memory.
The decrypted file is a perl program (xx.pl) which goes into a string variable (xxpldecrypted).
The program has some 3000 lines.
The C program then launches the xx.pl via system(perl -e 'eval{xxpldecrypted}' ) perl -e gets snagged by the internal single quotes (since that is what surronds de eval's code). I cant just system("perl kk.pl parm1 parm2") becasue that will show up in the process stack, defeating the key would be easy.
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <hasp_hl.h> #include <hasp_vcode.h> int kk () { hasp_status_t status; hasp_handle_t handle; int i; char filename[] = "prg"; printf("start : "); status = hasp_login(HASP_PROGNUM_DEFAULT_FID, (hasp_vendor_code_t *)vendor_code, &handle); switch (status) { case HASP_STATUS_OK: printf("OK\n"); ################################################### # this is where the read, decrypt and eval would go ################################################### hasp_logout(handle); return(1); break; default: printf("BAD\n"); return(0); } } int main(void) { int result; result = kk(); printf("result was %d\n",result); }
The other approach I am using is Inline::C where I use the kk function as a function within perl. The idea is the function would stop the program from working if the key was invalid. Unfortunately, there seem to be some symbols that can't be resolved.
 
Any advice is appreciated.
 
Thanks!
Gary

In reply to Blending perl and C (two approaches) by holandes777

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.