2013-01-14 4 views
1

masm32에서 DLL을 만드는 데 문제가 있습니다. 내가 뭘 할지라도 * .exe가 아닌 * .exe 파일이 출력됩니다. 다음 코드는 실제로 masm32 -> 코드 -> 새 DLL 작성으로 작성된 코드입니다. 난 그냥 프로젝트 -> 모두 빌드를 사용하여 빌드합니다. 내가 뭘 잘못 했니?MASM32를 사용하여 DLL 만들기

mydll.def

LIBRARY mydll 
EXPORTS my_proc 
; EXPORTS [your_exported_proc_name] 

MAKEIT.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 
+0

링커의/OUT 옵션을 사용하여 파일 이름을 지정하십시오. –

+0

그래서 그냥 이름인가요? 수동으로 .exe를 .dll로 변경할 수 있습니다. xD – user1913596

+1

사실 Portable Executable 형식은 .exe 및 .dll 파일에서 모두 동일합니다. .exe 파일은 함수를 내보내고 .dll 파일과 같이 다른 프로세스에 동적으로로드 할 수도 있습니다. 일반적인 차이점은 .dll 파일에는 진입 점이 없지만 초기화가 가능하다는 것입니다. –

답변

0

당신은 비주얼 스튜디오에 대한 라이센스가있는 경우 당신은 비주얼 스튜디오를 사용 할 수 있습니다 masm32 프로그래밍, Visual Studio를 설치하는 방법에 대한 자세한 내용은 here을 제공된 단계는 프로젝트 속성으로 이동하고 구성 속성 아래에서 구성 유형을 동적 라이브러리로 변경합니다.