News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Print Function In DLL Creation

Started by nathanpc, October 02, 2009, 01:04:40 AM

Previous topic - Next topic

nathanpc

Hello,
I'm now trying to learn how a DLL functions and there is nothing better to learn this than doing some test DLLs, but when i try to use a print in my test DLL i' m getting some errors in the compilling, see my code:
    .386
    .model flat, stdcall
    option casemap :none   ; case sensitive

    include D:\masm32\include\windows.inc
    include D:\masm32\include\user32.inc
    include D:\masm32\include\kernel32.inc

    includelib D:\masm32\lib\user32.lib
    includelib D:\masm32\lib\kernel32.lib

    szText MACRO Name, Text:VARARG
      LOCAL lbl
        jmp lbl
          Name db Text,0
        lbl:
      ENDM

    m2m MACRO M1, M2
      push M2
      pop  M1
    ENDM

    return MACRO arg
      mov eax, arg
      ret
    ENDM

.code

LibMain proc

    jmp @F
      MbMess db "Test function",0
    @@:
    ret

print MbMess, 13, 10

LibMain endp
End LibMain

Now see my compiller log:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved

Assembling: tstdll.asm
tstdll.asm(38) : error A2008: syntax error : print
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

What is wrong?

Thanks,
Nathan Paulino Campos

BlackVortex

print is a macro, so you need additional includes. I think :
    include \masm32\include\masm32rt.inc
should be enough

nathanpc

I've added it and now i'm getting this errors:
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: tstdll.asm
D:\masm32\include\masm32rt.inc(33) : warning A4011: multiple .MODEL directives f
ound : .MODEL ignored
D:\masm32\include\masm32rt.inc(38) : fatal error A1000: cannot open file : \masm
32\include\windows.inc
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.


Thanks.

2-Bit Chip

Go to:
Start Menu -> Control Panel -> System -> Advanced system settings -> Environment Variables

Under System Variables, put in
Variable name  : "SystemDrive"
Variable value : "C:;D:;"

MichaelW

Nathan,

If you are going to add:

include \masm32\include\masm32rt.inc

Then to avoid duplicate definitions you need to remove all of the following:

    .386
    .model flat, stdcall
    option casemap :none   ; case sensitive

    include D:\masm32\include\windows.inc
    include D:\masm32\include\user32.inc
    include D:\masm32\include\kernel32.inc

    includelib D:\masm32\lib\user32.lib
    includelib D:\masm32\lib\kernel32.lib

    szText MACRO Name, Text:VARARG
      LOCAL lbl
        jmp lbl
          Name db Text,0
        lbl:
      ENDM

    m2m MACRO M1, M2
      push M2
      pop  M1
    ENDM

    return MACRO arg
      mov eax, arg
      ret
    ENDM


If this does not make sense to you, then take a look at what is in \masm32\include\masm32rt.inc, and at the macros defined in \masm32\macros\macros.asm.

eschew obfuscation

nathanpc

I've builded the DLL without errors with this code:
    .386
    option casemap :none   ; case sensitive
    include \masm32\include\masm32rt.inc

.code
LibMain proc

    jmp @F
      MbMess db "Test function",0
    @@:
    ret

print MbMess, 13, 10

LibMain endp
End LibMain

Now i'm going to read about calling a DLL in a app(the MASM example).

Thanks!

2-Bit Chip


PBrennick

Any duplicate variable names as is the case of names such as szText, m2m and return to name the very obvious will generate error not warnings as Michael so correctly states.

Add to this the fact that warnings can lead you to realize you are not programming in a 'clean' fashion my recommendation is that you listen carefully to what Michael says.

Having said that, I appreciate your post. A lot of us have been around a long time and we can now make mistakes we never made before. Fellows such as yourself tend to keep us on our toes.

:U

Paul
The GeneSys Project is available from:
The Repository or My crappy website