1

我在 masm32 中创建 DLL 时遇到问题。无论我做什么,输出始终是 *.exe 文件,而不是 *.dll。下面的代码其实就是masm32 -> Code -> Create New DLL 创建的。我只是使用 Project -> Build All 来构建它。我做错了什么伙计们?

mydll.def

LIBRARY mydll
EXPORTS my_proc
; EXPORTS [your_exported_proc_name]

制作.bat

@echo off
if exist mydll.obj del mydll.obj
if exist mydll.dll del mydll.dll
\masm32\bin\ml /c /coff mydll.asm
\masm32\bin\Link /SUBSYSTEM:WINDOWS /DLL /DEF:mydll.def mydll.obj 
del mydll.obj
del mydll.exp
dir mydll.*
pause

mydll.asm

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    include \masm32\include\masm32rt.inc
    include \masm32\include\windows.inc
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    ; -------------------------------------------
    ; Build this DLL with the provided MAKEIT.BAT
    ; -------------------------------------------

      .data?
        hInstance dd ?

      .code

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

LibMain proc instance:DWORD,reason:DWORD,unused:DWORD 

    .if reason == DLL_PROCESS_ATTACH
      mrm hInstance, instance       ; copy local to global
      mov eax, TRUE                 ; return TRUE so DLL will start

    .elseif reason == DLL_PROCESS_DETACH

    .elseif reason == DLL_THREAD_ATTACH

    .elseif reason == DLL_THREAD_DETACH

    .endif

    ret

LibMain endp

My_proc proc 

    ret

My_proc endp

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

  comment * -----------------------------------------------------
          You should add the procedures your DLL requires AFTER
          the LibMain procedure. For each procedure that you
          wish to EXPORT you must place its name in the "mydll.def"
          file so that the linker will know which procedures to
          put in the EXPORT table in the DLL. Use the following
          syntax AFTER the LIBRARY name on the 1st line.
          LIBRARY mydll
          EXPORTS YourProcName
          EXPORTS AnotherProcName
          ------------------------------------------------------- *

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end LibMain
4

1 回答 1

0

如果您有 Visual Studio 的许可证,那么您可以使用 Visual Studio 进行 masm32 编程,按照提供的步骤转到项目属性并在配置属性下将配置类型更改为动态库后,可以在此处找到如何设置 Visual Studio 的详细信息.

于 2013-02-10T03:23:17.803 回答