diff options
| author | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-12 14:12:39 +0000 |
|---|---|---|
| committer | osmiy <osmiy@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2006-07-12 14:12:39 +0000 |
| commit | 1ed5a442bcfd8ed5f0a89b9ae99b361f00c376a9 (patch) | |
| tree | 18066961d998bc222c16e6b5de9e879755c765f4 /src/libs/zbxlog | |
| parent | a62b9e10b87ee280ae3c72f75acbc6777dd92009 (diff) | |
| download | zabbix-1ed5a442bcfd8ed5f0a89b9ae99b361f00c376a9.tar.gz zabbix-1ed5a442bcfd8ed5f0a89b9ae99b361f00c376a9.tar.xz zabbix-1ed5a442bcfd8ed5f0a89b9ae99b361f00c376a9.zip | |
Fix Win32 agent resource messages
git-svn-id: svn://svn.zabbix.com/trunk@3040 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'src/libs/zbxlog')
| -rw-r--r-- | src/libs/zbxlog/log.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/libs/zbxlog/log.c b/src/libs/zbxlog/log.c index 7c671160..d2d2b03e 100644 --- a/src/libs/zbxlog/log.c +++ b/src/libs/zbxlog/log.c @@ -34,6 +34,7 @@ static ZBX_MUTEX log_file_access; #if defined(WIN32) #include "messages.h" + #include "service.h" static HANDLE system_log_handle = INVALID_HANDLE_VALUE; @@ -293,7 +294,7 @@ char *strerror_from_system(unsigned long error) static char buffer[ZBX_MESSAGE_BUF_SIZE]; /* !!! Attention static !!! not thread safely - Win32*/ - memset(buffer, 0, ZBX_MESSAGE_BUF_SIZE); + memset(buffer, 0, sizeof(buffer)); if(FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, @@ -301,7 +302,7 @@ char *strerror_from_system(unsigned long error) error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, - 1023, + sizeof(buffer), NULL) == 0) { zbx_snprintf(buffer, sizeof(buffer), "3. MSG 0x%08X - Unable to find message text [0x%X]", error , GetLastError()); @@ -325,24 +326,24 @@ char *strerror_from_module(unsigned long error, const char *module) #if defined(WIN32) static char buffer[ZBX_MESSAGE_BUF_SIZE]; /* !!! Attention static !!! not thread safely - Win32*/ + char *strings[2]; - assert(module); - - memset(buffer, 0, ZBX_MESSAGE_BUF_SIZE); + memset(strings,0,sizeof(char *)*2); + memset(buffer, 0, sizeof(buffer)); if (FormatMessage( - FORMAT_MESSAGE_FROM_HMODULE, - GetModuleHandle(module), + FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_ARGUMENT_ARRAY, + module ? GetModuleHandle(module) : NULL, error, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), /* Default language */ - buffer, - 1024, - NULL) == 0) + (LPTSTR)buffer, + sizeof(buffer), + strings) == 0) { - zbx_snprintf(buffer, sizeof(buffer), "3. MSG 0x%08X - Unable to find message text [0x%X]", error , GetLastError()); + zbx_snprintf(buffer, sizeof(buffer), "3. MSG 0x%08X - Unable to find message text [%s]", error , strerror_from_system(GetLastError())); } - return buffer; + return (char *)buffer; #else /* not WIN32 */ |
