1. Workaround Euphoria To C Translator 4.0.0
- Posted by moskito_x Mar 29, 2010
- 1339 views
- Last edited Mar 30, 2010
PART #1 Euphoria To C Translator 4.0.0 borland is no longer supported
to test it i now must have open-watcom and so i downloaded "open-watcom-c-win32-1.9RC2.exe"
my 8th c-compiler one more .. so what
i will try Euphoria To C Translator without -bor
to try out by yourself you need to install Ming (swf output) wrapper (alpha04) http://rapideuphoria.com/euming04.zip
libpng13.dll and zlib1.dll
unzip euming04.zip, for example in "D:\euphoria-40b2\euming04\"
to keep your installation clean copy the "ming" Folder to "mingT" Folder
now it looks like
"D:\euphoria-40b2\"
"D:\euphoria-40b2\euming04\"
"D:\euphoria-40b2\euming04\ming"
"D:\euphoria-40b2\euming04\mingT"
in mingT folder put DTX_JTestC.exw and dtx-makeTDllC.bat
see below
DTX_JTestC.exw -------------------------------------- include ming.ew include get.e with trace -- with profile trace(1) global procedure main() init_ming() Ming_useSWFVersion(VERSION5) end procedure main() --------------------------------------
the drive letter D: has to be changed to your WATCOM installation
dtx-makeTDllC.bat -------------------------------------- @echo off set PATH=D:\WATCOM\BINNT;%PATH% set PATH=D:\WATCOM\BINW;%PATH% set INCLUDE=D:\WATCOM\H;%INCLUDE% set INCLUDE=D:\WATCOM\H\NT;%INCLUDE% set WATCOM=D:\WATCOM set EDPATH=D:\WATCOM\EDDAT euc -dll -keep -emake DTX_JTestC.exw --------------------------------------
open a command Shell window
click-> START - run - cmd
the drive letter D: has to be changed to your euphoria installation
type
cd \
cd D:\euphoria-40b2\euming04\mingT
to make C Code
type
dtx-makeTDllC
D:\euphoria-40b2\euming04\MingT>dtx-makeTDllC Translating code, pass: 1 2 3 4 5 generating Writing emake file emake.bat 8.c files were created. To build your project, type emake.bat Warning ( translator ): <0216>:: Watcom should have the H and the H\NT includes at the front of the INCLUDE variable. Warning : <0217>:: Statements have been inserted to trace execution of your program.
run emake.bat
type
emake
-------------------------------------- D:\euphoria-40b2\euming04\MingT>emake Compiling with Watcom Compiling 6% init-.c Compiling 22% DTX_JTestC.c Compiling 33% main-.c Compiling 44% ming.c Compiling 56% dll.c Compiling 67% misc.c Compiling 78% machine.c Compiling 89% get.c Linking 100% DTX_JTestC.dll You can now use DTX_JTestC.dll --------------------------------------
it looks well
explore just created "DTX_JTestC.dll"
-------------------------------------- File type: WINDOWS EXECUTABLE File Header: Machine: 0x014C (Intel x86) Number of Sections: 5 Time Date Stamp: 0x4BB0FDB7 (29.03.2010 20:21:27) Pointer to Symbol Table: 0x00000000 Number of Symbols: 0 Size of Optional Header: 0x00E0 (224) Characteristics: 0x2182 File is executable. Low bytes of machine word are reversed. 32 bit word machine. File is a DLL. Optional Header: Magic: 0x010B Linker Version: 2.18 Size of Code: 0x0003FC00 (261120) Size of Initialized Data: 0x00024200 (147968) Size of Uninitialized Data: 0x00000000 (0) Adress of Entry Point: 0x00032D56 Base of Code: 0x00001000 Base of Data: 0x00041000 Image Base: 0x00400000 Section Align: 0x00001000 File Align: 0x00000200 Operating System Version: 1.11 Image Version: 0.00 Subsystem Version: 4.00 ...... Number of Rva and Sizes: 16 Data Directory: Export directory: VA: 0x000C9000 Size: 0x00000094 (148) Import directory: VA: 0x00041000 Size: 0x00000D2B (3371) ...... (unknown directory entry): VA: 0 Size: 0 Export Table: Name: DTX_JTestC.dll Time Date Stamp: 0x00000000 Version: 0.00 Ordinal Base: 1 Number of Functions: 5 Number of Names: 5 Ordinal Entry Point Name 1 0x00002210 main 4 0x00019C40 regcomp_ 2 0x00019B80 regerror_ 5 0x00019CF0 regexec_ 3 0x00019C30 regfree_ Import Table: USER32.DLL Import Adress Table: 0x0004124C Import Name Table: 0x00041050 Time Date Stamp: 0x00000000 Index of first forwarder reference: 0x00000000 0x0004146C 1 CharUpperA 0x0004147A 2 MessageBoxA KERNEL32.DLL Import Adress Table: 0x00041258 Import Name Table: 0x0004105C Time Date Stamp: 0x00000000 Index of first forwarder reference: 0x00000000 0x00041488 1 AllocConsole 0x00041498 2 CloseHandle 0x000414A6 3 CreateConsoleScreenBuffer ...... 0x00041B80 92 WriteConsoleA 0x00041B90 93 WriteConsoleOutputA 0x00041BA6 94 WriteConsoleOutputAttribute 0x00041BC4 95 WriteConsoleOutputCharacterA 0x00041BE4 96 WriteFile WS2_32.DLL Import Adress Table: 0x000413DC Import Name Table: 0x000411E0 Time Date Stamp: 0x00000000 Index of first forwarder reference: 0x00000000 0x00041BF0 1 WSACleanup 0x00041BFE 2 WSAGetLastError 0x00041C10 3 WSAStartup 0x00041C1E 4 __WSAFDIsSet ..... 0x00041D16 25 shutdown 0x00041D22 26 socket Section Table: Section Header #1 Name: AUTO Virtual Size: 0x0003FB9C (261020) ..... Number of Relocations: 0 Number of Line Numbers: 0 Characteristics: 0x42000040 Section contains initialized data. Section can be discarded. Section is readable. --------------------------------------
only 5 Entry Points in our "DTX_JTestC.dll" ???
the "DTX_JTestC.dll" made with EUPHORIA 3.1.1
there are about 259 Entry Points ???
Ordinal Entry Point Name
1 0x00002210 main
4 0x00019C40 regcomp_
2 0x00019B80 regerror_
5 0x00019CF0 regexec_
3 0x00019C30 regfree_
------------------------------------
if you want to test the "DTX_JTestC.dll" with a calling program
there will be a zip file with all included
also test.wpj a project file for Watcom IDE
let me know is of interest to you.
ONLY TO EXPLAIN WHATS GOING ON A SMALL PIECE OF CODE
gen32.c --> to Test.exe -------------------------------------- #include <windows.h> #include <stdio.h> #include <malloc.h> #include "gen32.h" #include "stddef.h" /* defines offsetof macro */ HINSTANCE MyInstance; static BOOL FirstInstance( HINSTANCE ); static BOOL AnyInstance( HINSTANCE, int, LPSTR ); HWND hwndH; long _EXPORT FAR PASCAL WindowProc( HWND, unsigned, UINT, LONG ); int w4; ..... typedef void (WINAPI *PFNDLL)( VOID ); HINSTANCE dllctrl_inst; PFNDLL idll; ..... dllctrl_inst = LoadLibrary( "DTX_JTestC.dll" ); if( dllctrl_inst != NULL ) { idll = (PFNDLL)GetProcAddress( dllctrl_inst, "main" ); if( idll != NULL ) { idll(); } } ..... --------------------------------------
copy the new DTX_JTestC.dll to the Folder
inside "test.exe"
run test.exe
oh, oh, oh it crashes
------------------------------------
a look at "ctrace-d.out" to see what's happend
ctrace-d.out
-------------------------------------- DTX_JTestC.exw:14 main() DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ..... ming.ew:84 SWF_versionNum = get_version() ming.ew:77 xSWF_versionNum_a = define_c_var(ming_dll, "SWF_versionNum") ..... DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5) ming.ew:542 xMing_useSWFVersion = define_c_proc(ming_dll, calltype & "Min ..... DTX_JTestC.exw:12 end procedure DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", dll.e:56 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, r ming.ew:149 if xMing_init != -1 then ming.ew:152 puts(2, "Fatal: ming.ew: Ming_init error\n") ming.ew:153 abort(1) === THE END === --------------------------------------
It looks like the code will be executed 2 times
1 x seems automatic and
next time with crash at ming.ew:152
why 2 x init_ming() ?? I call main() only once ???? I dont't know but that is not would I have expected
the code runs automatic when I open the DTX_JTestC.dll
it runs again when I call "_1main()"
Let me try to change this behavior below the both .c Files
DTX_JTestC.c -------------------------------------- // Euphoria To C version 4.0.0 beta 2 (r2670) #include "include/euphoria.h" #include "main-.h" void __stdcall _1main() { int _0, _1, _2; ctrace("DTX_JTestC.exw:10 init_ming()"); _2init_ming(); ctrace("DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5)"); _2Ming_useSWFVersion(5); ctrace("DTX_JTestC.exw:12 end procedure"); return; ; } --------------------------------------
main-.c (shortened) -------------------------------------- // Euphoria To C version 4.0.0 beta 2 (r2670) #include <time.h> #include "include\euphoria.h" #include "main-.h" int Argc; char **Argv; unsigned default_heap; __declspec(dllimport) unsigned __stdcall GetProcessHeap(void); ..... char *stack_base; int total_stack_size = 262144; int __stdcall _CRT_INIT (int, int, void *); void EuInit() { ..... Argc = 0; default_heap = GetProcessHeap(); ..... init_literal(); ..... ctrace("machine.e:307 check_calls = 1"); ctrace("ming.ew:16 ming_dll = open_dll(\"libming_eu1.dll\")"); _0 = _3open_dll(_477); ..... ctrace("ming.ew:17 if ming_dll = 0 then"); if (binary_op_a(NOTEQ, _2ming_dll_1087, 0)){ goto L1; // [71] 101 } ..... ctrace("ming.ew:22 abort(1)"); UserCleanup(1); L1: ctrace("ming.ew:26 init_rtns = {} -- these must be parameterless procedures"); ..... ctrace("ming.ew:32 SWF_versionNum = -1 -- not initialised"); _2SWF_versionNum_1097 = -1; ctrace("ming.ew:88 init_rtns &= rid_get_version -- call get_version as part of init_ming()"); ..... ctrace("DTX_JTestC.exw:6 trace(1)"); TraceOn = 1; -->>>> ctrace("DTX_JTestC.exw:14 main()"); -->>>> _1main(); ..... DeRef1(_2M_PI_1147); ; } int __stdcall LibMain(int hDLL, int Reason, void *Reserved) { if (Reason == 1) EuInit(); return 1; } --------------------------------------
look at
ctrace("DTX_JTestC.exw:10 init_ming()");
_2init_ming();
ctrace("DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5)");
_2Ming_useSWFVersion(5);
ctrace("DTX_JTestC.exw:12 end procedure");
return;
>>>>
returns to main-.c ! this works because it's all done by the
initial code in main-.c before it jumps to DTX_JTestC.c _1main();
----------
for example: done in main-.c
default_heap = GetProcessHeap();
init_literal();
ming_dll = open_dll(\"libming_eu1.dll\")");
etc.
in trace mode Watcom IDE (test.exe) after
idll = (PFNDLL)GetProcAddress( dllctrl_inst, "main" );
if( idll != NULL ) {
next step key(F10)
>>>> idll();
that crashes ! thats what i expected.
Because now DTX_JTestC.c "_1main();" will called directly
without calling the inital code in main-.c
but I have no other choice the only entry point in my DLL is "main"
DTX_JTestC.c _1main();
to explain that more in detail
let's add a few code
-------------------------------------- main-.c before -------------------------------------- int __stdcall LibMain(int hDLL, int Reason, void *Reserved) { if (Reason == 1) EuInit(); return 1; } -------------------------------------- main-.c with new code -------------------------------------- int __stdcall LibMain(int hDLL, int Reason, void *Reserved) { TraceOn = 1; if (Reason > 1) { ctrace("main-.c:148 before Reason call By Me");} else { ctrace("main-.c:148 before Reason call NOT By Me");} if (Reason == 2) { ctrace("main-.c:151 before Euinit"); EuInit(); ctrace("main-.c:153 after Euinit"); } return Reason; } --------------------------------------
next Post PART#2
2. Re: Workaround Euphoria To C Translator 4.0.0
- Posted by jimcbrown (admin) Mar 29, 2010
- 1254 views
I don't know why the site has not been updated yet, but we are in beta 3 now, not beta 2.
Also, there is an installer which includes openwatcom, so you only have to run one installer to install everything you need for Euphora-to-C.
Could you install http://sourceforge.net/projects/rapideuphoria/files/Rapid%20Euphoria/4.0b3/euphoria-40b3-ow.exe/download from http://sourceforge.net/projects/rapideuphoria/files/ and see if you can reproduce the problem with beta 3?
(There is a combined installer for beta 2 at http://sourceforge.net/projects/rapideuphoria/files/Rapid%20Euphoria/4.0b2/euphoria-40b2-ow.exe/download but this is old and has known bugs that have since been fixed, so please don't use beta 2.)
3. Re: Workaround Euphoria To C Translator 4.0.0
- Posted by moskito_x Mar 29, 2010
- 1253 views
PART#2
run emake.bat > put DLL in Folder with Test.exe> look at ctrace-d.out
run test.exe
-------------------------------------- ctrace-d.out -------------------------------------- main-.c:148 before Reason call NOT By Me DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", main-.c:148 before Reason call NOT By Me === THE END === --------------------------------------
less Lines but it crashes
NOTICE: 2 times "main-.c:148 before Reason call NOT By Me"
let's add a few code more
main-.c with new "__export" at Line 144 int __stdcall __export LibMain(int hDLL, int Reason, void *Reserved)
run emake.bat
------------------------------------
explore "DTX_JTestC.dll" -------------------------------------- Export Table: Name: DTX_JTestC.dll Time Date Stamp: 0x00000000 Version: 0.00 Ordinal Base: 1 Number of Functions: 6 Number of Names: 6 Ordinal Entry Point Name 2 0x00002640 _LibMain@12 1 0x00002210 main 5 0x00019C70 regcomp_ 3 0x00019BB0 regerror_ 6 0x00019D20 regexec_ 4 0x00019C60 regfree_ --------------------------------------
NOTICE: a new Entry Point _LibMain@12
now we must change gen32.c to point to this
-------------------------------------- gen32.c -------------------------------------- old typedef void (WINAPI *PFNDLL)( VOID ); new typedef int (WINAPI *PFNDLL)(HINSTANCE this_inst, int Reason, void *Reserved); ..... old idll = (PFNDLL)GetProcAddress( dllctrl_inst, "main" ); idll(); new idll = (PFNDLL)GetProcAddress( dllctrl_inst, "_LibMain@12" ); w4 = idll(this_inst,3,pp); // Reason=3 --------------------------------------
inside Watcom IDE run "make all" to make our new test.exe
run test.exe look at "ctrace-d.out"
-------------------------------------- ctrace-d.out -------------------------------------- main-.c:148 before Reason call NOT By Me main-.c:148 before Reason call NOT By Me === THE END === --------------------------------------
now it works no crash Of course, the code is doing nothing
only call "LibMain" with "Reason=3"
and remember Euinit() will only excecuted when Reason=2 look above main-.c
so let's try this and hope it works
change gen32.c from
w4 = idll(this_inst,3,pp); Reason=3
to
w4 = idll(this_inst,2,pp); Reason=2
------------------------------------
inside Watcom IDE run "make all" to make our new test.exe
run test.exe look at "ctrace-d.out"
-------------------------------------- ctrace-d.out -------------------------------------- main-.c:148 before Reason call NOT By Me main-.c:148 before Reason call By Me main-.c:151 before Euinit machine.e:156 mem = allocate(4) machine.e:108 return machine_func(M_ALLOC, n) machine.e:307 check_calls = 1 ming.ew:16 ming_dll = open_dll("libming_eu1.dll") dll.e:37 return machine_func(M_OPEN_DLL, file_name) ming.ew:17 if ming_dll = 0 then ming.ew:26 init_rtns = {} -- these must be parameterless pro ming.ew:32 SWF_versionNum = -1 -- not initialised ming.ew:88 init_rtns &= rid_get_version -- call get_version as part of init_m DTX_JTestC.exw:6 trace(1) DTX_JTestC.exw:14 main() DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", dll.e:56 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, r ming.ew:149 if xMing_init != -1 then ming.ew:150 ret = c_func(xMing_init, {}) ming.ew:155 return ret ming.ew:163 if rc then ming.ew:167 for i = 1 to length(init_rtns) do ming.ew:168 call_proc(init_rtns[i], {}) ming.ew:84 SWF_versionNum = get_version() ming.ew:77 xSWF_versionNum_a = define_c_var(ming_dll, "SWF_versionNum") dll.e:42 return machine_func(M_DEFINE_VAR, {lib, variable_name}) ming.ew:78 version = peek4u(xSWF_versionNum_a) ming.ew:79 return version ming.ew:85 end procedure ming.ew:169 end for ming.ew:170 end procedure DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5) ming.ew:542 xMing_useSWFVersion = define_c_proc(ming_dll, calltype & "Min dll.e:50 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, 0 ming.ew:543 if xMing_useSWFVersion != -1 then ming.ew:544 c_proc(xMing_useSWFVersion, {swf_version}) ming.ew:548 end procedure DTX_JTestC.exw:12 end procedure main-.c:153 after Euinit main-.c:148 before Reason call NOT By Me === THE END === --------------------------------------
Everything is ok. Thats what I want "init_ming()" only 1 times
next Post PART#3
4. Re: Workaround Euphoria To C Translator 4.0.0
- Posted by moskito_x Mar 29, 2010
- 1227 views
PART #3
summing-up
------------------------------------
a.) change if (Reason == 1) to if (Reason == 2)
b.) put an _export before LibMain(...)
c.) call NOT "main" call directly "LibMain"
in our case _LibMain@12
that's it
you can also cleanup your DTX_JTestC.lnk at the end of the file delete EXPORT main='_1main@0' you can not call '_1main@0' via 'main' this will terminate your calling program DTX_JTestC.lnk -------------------------------------- FILE init-.obj .... FILE DTX_JTestC.obj FILE main-.obj FILE ming.obj FILE dll.obj FILE misc.obj FILE machine.obj FILE get.obj NAME DTX_JTestC.dll .... EXPORT main='_1main@0'
moskito_x
5. Re: Workaround Euphoria To C Translator 4.0.0
- Posted by moskito_x Mar 30, 2010
- 1218 views
Hello
@jimcbrown
Now I downloaded euphoria-40b3-ow.exe
change all my path and environment thats point to my new Folder
D:\euphoria-40b3-ow\bin
copy the euming04 Folder also to D:\euphoria-40b3-ow
open my commad shell
and type
dtx-makeTDllC
D:\euphoria-40b3-ow\euming04\MingT>dtx-makeTDllC Translating code, pass: 1 2 3 4 5 generating Writing emake file emake.bat 8.c files were created. To build your project, type emake.bat Warning ( translator ): <0216>:: Watcom should have the H and the H\NT includes at the front of the INCLUDE variable. Warning : <0217>:: Statements have been inserted to trace execution of your program.
type
emake
D:\euphoria-40b3-ow\euming04\MingT>emake Compiling with Watcom Compiling 6% init-.c Compiling 22% DTX_JTestC.c Compiling 33% main-.c Compiling 44% ming.c Compiling 56% dll.c Compiling 67% misc.c Compiling 78% machine.c Compiling 89% get.c Linking 100% DTX_JTestC.dll You can now use DTX_JTestC.dll
looking at my C Code
----------------------------------- DTX_JTestC.c ----------------------------------- // Euphoria To C version 4.0.0 beta 3 (r3116) #include "include/euphoria.h" #include "main-.h" void __stdcall _1main() { int _0, _1, _2; ctrace("DTX_JTestC.exw:10 init_ming()"); _2init_ming(); ctrace("DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5)"); _2Ming_useSWFVersion(5); ctrace("DTX_JTestC.exw:12 end procedure"); return; ; } // 0x206798A3
----------------------------------- main-.c ----------------------------------- // Euphoria To C version 4.0.0 beta 3 (r3116) #include <time.h> #include "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 short *poke2_addr; unsigned long *poke4_addr; struct d temp_d; double temp_dbl; char *stack_base; int total_stack_size = 262144; int __stdcall _CRT_INIT (int, int, void *); void EuInit() { s1_ptr _0switch_ptr; int _221 = 0; int _218 = 0; int _0, _1, _2; Argc = 0; default_heap = GetProcessHeap(); _02 = (unsigned char**) malloc( 4 * 7 ); _02[0] = (unsigned char*) malloc( 4 ); _02[0][0] = 6; _02[1] = "\x01\x02\x03\x00\x00\x00\x03"; _02[2] = "\x02\x00\x02\x03\x03\x03\x03"; _02[3] = "\x03\x00\x00\x02\x00\x00\x00"; _02[4] = "\x04\x00\x00\x00\x02\x00\x00"; _02[5] = "\x05\x00\x00\x00\x00\x02\x00"; _02[6] = "\x06\x00\x00\x00\x00\x00\x02"; eu_startup(_00, _01, _02, 1, (int)CLOCKS_PER_SEC, (int)CLK_TCK); _0switch_ptr = NewS1( 3 ); _0switch_ptr->base[1] = NewString("-dll"); _0switch_ptr->base[2] = NewString("-emake"); _0switch_ptr->base[3] = NewString("-keep"); _0switches = MAKE_SEQ( _0switch_ptr ); init_literal(); _4PI_HALF_470 = NewDouble(DBL_PTR(_4PI_468)->dbl / DBL_PTR(_177)->dbl); _218 = power(2, 32); if (IS_ATOM_INT(_218)) { _5MAX_ADDR_544 = _218 - 1; if ((long)((unsigned long)_5MAX_ADDR_544 +(unsigned long) HIGH_BITS) >= 0) _5MAX_ADDR_544 = NewDouble((double)_5MAX_ADDR_544); } else { _5MAX_ADDR_544 = NewDouble(DBL_PTR(_218)->dbl - (double)1); } DeRef1(_218); _218 = NOVALUE; _221 = 1048576; _5LOW_ADDR_547 = 1048575; _221 = NOVALUE; ctrace("machine.e:156 mem = allocate(4)"); _0 = _5allocate(4); DeRef1(_5mem_643); _5mem_643 = _0; ctrace("machine.e:307 check_calls = 1"); _5check_calls_752 = 1; Concat((object_ptr)&_6HEX_DIGITS_769, _6DIGITS_767, _298); Concat((object_ptr)&_6START_NUMERIC_772, _6DIGITS_767, _300); ctrace("ming.ew:16 ming_dll = open_dll(\"libming_eu1.dll\")"); RefDS(_477); _0 = _3open_dll(_477); DeRef1(_2ming_dll_1087); _2ming_dll_1087 = _0; ctrace("ming.ew:17 if ming_dll = 0 then"); if (binary_op_a(NOTEQ, _2ming_dll_1087, 0)){ goto L1; // [71] 101 } ctrace("ming.ew:18 puts(2, \"Error, can't locate libming.dll\\nIf you did not receive libming.dll\")"); EPuts(2, _480); // DJP ctrace("ming.ew:19 puts(2, \" with this program then please go to http://www.shingles.net.nz/libming\\n\")"); EPuts(2, _481); // DJP ctrace("ming.ew:20 printf(2, \"\\n!!! This version was coded with libming.dll version %s in mind\\n\", VERSION)"); EPrintf(2, _482, _2VERSION_142); ctrace("ming.ew:21 puts(2, \"You should get that version of the dll and put it in the folder of this program.\\n\")"); EPuts(2, _483); // DJP ctrace("ming.ew:22 abort(1)"); UserCleanup(1); L1: ctrace("ming.ew:26 init_rtns = {} -- these must be parameterless procedures"); RefDS(_7); DeRef1(_2init_rtns_1096); _2init_rtns_1096 = _7; ctrace("ming.ew:32 SWF_versionNum = -1 -- not initialised"); _2SWF_versionNum_1097 = -1; _2rid_get_version_1143 = CRoutineId(72, 2, _502); ctrace("ming.ew:88 init_rtns &= rid_get_version -- call get_version as part of init_ming()"); Append(&_2init_rtns_1096, _2init_rtns_1096, _2rid_get_version_1143); _2SWFBUTTON_DRAGOVER_2387 = (32 | 128); _2SWFBUTTON_DRAGOUT_2389 = (16 | 256); ctrace("DTX_JTestC.exw:6 trace(1)"); TraceOn = 1; ctrace("DTX_JTestC.exw:14 main()"); _1main(); ; } int __stdcall LibMain(int hDLL, int Reason, void *Reserved) { if (Reason == 1) EuInit(); return 1; } // GenerateUserRoutines // 0x0ACF5375
Copy the DTX_JTestC.dll into Test.exe Folder
run test.exe
The First Thing it's real good, it don't crash !
looking at ctrace-d.out
and we will see the code is executing twice
----------------------------------- ctrace-d.out ----------------------------------- DTX_JTestC.exw:14 main() DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", dll.e:56 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, r ming.ew:149 if xMing_init != -1 then ming.ew:150 ret = c_func(xMing_init, {}) ming.ew:155 return ret ming.ew:163 if rc then ming.ew:167 for i = 1 to length(init_rtns) do ming.ew:168 call_proc(init_rtns[i], {}) ming.ew:84 SWF_versionNum = get_version() ming.ew:77 xSWF_versionNum_a = define_c_var(ming_dll, "SWF_versionNum") dll.e:42 return machine_func(M_DEFINE_VAR, {lib, variable_name}) ming.ew:78 version = peek4u(xSWF_versionNum_a) ming.ew:79 return version ming.ew:85 end procedure ming.ew:169 end for ming.ew:170 end procedure DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5) ming.ew:542 xMing_useSWFVersion = define_c_proc(ming_dll, calltype & "Min dll.e:50 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, 0 ming.ew:543 if xMing_useSWFVersion != -1 then ming.ew:544 c_proc(xMing_useSWFVersion, {swf_version}) ming.ew:548 end procedure DTX_JTestC.exw:12 end procedure DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", dll.e:56 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, r ming.ew:149 if xMing_init != -1 then ming.ew:150 ret = c_func(xMing_init, {}) ming.ew:155 return ret ming.ew:163 if rc then ming.ew:167 for i = 1 to length(init_rtns) do ming.ew:168 call_proc(init_rtns[i], {}) ming.ew:84 SWF_versionNum = get_version() ming.ew:77 xSWF_versionNum_a = define_c_var(ming_dll, "SWF_versionNum") dll.e:42 return machine_func(M_DEFINE_VAR, {lib, variable_name}) ming.ew:78 version = peek4u(xSWF_versionNum_a) ming.ew:79 return version ming.ew:85 end procedure ming.ew:169 end for ming.ew:170 end procedure DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5) ming.ew:542 xMing_useSWFVersion = define_c_proc(ming_dll, calltype & "Min dll.e:50 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, 0 ming.ew:543 if xMing_useSWFVersion != -1 then ming.ew:544 c_proc(xMing_useSWFVersion, {swf_version}) ming.ew:548 end procedure DTX_JTestC.exw:12 end procedure === THE END ===
Change LibMain Method in main-.c
New code in int __stdcall __export LibMain(int hDLL, int Reason, void *Reserved) { TraceOn = 1; if (Reason > 1) { ctrace("main-.c:148 before Reason call By Me");} else { ctrace("main-.c:148 before Reason call NOT By Me");} if (Reason == 2) { ctrace("main-.c:151 before Euinit"); EuInit(); ctrace("main-.c:153 after Euinit"); } return Reason; }
edit my gen32.c code
dllctrl_inst = LoadLibrary( "DTX_JTestC.dll" ); if( dllctrl_inst != NULL ) { idll = (PFNDLL)GetProcAddress( dllctrl_inst, "_LibMain@12" ); if( idll != NULL ) { w4 = idll(this_inst,2,pp); // Reason=2 ...
in the WATCOM IDE > Make ALL to get new test.exe
run Test.exe looking at ctrace-d.out
and we will see the code is executing only one time
----------------------------------- ctrace-d.out ----------------------------------- main-.c:148 before Reason call NOT By Me main-.c:148 before Reason call By Me main-.c:151 before Euinit machine.e:156 mem = allocate(4) machine.e:108 return machine_func(M_ALLOC, n) machine.e:307 check_calls = 1 ming.ew:16 ming_dll = open_dll("libming_eu1.dll") dll.e:37 return machine_func(M_OPEN_DLL, file_name) ming.ew:17 if ming_dll = 0 then ming.ew:26 init_rtns = {} -- these must be parameterless pro ming.ew:32 SWF_versionNum = -1 -- not initialised ming.ew:88 init_rtns &= rid_get_version -- call get_version as part of init_m DTX_JTestC.exw:6 trace(1) DTX_JTestC.exw:14 main() DTX_JTestC.exw:10 init_ming() ming.ew:162 rc = Ming_init() ming.ew:147 ret = -1 ming.ew:148 xMing_init = define_c_func(ming_dll, calltype & "Ming_init", dll.e:56 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, r ming.ew:149 if xMing_init != -1 then ming.ew:150 ret = c_func(xMing_init, {}) ming.ew:155 return ret ming.ew:163 if rc then ming.ew:167 for i = 1 to length(init_rtns) do ming.ew:168 call_proc(init_rtns[i], {}) ming.ew:84 SWF_versionNum = get_version() ming.ew:77 xSWF_versionNum_a = define_c_var(ming_dll, "SWF_versionNum") dll.e:42 return machine_func(M_DEFINE_VAR, {lib, variable_name}) ming.ew:78 version = peek4u(xSWF_versionNum_a) ming.ew:79 return version ming.ew:85 end procedure ming.ew:169 end for ming.ew:170 end procedure DTX_JTestC.exw:11 Ming_useSWFVersion(VERSION5) ming.ew:542 xMing_useSWFVersion = define_c_proc(ming_dll, calltype & "Min dll.e:50 return machine_func(M_DEFINE_C, {lib, routine_name, arg_types, 0 ming.ew:543 if xMing_useSWFVersion != -1 then ming.ew:544 c_proc(xMing_useSWFVersion, {swf_version}) ming.ew:548 end procedure DTX_JTestC.exw:12 end procedure main-.c:153 after Euinit main-.c:148 before Reason call NOT By Me === THE END ===
moskito_x
6. Re: Workaround Euphoria To C Translator 4.0.0
- Posted by useless Mar 30, 2010
- 1182 views
I knew there was a reason i don't compile Eu code.
useless