How do i get return values from a function within a dll file i made ?
Posted on 2001-03-15 08:12:00 by lsx
Simple. return values are placed in eax, when your DLL function finishes, place the return value in eax, it should still be there, when it returns to your calling application. umbongo
Posted on 2001-03-15 08:24:00 by umbongo
But if i want to get more than 1 parameter ?
Posted on 2001-03-15 11:29:00 by lsx
Make one of the inputs to the function a pointer to the return structure! Mirno
Posted on 2001-03-15 11:53:00 by Mirno
If you just want some low number of return values, pass the addresses of where they should be stored to your dll, then the dll can set the data. This is byref parameter passing.

.data
Thing1  DW  0
Thing2  DW  0

.code 
invoke MyDLL, ADDR Thing1, ADDR Thing2



...
(inside the dll)
MyDll PROC pThing1:DWORD, pThing1:DWORD
  mov ecx, pThing1
  mov eax, 5     ; dummy return data
  mov , eax
  mov ecx, pThing2
  mov eax, 10     ; dummy return data
  mov , eax
  mov eax, 0      ; eax = 0 usually means a good ending
  ret
MyDll ENDP
And yes, if you have lots and lots of parameters to pass back and fourth, make a structure and pass the address of the structure.
Posted on 2001-03-15 14:15:00 by Ernie