#include "socketwrapper.h"
-typedef void (__stdcall* _SSL_load_error_strings)();
-typedef int (__stdcall* _SSL_library_init)();
-typedef SSL_METHOD* (__stdcall* _SSLv23_method)();
-typedef SSL_CTX* (__stdcall* _SSL_CTX_new)(SSL_METHOD*);
-typedef void (__stdcall* _SSL_CTX_free)(SSL_CTX*);
-typedef SSL* (__stdcall* _SSL_new)(SSL_CTX*);
-typedef void (__stdcall* _SSL_free)(SSL*);
-typedef int (__stdcall* _SSL_shutdown)(SSL*);
-typedef int (__stdcall* _SSL_get_fd)(SSL*);
-typedef int (__stdcall* _SSL_set_fd)(SSL*, int);
-typedef int (__stdcall* _SSL_accept)(SSL*);
-typedef int (__stdcall* _SSL_connect)(SSL*);
-typedef int (__stdcall* _SSL_write)(SSL*, const void*, int);
-typedef int (__stdcall* _SSL_peek)(SSL*, void*, int);
-typedef int (__stdcall* _SSL_read)(SSL*, void*, int);
-typedef int (__stdcall* _SSL_get_error)(SSL*, int);
+typedef void (__cdecl* _SSL_load_error_strings)();
+typedef int (__cdecl* _SSL_library_init)();
+typedef SSL_METHOD* (__cdecl* _SSLv23_method)();
+typedef SSL_CTX* (__cdecl* _SSL_CTX_new)(SSL_METHOD*);
+typedef void (__cdecl* _SSL_CTX_free)(SSL_CTX*);
+typedef SSL* (__cdecl* _SSL_new)(SSL_CTX*);
+typedef void (__cdecl* _SSL_free)(SSL*);
+typedef int (__cdecl* _SSL_shutdown)(SSL*);
+typedef int (__cdecl* _SSL_get_fd)(SSL*);
+typedef int (__cdecl* _SSL_set_fd)(SSL*, int);
+typedef int (__cdecl* _SSL_accept)(SSL*);
+typedef int (__cdecl* _SSL_connect)(SSL*);
+typedef int (__cdecl* _SSL_write)(SSL*, const void*, int);
+typedef int (__cdecl* _SSL_peek)(SSL*, void*, int);
+typedef int (__cdecl* _SSL_read)(SSL*, void*, int);
+typedef int (__cdecl* _SSL_get_error)(SSL*, int);
_SSL_load_error_strings pSSL_load_error_strings;
_SSL_library_init pSSL_library_init;
|| !(pSSL_read = (_SSL_read)GetProcAddress(g_hOpenSSL, "SSL_read"))
|| !(pSSL_get_error = (_SSL_get_error)GetProcAddress(g_hOpenSSL, "SSL_get_error")))
{
- FreeLibrary(g_hOpenSSL);
+ if(g_hOpenSSL)
+ FreeLibrary(g_hOpenSSL);
g_hOpenSSL = NULL;
return FALSE;
}
void SetSSLTimeoutCallback(DWORD Timeout, LPSSLTIMEOUTCALLBACK pCallback)
{
+ if(!g_bOpenSSLLoaded)
+ return;
EnterCriticalSection(&g_OpenSSLLock);
g_OpenSSLTimeout = Timeout;
g_pOpenSSLTimeoutCallback = pCallback;
BOOL r;
DWORD Time;
SSL** ppSSL;
+ if(!g_bOpenSSLLoaded)
+ return FALSE;
r = FALSE;
Time = timeGetTime();
EnterCriticalSection(&g_OpenSSLLock);
{
BOOL r;
SSL** ppSSL;
+ if(!g_bOpenSSLLoaded)
+ return FALSE;
r = FALSE;
EnterCriticalSection(&g_OpenSSLLock);
if(ppSSL = FindSSLPointerFromSocket(s))
BOOL IsSSLAttached(SOCKET s)
{
SSL** ppSSL;
+ if(!g_bOpenSSLLoaded)
+ return FALSE;
EnterCriticalSection(&g_OpenSSLLock);
ppSSL = FindSSLPointerFromSocket(s);
LeaveCriticalSection(&g_OpenSSLLock);
int sendS(SOCKET s, const char * buf, int len, int flags)
{
SSL** ppSSL;
+ if(!g_bOpenSSLLoaded)
+ return send(s, buf, len, flags);
EnterCriticalSection(&g_OpenSSLLock);
ppSSL = FindSSLPointerFromSocket(s);
LeaveCriticalSection(&g_OpenSSLLock);
int recvS(SOCKET s, char * buf, int len, int flags)
{
SSL** ppSSL;
+ if(!g_bOpenSSLLoaded)
+ return recv(s, buf, len, flags);
EnterCriticalSection(&g_OpenSSLLock);
ppSSL = FindSSLPointerFromSocket(s);
LeaveCriticalSection(&g_OpenSSLLock);