#include <stdio.h>
#include <stdlib.h>
-#ifdef __UNIX__
+#ifndef _MSC_VER
#include <unistd.h>
#endif
namespace processes {
-#ifdef __WIN32__
+#ifdef _MSC_VER
#include <tlhelp32.h>
const astring NTVDM_NAME = "ntvdm.exe";
// the umbrella process that hangs onto 16 bit tasks for NT.
- #ifdef _MSCVER
- #include <vdmdbg.h>
- #endif
-#endif
-#ifdef __UNIX__
+// #ifdef _MSCVER
+// #include <vdmdbg.h>
+// #endif
+#else
#include <signal.h>
#include <stdio.h>
#endif
class process_implementation_hider
{
public:
-#ifdef __WIN32__
+#ifdef _MSC_VER
// psapi members:
application_instance psapi_dll;
application_instance vdm_dll;
BOOL (WINAPI *enumerate_processes)(basis::un_int *, basis::un_int cb, basis::un_int *);
BOOL (WINAPI *enumerate_modules)(HANDLE, HMODULE *, basis::un_int, basis::un_int *);
basis::un_int (WINAPI *get_module_name)(HANDLE, HMODULE, LPTSTR, basis::un_int);
-#ifdef _MSCVER
- INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM);
-#endif
+//#ifdef _MSCVER
+// INT (WINAPI *tasker_16bit)(basis::un_int, TASKENUMPROCEX fp, LPARAM);
+//#endif
// toolhelp members:
application_instance kernel32_dll;
process_implementation_hider()
: psapi_dll(NIL), vdm_dll(NIL), enumerate_processes(NIL),
enumerate_modules(NIL), get_module_name(NIL),
-#ifdef _MSCVER
- tasker_16bit(NIL),
-#endif
+//#ifdef _MSCVER
+// tasker_16bit(NIL),
+//#endif
kernel32_dll(NIL), create_snapshot(NIL), first_process(NIL),
next_process(NIL) {}
process_control::process_control()
: _ptrs(new process_implementation_hider),
-#ifdef __WIN32__
+#ifdef _MSC_VER
_use_psapi(true),
-#endif
-#ifdef __UNIX__
+#else
_rando(new chaos),
#endif
_healthy(false)
// Check to see if were running under Windows95 or Windows NT.
version osver = application_configuration::get_OS_version();
-#ifdef __WIN32__
+#ifdef _MSC_VER
if (osver.v_revision() == VER_PLATFORM_WIN32_WINDOWS) {
// we're on Windows 95, so use the toolhelp API for the processes.
_use_psapi = false;
_healthy = initialize_psapi_support();
else
_healthy = initialize_toolhelp_support();
-#endif
-#ifdef __UNIX__
+#else
_healthy = true;
#endif
}
process_control::~process_control()
{
WHACK(_ptrs);
-#ifdef __UNIX__
+#ifndef _MSC_VER
WHACK(_rando);
#endif
}
bool process_control::query_processes(process_entry_array &to_fill)
{
if (!_healthy) return false;
-#ifdef __WIN32__
+#ifdef _MSC_VER
if (!_use_psapi) {
// we're on Windows 95 or something, so use the toolhelp API for the
// processes.
// we're on Windows NT and so on; use the process API (PSAPI) to get info.
return get_processes_with_psapi(to_fill);
}
-#endif
-#ifdef __UNIX__
+#else
return get_processes_with_ps(to_fill);
#endif
}
-#ifdef __WIN32__
+#ifdef _MSC_VER
bool process_control::initialize_psapi_support()
{
// create an instance of the PSAPI dll for querying 32-bit processes and
_ptrs->get_module_name
= (basis::un_int (WINAPI *)(HANDLE, HMODULE, LPTSTR, basis::un_int))
GetProcAddress(_ptrs->psapi_dll, "GetModuleFileNameExA");
-#ifdef _MSCVER
- _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM))
- GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx");
-#endif
+//#ifdef _MSCVER
+// _ptrs->tasker_16bit = (INT(WINAPI *)(basis::un_int, TASKENUMPROCEX, LPARAM))
+// GetProcAddress(_ptrs->vdm_dll, "VDMEnumTaskWOWEx");
+//#endif
if (!_ptrs->enumerate_processes || !_ptrs->enumerate_modules
|| !_ptrs->get_module_name
-#ifdef _MSCVER
- || !_ptrs->tasker_16bit
-#endif
+//#ifdef _MSCVER
+// || !_ptrs->tasker_16bit
+//#endif
) return false;
return true;
FUNCDEF("zap_process");
#endif
if (!_healthy) return false;
-#ifdef __UNIX__
+#ifndef _MSC_VER
int ret = kill(to_zap, 9);
// send the serious take-down signal to the process.
return !ret;
-#endif
-#ifdef __WIN32__
+#else
HANDLE h = OpenProcess(PROCESS_TERMINATE, false, to_zap);
if (!h) {
#ifdef DEBUG_PROCESS_CONTROL
}
//hmmm: implement more specifically.
-#ifdef __UNIX__
+#ifndef _MSC_VER
//put in the single process grabber deal.
-#endif
-#ifdef __WIN32__
+#else
//grab the entry from the list.
#endif
//////////////
-#ifdef __WIN32__
+#ifdef _MSC_VER
// this section is the PSAPI version of the query.
// called back on each 16 bit task.
(new_entry.path().end() - NTVDM_NAME.length() + 1,
new_entry.path().end());
temp.to_lower();
-#ifdef _MSCVER
-//hmmm: pull this back in for mingw when it seems to be supported, if ever.
- if (temp == NTVDM_NAME) {
- // set up a callback stampede on the 16 bit processes.
- process_info_clump info(pid_list[i], to_fill);
- _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit,
- (LPARAM)&info);
- }
-#endif
+//#ifdef _MSCVER
+////hmmm: pull this back in for mingw when it seems to be supported, if ever.
+// if (temp == NTVDM_NAME) {
+// // set up a callback stampede on the 16 bit processes.
+// process_info_clump info(pid_list[i], to_fill);
+// _ptrs->tasker_16bit(pid_list[i], (TASKENUMPROCEX)process_16bit,
+// (LPARAM)&info);
+// }
+//#endif
}
}
}
#endif // __WIN32__
-#ifdef __UNIX__
+#ifndef _MSC_VER
#define CLOSE_TEMPORARY_FILE { \
/* continuable_error("process_control", "get_processes_with_ps", error); */ \