00001 #ifndef PROCESS_CONTROL_CLASS 00002 #define PROCESS_CONTROL_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : process_control * 00007 * Author : Chris Koeritz * 00008 * * 00009 ******************************************************************************* 00010 * Copyright (c) 2000-$now By Author. This program is free software; you can * 00011 * redistribute it and/or modify it under the terms of the GNU General Public * 00012 * License as published by the Free Software Foundation; either version 2 of * 00013 * the License or (at your option) any later version. This is online at: * 00014 * http://www.fsf.org/copyleft/gpl.html * 00015 * Please send any updates to: fred@gruntose.com * 00016 \*****************************************************************************/ 00017 00018 #include "dll_processes.h" 00019 00020 #include <basis/object_base.h> 00021 00022 // forward. 00023 class process_entry; 00024 class process_entry_array; 00025 class process_implementation_hider; 00026 00028 00033 class PROCESSES_CLASS_STYLE process_control : public virtual object_base 00034 { 00035 public: 00036 process_control(); 00037 ~process_control(); 00038 00039 IMPLEMENT_CLASS_NAME("process_control"); 00040 00041 bool healthy() const { return _healthy; } 00043 00047 process_entry query_process(u_int to_query); 00049 00050 bool query_processes(process_entry_array &to_fill); 00052 00053 bool zap_process(u_int to_zap); 00055 00058 static bool find_process_in_list(const process_entry_array &processes, 00059 const istring &app_name, int_set &pids); 00061 00067 void sort_by_name(process_entry_array &to_sort); 00068 // sorts the list by process name. 00069 void sort_by_pid(process_entry_array &to_sort); 00070 // sorts the list by process id. 00071 00072 private: 00073 process_implementation_hider *_ptrs; 00074 #ifdef __UNIX__ 00075 chaos *_rando; 00076 #endif 00077 #ifdef __WIN32__ 00078 bool _use_psapi; 00079 #endif 00080 bool _healthy; 00081 00082 #ifdef __UNIX__ 00083 bool get_processes_with_ps(process_entry_array &to_fill); 00085 #endif 00086 #ifdef __WIN32__ 00087 // fill in our function pointers to access the kernel functions appropriate 00088 // for either NT (psapi) or 9x (toolhelp). 00089 bool initialize_psapi_support(); 00090 bool initialize_toolhelp_support(); 00091 00092 bool get_processes_with_psapi(process_entry_array &to_fill); 00094 bool get_processes_with_toolhelp(process_entry_array &to_fill); 00096 #endif 00097 }; 00098 00099 #endif // outer guard. 00100
1.5.1