Crash when string is passed to a C++ DLL function

 

I pass a string to C++ DLL, and I have no idea why it always crashed.
Anyone can help me. Thanks very much!!

My MQ4 Code:

#import "EaLog.dll"
void EALOG_WriteLine(string);
#import

int start()
{
EALOG_WriteLine("111");
return (0);
}

My C++ DLL Code:

void EALOG_WriteLine(char * str)
{
MessageBoxA(NULL, str, NULL, MB_OK);
}

After running strategy tester, the "111" message box popup, then it crash after closing the message box.
The following is the chrash Details,

Interbank FX Trader s: Crash Details

There has been a critical error
Time : 2009.10.28 16:13
Program : Client Terminal
Version : 4.00 (build: 220, 7 Nov 2008)
OS : Windows XP Professional 5.1 Service Pack 3 (Build 2600)
Processors : 2 x X86 (level 15)
Memory : 2097151/1013332 kb
Exception : C0000005
Address : 9FE9676C
Access Type : read
Access Addr : 9FE9676C

Registers : EAX=00000000 CS=001b EIP=9FE9676C EFLGS=00010246
: EBX=0045FE84 SS=0023 ESP=0533BD48 EBP=0533BD80
: ECX=7C93005D DS=0023 ESI=032FB298 FS=003b
: EDX=000000FE ES=0023 EDI=032FB2A0 GS=0000

Stack Trace : 004554D1 FFFFFFFF 00000000 00000000
: 00000000 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000
: 00000000 00000000 00000000 00000000

Modules :
1 : 00400000 004F6000 c:\program files\interbank fx trader 4\terminal.exe
2 : 02A80000 0000C000 c:\program files\inventec\dreye\dreyemt\dreyemt.dll
3 : 03650000 0054B000 c:\windows\system32\xpsp2res.dll
4 : 04030000 00007000 c:\program files\hot keyboard pro\hkhook21.dll
5 : 04240000 00009000 c:\windows\system32\normaliz.dll
6 : 04AF0000 00018000 c:\program files\interbank fx trader 4\experts\libraries\ealog.dll
7 : 10000000 0000E000 c:\program files\inventec\dreye\dreyemt\dreyeimhook.dll
8 : 3E4C0000 000E6000 c:\windows\system32\wininet.dll
9 : 3EB60000 001E8000 c:\windows\system32\iertutil.dll
10 : 43D90000 00132000 c:\windows\system32\urlmon.dll
11 : 5A410000 00037000 c:\windows\system32\uxtheme.dll
12 : 5D400000 00114000 c:\windows\system32\msxml3.dll
13 : 5F800000 000F2000 c:\windows\system32\mfc42u.dll
14 : 605B0000 00055000 c:\windows\system32\hnetcfg.dll
15 : 611C0000 00009000 c:\windows\system32\mfc42loc.dll
16 : 621F0000 00009000 c:\windows\system32\lpk.dll
17 : 65E30000 00037000 c:\program files\microsoft office\office12\groovesystemservices.dll
18 : 661C0000 0021D000 c:\program files\microsoft office\office12\grooveshellextensions.dll
19 : 68000000 00036000 c:\windows\system32\rsaenh.dll
20 : 68EF0000 000F1000 c:\program files\microsoft office\office12\grooveutil.dll
21 : 68FF0000 00007000 c:\program files\microsoft office\office12\groovenew.dll
22 : 69A00000 00055000 c:\windows\system32\netapi32.dll
23 : 719B0000 0003E000 c:\windows\system32\mswsock.dll
24 : 719F0000 00008000 c:\windows\system32\wshtcpip.dll
25 : 71A00000 00008000 c:\windows\system32\ws2help.dll
26 : 71A10000 00017000 c:\windows\system32\ws2_32.dll
27 : 72C80000 00008000 c:\windows\system32\msacm32.drv
28 : 72C90000 00009000 c:\windows\system32\wdmaud.drv
29 : 73640000 0002E000 c:\windows\system32\msctfime.ime
30 : 73D30000 000FE000 c:\windows\system32\mfc42.dll
31 : 73FA0000 0006B000 c:\windows\system32\usp10.dll
32 : 74680000 0004C000 c:\windows\system32\msctf.dll
33 : 76060000 00156000 c:\windows\system32\setupapi.dll
34 : 762F0000 00005000 c:\windows\system32\msimg32.dll
35 : 76300000 0001D000 c:\windows\system32\imm32.dll
36 : 76320000 00047000 c:\windows\system32\comdlg32.dll
37 : 765E0000 00093000 c:\windows\system32\crypt32.dll
38 : 76990000 0013D000 c:\windows\system32\ole32.dll
39 : 76B10000 0002A000 c:\windows\system32\winmm.dll
40 : 76C00000 0002E000 c:\windows\system32\wintrust.dll
41 : 76C60000 00028000 c:\windows\system32\imagehlp.dll
42 : 76D70000 00022000 c:\windows\system32\apphelp.dll
43 : 76DB0000 00012000 c:\windows\system32\msasn1.dll
44 : 76EF0000 00027000 c:\windows\system32\dnsapi.dll
45 : 76F30000 0002C000 c:\windows\system32\wldap32.dll
46 : 76F80000 00008000 c:\windows\system32\winrnr.dll
47 : 76F90000 00006000 c:\windows\system32\rasadhlp.dll
48 : 76FA0000 0007F000 c:\windows\system32\clbcatq.dll
49 : 77020000 0009B000 c:\windows\system32\comres.dll
50 : 770F0000 0008B000 c:\windows\system32\oleaut32.dll
51 : 77180000 00103000 c:\windows\winsxs\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll
52 : 77BA0000 00007000 c:\windows\system32\midimap.dll
53 : 77BB0000 00015000 c:\windows\system32\msacm32.dll
54 : 77BD0000 00008000 c:\windows\system32\version.dll
55 : 77BE0000 00058000 c:\windows\system32\msvcrt.dll
56 : 77D10000 0008F000 c:\windows\system32\user32.dll
57 : 77DA0000 000A7000 c:\windows\system32\advapi32.dll
58 : 77E50000 00092000 c:\windows\system32\rpcrt4.dll
59 : 77EF0000 00049000 c:\windows\system32\gdi32.dll
60 : 77F40000 00076000 c:\windows\system32\shlwapi.dll
61 : 77FC0000 00011000 c:\windows\system32\secur32.dll
62 : 78130000 0009B000 c:\windows\winsxs\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\msvcr80.dll
63 : 7C630000 0001B000 c:\windows\winsxs\x86_microsoft.vc80.atl_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_473666fd\atl80.dll
64 : 7C800000 0011F000 c:\windows\system32\kernel32.dll
65 : 7C920000 00097000 c:\windows\system32\ntdll.dll
66 : 7D590000 007F5000 c:\windows\system32\shell32.dll

Call stack :

 
try not to display messagebox. try to log the string to harddisk. messagebox may be modal and mt4 must wait for it and mt4 may not like that.
 
fx1.net wrote >>
try not to display messagebox. try to log the string to harddisk. messagebox may be modal and mt4 must wait for it and mt4 may not like that.

I delete the messagebox line, but it still crash.

 
How is this sample code?
Files:
ealog.zip  4 kb
 
fai wrote >>
How is this sample code?

I correct this issue by adding __stdcall in my export funtion.

Thanks a lot!!!!!

Reason: