Using qWord's routine (http://www.masmforum.com/board/index.php?topic=18148.msg153034#msg153034), I see that CoGetMalloc gets included in executables even if it is apparently not needed (it gets never called, verified with a breakpoint).
MB includes masm32rt.inc, for compatibility reasons, but my testbed doesn't need masm32.lib to work.
If I use a modified masm32rt.inc that does not include masm32.lib, the testbed runs just fine, and CoGetMalloc is no longer visible.
If I use the original masm32rt.inc that does include masm32.lib, and use just qWord's routine, printing with my macros, the testbed runs just fine, and CoGetMalloc is not visible.
So somewhere in the process the linker sees "include masm32.lib", and decides that having CoGetMalloc would be nice, too...
Is there any sound method to find out why CoGetMalloc gets linked, for no particular reason??
::)
That function call is in Ernie Murphy's "alloc.asm" procedure.
I know, Hutch. But Alloc doesn't get called by my executables, that's the mystery :(
I tried Dependency Walker, but it wasn't particularly helpful. Apart from this specific case (I could perfectly live with ole32 included for no reason), I am curious how that could be tracked down...
Sound like MASM's famous prototype bug: If the name of a already declared prototype occurs in an expression that is evaluated (e.g. by/inside a (text-)macro), MASM adds a EXTERN entry in the object file, even if the function is never called.
e.g.:
include \masm32\include\masm32rt.inc
.code
main proc
FOO TEXTEQU <MessageBoxW>
FOO2 TEXTEQU FOO
exit
main endp
end main
MessageBoxW occurs in the object file.
BTW: the above link is broken
EDIT: example
Quote from: qWord on August 06, 2013, 04:54:22 AMSounds like MASM's famous prototype bug
Indeed, JWasm does not include ole32, while ML 6.15 and 10.0 do :t
QuoteBTW: the above link is broken
Corrected above, thanks.
I investigated a bit further and found out that by commenting out lines 15+16 of Masm32.inc ...
; Alloc PROTO :DWORD
; Free PROTO :DWORD... the problem disappears also for ML.exe. Neither Alloc nor Free appear in macros.asm, and Alloc also doesn't appear in \Masm32\help\masmlib.chm
However, Malloc and Free are in the help file, under "Memory functions" ::)
Both are (very old) parts of the masm32 library:
\Masm32\m32lib\alloc.asm
\Masm32\m32lib\free.asmAnd I found a hilarious workaround to disable them without changing Masm32.inc:
Alloc MACRO arg
echo NO_Alloc arg
ENDM
Free MACRO arg
echo NO_Free arg
ENDM
include \masm32\MasmBasic\MasmBasic.inc ; download (http://masm32.com/board/index.php?topic=94.0)
...The echos:
NO_Alloc PROTO :DWORD
NO_Free PROTO :DWORDWorks perfectly, Ole32 is gone :biggrin:
However, re-installing fails:
PURGE Alloc, Free
Alloc PROTO :DWORD
Free PROTO :DWORD
.code
invoke Alloc, 100 ; error A2148: invalid symbol type in expression : Alloc
invoke Free, eax ; error A2148
Mysteries of Masm :lol: