i want to know how i can use data from my dll in my app ex:
DLL
.data
String01 db 'This is My String',0

EXE

messageboxa,0, 'offset' string01,txt,0

and can i share a dword between my app and my dll

something like this

call some func in my dll that change the value of a dword val

and also get this val in my app.

thanks to help me
Posted on 2002-11-06 06:50:28 by Thor0Asgard
Yes you can... If you couldn't you wouldn't be able to call MessageBox from your app (its in a DLL after all).

Pass the address of the variable you want to modify, like you would if programming in C.

invoke MyDLLFunc, ADDR MyVariable

in the DLL:


MyDLLFunc PROC pVarToChange:DWORD
mov eax, pVarToChange
inc [eax]
ret


Mirno
Posted on 2002-11-06 07:52:37 by Mirno
sppose i've got a val Val0
in my dll
.data
Val dd 0
.code

dllfunc proc,arg0,arg1,argx...
do something
....
mov val0,some number
ret
dllfunc endp

sometihing in my app like
.code
cmp eax,val0
je ...


you see i want to know if there's a way to share data between app and dll but this data is into my dll.

sorry again for my bad explainations
Posted on 2002-11-06 08:15:47 by Thor0Asgard
Maybe this can help

http://www.asmcommunity.net/board/index.php?topic=5154&highlight=sharing+dll

just remember to use the search tool.
Posted on 2002-11-06 08:32:14 by roticv
To have a variable shared between your app, and the DLL defeats the purpose of a DLL.
It is a library, it is supposed to be moveable, and independant of the executables that call it, if it is coded any other way, then it may as well be a statically linked library (in which case you just use extern).
Its like having a libaray (of books) with one page ripped out, and only you have a copy of that page... No one else can borrow the book, so why put it in the library?

Make one of the arguments to the function be the address of the variable you want to modify, and it then becomes a portable function.

Mirno
Posted on 2002-11-06 08:53:50 by Mirno
You have to export variable address exactly the same as func name.
See attach.
Posted on 2002-11-06 11:46:48 by Four-F
Thor0Asgard,
what do you know about 'scope' and how it applies to variables? If you don't know much, then i would suggest that you do some reading on it, as it is one of the fundamental basics of programming, and if you are going to jump straight into asm then you need to pay close attention to it otherwise you will end up with lots of hard to trace bugs.

If you really want to be able to change a var insode your dll, then don't export it, instead you should use a pair of get/set functions in your dll. The exe calls the set function with a value to set the var, and calls the get function to get the var returned in eax. Doing it this way involves writing about 5 more lines of code, but programatically it is a lot safer long term.
Posted on 2002-11-06 17:46:30 by sluggy