Re: Workaround Euphoria To C Translator 4.0.0
- Posted by moskito_x Mar 29, 2010
- 1252 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