首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用MASM32创建动态链接库

使用MASM32创建动态链接库
EN

Stack Overflow用户
提问于 2013-01-14 19:18:54
回答 1查看 2.7K关注 0票数 1

我在masm32中创建动态链接库时遇到问题。无论我做什么,输出总是*.exe文件,而不是*.dll。以下代码实际上是由masm32 -> Code -> Create New DLL创建的代码。我只是使用Project -> Build All来构建它。伙计们,我做错了什么?

mydll.def

代码语言:javascript
复制
LIBRARY mydll
EXPORTS my_proc
; EXPORTS [your_exported_proc_name]

makeit.bat

代码语言:javascript
复制
@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

代码语言:javascript
复制
; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    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
EN

回答 1

Stack Overflow用户

发布于 2013-02-10 11:23:18

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14317477

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档