225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
|
-
+
-
+
|
* as EOF so we will loop around again. If no Ctrl signal handlers
* have been established, the default signal OS handler in a separate
* thread will terminate the program. If a Ctrl signal handler
* has been established (through an extension for example), it
* will run and take whatever action it deems appropriate.
*/
do {
result = ReadConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
result = ReadConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
NULL);
} while (result && ntchars == 0 && GetLastError() == ERROR_OPERATION_ABORTED);
if (nbytesread != NULL) {
*nbytesread = ntchars * sizeof(WCHAR);
}
return result;
}
static BOOL
WriteConsoleBytes(
HANDLE hConsole,
const void *lpBuffer,
DWORD nbytes,
LPDWORD nbyteswritten)
{
DWORD ntchars;
BOOL result;
result = WriteConsole(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
result = WriteConsoleW(hConsole, lpBuffer, nbytes / sizeof(WCHAR), &ntchars,
NULL);
if (nbyteswritten != NULL) {
*nbyteswritten = ntchars * sizeof(WCHAR);
}
return result;
}
|