Well,to Get things more clear,i just tried to create a DLL& Call the functions in it from another EXE.
My DLL-file(MyDLL.asm) contains 2 functions
1)GrabTime ->Which Grabs the Local Time using 'GetLocalTime' API
2.)Write2LogFile->Write these Time to a File-'Log2.txt' in Desktop

Both these functions were exported through a (MyDll.def).

But ,it just displays an "Illegal functn Call"msg when tried to call thru an EXE.
But when track it through SOFTICE...It just accomplish what it intended to do...No bad Messages.!!

I can't get it.Please help......
Posted on 2004-02-14 20:51:43 by zakham
Hi,

Try changing line 45 to 47 in mydllcall.asm from:


call [pGrabTime]

lea pStr,eax

to


call pGrabTime

mov pStr,eax


Ossa
Posted on 2004-02-15 05:49:23 by Ossa
Ya...There is a problem in lea pStr,eax .
.B'cze i am returning the Offset of string from GrabTime Function.
As Ossa Wrote-> I Changed
.

lea pStr,eax

to


mov pStr,eax

But what ab't the API Call.
Both the calls,Call as well Call pGrabTime is working.
How it's Working.?I don't know?
Again, the real problem wasn in the DLL file i inserted 'int 3' -> for debugging in SoftIce.
It wass the Main culprit.
When i comment it. change mov pStr,eax
.Everything turned okay.!!!
Posted on 2004-02-18 11:44:07 by zakham
Hi :)
This might clarify a few points:

1) Under MASM, this two lines are equivalent:
call [pStr]

call pStr


2) The pStr variable already holds a pointer, so you don't need to do LEA.
lea eax,pStr    ;This gets the address labeled as "pStr" into EAX.

mov eax,pStr ;This gets the VALUE found at address labeled as "pStr" into EAX.


3) The int 3 instruction is only meant to be executed under a debugger. If you leave them in your final version, it will cause a GPF when executed.

Hope that helps :alright:
Posted on 2004-02-18 13:30:34 by QvasiModo
Hi QvasiModo,

Hate to disagree but if pStr is a pointer (offset) and not a data label...

lea eax,pStr    ;This gets the address labeled as "pStr" into EAX.

mov eax,pStr ;This gets the VALUE found at address labeled as "pStr" into EAX.


mov eax,pStr moves the pointer in to eax, to dereference the pointer you must use a register..

mov eax,pStr

mov eax,[eax]
Posted on 2004-02-18 13:46:23 by donkey
:grin:
I haven't read the sources, but I assume that pStr is defined like this:
.data

pstr dd 0

And gets filled with a pointer on runtime.
lea eax,pStr ;puts the address pStr in eax.

mov eax,pStr ;gets the value of pStr in eax, which in turn is a pointer in this particular case.

Of course, to use a pointer to a pointer one must do:
mov eax,pStr

mov eax,[eax]

So I think we are talking of two different things :)
Posted on 2004-02-18 13:59:43 by QvasiModo
QvasiModo Wrote...
I haven't read the sources, but I assume that pStr is defined like this:
 .data

pStr dd 0


Well....U could have a glance at my (lame) code FIRST...!
Even it's lame... I never declared 'pStr' as pStr dd 0
Instead it's
[B][I]        pStr		LPSTR	0

pGrabTime dd 0
szGrabTime db "GrabTime",0 [/I][/B]


My Question was:After the call to get the function Address
		Invoke	GetProcAddress,eax,addr szGrabTime

mov pGrabTime,eax


Both the calls


Call [pGrabTime] ;Which we usually do...

&
Call pGrabTime ;Which shouldn't Work !..

Are Working....I need a satisfactory Answer as how the 2nd call (Call pGrabTime) is still working..
Posted on 2004-02-20 17:59:56 by zakham
Brackets around names are implicit. The assembler ignores your extra brackets.
You can even do CALL [[[[]]]] and it will work.
Posted on 2004-02-20 18:41:47 by death

Brackets around names are implicit. The assembler ignores your extra brackets.
You can even do CALL [[[[]]]] and it will work.


Brackets around names are ignored in MASM, every other assembler requires them and they are not ignored. You cannot do [[[[]]]] in anything but MASM so "The assembler" is not the right word to use here. I generally always include brackets, that way it is compatible with every assembler, not just MASM. But since his code is MASM I left them out.
Posted on 2004-02-20 19:06:42 by donkey

... so "The assembler" is not the right word to use here ...

"The assembler" isn't a word, is it? and it is exactly what I meant. I spoke in terms of the context in which the question was asked. If I'd want to generalize, I'd say "An assembler".
Posted on 2004-02-20 19:14:01 by death
Okey Dokey.
Posted on 2004-02-20 19:18:40 by donkey

Well....U could have a glance at my (lame) code FIRST...!

Hey, don't take it personally. I just assumed the most common situation.
Even it's lame... I never declared 'pStr' as pStr dd 0
Instead it's
[B][I]        pStr		LPSTR	0

pGrabTime dd 0
szGrabTime db "GrabTime",0 [/I][/B]


Aren't this lines equivalent?


pStr dd 0
pStr DWORD 0
pStr LPSTR 0

My Question was:After the call to get the function Address
		Invoke	GetProcAddress,eax,addr szGrabTime

mov pGrabTime,eax


Both the calls


Call [pGrabTime] ;Which we usually do...

&
Call pGrabTime ;Which shouldn't Work !..

Are Working....I need a satisfactory Answer as how the 2nd call (Call pGrabTime) is still working..

That question was answered already (more than once) in this thread. Could you care to read my (lame) post AGAIN?

PS: What's your attitude about? I was trying to help! :mad:
Posted on 2004-02-21 18:12:48 by QvasiModo
QvasiModo


SORRY...SORRY....SORRY..

My intention was not to hurt u.
You tried to help me...
Sorry..if u feel hurt.
Posted on 2004-02-22 11:16:52 by zakham
Mhm, ok, not problem. I'm not really mad anyway, let's forget it.
(Just make sure you use more smilies next time, the lack of body language makes people misunderstand you without them. It happened a lot to me :( ).
Posted on 2004-02-23 12:09:51 by QvasiModo
its the 1000th time i see ppl get confused by pointers/labels/offsets , and i cant hide my hate anymore from this fucking stupid masm/tasm syntax that has done soo much harm. Also, i strongly deny to lea any right to exist because it fucking has no use and it still confuses people, and i dont care about saving one opcode or doing fast muls. it sucks.

have a nice day.
Posted on 2004-02-23 16:02:57 by HeLLoWorld