Oxygen Basic
Programming => Example Code => Topic started by: Brian Alvarez on January 11, 2019, 10:40:18 AM
-
Hello, i am in need of some DLL examples. Maybe i could figure out, but i rather not trial and error this time. :)
I basically need to know how to capture, %DLL_PROCESS_ATTACH, %DLL_PROCESS_DETACH, %DLL_THREAD_ATTACH and
%DLL_THREAD_DETACH.
Also, are the extern tags the ones needed for exporting the functions? Thanks!
-
Have you looked at how Charles is building the oxygen.dll?
-
Hi Brian,
A minimal 64bit o2 DLL:
'
$dll
$filename "t64.dll"
uses RTL64
'print "t64.dll Loaded"
function HelloA(string s) as string, export
return "HelloA "+s
end function
function HelloW(wstring s) as wstring, export
return "HelloW "+s
end function
Also supported without tagging each function:
extern export
..
end extern
Do you still need the low-level stuff: %DLL_PROCESS_ATTACH ?
-
It might be worth looking at the DLLC code as Charles does some amazing things with virtual shared objects and dynamic FFI.
-
Do you still need the low-level stuff: %DLL_PROCESS_ATTACH ?
Hello Charles, Im trying to emulate an example that requires the %DLL_PROCESS_DETACH stuff, so, it would be great to have an example if possible. :)
-
You can see it near the beginning of the RTLs:
DLL entry code in RTL64.inc
% mode64bit
'=================
#ifdef dll
'=================
'
'DLL EQUATES
'
% DLL_PROCESS_ATTACH 1
% DLL_THREAD_ATTACH 2
% DLL_THREAD_DETACH 3
% DLL_PROCESS_DETACH 0
% DLL_PROCESS_VERIFIER 4
'
select rdx
case DLL_PROCESS_ATTACH : jmp fwd dll_start
case DLL_PROCESS_DETACH : jmp fwd dll_finish
case DLL_THREAD_ATTACH : mov rax,0 : ret
case DLL_THREAD_DETACH : mov rax,0 : ret
end select
mov rax,0
ret
'---------
dll_start:
'=========
'
jmp fwd prolog
'----------
dll_finish:
'==========
'
push rbx : push rsi : push rdi : push rax : push rbp
mov rbp,rsp
'
lea rip rbx,bssdata
'
! finish()
finish()
'
mov rax,0
mov rsp,rbp
pop rbp : add rsp,8 : pop rdi : pop rsi : pop rbx
ret
'==========
#endif 'DLL
'==========