BgImage::SetBg() is getting called *before* _DllMainCRTStartup ever gets called, and therefore is using a CriticalSection that was never initialized (using the debug build it simply crashes outright, the release one just sometimes crashes). Setting up a lazy init in ECS seems to have fixed the problem:
I admit I know *nothing* about DLLs, so there might be something else going wrong here, it seems odd to me that you'd get a function called before getting an ATTACH message, but this seems to have fixed my problem. Thanks for the great plugin!
bool CriticalSectionInited=false;
CRITICAL_SECTION CriticalSection;
void ECS() {
if (!CriticalSectionInited) {
InitializeCriticalSection(&CriticalSection);
CriticalSectionInited = true;
}
EnterCriticalSection(&CriticalSection);
}
.
.
.
BOOL WINAPI _DllMainCRTStartup(HINSTANCE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) {
g_hInstance=hInst;
switch (ul_reason_for_call) {
case DLL_PROCESS_ATTACH:
if (!CriticalSectionInited) {
InitializeCriticalSection(&CriticalSection);
CriticalSectionInited = true;
}
break;