Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 1 | //===- Win32/Process.cpp - Win32 Process Implementation ------- -*- C++ -*-===// |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 2 | // |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | f3ebc3f | 2007-12-29 20:36:04 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 7 | // |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file provides the Win32 specific implementation of the Process class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 14 | #include "Windows.h" |
Daniel Dunbar | 9b92e2b | 2011-09-23 23:23:36 +0000 | [diff] [blame] | 15 | #include <direct.h> |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 16 | #include <io.h> |
| 17 | #include <malloc.h> |
| 18 | #include <psapi.h> |
Jeff Cohen | 7ae0bc7 | 2004-12-20 03:24:56 +0000 | [diff] [blame] | 19 | |
Reid Spencer | 187b4ad | 2006-06-01 19:03:21 +0000 | [diff] [blame] | 20 | #ifdef __MINGW32__ |
| 21 | #if (HAVE_LIBPSAPI != 1) |
| 22 | #error "libpsapi.a should be present" |
| 23 | #endif |
| 24 | #else |
David Majnemer | f636cf4 | 2013-10-06 20:44:34 +0000 | [diff] [blame^] | 25 | #pragma comment(lib, "psapi.lib") |
Reid Spencer | 187b4ad | 2006-06-01 19:03:21 +0000 | [diff] [blame] | 26 | #endif |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 27 | |
| 28 | //===----------------------------------------------------------------------===// |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 29 | //=== WARNING: Implementation here must contain only Win32 specific code |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 30 | //=== and must not be UNIX code |
| 31 | //===----------------------------------------------------------------------===// |
| 32 | |
Jeff Cohen | 07e22ba | 2005-02-19 03:01:13 +0000 | [diff] [blame] | 33 | #ifdef __MINGW32__ |
Jeff Cohen | 53fbecc | 2004-12-23 03:44:40 +0000 | [diff] [blame] | 34 | // This ban should be lifted when MinGW 1.0+ has defined this value. |
| 35 | # define _HEAPOK (-2) |
| 36 | #endif |
| 37 | |
Chandler Carruth | 5473dfb | 2012-12-31 11:45:20 +0000 | [diff] [blame] | 38 | using namespace llvm; |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 39 | using namespace sys; |
| 40 | |
Chandler Carruth | 97683aa | 2012-12-31 11:17:50 +0000 | [diff] [blame] | 41 | |
| 42 | process::id_type self_process::get_id() { |
Aaron Ballman | f0b5384 | 2013-06-08 20:29:03 +0000 | [diff] [blame] | 43 | return GetCurrentProcessId(); |
Chandler Carruth | 97683aa | 2012-12-31 11:17:50 +0000 | [diff] [blame] | 44 | } |
| 45 | |
Chandler Carruth | ef7f968 | 2013-01-04 23:19:55 +0000 | [diff] [blame] | 46 | static TimeValue getTimeValueFromFILETIME(FILETIME Time) { |
| 47 | ULARGE_INTEGER TimeInteger; |
| 48 | TimeInteger.LowPart = Time.dwLowDateTime; |
| 49 | TimeInteger.HighPart = Time.dwHighDateTime; |
| 50 | |
| 51 | // FILETIME's are # of 100 nanosecond ticks (1/10th of a microsecond) |
| 52 | return TimeValue( |
| 53 | static_cast<TimeValue::SecondsType>(TimeInteger.QuadPart / 10000000), |
| 54 | static_cast<TimeValue::NanoSecondsType>( |
| 55 | (TimeInteger.QuadPart % 10000000) * 100)); |
| 56 | } |
| 57 | |
| 58 | TimeValue self_process::get_user_time() const { |
| 59 | FILETIME ProcCreate, ProcExit, KernelTime, UserTime; |
| 60 | if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, |
| 61 | &UserTime) == 0) |
| 62 | return TimeValue(); |
| 63 | |
| 64 | return getTimeValueFromFILETIME(UserTime); |
| 65 | } |
| 66 | |
| 67 | TimeValue self_process::get_system_time() const { |
| 68 | FILETIME ProcCreate, ProcExit, KernelTime, UserTime; |
| 69 | if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, |
| 70 | &UserTime) == 0) |
| 71 | return TimeValue(); |
| 72 | |
| 73 | return getTimeValueFromFILETIME(KernelTime); |
| 74 | } |
| 75 | |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 76 | // This function retrieves the page size using GetSystemInfo and is present |
Chandler Carruth | 15dcad9 | 2012-12-31 23:23:35 +0000 | [diff] [blame] | 77 | // solely so it can be called once to initialize the self_process member below. |
| 78 | static unsigned getPageSize() { |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 79 | // NOTE: A 32-bit application running under WOW64 is supposed to use |
| 80 | // GetNativeSystemInfo. However, this interface is not present prior |
| 81 | // to Windows XP so to use it requires dynamic linking. It is not clear |
| 82 | // how this affects the reported page size, if at all. One could argue |
| 83 | // that LLVM ought to run as 64-bits on a 64-bit system, anyway. |
| 84 | SYSTEM_INFO info; |
| 85 | GetSystemInfo(&info); |
NAKAMURA Takumi | 7a04234 | 2013-09-04 14:12:26 +0000 | [diff] [blame] | 86 | // FIXME: FileOffset in MapViewOfFile() should be aligned to not dwPageSize, |
| 87 | // but dwAllocationGranularity. |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 88 | return static_cast<unsigned>(info.dwPageSize); |
| 89 | } |
| 90 | |
Chandler Carruth | 15dcad9 | 2012-12-31 23:23:35 +0000 | [diff] [blame] | 91 | // This constructor guaranteed to be run exactly once on a single thread, and |
| 92 | // sets up various process invariants that can be queried cheaply from then on. |
| 93 | self_process::self_process() : PageSize(getPageSize()) { |
Reid Spencer | 91886b7 | 2004-09-15 05:47:40 +0000 | [diff] [blame] | 94 | } |
| 95 | |
Chandler Carruth | 15dcad9 | 2012-12-31 23:23:35 +0000 | [diff] [blame] | 96 | |
Michael J. Spencer | 447762d | 2010-11-29 18:16:10 +0000 | [diff] [blame] | 97 | size_t |
Reid Spencer | ac38f3a | 2004-12-20 00:59:28 +0000 | [diff] [blame] | 98 | Process::GetMallocUsage() |
| 99 | { |
Jeff Cohen | 7ae0bc7 | 2004-12-20 03:24:56 +0000 | [diff] [blame] | 100 | _HEAPINFO hinfo; |
| 101 | hinfo._pentry = NULL; |
| 102 | |
| 103 | size_t size = 0; |
| 104 | |
| 105 | while (_heapwalk(&hinfo) == _HEAPOK) |
| 106 | size += hinfo._size; |
| 107 | |
| 108 | return size; |
Reid Spencer | ac38f3a | 2004-12-20 00:59:28 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Chandler Carruth | ef7f968 | 2013-01-04 23:19:55 +0000 | [diff] [blame] | 111 | void Process::GetTimeUsage(TimeValue &elapsed, TimeValue &user_time, |
| 112 | TimeValue &sys_time) { |
Reid Spencer | ac38f3a | 2004-12-20 00:59:28 +0000 | [diff] [blame] | 113 | elapsed = TimeValue::now(); |
| 114 | |
Chandler Carruth | ef7f968 | 2013-01-04 23:19:55 +0000 | [diff] [blame] | 115 | FILETIME ProcCreate, ProcExit, KernelTime, UserTime; |
| 116 | if (GetProcessTimes(GetCurrentProcess(), &ProcCreate, &ProcExit, &KernelTime, |
| 117 | &UserTime) == 0) |
| 118 | return; |
Reid Spencer | ac38f3a | 2004-12-20 00:59:28 +0000 | [diff] [blame] | 119 | |
Chandler Carruth | ef7f968 | 2013-01-04 23:19:55 +0000 | [diff] [blame] | 120 | user_time = getTimeValueFromFILETIME(UserTime); |
Chandler Carruth | b79a7aa | 2013-01-04 23:46:04 +0000 | [diff] [blame] | 121 | sys_time = getTimeValueFromFILETIME(KernelTime); |
Reid Spencer | ac38f3a | 2004-12-20 00:59:28 +0000 | [diff] [blame] | 122 | } |
| 123 | |
Reid Spencer | cf15b87 | 2004-12-27 06:17:27 +0000 | [diff] [blame] | 124 | // Some LLVM programs such as bugpoint produce core files as a normal part of |
Aaron Ballman | dcd5757 | 2013-08-16 14:33:07 +0000 | [diff] [blame] | 125 | // their operation. To prevent the disk from filling up, this configuration |
| 126 | // item does what's necessary to prevent their generation. |
Reid Spencer | cf15b87 | 2004-12-27 06:17:27 +0000 | [diff] [blame] | 127 | void Process::PreventCoreFiles() { |
Aaron Ballman | dcd5757 | 2013-08-16 14:33:07 +0000 | [diff] [blame] | 128 | // Windows does have the concept of core files, called minidumps. However, |
| 129 | // disabling minidumps for a particular application extends past the lifetime |
| 130 | // of that application, which is the incorrect behavior for this API. |
| 131 | // Additionally, the APIs require elevated privileges to disable and re- |
| 132 | // enable minidumps, which makes this untenable. For more information, see |
| 133 | // WerAddExcludedApplication and WerRemoveExcludedApplication (Vista and |
| 134 | // later). |
| 135 | // |
| 136 | // Windows also has modal pop-up message boxes. As this method is used by |
| 137 | // bugpoint, preventing these pop-ups is additionally important. |
Jeff Cohen | 81549a5 | 2005-02-18 07:05:18 +0000 | [diff] [blame] | 138 | SetErrorMode(SEM_FAILCRITICALERRORS | |
| 139 | SEM_NOGPFAULTERRORBOX | |
| 140 | SEM_NOOPENFILEERRORBOX); |
Reid Spencer | cf15b87 | 2004-12-27 06:17:27 +0000 | [diff] [blame] | 141 | } |
| 142 | |
Rui Ueyama | 471d0c5 | 2013-09-10 19:45:51 +0000 | [diff] [blame] | 143 | /// Returns the environment variable \arg Name's value as a string encoded in |
| 144 | /// UTF-8. \arg Name is assumed to be in UTF-8 encoding. |
| 145 | Optional<std::string> Process::GetEnv(StringRef Name) { |
| 146 | // Convert the argument to UTF-16 to pass it to _wgetenv(). |
| 147 | SmallVector<wchar_t, 128> NameUTF16; |
| 148 | if (error_code ec = windows::UTF8ToUTF16(Name, NameUTF16)) |
| 149 | return None; |
| 150 | |
| 151 | // Environment variable can be encoded in non-UTF8 encoding, and there's no |
| 152 | // way to know what the encoding is. The only reliable way to look up |
| 153 | // multibyte environment variable is to use GetEnvironmentVariableW(). |
David Majnemer | f636cf4 | 2013-10-06 20:44:34 +0000 | [diff] [blame^] | 154 | std::vector<wchar_t> Buf(16); |
| 155 | size_t Size = 0; |
| 156 | for (;;) { |
| 157 | Size = GetEnvironmentVariableW(&NameUTF16[0], &Buf[0], Buf.size()); |
| 158 | if (Size < Buf.size()) |
| 159 | break; |
Rui Ueyama | 471d0c5 | 2013-09-10 19:45:51 +0000 | [diff] [blame] | 160 | // Try again with larger buffer. |
David Majnemer | f636cf4 | 2013-10-06 20:44:34 +0000 | [diff] [blame^] | 161 | Buf.resize(Size + 1); |
| 162 | } |
| 163 | if (Size == 0) |
| 164 | return None; |
Rui Ueyama | 471d0c5 | 2013-09-10 19:45:51 +0000 | [diff] [blame] | 165 | |
| 166 | // Convert the result from UTF-16 to UTF-8. |
David Majnemer | f636cf4 | 2013-10-06 20:44:34 +0000 | [diff] [blame^] | 167 | SmallVector<char, 128> Res; |
Rui Ueyama | 471d0c5 | 2013-09-10 19:45:51 +0000 | [diff] [blame] | 168 | if (error_code ec = windows::UTF16ToUTF8(&Buf[0], Size, Res)) |
| 169 | return None; |
| 170 | return std::string(&Res[0]); |
| 171 | } |
| 172 | |
Jeff Cohen | b90c31f | 2005-01-01 22:54:05 +0000 | [diff] [blame] | 173 | bool Process::StandardInIsUserInput() { |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 174 | return FileDescriptorIsDisplayed(0); |
Jeff Cohen | b90c31f | 2005-01-01 22:54:05 +0000 | [diff] [blame] | 175 | } |
| 176 | |
| 177 | bool Process::StandardOutIsDisplayed() { |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 178 | return FileDescriptorIsDisplayed(1); |
Jeff Cohen | b90c31f | 2005-01-01 22:54:05 +0000 | [diff] [blame] | 179 | } |
| 180 | |
| 181 | bool Process::StandardErrIsDisplayed() { |
Dan Gohman | e592923 | 2009-09-11 20:46:33 +0000 | [diff] [blame] | 182 | return FileDescriptorIsDisplayed(2); |
| 183 | } |
| 184 | |
| 185 | bool Process::FileDescriptorIsDisplayed(int fd) { |
Bill Wendling | 2b07965 | 2012-07-19 00:06:06 +0000 | [diff] [blame] | 186 | DWORD Mode; // Unused |
NAKAMURA Takumi | 23ebef1 | 2010-11-10 08:37:47 +0000 | [diff] [blame] | 187 | return (GetConsoleMode((HANDLE)_get_osfhandle(fd), &Mode) != 0); |
Jeff Cohen | b90c31f | 2005-01-01 22:54:05 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Douglas Gregor | 1543661 | 2009-05-11 18:05:52 +0000 | [diff] [blame] | 190 | unsigned Process::StandardOutColumns() { |
| 191 | unsigned Columns = 0; |
| 192 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 193 | if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) |
| 194 | Columns = csbi.dwSize.X; |
| 195 | return Columns; |
| 196 | } |
| 197 | |
| 198 | unsigned Process::StandardErrColumns() { |
| 199 | unsigned Columns = 0; |
| 200 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 201 | if (GetConsoleScreenBufferInfo(GetStdHandle(STD_ERROR_HANDLE), &csbi)) |
| 202 | Columns = csbi.dwSize.X; |
| 203 | return Columns; |
| 204 | } |
| 205 | |
Daniel Dunbar | 712de82 | 2012-07-20 18:29:38 +0000 | [diff] [blame] | 206 | // The terminal always has colors. |
Benjamin Kramer | dfaa0f3 | 2012-07-20 19:49:33 +0000 | [diff] [blame] | 207 | bool Process::FileDescriptorHasColors(int fd) { |
Daniel Dunbar | 712de82 | 2012-07-20 18:29:38 +0000 | [diff] [blame] | 208 | return FileDescriptorIsDisplayed(fd); |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | bool Process::StandardOutHasColors() { |
Daniel Dunbar | 712de82 | 2012-07-20 18:29:38 +0000 | [diff] [blame] | 212 | return FileDescriptorHasColors(1); |
| 213 | } |
| 214 | |
| 215 | bool Process::StandardErrHasColors() { |
| 216 | return FileDescriptorHasColors(2); |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 217 | } |
Torok Edwin | 63e44bb | 2009-06-04 08:18:25 +0000 | [diff] [blame] | 218 | |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 219 | static bool UseANSI = false; |
| 220 | void Process::UseANSIEscapeCodes(bool enable) { |
| 221 | UseANSI = enable; |
| 222 | } |
| 223 | |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 224 | namespace { |
| 225 | class DefaultColors |
| 226 | { |
| 227 | private: |
| 228 | WORD defaultColor; |
| 229 | public: |
| 230 | DefaultColors() |
| 231 | :defaultColor(GetCurrentColor()) {} |
| 232 | static unsigned GetCurrentColor() { |
| 233 | CONSOLE_SCREEN_BUFFER_INFO csbi; |
| 234 | if (GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi)) |
| 235 | return csbi.wAttributes; |
| 236 | return 0; |
| 237 | } |
| 238 | WORD operator()() const { return defaultColor; } |
| 239 | }; |
| 240 | |
| 241 | DefaultColors defaultColors; |
| 242 | } |
| 243 | |
| 244 | bool Process::ColorNeedsFlush() { |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 245 | return !UseANSI; |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | const char *Process::OutputBold(bool bg) { |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 249 | if (UseANSI) return "\033[1m"; |
| 250 | |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 251 | WORD colors = DefaultColors::GetCurrentColor(); |
| 252 | if (bg) |
| 253 | colors |= BACKGROUND_INTENSITY; |
| 254 | else |
| 255 | colors |= FOREGROUND_INTENSITY; |
| 256 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors); |
| 257 | return 0; |
| 258 | } |
| 259 | |
| 260 | const char *Process::OutputColor(char code, bool bold, bool bg) { |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 261 | if (UseANSI) return colorcodes[bg?1:0][bold?1:0][code&7]; |
| 262 | |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 263 | WORD colors; |
| 264 | if (bg) { |
| 265 | colors = ((code&1) ? BACKGROUND_RED : 0) | |
| 266 | ((code&2) ? BACKGROUND_GREEN : 0 ) | |
| 267 | ((code&4) ? BACKGROUND_BLUE : 0); |
| 268 | if (bold) |
| 269 | colors |= BACKGROUND_INTENSITY; |
| 270 | } else { |
| 271 | colors = ((code&1) ? FOREGROUND_RED : 0) | |
| 272 | ((code&2) ? FOREGROUND_GREEN : 0 ) | |
| 273 | ((code&4) ? FOREGROUND_BLUE : 0); |
| 274 | if (bold) |
| 275 | colors |= FOREGROUND_INTENSITY; |
| 276 | } |
| 277 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), colors); |
| 278 | return 0; |
| 279 | } |
| 280 | |
Benjamin Kramer | 13d16f3 | 2012-04-16 08:56:50 +0000 | [diff] [blame] | 281 | static WORD GetConsoleTextAttribute(HANDLE hConsoleOutput) { |
| 282 | CONSOLE_SCREEN_BUFFER_INFO info; |
| 283 | GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &info); |
| 284 | return info.wAttributes; |
| 285 | } |
| 286 | |
| 287 | const char *Process::OutputReverse() { |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 288 | if (UseANSI) return "\033[7m"; |
| 289 | |
Benjamin Kramer | 13d16f3 | 2012-04-16 08:56:50 +0000 | [diff] [blame] | 290 | const WORD attributes |
| 291 | = GetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE)); |
| 292 | |
| 293 | const WORD foreground_mask = FOREGROUND_BLUE | FOREGROUND_GREEN | |
| 294 | FOREGROUND_RED | FOREGROUND_INTENSITY; |
| 295 | const WORD background_mask = BACKGROUND_BLUE | BACKGROUND_GREEN | |
| 296 | BACKGROUND_RED | BACKGROUND_INTENSITY; |
| 297 | const WORD color_mask = foreground_mask | background_mask; |
| 298 | |
| 299 | WORD new_attributes = |
| 300 | ((attributes & FOREGROUND_BLUE )?BACKGROUND_BLUE :0) | |
| 301 | ((attributes & FOREGROUND_GREEN )?BACKGROUND_GREEN :0) | |
| 302 | ((attributes & FOREGROUND_RED )?BACKGROUND_RED :0) | |
| 303 | ((attributes & FOREGROUND_INTENSITY)?BACKGROUND_INTENSITY:0) | |
| 304 | ((attributes & BACKGROUND_BLUE )?FOREGROUND_BLUE :0) | |
| 305 | ((attributes & BACKGROUND_GREEN )?FOREGROUND_GREEN :0) | |
| 306 | ((attributes & BACKGROUND_RED )?FOREGROUND_RED :0) | |
| 307 | ((attributes & BACKGROUND_INTENSITY)?FOREGROUND_INTENSITY:0) | |
| 308 | 0; |
| 309 | new_attributes = (attributes & ~color_mask) | (new_attributes & color_mask); |
| 310 | |
| 311 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), new_attributes); |
| 312 | return 0; |
| 313 | } |
| 314 | |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 315 | const char *Process::ResetColor() { |
Nico Rieck | 92d649a | 2013-09-11 00:36:48 +0000 | [diff] [blame] | 316 | if (UseANSI) return "\033[0m"; |
Torok Edwin | 9b5a47f | 2009-06-04 07:09:50 +0000 | [diff] [blame] | 317 | SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), defaultColors()); |
| 318 | return 0; |
| 319 | } |