Ability to write a custom DllMain routine

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
mango
New User
New User
Posts: 3
Joined: Fri May 23, 2008 4:45 pm

Ability to write a custom DllMain routine

Post by mango »

Hi all!

PB has support for all dll attach/detach etc. events, but returning zero from AttachProcess does not work. (According to MSDN, returning 0 from a dllmain procedure when attaching to a process makes the system unload the dll immediately and return an error for the caller, or if it's called at process creation, the creation itself fails)

A nice feature would be to allow users to create their own dllmain procedure (if they want to, or just stick with PB's handler which calls AttachProcess() AttachThread(), etc.)
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, allowing a return value from AttachProcess() would be nice; although you can use ExitProcess_() in the AttachProcess() function. I'm not sure if this is sensible, but that hasn't stopped me doing it in the past! :)
I may look like a mule, but I'm not a complete ass.
mango
New User
New User
Posts: 3
Joined: Fri May 23, 2008 4:45 pm

Post by mango »

srod wrote:Yes, allowing a return value from AttachProcess() would be nice; although you can use ExitProcess_() in the AttachProcess() function. I'm not sure if this is sensible, but that hasn't stopped me doing it in the past! :)
Well honestly if you are writing a plugin for an application, its not sensible. Imagine the main app calls loadlibrary (or openlibrary()) for your dll, which then finds out that it cannot find it's configuration file, (or anything else) so it cannot function. Calling ExitProcess() here kills the whole process which is certainly worse than having the caller process get a simple failure for it's LoadLibrary() call. The latter event is mostly handled by all programs that implement plugins.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Yes, I completely agree! :) Having the value returned from the dllmain function is a good request indeed.
I may look like a mule, but I'm not a complete ass.
Post Reply