Brian,
I'm reworking the RTLs and this is how The entry and exit code will be defined for DLLs (and EXEs.
#file FileName independent
%mode32bit
'=========
#ifdef dll
'=========
'
'DLL EQUATES
'
% DLL_PROCESS_DETACH 0
% DLL_PROCESS_ATTACH 1
% DLL_THREAD_ATTACH 2
% DLL_THREAD_DETACH 3
% DLL_PROCESS_VERIFIER 4
'
mov edx,[esp+8] 'second param of DLLmain
'
select edx
case DLL_PROCESS_ATTACH
jmp fwd prolog
case DLL_PROCESS_DETACH
! finish()
finish()
mov eax,0
case DLL_THREAD_ATTACH
mov eax,1
case DLL_THREAD_DETACH
mov eax,0
end select
ret 12
def _epilog 'FOR DLL
====================
._end_
lea edi,[ebp-8] 'temp list
call delbuf
mov eax,1
mov esp,ebp : pop ebp : add esp,4 : pop edi : pop esi : pop ebx
ret 12
._error_
push 0x30
"MISSING OR UNLOADABLE"
push eax
push ecx
push 0
call [ebx+472]
lea edi,[ebp-8] 'temp list
call delbuf
mov esp,ebp : pop ebp : add esp,4 : pop edi : pop esi : pop ebx
mov eax,0
ret 12
end def '_epilog
'=========
#else 'EXE
'=========
def _epilog 'FOR EXE
====================
._end_
mov edi,eax 'hold exit value in edi
push 0 'place for exit code
mov eax,esp
push eax
call getModuleHandle
push eax
call GetExitCodeProcess
mov eax,edi 'return exit value in eax
call ExitProcess
._error_
push 0x30
"MISSING OR UNLOADABLE"
push eax
push ecx
push 0
call [ebx+472]
mov eax,0
jmp _end_
end def
'==============
#endif 'DLL/EXE
'==============
'------
Prolog:
'======
...
After completing the prolog, setting up the Run-time library, it goes directly to your source code.
At the end of your source code, the finish procedure is inserted to cleardown o2's allocations. Then the epilog is invoked.