- Timestamp:
- 04/28/05 20:17:32 (8 years ago)
- Branches:
- master, 0.4.0, 0.4.1, 0.4.2, stable
- Children:
- e655f61
- Parents:
- d656933
- Location:
- modules
- Files:
-
- 5 edited
-
CheckSystem/CheckSystem.cpp (modified) (6 diffs)
-
CheckSystem/CheckSystem.h (modified) (1 diff)
-
CheckSystem/CheckSystem.vcproj (modified) (1 diff)
-
NRPEListener/NRPEListener.cpp (modified) (3 diffs)
-
NSClientListener/NSClientListener.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/CheckSystem/CheckSystem.cpp
rd656933 r945c381 7 7 #include <tlhelp32.h> 8 8 #include <EnumNtSrv.h> 9 #include <EnumProcess.h> 9 10 10 11 CheckSystem gNSClientCompat; … … 27 28 * @return 28 29 */ 29 CheckSystem::CheckSystem() {}30 CheckSystem::CheckSystem() : processMethod_(0) {} 30 31 /** 31 32 * Default d-tor … … 40 41 bool CheckSystem::loadModule() { 41 42 pdhThread.createThread(); 43 44 std::string wantedMethod = NSCModuleHelper::getSettingsString(C_SYSTEM_SECTION_TITLE, C_SYSTEM_ENUMPROC_METHOD, C_SYSTEM_ENUMPROC_METHOD_DEFAULT); 45 46 CEnumProcess tmp; 47 int method = tmp.GetAvailableMethods(); 48 49 if (wantedMethod == C_SYSTEM_ENUMPROC_METHOD_PSAPI) { 50 if (method == (method|ENUM_METHOD::PSAPI)) { 51 processMethod_ = ENUM_METHOD::PSAPI; 52 } else { 53 NSC_LOG_ERROR_STD("PSAPI method not avalible, check " C_SYSTEM_ENUMPROC_METHOD " option."); 54 } 55 } else { 56 if (method == (method|ENUM_METHOD::TOOLHELP)) { 57 processMethod_ = ENUM_METHOD::TOOLHELP; 58 } else { 59 NSC_LOG_ERROR_STD("TOOLHELP method not avalible, check " C_SYSTEM_ENUMPROC_METHOD " option."); 60 } 61 } 42 62 return true; 43 63 } … … 109 129 return checkCounter(command, argLen, char_args, msg, perf); 110 130 } 111 /*112 case REQ_PROCSTATE:113 rb = NSCommands::procState(arrayBuffer::arrayBuffer2list(argLen, char_args));114 msg = rb.msg_;115 perf = rb.perf_;116 return rb.code_;117 */118 131 return NSCAPI::returnIgnored; 119 132 } … … 390 403 * @return a hash_map with all running processes 391 404 */ 392 NSPROCLST GetProcessList(void) 393 { 394 HANDLE hProcessSnap; 395 PROCESSENTRY32 pe32; 405 NSPROCLST GetProcessList(int processMethod) 406 { 396 407 NSPROCLST ret; 397 398 // Take a snapshot of all processes in the system. 399 hProcessSnap = CreateToolhelp32Snapshot( TH32CS_SNAPPROCESS, 0 ); 400 if( hProcessSnap == INVALID_HANDLE_VALUE ) 401 throw "CreateToolhelp32Snapshot (of processes) failed"; 402 403 // Set the size of the structure before using it. 404 pe32.dwSize = sizeof( PROCESSENTRY32 ); 405 406 // Retrieve information about the first process, 407 // and exit if unsuccessful 408 if( !Process32First( hProcessSnap, &pe32 ) ) { 409 CloseHandle( hProcessSnap ); // Must clean up the snapshot object! 410 throw "Process32First failed!"; 411 } 412 413 // Now walk the snapshot of processes, and 414 // display information about each process in turn 415 do { 416 ret[pe32.szExeFile] = pe32.th32ProcessID; 417 } while( Process32Next( hProcessSnap, &pe32 ) ); 418 419 // Don't forget to clean up the snapshot object! 420 CloseHandle( hProcessSnap ); 408 if (processMethod == 0) { 409 NSC_LOG_ERROR_STD("ProcessMethod not defined or not available."); 410 return ret; 411 } 412 CEnumProcess enumeration; 413 enumeration.SetMethod(processMethod); 414 CEnumProcess::CProcessEntry entry; 415 for (BOOL OK = enumeration.GetProcessFirst(&entry); OK; OK = enumeration.GetProcessNext(&entry) ) { 416 ret[entry.lpFilename] = entry.dwPID; 417 } 421 418 return ret; 422 419 } … … 452 449 NSPROCLST runningProcs; 453 450 try { 454 runningProcs = GetProcessList( );451 runningProcs = GetProcessList(processMethod_); 455 452 } catch (char *c) { 456 453 NSC_LOG_ERROR_STD("ERROR: " + c); -
modules/CheckSystem/CheckSystem.h
rd656933 r945c381 6 6 class CheckSystem { 7 7 private: 8 int processMethod_; 8 9 PDHCollectorThread pdhThread; 9 10 -
modules/CheckSystem/CheckSystem.vcproj
rcea178b r945c381 181 181 </File> 182 182 <File 183 RelativePath="..\..\include\EnumProcess.cpp"> 184 </File> 185 <File 183 186 RelativePath="..\..\include\NSCHelper.cpp"> 184 187 </File> -
modules/NRPEListener/NRPEListener.cpp
rd656933 r945c381 223 223 void NRPEListener::onAccept(simpleSocket::Socket *client) 224 224 { 225 assert(client);226 225 if (!allowedHosts.inAllowedHosts(client->getAddrString())) { 227 226 NSC_LOG_ERROR("Unothorized access from: " + client->getAddrString()); … … 233 232 234 233 for (int i=0;i<100;i++) { 235 client->readAll(block );234 client->readAll(block, 1048); 236 235 if (block.getLength() >= NRPEPacket::getBufferLength()) 237 236 break; … … 243 242 return; 244 243 } 245 246 244 if (block.getLength() == NRPEPacket::getBufferLength()) { 247 245 try { -
modules/NSClientListener/NSClientListener.cpp
rd656933 r945c381 144 144 145 145 void NSClientListener::onAccept(simpleSocket::Socket *client) { 146 assert(client);147 146 if (!allowedHosts.inAllowedHosts(client->getAddrString())) { 148 147 NSC_LOG_ERROR("Unothorized access from: " + client->getAddrString());
Note: See TracChangeset
for help on using the changeset viewer.








