GetGlobalInfoW calls CreatePlugin:
CreatePlugin calls CreateFarPlugin:
|
FarPlugin = CreateFarPlugin(HInstanceDLL); |
CreateFarPlugin calls Initialize:
Initialize starts a background thread:
|
FTIdleThread->InitIdleThread("NetBox IdleThread"); |
Unfortunately, Far can still unload the plugin after calling GetGlobalInfoW under certain circumstances.
E.g. if it requires a newer Far version or if a plugin with the same GUID is already loaded.
If it happens and the thread managed to start already, it will get its code yanked off suddenly, execute rubbish and cause EXCEPTION_ACCESS_VIOLATION + EXCEPTION_EXECUTE_FAULT.
Example: https://bugs.farmanager.com/view.php?id=4097
It's better to start it later, when the plugin is truly loaded, e.g. in SetStartupInfoW.
GetGlobalInfoW calls CreatePlugin:
Far-NetBox/src/NetBox/NetBox.cpp
Line 60 in 7dd57b5
CreatePlugin calls CreateFarPlugin:
Far-NetBox/src/NetBox/NetBox.cpp
Line 30 in 7dd57b5
CreateFarPlugin calls Initialize:
Far-NetBox/src/NetBox/WinSCPPlugin.cpp
Line 19 in 7dd57b5
Initialize starts a background thread:
Far-NetBox/src/NetBox/FarPlugin.cpp
Line 1924 in 7dd57b5
Unfortunately, Far can still unload the plugin after calling GetGlobalInfoW under certain circumstances.
E.g. if it requires a newer Far version or if a plugin with the same GUID is already loaded.
If it happens and the thread managed to start already, it will get its code yanked off suddenly, execute rubbish and cause EXCEPTION_ACCESS_VIOLATION + EXCEPTION_EXECUTE_FAULT.
Example: https://bugs.farmanager.com/view.php?id=4097
It's better to start it later, when the plugin is truly loaded, e.g. in SetStartupInfoW.