diff options
Diffstat (limited to 'src/libs/zbxsys')
-rwxr-xr-x | src/libs/zbxsys/mutexs.c | 2 | ||||
-rwxr-xr-x | src/libs/zbxsys/symbols.c | 73 |
2 files changed, 75 insertions, 0 deletions
diff --git a/src/libs/zbxsys/mutexs.c b/src/libs/zbxsys/mutexs.c index 56a3e676..67d37db6 100755 --- a/src/libs/zbxsys/mutexs.c +++ b/src/libs/zbxsys/mutexs.c @@ -59,6 +59,7 @@ int zbx_mutex_create(ZBX_MUTEX *mutex, char *name) { #if defined(WIN32) + /* ignore "name" */ if(NULL == ((*mutex) = CreateMutex(NULL, FALSE, NULL))) { zbx_error("Error on mutex creating. [%s]", strerror_from_system(GetLastError())); @@ -71,6 +72,7 @@ int zbx_mutex_create(ZBX_MUTEX *mutex, char *name) int sem_id; union semun semopts; + /* !!! ignore "name" !!! */ if( -1 == (sem_key = ftok(CONFIG_FILE, (int)'z') )) { zbx_error("Can not create IPC key for path '%s', try to create for path '.' [%s]", CONFIG_FILE, strerror(errno)); diff --git a/src/libs/zbxsys/symbols.c b/src/libs/zbxsys/symbols.c new file mode 100755 index 00000000..f6b2c204 --- /dev/null +++ b/src/libs/zbxsys/symbols.c @@ -0,0 +1,73 @@ +/* +** ZABBIX +** Copyright (C) 2000-2005 SIA Zabbix +** +** This program is free software; you can redistribute it and/or modify +** it under the terms of the GNU General Public License as published by +** the Free Software Foundation; either version 2 of the License, or +** (at your option) any later version. +** +** This program is distributed in the hope that it will be useful, +** but WITHOUT ANY WARRANTY; without even the implied warranty of +** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +** GNU General Public License for more details. +** +** You should have received a copy of the GNU General Public License +** along with this program; if not, write to the Free Software +** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +**/ + +#include "common.h" +#include "symbols.h" + +#include "log.h" + +DWORD (__stdcall *zbx_GetGuiResources)(HANDLE,DWORD) = NULL; +BOOL (__stdcall *zbx_GetProcessIoCounters)(HANDLE,PIO_COUNTERS) = NULL; +BOOL (__stdcall *zbx_GetPerformanceInfo)(PPERFORMANCE_INFORMATION,DWORD) = NULL; +BOOL (__stdcall *zbx_GlobalMemoryStatusEx)(LPMEMORYSTATUSEX) = NULL; + + +static FARPROC GetProcAddressAndLog(HMODULE hModule,LPCSTR procName) +{ + FARPROC ptr; + + ptr=GetProcAddress(hModule,procName); + if ( NULL == ptr ) + zbx_error("Unable to resolve symbol '%s'", procName); + + return ptr; +} + +void import_symbols(void) +{ + HMODULE hModule; + + if(NULL != (hModule = GetModuleHandle("USER32.DLL")) ) + { + zbx_GetGuiResources = (DWORD (__stdcall *)(HANDLE,DWORD))GetProcAddressAndLog(hModule,"GetGuiResources"); + } + else + { + zbx_error("Unable to get handle to USER32.DLL"); + } + + if(NULL != (hModule=GetModuleHandle("KERNEL32.DLL")) ) + { + zbx_GetProcessIoCounters = (BOOL (__stdcall *)(HANDLE,PIO_COUNTERS))GetProcAddressAndLog(hModule,"GetProcessIoCounters"); + zbx_GlobalMemoryStatusEx = (BOOL (__stdcall *)(LPMEMORYSTATUSEX))GetProcAddressAndLog(hModule,"GlobalMemoryStatusEx"); + } + else + { + zbx_error("Unable to get handle to KERNEL32.DLL"); + } + + if(NULL != (hModule=GetModuleHandle("PSAPI.DLL")) ) + { + zbx_GetPerformanceInfo = (BOOL (__stdcall *)(PPERFORMANCE_INFORMATION,DWORD))GetProcAddressAndLog(hModule,"GetPerformanceInfo"); + } + else + { + zbx_error("Unable to get handle to PSAPI.DLL"); + } +} |