The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: lamer on May 02, 2005, 06:52:17 PM

Title: invoke instead of call
Post by: lamer on May 02, 2005, 06:52:17 PM
Hi all!
I have just written my first DLL in ASM! :dance:
And I am a bit confused: if I work with LoadLibrary etc - I have to point to functions of DLL by call - but I want by invoke. If I add incudes to .inc and .lib. files - I can point to functions by invoke, but then the DLL is loaded when the main program starts. Is there any way to load DLL by demand and work with invoke? Like in VB, for example - I just can add Declare and point to function at any time.
Title: Re: invoke instead of call
Post by: hitchhikr on May 02, 2005, 06:55:33 PM
You probably need some prototypes for the dlls functions to use invoke.
Title: Re: invoke instead of call
Post by: lamer on May 02, 2005, 07:06:16 PM
Where?
I have them in .inc file - but if add it in include, I pass the linking, but fail on build with: error LNK2001: unresolved external symbol _blablabla@8 - until I add icludelib for .lib file.
Title: Re: invoke instead of call
Post by: hitchhikr on May 02, 2005, 07:23:22 PM
That's normal i would say, where is the problem exactly ?
And what about pasting some bits of code ?
Title: Re: invoke instead of call
Post by: lamer on May 02, 2005, 08:23:13 PM
OK, this is the DLL and test project. The test project now works with LoadLibrary and call. I have commented lines with "invoke" and appropriate includes in .inc file. I have written it with RadAsm so I have added project files as well. Thanks.

[attachment deleted by admin]
Title: Re: invoke instead of call
Post by: AeroASM on May 02, 2005, 08:52:33 PM
Quote from: lamer on May 02, 2005, 07:06:16 PM
I pass the linking, but fail on build with: error LNK2001: unresolved external symbol _blablabla@8

That is a link error.

just to clarify: assemble means turn .asm into binary format, like COFF (.obj), OMF, flat etc

Linking was invented by Microsoft (i think??) and means turning .obj into .exe

Build means assemble, then link.
Title: Re: invoke instead of call
Post by: James Ladd on May 02, 2005, 09:12:30 PM
Do you have a .DEF files as well so specify the exported name ?
Title: Re: invoke instead of call
Post by: hutch-- on May 02, 2005, 11:28:40 PM
lamer,

You can stop guessing and actually have a look at the tutorial in the forum web site for constructing a DLL. Once you get the idea they are simple enough to do.
Title: Re: invoke instead of call
Post by: farrier on May 03, 2005, 05:42:42 AM
lamer,

You might want to look at:

http://www.masmforum.com/simple/index.php?topic=694.0

Hth

farrier
Title: Re: invoke instead of call
Post by: pbrennick on May 03, 2005, 02:17:04 PM
The DLL entry point does not look correct to me.  It need something like the following:


        .if reason==DLL_PROCESS_ATTACH  ; When the dll is loaded
          ;call the procedure here
        .endif


Then, if that procedure is the only call in the DLL, you do not need .lib or .inc, just load the dll and it will execute immediately.  I use this method with my Spash screen DLL.  If you need the example, I will attach it, just ask.

Paul
Title: Re: invoke instead of call
Post by: lamer on May 03, 2005, 08:29:01 PM
Quote from: pbrennick on May 03, 2005, 02:17:04 PM
it will execute immediately.
And what if I should pass parameters to function? And get them back? Do it at DLL entry point?  :(
Title: Re: invoke instead of call
Post by: AeroASM on May 03, 2005, 08:51:03 PM
If you want to pass parameters, then put in your own functions.