News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Creating a DLL without Dependencies

Started by x64Core, May 29, 2012, 01:45:52 PM

Previous topic - Next topic

x64Core

Hello all guys, fine, I'm trying create a DLL without dependencies :P
but, it adds MSVCRT.DLL:


then, exist a way to create it without MSVCRT.DLL?
the DLL is right, has a size of 3kb wow!

any words, thanks !  :biggrin:


code:

include masm32rt.inc

.data
mymsg db "Hello world from DLL :D",0
.code
DllEntry proc hInst:HINSTANCE, reason:DWORD, reserved1:DWORD
    invoke MessageBox,NULL,addr mymsg,addr mymsg,MB_OK
    ret
DllEntry Endp


End DllEntry



P1

Quote from: RHL on May 29, 2012, 01:45:52 PM
Hello all guys, fine, I'm trying create a DLL without dependencies :P
but, it adds MSVCRT.DLL:


then, exist a way to create it without MSVCRT.DLL?
the DLL is right, has a size of 3kb wow!

any words, thanks !  :biggrin:


code:

include masm32rt.inc

.data
mymsg db "Hello world from DLL :D",0
.code
DllEntry proc hInst:HINSTANCE, reason:DWORD, reserved1:DWORD
    invoke MessageBox,NULL,addr mymsg,addr mymsg,MB_OK
    ret
DllEntry Endp


End DllEntry

That is easy, just don't use ANY Windows API functions or procedures, including MessageBox.

Regards,  P1   8)

x64Core

but why? in a Portable Executable I can do the same,
and it does not require of MSVCRT.DLL.... :(

dedndave

well - msvcrt should not be getting pulled in
it looks as though you have a call to the "wait_key" macro or something
i build it here - and the only dependency is user32.dll

what ML and LINK command lines are you using ?
ml /c /coff dll.asm
link /dll /subsystem:windows dll.obj

is what i used
if there were any exported functions, you'd also want a DEF file and use...
link /dll /def:dll.def /subsystem:windows dll.obj

Bill Cravener has a nice little example
\masm32\examples\Bill_Cravener\mvolume

what program are you using to see the dependencies ?

x64Core

Hello Dave  :biggrin:
thanks bro, yeah that's right!  :shock: I'm using CFF explorer, it's very good :P


is rare... only I deleted the invoke line of menssagebox, assemble, and look at the exe, then came back to write the line
and gave me this result  :icon_eek:

but now:



is created the export table :|
why?, I'm not export any function...



x64Core

surely, it are  in the newer versions of MASM, because I do not have them :P

hutch--

RHL,

The reason why you are getting MSVCRT included is because it is contained in the MASM32RT include file. The way to avoid this is to include specific include file AFTER windows.inc.


Include \masm32\include\windows.inc  ; always first
Include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
etc etc ....

dedndave

i am afraid that Hutch and i are not on the same page, here - lol
i don't think any libs are imported unless a function is used

as for the export table...
i guess it assumes you are going to have an exported function
maybe if you create a DEF file that has no exports - only the DLL name

x64Core

yeah, that's right  :icon_redface:
thanks a lot guys, really I appreciate your help

hutch--

This is the catch, if your DLL does not call the OS at all, then you have no imports but as soon as it does you need the import library for any API function that you call. You can try risky and unreliable methods but you live dangerously doing so.

Vortex

Hi RHL,

Here is a quick example for you. The DLL in the attachment does not import any function. It exports only one function named StrLen.