Author Topic: mangled names linking modules  (Read 309 times)

markallyn

  • Member
  • **
  • Posts: 63
Re: mangled names linking modules
« Reply #15 on: September 14, 2017, 04:44:30 AM »
Good afternoon, aw27,

Thanks for the taskmanager tip!  Very very helpful.

I've learned a great deal from you and Vortex over the last couple of days.  First there was the business about PROTO/EXTERN.  I think that part is cleared up with the exception of the difference in syntax for file names that seem to be true of the two declarations.  The other matter you were perhaps less aware of, but without knowing it you clarified what PROC does and which had completely passed me by.  Namely, if the arguments are added after the PROC keyword there is no requirement to set up the stack--PROC does it for you.  In fact, as I learned, if you DO set up a stack, it really messes up the PROC and it won't run correctly because it attempts to push ebp a second time.

The only documentation I have is an old book of V. 6.1 masm.  The book makes it sound like you can use the invoke command either with the PROTO definition OR with EXTERN.  But, when I tried that the program failed.  Did MASM later versions change the rule?

Thanks again for staying with me.

Mark

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 4813
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: mangled names linking modules
« Reply #16 on: September 14, 2017, 08:07:06 AM »
Mark,

If you are going to use any recent (in the last 20 years) version of 32 bit MASM, use a PROTOTYPE for a procedure/function if you are going to use the "invoke" notation.

YourFunction PROTO STDCALL :DWORD,:DWORD etc .....


You can make the procedure call manually,

push arg2
push arg1
call function
mov retval, eax


To do this you need to include the system library that contains the function.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :biggrin:

aw27

  • Member
  • ****
  • Posts: 709
Re: mangled names linking modules
« Reply #17 on: September 14, 2017, 03:29:51 PM »
Quote
if you DO set up a stack, it really messes up the PROC and it won't run correctly because it attempts to push ebp a second time
If you want to roll your own you will be better off making the procedure naked.
OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE