1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

init: Fix DllMain

Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Andreas Schneider
2018-08-14 08:13:37 +02:00
parent f65882cca6
commit 86d00f438c

View File

@@ -226,19 +226,27 @@ int ssh_finalize(void) {
#ifdef _MSC_VER #ifdef _MSC_VER
/* Library constructor and destructor */ /* Library constructor and destructor */
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) BOOL WINAPI DllMain(HINSTANCE hinstDLL,
DWORD fdwReason,
LPVOID lpvReserved)
{ {
int rc; int rc = 0;
if (fdwReason == DLL_PROCESS_ATTACH) {
rc = ssh_init();
} else if (fdwReason == DLL_PROCESS_DETACH) {
rc = ssh_finalize();
}
switch(fdwReason) {
case DLL_PROCESS_ATTACH:
rc = _ssh_init(1);
if (rc != 0) { if (rc != 0) {
fprintf(stderr, "DllMain: ssh_init failed!");
return FALSE; return FALSE;
} }
break;
case DLL_PROCESS_DETACH:
_ssh_finalize(1);
break;
default:
break;
}
return TRUE; return TRUE;
} }
#endif /* _MSC_VER */ #endif /* _MSC_VER */