IDE: Visual Studio 2015 Version: 10.0.2255 Target: Island(Windows 32-bit) Description:
When creating a DLL in Silver (for example by creating a command line application and changing the Executeble Type from Exe to Library) there is no way that I could find to specify DllMain.
Statements at file scope aren’t executed at all (RemObjects.Elements.System.<global>::Main doesn’t get called) l which is kinda good, but there still needs to be a way to define a DllMain function.
If you look at IslandRTL I do implement dllmainstartup:
method ExternalCalls.DllMainCRTStartup(aModule: rtl.HMODULE; aReason: rtl.DWORD; aReserved: ^Void): Boolean;
begin
fModuleHandle := aModule;
var m: VoidMethod;
if aReason = rtl.DLL_PROCESS_ATTACH then begin
m := @DllEntry;
if assigned(m) then m();
end;
if aReason = rtl.DLL_PROCESS_ATTACH then
m := @DllExit;
if assigned(m) then m();
exit true;
end;
You should be able to override these two:
[SymbolName('__elements_dll_entry'), &Weak]
class method DllEntry; external;
[SymbolName('__elements_dll_exit'), &Weak]
class method DllExit; external;
(By defining non weak static methods with no arguments with those symbol names)
The convoluted way to solve this is to add two more function for thread callbacks. The simple way would be to simply forward the 3 parameters to a single DllMain function and let the programmer do the if/switch on the fdwReason etc.