Does anyone know why, with PB, the simplest DLL (a "Hello World" DLL) is about 8KB, while the smallest EXE is about 3-4 KB?
(It' not important to me at all - I'm just curious!)
DLL larger than EXE?
Re: DLL larger than EXE?
because you forgot to turn Debugger off in the DLL? 
5.42 x86 PB MessageRequester("Hello world") EXE = 4608 bytes, DLL = 5120 bytes (including AttachProcess/DetachProcess/AttachThread/DetatchThread functions)

5.42 x86 PB MessageRequester("Hello world") EXE = 4608 bytes, DLL = 5120 bytes (including AttachProcess/DetachProcess/AttachThread/DetatchThread functions)
Re: DLL larger than EXE?
DLLs usually have some initialization (and de-initialization) code that executables lack.
Re: DLL larger than EXE?
No, that's not it... I just checked and I do have the debugger turned off.Keya wrote:because you forgot to turn Debugger off in the DLL?
5.42 x86 PB MessageRequester("Hello world") EXE = 4608 bytes, DLL = 5120 bytes (including AttachProcess/DetachProcess/AttachThread/DetatchThread functions)
But I'm using a different version: 5.31 x86. Maybe something was optimized in the meantime.
Last edited by firace on Tue Aug 23, 2016 7:59 pm, edited 1 time in total.
Re: DLL larger than EXE?
I do have quite a few DLLs that are just 2-3 KB on my system, though...eesau wrote:DLLs usually have some initialization (and de-initialization) code that executables lack.
For instance: C:\Program Files\Common Files\System\ado\msader15.dll
Re: DLL larger than EXE?
strange, have a look at the .asm output (compile with purebasic.exe /COMMENTED)
Re: DLL larger than EXE?
This is the output. To my noob eyes, nothing special stands out...Keya wrote:strange, have a look at the .asm output (compile with purebasic.exe /COMMENTED)
Code: Select all
;
; PureBasic 5.31 (Windows - x86) generated code
;
; (c) 2014 Fantaisie Software
;
; The header must remain intact for Re-Assembly
;
; :DLL
; Requester
; FileSystem
; Date
; Object
; SimpleList
; :System
; KERNEL32
; :Import
;
format MS COFF
;
;
extrn _PB_FreeFileSystem@0
extrn _PB_InitRequester@0
extrn _PB_MessageRequester2@12
extrn _GetModuleHandleA@4
extrn _HeapCreate@12
extrn _HeapDestroy@4
extrn _memset
extrn PB_StringBase
extrn _SYS_InitString@0
extrn _SYS_FreeStrings@0
;
extrn _PB_StringBasePosition
public _PB_Instance
public _PB_ExecutableType
public _PB_OpenGLSubsystem
public _PB_MemoryBase
public PB_Instance
public PB_MemoryBase
public _PB_EndFunctions
public _DLLEntryPoint@12
public _Procedure0
macro pb_public symbol
{
public _#symbol
public symbol
_#symbol:
symbol:
}
macro pb_align value { rb (value-1) - ($-_PB_DataSection + value-1) mod value }
macro pb_bssalign value { rb (value-1) - ($-_PB_BSSSection + value-1) mod value }
;
section '.code' code readable executable align 4096
;
;
_DLLEntryPoint@12:
CMP dword [esp+8], 1
JNE .SkipProcessAttach
MOV eax, [esp+4]
MOV [_PB_Instance],eax
CALL PB_DllInit
.SkipProcessAttach:
CMP dword [esp+8], 2
JNE .SkipThreadAttach
.SkipThreadAttach:
CMP dword [esp+8], 0
JNE .SkipProcessDetach
CALL _PB_EOP
.SkipProcessDetach:
CMP dword [esp+8], 3
JNE .SkipThreadDetach
.SkipThreadDetach:
MOV eax,1
RET 12
;
PB_DllInit:
PUSH dword 0
PUSH dword 4096
PUSH dword 0
CALL _HeapCreate@12
MOV [PB_MemoryBase],eax
CALL _SYS_InitString@0
CALL _PB_InitRequester@0
; DisableDebugger
;
;
RET
_PB_EOP_NoValue:
_PB_EOP:
CALL _PB_EndFunctions
CALL _SYS_FreeStrings@0
PUSH dword [PB_MemoryBase]
CALL _HeapDestroy@4
RET
_PB_EndFunctions:
CALL _PB_FreeFileSystem@0
RET
;
;
section '.data' data readable writeable
;
_PB_DataSection:
_PB_OpenGLSubsystem: db 0
pb_public PB_DEBUGGER_LineNumber
dd -1
pb_public PB_DEBUGGER_IncludedFiles
dd 0
pb_public PB_DEBUGGER_FileName
db 0
pb_public PB_Compiler_Unicode
dd 0
pb_public PB_Compiler_Thread
dd 0
pb_public PB_Compiler_Purifier
dd 0
pb_public PB_Compiler_Debugger
dd 0
_PB_ExecutableType: dd 0
public _SYS_StaticStringStart
_SYS_StaticStringStart:
_S2: db "This is a PureBasic DLL !",0
_S1: db "Hello",0
pb_public PB_NullString
db 0
public _SYS_StaticStringEnd
_SYS_StaticStringEnd:
align 4
align 4
align 4
s_s:
dd 0
dd -1
align 4
;
section '.bss' readable writeable
_PB_BSSSection:
align 4
;
I_BSSStart:
_PB_MemoryBase:
PB_MemoryBase: rd 1
_PB_Instance:
PB_Instance: rd 1
;
align 4
PB_DataPointer rd 1
align 4
align 4
align 4
align 4
I_BSSEnd:
section '.code' code readable executable align 4096
; ProcedureDLL MyFunction()
_Procedure0:
PS0=4
; MessageRequester("Hello", "This is a PureBasic DLL !", 0)
PUSH dword 0
PUSH dword _S2
PUSH dword _S1
CALL _PB_MessageRequester2@12
; EndProcedure
XOR eax,eax
_EndProcedure1:
RET
section '.data' data readable writeable
SYS_EndDataSection: