Add additional windows logging for DoMonitor

This commit is contained in:
Juliusz Sosinowicz
2023-07-04 13:44:04 +02:00
parent f58539581d
commit 7af1f0cf05
3 changed files with 28 additions and 3 deletions

View File

@ -1339,7 +1339,32 @@ static int StopMonitor(wolfSSL_CRL_mfd_t mfd)
return 0; return 0;
} }
#define DM_ERROR() do { status = MONITOR_SETUP_E; goto cleanup; } while(0) #ifdef DEBUG_WOLFSSL
#define SHOW_WINDOWS_ERROR() do { \
LPVOID lpMsgBuf; \
DWORD dw = GetLastError(); \
FormatMessageA( \
FORMAT_MESSAGE_ALLOCATE_BUFFER | \
FORMAT_MESSAGE_FROM_SYSTEM | \
FORMAT_MESSAGE_IGNORE_INSERTS, \
NULL, \
dw, \
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), \
(LPSTR) &lpMsgBuf, \
0, NULL ); \
WOLFSSL_MSG_EX("DoMonitor failed with error %d: %s\n", \
dw, lpMsgBuf); \
LocalFree(lpMsgBuf); \
} while(0)
#else
#define SHOW_WINDOWS_ERROR()
#endif
#define DM_ERROR() do { \
SHOW_WINDOWS_ERROR(); \
status = MONITOR_SETUP_E; \
goto cleanup; \
} while(0)
/* windows monitoring /* windows monitoring
* Tested initially by hand by running * Tested initially by hand by running

View File

@ -323,7 +323,7 @@ static void wolfssl_log(const int logLevel, const char *const logMessage)
#ifndef WOLFSSL_DEBUG_ERRORS_ONLY #ifndef WOLFSSL_DEBUG_ERRORS_ONLY
#if !defined(_WIN32) && defined(XVSNPRINTF) && !defined(NO_WOLFSSL_MSG_EX) #if defined(XVSNPRINTF) && !defined(NO_WOLFSSL_MSG_EX)
#include <stdarg.h> /* for var args */ #include <stdarg.h> /* for var args */
#ifndef WOLFSSL_MSG_EX_BUF_SZ #ifndef WOLFSSL_MSG_EX_BUF_SZ
#define WOLFSSL_MSG_EX_BUF_SZ 100 #define WOLFSSL_MSG_EX_BUF_SZ 100

View File

@ -166,7 +166,7 @@ WOLFSSL_API void wolfSSL_Debugging_OFF(void);
#define WOLFSSL_STUB(m) \ #define WOLFSSL_STUB(m) \
WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented)) WOLFSSL_MSG(WOLFSSL_LOG_CAT(wolfSSL Stub, m, not implemented))
WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void); WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void);
#if !defined(_WIN32) && defined(XVSNPRINTF) #if defined(XVSNPRINTF)
WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...); WOLFSSL_API void WOLFSSL_MSG_EX(const char* fmt, ...);
#define HAVE_WOLFSSL_MSG_EX #define HAVE_WOLFSSL_MSG_EX
#else #else