1 /*****************************************************************************\
3 * Name : windoze_helper *
4 * Author : Chris Koeritz *
6 *******************************************************************************
7 * Copyright (c) 1994-$now By Author. This program is free software; you can *
8 * redistribute it and/or modify it under the terms of the GNU General Public *
9 * License as published by the Free Software Foundation; either version 2 of *
10 * the License or (at your option) any later version. This is online at: *
11 * http://www.fsf.org/copyleft/gpl.html *
12 * Please send any updates to: fred@gruntose.com *
13 \*****************************************************************************/
15 #include "windoze_helper.h"
17 ///#include "build_configuration.h"
18 ///#include "convert_utf.h"
19 ///#include "function.h"
21 ///#include "portable.h"
23 ///#include "version_record.h"
24 #include <configuration/application_configuration.h>
27 ///#include <stdlib.h>
35 #include <sys/times.h>
36 #include <sys/utsname.h>
42 //hmmm: need code for the wait cursor stuff.
52 using namespace basis;
53 using namespace structures;
54 using namespace configuration;
56 #undef static_class_name
57 #define static_class_name() "windoze_helper"
60 //#define DEBUG_PORTABLE
61 // uncomment for noisy debugging.
63 //#define DEBUG_UPTIME
64 // uncomment to get noisier reporting about system and rolling uptime.
66 //#define JUMP_TIME_49_DAYS
67 // uncomment to make our uptimes start just before the 32 bit uptime rollover.
68 //#define JUMP_TIME_497_DAYS
69 // uncomment to make our uptimes start just before the jiffies rollover.
71 //#define ENABLE_ROLLOVER_BUG
72 // uncomment to get old behavior back where the uptime was not rolling
73 // over properly. this turns off our remainder calculation and leaves the
74 // conversion as a simple cast, which will fail and get stuck at 2^32-1.
76 #define SUPPORT_SHELL_EXECUTE
77 // if this is not commented out, then the ShellExecute version of launch_
78 // -process() is available. when commented out, ShellExecute is turned off.
79 // disabling this support is the most common because the ShellExecute method
80 // in win32 was only supported for wk203 and wxp, that is only after
81 // windows2000 was already available. since nt and w2k don't support this,
82 // we just usually don't mess with it. it didn't answer a single one of our
83 // issues on windows vista (wfista) anyway, so it's not helping.
85 // ensure we always have debugging turned on if the jump is enabled.
86 #ifdef JUMP_TIME_49_DAYS
90 #ifdef JUMP_TIME_497_DAYS
94 // the JUMP..DAYS macros are mutually exclusive. use none or one, not both.
95 #ifdef JUMP_TIME_497_DAYS
96 #ifdef JUMP_TIME_49_DAYS
97 #error One cannot use both 497 day and 49 day bug inducers
100 #ifdef JUMP_TIME_49_DAYS
101 #ifdef JUMP_TIME_497_DAYS
102 #error One cannot use both 49 day and 497 day bug inducers
108 namespace application {
111 mutex BASIS_EXTERN &__uptime_synchronizer();
112 // used by our low-level uptime methods to protect singleton variables.
113 mutex BASIS_EXTERN &__process_synchronizer();
114 // used for synchronizing our records of child processes.
116 int_set BASIS_EXTERN &__our_kids();
117 // the static list of processes we've started.
120 const int MAXIMUM_COMMAND_LINE = 32 * KILOBYTE;
121 // maximum command line that we'll deal with here.
124 const char *UPTIME_REPORT_FILE = "/tmp/uptime_report.log";
127 const char *UPTIME_REPORT_FILE = "c:/uptime_report.log";
131 #define LOG(s) STAMPED_EMERGENCY_LOG(program_wide_logger(), s);
133 #define COMPLAIN(to_print) { \
134 guards::write_to_console((isprintf("basis/portable::%s: ", func) + to_print).s()); \
137 static const double __rollover_point = 2.0 * double(MAXINT);
138 // this number is our rollover point for 32 bit integers.
140 double rolling_uptime()
142 auto_synchronizer l(__uptime_synchronizer());
143 // protect our rollover records.
145 static u_int __last_ticks = 0;
146 static int __rollovers = 0;
148 u_int ticks_up = system_uptime();
149 // acquire the current uptime as a 32 bit unsigned int.
151 if (ticks_up < __last_ticks) {
152 // rollover happened. increment our tracker.
155 __last_ticks = ticks_up;
157 double to_return = double(__rollovers) * __rollover_point + double(ticks_up);
161 static FILE *__outfile = fopen(UPTIME_REPORT_FILE, "a+b");
162 static double old_value = 0;
163 if (absolute_value(old_value - to_return) > 9.9999) {
164 // only report when the time changes by more than 10 ms.
165 fprintf(__outfile, "-> uptime=%.0f\n", to_return);
167 old_value = to_return;
168 if (__rollover_point - to_return <= 40.00001) {
169 fprintf(__outfile, "---> MAXIMUM UPTIME SOON!\n");
179 u_int system_uptime()
182 return timeGetTime();
184 auto_synchronizer l(__uptime_synchronizer());
186 static clock_t __ctps = sysconf(_SC_CLK_TCK); // clock ticks per second.
187 static const double __multiplier = 1000.0 / double(__ctps);
188 // the multiplier gives us our full range for the tick counter.
191 static FILE *__outfile = fopen(UPTIME_REPORT_FILE, "wb");
192 if (__multiplier - u_int(__multiplier) > 0.000001) {
193 fprintf(__outfile, "uptime multiplier is "
194 "non-integral (%f)!\n", __multiplier);
199 // read uptime info from the OS.
201 u_int real_ticks = times(&uptime);
203 #ifdef JUMP_TIME_497_DAYS
204 static u_int old_value_497 = 0;
205 bool report_497 = (absolute_value(real_ticks - old_value_497) > 99);
207 old_value_497 = real_ticks; // update before changing it.
208 fprintf(__outfile, "pre kludge497 tix=%u\n", real_ticks);
211 real_ticks += u_int(49.0 * double(DAY_ms) + 17.0 * double(HOUR_ms));
213 fprintf(__outfile, "post kludge497 tix=%u\n", real_ticks);
218 // now turn this into the number of milliseconds.
219 double ticks_up = (double)real_ticks;
220 ticks_up = ticks_up * __multiplier; // convert to time here.
222 #ifdef JUMP_TIME_497_DAYS
223 #ifndef ENABLE_ROLLOVER_BUG
224 // add in additional time so we don't have to wait forever. we make the
225 // big number above rollover, but that's still got 27.5 or so minutes before
226 // we really rollover. so we add that part of the fraction (lost in the
227 // haze of the multiplier) in here. we don't add this in unless they are
228 // not exercising the rollover bug, because we already know that the 497
229 // day bug will show without the addition. but when we're already fixing
230 // the uptime, we jump time a bit forward so we only have to wait a couple
231 // minutes instead of 27.
232 ticks_up += 25.0 * MINUTE_ms;
236 #ifdef JUMP_TIME_49_DAYS
237 static u_int old_value_49 = 0;
238 bool report_49 = (absolute_value(u_int(ticks_up) - old_value_49) > 999);
240 old_value_49 = u_int(ticks_up); // update before changing it.
241 fprintf(__outfile, "pre kludge49 up=%f\n", ticks_up);
244 ticks_up += 49.0 * double(DAY_ms) + 17.0 * double(HOUR_ms);
246 fprintf(__outfile, "post kludge49 up=%f\n", ticks_up);
251 #ifndef ENABLE_ROLLOVER_BUG
252 // fix the return value if is has actually gone over the 2^32 limit for uint.
253 // casting a double larger than 2*MAXINT to a u_int on some platforms does
254 // not calculate a rolled-over value, but instead leaves the int at 2*MAXINT.
255 // thus we make sure it will be correct, as long as there are no more than
256 // 2^32-1 rollovers, which would be about 584,542 millenia. it's unlikely
257 // earth will last that long, so this calculation seems safe.
258 u_int divided = u_int(ticks_up / __rollover_point);
259 double to_return = ticks_up - (double(divided) * __rollover_point);
261 // we use the previous version of this calculation, which expected a u_int
262 // to double conversion to provide a modulo operation rather than just leaving
263 // the u_int at its maximum value (2^32-1). however, that expectation is not
264 // guaranteed on some platforms (e.g., ARM processor with floating point
265 // emulation) and thus it becomes a bug around 49 days and 17 hours into
266 // OS uptime because the value gets stuck at 2^32-1 and never rolls over.
267 double to_return = ticks_up;
271 static u_int old_value = 0;
272 int to_print = int(u_int(to_return));
273 if (absolute_value(int(old_value) - to_print) > 9) {
274 // only report when the time changes by more than 10 ms.
275 fprintf(__outfile, "-> uptime=%u\n", to_print);
277 old_value = u_int(to_print);
278 if (__rollover_point - to_return <= 40.00001) {
279 fprintf(__outfile, "---> MAXIMUM UPTIME SOON!\n");
285 return u_int(to_return);
289 void sleep_ms(u_int msec)
299 istring null_device()
309 bool event_poll(MSG &message)
315 if (!PeekMessage(&message, NIL, 0, 0, PM_REMOVE))
317 TranslateMessage(&message);
318 DispatchMessage(&message);
323 // makes a complaint about a failure.
324 #ifndef EMBEDDED_BUILD
325 #define COMPLAIN_QUERY(to_print) { \
326 unlink(tmpfile.s()); \
327 COMPLAIN(to_print); \
330 #define COMPLAIN_QUERY(to_print) { \
331 COMPLAIN(to_print); \
336 istring get_cmdline_from_proc()
338 FUNCDEF("get_cmdline_from_proc");
339 isprintf cmds_filename("/proc/%d/cmdline", portable::process_id());
340 FILE *cmds_file = fopen(cmds_filename.s(), "r");
342 COMPLAIN("failed to open our process's command line file.\n");
346 char *buff = new char[size + 1];
347 ssize_t chars_read = getline(&buff, &size, cmds_file);
348 // read the first line, giving ample space for how long it might be.
349 fclose(cmds_file); // drop the file again.
350 if (!chars_read || negative(chars_read)) {
351 COMPLAIN("failed to get any characters from our process's cmdline file.\n");
354 istring buffer = buff;
356 // clean out quote characters from the name.
357 for (int i = buffer.length() - 1; i >= 0; i--) {
358 if (buffer[i] == '"') buffer.zap(i, i);
363 // deprecated; better to use the /proc/pid/cmdline file.
364 istring query_for_process_info()
366 FUNCDEF("query_for_process_info");
367 istring to_return = "unknown";
368 // we ask the operating system about our process identifier and store
369 // the results in a temporary file.
371 isprintf tmpfile("/tmp/proc_name_check_%d_%d.txt", portable::process_id(),
372 rando.inclusive(0, 128000));
373 isprintf cmd("ps h --format \"%%a\" %d >%s", portable::process_id(),
375 // run the command to locate our process info.
376 int sysret = system(cmd.s());
377 if (negative(sysret)) {
378 COMPLAIN_QUERY("failed to run ps command to get process info");
381 // open the output file for reading.
382 FILE *output = fopen(tmpfile.s(), "r");
384 COMPLAIN_QUERY("failed to open the ps output file");
387 // read the file's contents into a string buffer.
388 char buff[MAXIMUM_COMMAND_LINE];
389 size_t size_read = fread(buff, 1, MAXIMUM_COMMAND_LINE, output);
391 // success at finding some text in the file at least.
392 while (size_read > 0) {
393 const char to_check = buff[size_read - 1];
394 if ( !to_check || (to_check == '\r') || (to_check == '\n')
395 || (to_check == '\t') )
399 to_return.reset(istring::UNTERMINATED, buff, size_read);
401 // couldn't read anything.
402 COMPLAIN_QUERY("could not read output of process list");
409 istring module_name(const void *module_handle)
412 //hmmm: implement module name for linux if that makes sense.
413 if (module_handle) {}
414 return application_name();
415 #elif defined(__WIN32__)
416 flexichar low_buff[MAX_ABS_PATH + 1];
417 GetModuleFileName((HMODULE)module_handle, low_buff, MAX_ABS_PATH - 1);
418 istring buff = from_unicode_temp(low_buff);
422 #pragma message("module_name unknown for this operating system.")
423 return application_name();
429 #if defined(__UNIX__)
431 #elif defined(__WIN32__)
432 return GetLastError();
434 #pragma error("hmmm: no code for error number for this operating system")
439 istring system_error_text(u_int to_name)
441 #if defined(__UNIX__)
442 return strerror(to_name);
443 #elif defined(__WIN32__)
444 char error_text[1000];
445 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NIL, to_name,
446 MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)error_text,
447 sizeof(error_text) - 1, NIL);
448 istring to_return = error_text;
449 // trim off the ridiculous carriage return they add.
450 while ( (to_return[to_return.end()] == '\r')
451 || (to_return[to_return.end()] == '\n') )
452 to_return.zap(to_return.end(), to_return.end());
455 #pragma error("hmmm: no code for error text for this operating system")
462 bool is_address_valid(const void *address, int size_expected, bool writable)
464 return address && !IsBadReadPtr(address, size_expected)
465 && !(writable && IsBadWritePtr((void *)address, size_expected));
470 version get_OS_version()
474 utsname kernel_parms;
475 uname(&kernel_parms);
476 to_return = version(kernel_parms.release);
477 #elif defined(__WIN32__)
479 info.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
480 ::GetVersionEx(&info);
481 to_return = version(isprintf("%u.%u.%u.%u", u_short(info.dwMajorVersion),
482 u_short(info.dwMinorVersion), u_short(info.dwPlatformId),
483 u_short(info.dwBuildNumber)));
484 #elif defined(EMBEDDED_BUILD)
485 // no version support.
487 #pragma error("hmmm: need version info for this OS!")
492 // for non-win32 and non-unix OSes, this might not work.
493 #if defined(__UNIX__) || defined(__WIN32__)
494 u_int process_id() { return getpid(); }
496 #pragma error("hmmm: need process id implementation for this OS!")
497 u_int process_id() { return 0; }
500 istring current_directory()
504 char buff[MAX_ABS_PATH];
505 getcwd(buff, MAX_ABS_PATH - 1);
507 #elif defined(__WIN32__)
508 flexichar low_buff[MAX_ABS_PATH + 1];
509 GetCurrentDirectory(MAX_ABS_PATH, low_buff);
510 to_return = from_unicode_temp(low_buff);
512 #pragma error("hmmm: need support for current directory on this OS.")
518 timeval fill_timeval_ms(int duration)
520 timeval time_out; // timeval has tv_sec=seconds, tv_usec=microseconds.
522 // duration is immediate for the check; just a quick poll.
524 time_out.tv_usec = 0;
525 #ifdef DEBUG_PORTABLE
526 // LOG("no duration specified");
529 // a non-zero duration means we need to compute secs and usecs.
530 time_out.tv_sec = duration / 1000;
531 // set the number of seconds from the input in milliseconds.
532 duration -= time_out.tv_sec * 1000;
533 // now take out the chunk we've already recorded as seconds.
534 time_out.tv_usec = duration * 1000;
535 // set the number of microseconds from the remaining milliseconds.
536 #ifdef DEBUG_PORTABLE
537 // LOG(isprintf("duration of %d ms went to %d sec and %d usec.", duration,
538 // time_out.tv_sec, time_out.tv_usec));
544 //hmmm: this doesn't seem to account for quoting properly at all?
545 basis::char_star_array break_line(istring &app, const istring ¶meters)
547 basis::char_star_array to_return;
550 // find the positions of the spaces and count them.
551 for (int j = 0; j < parameters.length(); j++) {
552 if (parameters[j] == ' ') {
557 // first, add the app name to the list of parms.
558 to_return += new char[app.length() + 1];
559 app.stuff(to_return[0], app.length());
561 // now add each space-separated parameter to the list.
562 for (int i = 0; i < num; i++) {
563 int len = posns[i] - last_posn;
564 to_return += new char[len + 1];
565 parameters.substring(last_posn, posns[i] - 1).stuff(to_return[i + 1], len);
566 last_posn = posns[i] + 1;
568 // catch anything left after last separator.
569 if (last_posn < parameters.length() - 1) {
570 int len = parameters.length() - last_posn;
571 to_return += new char[len + 1];
572 parameters.substring(last_posn, parameters.length() - 1)
573 .stuff(to_return[to_return.last()], len);
575 // add the sentinel to the list of strings.
577 #ifdef DEBUG_PORTABLE
578 for (int q = 0; to_return[q]; q++) {
579 printf("%d: %s\n", q, to_return[q]);
582 // now a special detour; fix the app name to remove quotes, which are
583 // not friendly to pass to exec.
584 if (app[0] == '"') app.zap(0, 0);
585 if (app[app.end()] == '"') app.zap(app.end(), app.end());
591 void exiting_child_signal_handler(int sig_num)
593 FUNCDEF("exiting_child_signal_handler");
594 if (sig_num != SIGCHLD) {
595 // uhhh, this seems wrong.
597 auto_synchronizer l(__process_synchronizer());
598 for (int i = 0; i < __our_kids().length(); i++) {
600 pid_t exited = waitpid(__our_kids()[i], &status, WNOHANG);
601 if ( (exited == -1) || (exited == __our_kids()[i]) ) {
602 // negative one denotes an error, which we are going to assume means the
603 // process has exited via some other method than our wait. if the value
604 // is the same as the process we waited for, that means it exited.
605 __our_kids().zap(i, i);
607 } else if (exited != 0) {
608 // zero would be okay; this result we do not understand.
609 #ifdef DEBUG_PORTABLE
610 printf("unknown result %d waiting for process %d", exited,
618 u_int launch_process(const istring &app_name_in, const istring &command_line,
619 int flag, u_int &child_id)
622 istring app_name = app_name_in;
623 if (app_name[0] != '"')
624 app_name.insert(0, "\"");
625 if (app_name[app_name.end()] != '"')
628 // unix / linux implementation.
629 if (flag & RETURN_IMMEDIATELY) {
630 // they want to get back right away.
631 pid_t kid_pid = fork();
632 #ifdef DEBUG_PORTABLE
633 printf("launch fork returned %d\n", kid_pid);
636 // this is the child; we now need to launch into what we were asked for.
637 #ifdef DEBUG_PORTABLE
638 printf((isprintf("process %d execing ", process_id()) + app_name
639 + " parms " + command_line + "\n").s());
641 basis::char_star_array parms = break_line(app_name, command_line);
642 execv(app_name.s(), parms.observe());
643 // oops. failed to exec if we got to here.
644 #ifdef DEBUG_PORTABLE
645 printf((isprintf("child of fork (pid %d) failed to exec, "
646 "error is ", process_id()) + system_error_text(system_error())
649 exit(0); // leave since this is a failed child process.
651 // this is the parent. let's see if the launch worked.
654 u_int to_return = system_error();
655 #ifdef DEBUG_PORTABLE
656 printf((isprintf("parent %d is returning after failing to create, "
657 "error is ", process_id()) + system_error_text(to_return)
662 // yes, launch worked okay.
665 auto_synchronizer l(__process_synchronizer());
666 __our_kids() += kid_pid;
668 // hook in our child exit signal handler.
669 signal(SIGCHLD, exiting_child_signal_handler);
671 #ifdef DEBUG_PORTABLE
672 printf((isprintf("parent %d is returning after successfully "
673 "creating %d ", process_id(), kid_pid) + app_name
674 + " parms " + command_line + "\n").s());
680 // assume they want to wait.
681 return system((app_name + " " + command_line).s());
683 #elif defined(__WIN32__)
685 //checking on whether we have admin rights for the launch.
686 //if (IsUserAnAdmin()) {
687 // MessageBox(0, (istring("IS admin with ") + app_name_in + " " + command_line).s(), "launch process", MB_OK);
689 // MessageBox(0, (istring("NOT admin for ") + app_name_in + " " + command_line).s(), "launch process", MB_OK);
692 PROCESS_INFORMATION process_info;
693 ZeroMemory(&process_info, sizeof(PROCESS_INFORMATION));
695 #ifdef SUPPORT_SHELL_EXECUTE
696 if (flag & SHELL_EXECUTE) {
697 // new code for using shell execute method--required on vista for proper
698 // launching with the right security tokens.
700 if (flag & HIDE_APP_WINDOW) {
701 // magic that hides a console window for mswindows.
704 show_cmd = SW_SHOWNORMAL;
707 SHELLEXECUTEINFO exec_info;
708 ZeroMemory(&exec_info, sizeof(SHELLEXECUTEINFO));
709 exec_info.cbSize = sizeof(SHELLEXECUTEINFO);
710 exec_info.fMask = SEE_MASK_NOCLOSEPROCESS // get the process info.
711 | SEE_MASK_FLAG_NO_UI; // turn off any visible error dialogs.
712 exec_info.hwnd = GetDesktopWindow();
713 //hmmm: is get desktop window always appropriate?
714 to_unicode_persist(temp_verb, "open");
715 //does "runas" work on xp also? or anywhere?
716 exec_info.lpVerb = temp_verb;
717 to_unicode_persist(temp_file, app_name);
718 exec_info.lpFile = temp_file;
719 to_unicode_persist(temp_parms, command_line);
720 exec_info.lpParameters = temp_parms;
721 exec_info.nShow = show_cmd;
722 // exec_info.hProcess = &process_info;
724 BOOL worked = ShellExecuteEx(&exec_info);
726 return system_error();
727 // copy out the returned process handle.
728 process_info.hProcess = exec_info.hProcess;
729 process_info.dwProcessId = GetProcessId(exec_info.hProcess);
732 // standard windows implementation using CreateProcess.
733 STARTUPINFO startup_info;
734 ZeroMemory(&startup_info, sizeof(STARTUPINFO));
735 startup_info.cb = sizeof(STARTUPINFO);
737 if (flag & HIDE_APP_WINDOW) {
738 // magic that hides a console window for mswindows.
739 // version ver = portable::get_OS_version();
740 // version vista_version(6, 0);
741 // if (ver < vista_version) {
742 // // we suspect that this flag is hosing us in vista.
743 create_flag = CREATE_NO_WINDOW;
746 istring parms = app_name + " " + command_line;
747 bool success = CreateProcess(NIL, to_unicode_temp(parms), NIL, NIL, false,
748 create_flag, NIL, NIL, &startup_info, &process_info);
750 return system_error();
751 // success then, merge back into stream.
753 #ifdef SUPPORT_SHELL_EXECUTE
757 // common handling for CreateProcess and ShellExecuteEx.
758 child_id = process_info.dwProcessId;
760 if (flag & AWAIT_VIA_POLLING) {
761 // this type of waiting is done without blocking on the process.
765 // check if the process is gone yet.
766 BOOL ret = GetExitCodeProcess(process_info.hProcess, &retval);
770 // if they aren't saying it's still active, then we will leave.
771 if (retval != STILL_ACTIVE)
776 } else if (flag & AWAIT_APP_EXIT) {
777 // they want to wait for the process to exit.
778 WaitForInputIdle(process_info.hProcess, INFINITE);
779 WaitForSingleObject(process_info.hProcess, INFINITE);
780 GetExitCodeProcess(process_info.hProcess, &retval);
782 // drop the process and thread handles.
783 if (process_info.hProcess)
784 CloseHandle(process_info.hProcess);
785 if (process_info.hThread)
786 CloseHandle(process_info.hThread);
787 return (u_int)retval;
789 #pragma error("hmmm: launch_process: no implementation for this OS.")
794 ////////////////////////////////////////////////////////////////////////////
798 char *itoa(int to_convert, char *buffer, int radix)
800 // slow implementation; may need enhancement for serious speed.
801 // ALSO: only supports base 10 and base 16 currently.
802 const char *formatter = "%d";
803 if (radix == 16) formatter = "%x";
804 isprintf printed(formatter, to_convert);
805 printed.stuff(buffer, printed.length() + 1);
815 void show_wait_cursor() { SetCursor(LoadCursor(NULL, IDC_WAIT)); }
817 void show_normal_cursor() { SetCursor(LoadCursor(NULL, IDC_ARROW)); }
819 istring rc_string(UINT id, application_instance instance)
821 flexichar temp[MAX_ABS_PATH + 1];
822 int ret = LoadString(instance, id, temp, MAX_ABS_PATH);
823 if (!ret) return istring();
824 return istring(from_unicode_temp(temp));
827 istring rc_string(u_int id) { return rc_string(id, GET_INSTANCE_HANDLE()); }
830 const char *opsystem_name(known_operating_systems which)
833 case WIN_95: return "WIN_95";
834 case WIN_NT: return "WIN_NT";
835 case WIN_2K: return "WIN_2K";
836 case WIN_XP: return "WIN_XP";
837 case WIN_SRV2K3: return "WIN_SRV2K3";
838 case WIN_VISTA: return "WIN_VISTA";
839 case WIN_SRV2K8: return "WIN_SRV2K8";
840 default: return "UNKNOWN_OS";
844 known_operating_systems determine_OS()
846 version osver = application_configuration::get_OS_version();
847 if ( (osver.v_major() == 4) && (osver.v_minor() == 0) ) {
848 if (osver.v_revision() == VER_PLATFORM_WIN32_WINDOWS) return WIN_95;
849 if (osver.v_revision() == VER_PLATFORM_WIN32_NT) return WIN_NT;
850 } else if ( (osver.v_major() == 5) && (osver.v_minor() == 0) ) {
852 } else if ( (osver.v_major() == 5) && (osver.v_minor() == 1) ) {
854 } else if ( (osver.v_major() == 5) && (osver.v_minor() == 2) ) {
856 } else if ( (osver.v_major() == 6) && (osver.v_minor() == 0) ) {
858 } else if ( (osver.v_major() == 6) && (osver.v_minor() == 1) ) {
868 #undef static_class_name