New question about dll and passing ....

Just starting out? Need help? Post your questions and find answers here.
plopzz
New User
New User
Posts: 4
Joined: Sun Apr 27, 2003 12:42 pm

New question about dll and passing ....

Post by plopzz »

I try now to make 1 dll who have to passing a structure to caller

i call like this :

Result = namefunction(Buflen,Buffer)

dll have to return a structure (buflen = size of structure and buffer = pointer of structure)

so how i can return the structure in the dll ???

I have declared the structure in the dll and in the caller app

Thanks
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

If the structure is declared in the DLL, Buflen must be at least SizeOf(structure) bytes in size, spo you shouldn't need to pass it.

Code: Select all

Structure MyStruc
  value1.l
  value2.l
EndStructure

ProcedureDLL namefunction(Buffer)
  *foo.MyStruc = Buffer
  *foo\value1 = 1
  *foo\value2 = 2
  ProcedureReturn *foo
EndProcedureDLL
El_Choni
plopzz
New User
New User
Posts: 4
Joined: Sun Apr 27, 2003 12:42 pm

Post by plopzz »

El_Choni wrote:If the structure is declared in the DLL, Buflen must be at least SizeOf(structure) bytes in size, spo you shouldn't need to pass it.

Code: Select all

Structure MyStruc
  value1.l
  value2.l
EndStructure

ProcedureDLL namefunction(Buffer)
  *foo.MyStruc = Buffer
  *foo\value1 = 1
  *foo\value2 = 2
  ProcedureReturn *foo
EndProcedureDLL
I already use ProcedureReturn for the state of function (True or False)
I have to use the same syntax because the main app are not written by me
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Anyway, you don't need to return the pointer to the Buffer, since the caller supplies it.
El_Choni
plopzz
New User
New User
Posts: 4
Joined: Sun Apr 27, 2003 12:42 pm

Post by plopzz »

El_Choni wrote:Anyway, you don't need to return the pointer to the Buffer, since the caller supplies it.
From the doc of app :
------------------------------------------------------------------------
Arguments :
BUFLEN
After the function is performed, this variable returns the actual buffer length occupied. The function only returns the required buffer length if the value of the BUFLEN and BUFFER variables is 0. (32-bit)

BUFFER
Pointer to the data structure which contains (...)
------------------------------------------------------------------------

If i'm right, and as i write the dll, i need to return the length of the structure and put the structure content in the pointer ?

My main problem are :
How i return BUFLEN ? i have to write directly in memory ?? put 1 PUSH command ? if i add ADD esp,-8, push, push, the application caller crash
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

I think I would need more info to understand this. I don't know if the function must return something or not. With the info you supply, I would assume that the function receives the pointer to the Bufflen variable, which you must fill in with the size of teh structure. If Bufflen is 0 you can't Poke there, so you just:

Code: Select all

ProcedureReturn RequiredBufferLength
While Buffer seems to be the direct Buffer pointer. And if the functions succeeds, return 0. But these are only guesses. Based on the info you supply, I can't help you further, sorry.
El_Choni
plopzz
New User
New User
Posts: 4
Joined: Sun Apr 27, 2003 12:42 pm

Post by plopzz »

Procedurereturn must return the status (and nothing else)

This is what i had understand (for the moment :p)

First call of dll : app call with buflen = 0 .. At this time, i return the length (sizeof) of structure in the buffer (its a pointer, so i directly pokeL in memory :/ )...

my structure have $18 of size

The dll are called another time, but with a buflen = $1E (???)
I put the structure address in buffer

But the structure seem to be wrong ... for the moment i search where i'm wrong

I hate all those app with poor docs (u say i don't give to u more infos, but i had copy/paste all infos from docs :p)

Btw, thanks for the time u spare with me
Post Reply