1. using dlls

Hi all !
	I=B4m just starting using external dlls and need some help.

The dll is dxsoftex.dll  (from <http://www.dxsoft.com/dxs-exch.zip> )and=
=20
the functions are these:

--int DxsoftExchangeInit(int canal_number);
--int DxsoftGetSymFromRxBuffer(void);
--int DxsoftPutSymToTxBuffer(char sym);
--int DxsoftGetSymFromTxBuffer(void);
--int DxsoftPutSymToRxBuffer(char sym);

the code:

include win32lib.ew
atom ad
integer a1,b1,c1,d1,e1,a

ad =3D open_dll("dxsoftex.dll")
puts(1,sprint(ad)&"\n")    ------ ad gives 9895936

a1 =3D define_c_func(ad,"DxsoftExchangeInit", {C_INT}, C_INT)
puts(1, sprint(a1)&"\n")
b1 =3D define_c_func(ad,"DxsoftGetSymFromRxBuffer",{C_CHAR}, C_INT)
puts(1, sprint(b1)&"\n")
c1 =3D define_c_func(ad,"DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
puts(1, sprint(c1)&"\n")
d1 =3D define_c_func(ad,"DxsoftGetSymFromTxBuffer(void)",{C_CHAR}, C_INT)
puts(1, sprint(d1)&"\n")
e1 =3D define_c_func(ad,"DxsoftPutSymToRxBuffer(char sym)",{C_CHAR}, C_INT)=

puts(1, sprint(e1)&"\n")


I stopped here because a1..e1 gives every time only the value -1
which means that these functions "could not be found".
What am I doing wrong ?

Thanks

Rubens

new topic     » topic index » view message » categorize

2. Re: using dlls

Well, there seems to be a few problems. Firstly, you don't need 
win32lib.ew to define DLL functions, you should be using dll.e. For d1 and 
e1, you are including the parameters in the name. Also, the functions that 
have (void) do not take any parameters. Another thing you may not have found 
is that the functions have underscores prepended to them. This means that 
they probably use the C calling convention. This doesn't cause a problem 
when you define the function, but when you call it, it would probably crash. 
That means you will need to use eu 2.4. The only way to get around that is 
to re-compile the DLL. Here's some fixed code:

include dll.ew
atom ad, a1,b1,c1,d1,e1

ad = open_dll("dxsoftex.dll")

a1 = define_c_func(ad,"+_DxsoftExchangeInit", {C_INT}, C_INT)
b1 = define_c_func(ad,"+_DxsoftGetSymFromRxBuffer",{}, C_INT)
c1 = define_c_func(ad,"+_DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
d1 = define_c_func(ad,"+_DxsoftGetSymFromTxBuffer",{}, C_INT)
e1 = define_c_func(ad,"+_DxsoftPutSymToRxBuffer",{C_CHAR}, C_INT)

printf(1, "%d\n%d\n%d\n%d\n%d\n%d\n", {ad, a1, b1, c1, d1, e1})


>From: Rubens Monteiro Luciano <rml at rubis.trix.net>
>Reply-To: EUforum at topica.com
>To: EUforum at topica.com
>Subject: using dlls
>Date: Sun, 16 Nov 2003 02:31:21 -0200
>
>
>Hi all !
>	I'm just starting using external dlls and need some help.
>
>The dll is dxsoftex.dll  (from <http://www.dxsoft.com/dxs-exch.zip> )and
>the functions are these:
>
>--int DxsoftExchangeInit(int canal_number);
>--int DxsoftGetSymFromRxBuffer(void);
>--int DxsoftPutSymToTxBuffer(char sym);
>--int DxsoftGetSymFromTxBuffer(void);
>--int DxsoftPutSymToRxBuffer(char sym);
>
>the code:
>
>include win32lib.ew
>atom ad
>integer a1,b1,c1,d1,e1,a
>
>ad = open_dll("dxsoftex.dll")
>puts(1,sprint(ad)&"\n")    ------ ad gives 9895936
>
>a1 = define_c_func(ad,"DxsoftExchangeInit", {C_INT}, C_INT)
>puts(1, sprint(a1)&"\n")
>b1 = define_c_func(ad,"DxsoftGetSymFromRxBuffer",{C_CHAR}, C_INT)
>puts(1, sprint(b1)&"\n")
>c1 = define_c_func(ad,"DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
>puts(1, sprint(c1)&"\n")
>d1 = define_c_func(ad,"DxsoftGetSymFromTxBuffer(void)",{C_CHAR}, C_INT)
>puts(1, sprint(d1)&"\n")
>e1 = define_c_func(ad,"DxsoftPutSymToRxBuffer(char sym)",{C_CHAR}, C_INT)=
>
>puts(1, sprint(e1)&"\n")
>
>
>I stopped here because a1..e1 gives every time only the value -1
>which means that these functions "could not be found".
>What am I doing wrong ?
>
>Thanks
>
>Rubens
>

new topic     » goto parent     » topic index » view message » categorize

3. Re: using dlls

ok, thanks Ellilott, it works.
Where did you find this information (the "+_") ?
Could you show me where the this document is located?


Rubens

At 03:21 16/11/2003, you wrote:
>
>
>    Well, there seems to be a few problems. Firstly, you don't need 
> win32lib.ew to define DLL functions, you should be using dll.e. For d1 
> and e1, you are including the parameters in the name. Also, the functions 
> that have (void) do not take any parameters. Another thing you may not 
> have found is that the functions have underscores prepended to them. This 
> means that they probably use the C calling convention. This doesn't cause 
> a problem when you define the function, but when you call it, it would 
> probably crash. That means you will need to use eu 2.4. The only way to 
> get around that is to re-compile the DLL. Here's some fixed code:
>
>include dll.ew
>atom ad, a1,b1,c1,d1,e1
>
>ad = open_dll("dxsoftex.dll")
>
>a1 = define_c_func(ad,"+_DxsoftExchangeInit", {C_INT}, C_INT)
>b1 = define_c_func(ad,"+_DxsoftGetSymFromRxBuffer",{}, C_INT)
>c1 = define_c_func(ad,"+_DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
>d1 = define_c_func(ad,"+_DxsoftGetSymFromTxBuffer",{}, C_INT)
>e1 = define_c_func(ad,"+_DxsoftPutSymToRxBuffer",{C_CHAR}, C_INT)
>
>printf(1, "%d\n%d\n%d\n%d\n%d\n%d\n", {ad, a1, b1, c1, d1, e1})
>
>
>>From: Rubens Monteiro Luciano <rml at rubis.trix.net>
>>Reply-To: EUforum at topica.com
>>To: EUforum at topica.com
>>Subject: using dlls
>>Date: Sun, 16 Nov 2003 02:31:21 -0200
>>
>>
>>Hi all !
>>         I'm just starting using external dlls and need some help.
>>
>>The dll is dxsoftex.dll  (from <http://www.dxsoft.com/dxs-exch.zip> )and
>>the functions are these:
>>
>>--int DxsoftExchangeInit(int canal_number);
>>--int DxsoftGetSymFromRxBuffer(void);
>>--int DxsoftPutSymToTxBuffer(char sym);
>>--int DxsoftGetSymFromTxBuffer(void);
>>--int DxsoftPutSymToRxBuffer(char sym);
>>
>>the code:
>>
>>include win32lib.ew
>>atom ad
>>integer a1,b1,c1,d1,e1,a
>>
>>ad = open_dll("dxsoftex.dll")
>>puts(1,sprint(ad)&"\n")    ------ ad gives 9895936
>>
>>a1 = define_c_func(ad,"DxsoftExchangeInit", {C_INT}, C_INT)
>>puts(1, sprint(a1)&"\n")
>>b1 = define_c_func(ad,"DxsoftGetSymFromRxBuffer",{C_CHAR}, C_INT)
>>puts(1, sprint(b1)&"\n")
>>c1 = define_c_func(ad,"DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
>>puts(1, sprint(c1)&"\n")
>>d1 = define_c_func(ad,"DxsoftGetSymFromTxBuffer(void)",{C_CHAR}, C_INT)
>>puts(1, sprint(d1)&"\n")
>>e1 = define_c_func(ad,"DxsoftPutSymToRxBuffer(char sym)",{C_CHAR}, C_INT)=
>>
>>puts(1, sprint(e1)&"\n")
>>
>>
>>I stopped here because a1..e1 gives every time only the value -1
>>which means that these functions "could not be found".
>>What am I doing wrong ?
>>
>>Thanks
>>
>>Rubens
>
>
>
>TOPICA - Start your own email discussion group. FREE!
>
>

new topic     » goto parent     » topic index » view message » categorize

4. Re: using dlls

Well.... It's just something I know. I used Dependency Walker to find out 
the actual exported names from the DLL. Because they had a _, I knew they 
were probably cdecl (C calling convention), so you needed to add a '+' to 
the name.

>From: Rubens Monteiro Luciano <rml at rubis.trix.net>
>Subject: Re: using dlls
>
>ok, thanks Ellilott, it works.
>Where did you find this information (the "+_") ?
>Could you show me where the this document is located?
>
>
>Rubens
>
>At 03:21 16/11/2003, you wrote:
>>
>>
>>    Well, there seems to be a few problems. Firstly, you don't need 
>>win32lib.ew to define DLL functions, you should be using dll.e. For d1 and 
>>e1, you are including the parameters in the name. Also, the functions that 
>>have (void) do not take any parameters. Another thing you may not have 
>>found is that the functions have underscores prepended to them. This means 
>>that they probably use the C calling convention. This doesn't cause a 
>>problem when you define the function, but when you call it, it would 
>>probably crash. That means you will need to use eu 2.4. The only way to 
>>get around that is to re-compile the DLL. Here's some fixed code:
>>
>>include dll.ew
>>atom ad, a1,b1,c1,d1,e1
>>
>>ad = open_dll("dxsoftex.dll")
>>
>>a1 = define_c_func(ad,"+_DxsoftExchangeInit", {C_INT}, C_INT)
>>b1 = define_c_func(ad,"+_DxsoftGetSymFromRxBuffer",{}, C_INT)
>>c1 = define_c_func(ad,"+_DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
>>d1 = define_c_func(ad,"+_DxsoftGetSymFromTxBuffer",{}, C_INT)
>>e1 = define_c_func(ad,"+_DxsoftPutSymToRxBuffer",{C_CHAR}, C_INT)
>>
>>printf(1, "%d\n%d\n%d\n%d\n%d\n%d\n", {ad, a1, b1, c1, d1, e1})
>>
>>
>>>From: Rubens Monteiro Luciano <rml at rubis.trix.net>
>>>Reply-To: EUforum at topica.com
>>>To: EUforum at topica.com
>>>Subject: using dlls
>>>Date: Sun, 16 Nov 2003 02:31:21 -0200
>>>
>>>
>>>Hi all !
>>>         I'm just starting using external dlls and need some help.
>>>
>>>The dll is dxsoftex.dll  (from <http://www.dxsoft.com/dxs-exch.zip> )and
>>>the functions are these:
>>>
>>>--int DxsoftExchangeInit(int canal_number);
>>>--int DxsoftGetSymFromRxBuffer(void);
>>>--int DxsoftPutSymToTxBuffer(char sym);
>>>--int DxsoftGetSymFromTxBuffer(void);
>>>--int DxsoftPutSymToRxBuffer(char sym);
>>>
>>>the code:
>>>
>>>include win32lib.ew
>>>atom ad
>>>integer a1,b1,c1,d1,e1,a
>>>
>>>ad = open_dll("dxsoftex.dll")
>>>puts(1,sprint(ad)&"\n")    ------ ad gives 9895936
>>>
>>>a1 = define_c_func(ad,"DxsoftExchangeInit", {C_INT}, C_INT)
>>>puts(1, sprint(a1)&"\n")
>>>b1 = define_c_func(ad,"DxsoftGetSymFromRxBuffer",{C_CHAR}, C_INT)
>>>puts(1, sprint(b1)&"\n")
>>>c1 = define_c_func(ad,"DxsoftPutSymToTxBuffer",{C_CHAR}, C_INT)
>>>puts(1, sprint(c1)&"\n")
>>>d1 = define_c_func(ad,"DxsoftGetSymFromTxBuffer(void)",{C_CHAR}, C_INT)
>>>puts(1, sprint(d1)&"\n")
>>>e1 = define_c_func(ad,"DxsoftPutSymToRxBuffer(char sym)",{C_CHAR}, 
>>>C_INT)=
>>>
>>>puts(1, sprint(e1)&"\n")
>>>
>>>
>>>I stopped here because a1..e1 gives every time only the value -1
>>>which means that these functions "could not be found".
>>>What am I doing wrong ?
>>>
>>>Thanks
>>>
>>>Rubens
>>
>

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu