Re: Detecting a C translated bound program
- Posted by Matt Lewis <matthewwalkerlewis at gma??.com> Oct 26, 2007
- 601 views
OtterDad wrote: > > on my machine bound with Eu 2.4, and translated using watcom, both bound > programs > report Bound with C > Here's a simple demonstration of how to implement my idea:
--translate.ex include misc.e integer interpreted -- This if statement is to fool the tranlator's optimizer if platform() = WIN32 then interpreted = 1 else interpreted = 0 end if if not interpreted then puts(1, "I'm translated!\n") else puts(1, "I'm interpreted!\n") end if
After translating, I edited main-.c to make sure that _1interpreted was always set to 0. Of course, your file may look a bit different, since you're using 2.4 (and the optimizer might not be as aggressive, either), but the idea is the same. // main-.c // Euphoria To C version 3.1.1 #include <time.h> #include "C:\EUPHORIA\include\euphoria.h" #include "main-.h" int Argc; char **Argv; unsigned default_heap; __declspec(dllimport) unsigned __stdcall GetProcessHeap(void); unsigned long *peek4_addr; unsigned char *poke_addr; unsigned long *poke4_addr; struct d temp_d; double temp_dbl; char *stack_base; int total_stack_size = 262144; void __stdcall WinMain(void *hInstance, void *hPrevInstance, char *szCmdLine, int iCmdShow) { int _0, _1, _2; int argc; char **argv; default_heap = GetProcessHeap(); argc = 1; Argc = 1; argv = make_arg_cv(szCmdLine, &argc); winInstance = hInstance; stack_base = (char *)&_0; _02 = (int**) malloc( 4 * 3 ); _02[0] = (int*) malloc( 4 ); _02[0][0] = 2; _02[1] = (int*) malloc( 4 * 2 ); _02[1][0] = 1; _02[1][1] = 2; _02[2] = (int*) malloc( 4 * 1 ); _02[2][0] = 0; eu_startup(_00, _01, _02, 1, (int)CLOCKS_PER_SEC, (int)CLK_TCK); init_literal(); shift_args(argc, argv); RefDS(_150); _2PI = _150; _2PI_HALF = NewDouble(DBL_PTR(_2PI)->dbl / DBL_PTR(_151)->dbl); // if platform() = WIN32 then // interpreted = 1 _1interpreted = 0; goto L1; L2: // interpreted = 0 _1interpreted = 0; L1: // if not interpreted then if (_1interpreted != 0) goto L3; // puts(1, "I'm translated!\n") EPuts(1, _179); goto L4; L3: // puts(1, "I'm interpreted!\n") EPuts(1, _180); L4: Cleanup(0); }