1 | /* $Id: conin.cpp,v 1.16 2001-12-05 14:15:58 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 Console API Translation for OS/2
|
---|
5 | * 1998/02/10 Patrick Haller (haller@zebra.fh-weingarten.de)
|
---|
6 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
7 | */
|
---|
8 |
|
---|
9 |
|
---|
10 | #ifdef DEBUG
|
---|
11 | #define DEBUG_LOCAL
|
---|
12 | #define DEBUG_LOCAL2
|
---|
13 | #endif
|
---|
14 |
|
---|
15 |
|
---|
16 | /*****************************************************************************
|
---|
17 | * Remark *
|
---|
18 | *****************************************************************************
|
---|
19 | */
|
---|
20 |
|
---|
21 |
|
---|
22 | /*****************************************************************************
|
---|
23 | * Includes *
|
---|
24 | *****************************************************************************/
|
---|
25 |
|
---|
26 | #define INCL_WIN
|
---|
27 | #define INCL_DOSMEMMGR
|
---|
28 | #define INCL_DOSSEMAPHORES
|
---|
29 | #define INCL_DOSERRORS
|
---|
30 | #define INCL_DOSPROCESS
|
---|
31 | #define INCL_DOSMODULEMGR
|
---|
32 | #define INCL_VIO
|
---|
33 | #define INCL_AVIO
|
---|
34 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
35 |
|
---|
36 | #include <win32api.h>
|
---|
37 | #include <misc.h>
|
---|
38 | #include <string.h>
|
---|
39 | #include <stdlib.h>
|
---|
40 |
|
---|
41 | #include "conwin.h" // Windows Header for console only
|
---|
42 | #include "HandleManager.h"
|
---|
43 | #include "HMDevice.h"
|
---|
44 | #include "Conin.H"
|
---|
45 | #include "Console2.h"
|
---|
46 | #include <heapstring.h>
|
---|
47 |
|
---|
48 | #define DBG_LOCALLOG DBG_conin
|
---|
49 | #include "dbglocal.h"
|
---|
50 |
|
---|
51 |
|
---|
52 | /*****************************************************************************
|
---|
53 | * Name : DWORD HMDeviceConsoleInClass::CreateFile
|
---|
54 | * Purpose : this is called from the handle manager if a CreateFile() is
|
---|
55 | * performed on a handle
|
---|
56 | * Parameters: LPCSTR lpFileName name of the file / device
|
---|
57 | * PHMHANDLEDATA pHMHandleData data of the NEW handle
|
---|
58 | * PVOID lpSecurityAttributes ignored
|
---|
59 | * PHMHANDLEDATA pHMHandleDataTemplate data of the template handle
|
---|
60 | * Variables :
|
---|
61 | * Result :
|
---|
62 | * Remark : @@@PH CONIN$ handles should be exclusive
|
---|
63 | * reject other requests to this device
|
---|
64 | * Status : NO_ERROR - API succeeded
|
---|
65 | * other - what is to be set in SetLastError
|
---|
66 | *
|
---|
67 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
68 | *****************************************************************************/
|
---|
69 |
|
---|
70 | DWORD HMDeviceConsoleInClass::CreateFile (LPCSTR lpFileName,
|
---|
71 | PHMHANDLEDATA pHMHandleData,
|
---|
72 | PVOID lpSecurityAttributes,
|
---|
73 | PHMHANDLEDATA pHMHandleDataTemplate)
|
---|
74 | {
|
---|
75 | #ifdef DEBUG_LOCAL
|
---|
76 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::CreateFile %s(%s,%08x,%08x,%08x)\n",
|
---|
77 | lpHMDeviceName,
|
---|
78 | lpFileName,
|
---|
79 | pHMHandleData->hHMHandle,
|
---|
80 | lpSecurityAttributes,
|
---|
81 | pHMHandleDataTemplate);
|
---|
82 | #endif
|
---|
83 |
|
---|
84 | return(NO_ERROR);
|
---|
85 | }
|
---|
86 |
|
---|
87 | /*****************************************************************************
|
---|
88 | * Name : DWORD HMDeviceConsoleInClass::GetFileType
|
---|
89 | * Purpose : determine the handle type
|
---|
90 | * Parameters: PHMHANDLEDATA pHMHandleData
|
---|
91 | * Variables :
|
---|
92 | * Result : API returncode
|
---|
93 | * Remark :
|
---|
94 | * Status :
|
---|
95 | *
|
---|
96 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
97 | *****************************************************************************/
|
---|
98 |
|
---|
99 | DWORD HMDeviceConsoleInClass::GetFileType(PHMHANDLEDATA pHMHandleData)
|
---|
100 | {
|
---|
101 | dprintf(("KERNEL32: HMDeviceConsoleInClass::GetFileType %s(%08x)\n",
|
---|
102 | lpHMDeviceName,
|
---|
103 | pHMHandleData));
|
---|
104 |
|
---|
105 | return FILE_TYPE_CHAR;
|
---|
106 | }
|
---|
107 |
|
---|
108 | /*****************************************************************************
|
---|
109 | * Name :
|
---|
110 | * Purpose :
|
---|
111 | * Parameters:
|
---|
112 | * Variables :
|
---|
113 | * Result :
|
---|
114 | * Remark :
|
---|
115 | * Status :
|
---|
116 | *
|
---|
117 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
118 | *****************************************************************************/
|
---|
119 |
|
---|
120 | BOOL HMDeviceConsoleInClass::ReadFile(PHMHANDLEDATA pHMHandleData,
|
---|
121 | LPCVOID lpBuffer,
|
---|
122 | DWORD nNumberOfBytesToRead,
|
---|
123 | LPDWORD lpNumberOfBytesRead,
|
---|
124 | LPOVERLAPPED lpOverlapped,
|
---|
125 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
126 | {
|
---|
127 | ULONG ulCounter; /* character counter for the queue loop */
|
---|
128 | PSZ pszTarget; /* pointer to target buffer */
|
---|
129 | APIRET rc; /* API returncode */
|
---|
130 | INPUT_RECORD InputRecord; /* buffer for the event to be read */
|
---|
131 | ULONG ulPostCounter; /* semaphore post counter */
|
---|
132 | BOOL fLoop = TRUE; /* set to false if function may return to caller */
|
---|
133 |
|
---|
134 | #ifdef DEBUG_LOCAL
|
---|
135 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass::ReadFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
---|
136 | lpHMDeviceName,
|
---|
137 | pHMHandleData->hHMHandle,
|
---|
138 | lpBuffer,
|
---|
139 | nNumberOfBytesToRead,
|
---|
140 | lpNumberOfBytesRead,
|
---|
141 | lpOverlapped);
|
---|
142 | #endif
|
---|
143 |
|
---|
144 | ulCounter = 0; /* read ascii chars from queue */
|
---|
145 | pszTarget = (PSZ)lpBuffer;
|
---|
146 |
|
---|
147 | /* block if no key events are in the queue */
|
---|
148 | for (;fLoop;) /* until we got some characters */
|
---|
149 | {
|
---|
150 | iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_WAIT); /* if queue is currently empty */
|
---|
151 |
|
---|
152 | do
|
---|
153 | {
|
---|
154 | rc = iConsoleInputEventPop(&InputRecord); /* get event from queue */
|
---|
155 | if (rc == NO_ERROR) /* if we've got a valid event in the queue */
|
---|
156 | {
|
---|
157 | //@@@PH other events are discarded!
|
---|
158 | if ( (InputRecord.EventType == KEY_EVENT) && /* check event type */
|
---|
159 | (InputRecord.Event.KeyEvent.bKeyDown == TRUE) )
|
---|
160 | {
|
---|
161 | // console in line input mode ?
|
---|
162 | if (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT)
|
---|
163 | {
|
---|
164 | // continue until buffer full or CR entered
|
---|
165 | // Note: CRLF is actually returned at the end of the buffer!
|
---|
166 | if (InputRecord.Event.KeyEvent.uChar.AsciiChar == 0x0d)
|
---|
167 | fLoop = FALSE;
|
---|
168 | }
|
---|
169 | else
|
---|
170 | // return on any single key in buffer :)
|
---|
171 | // fLoop = FALSE;
|
---|
172 | // @@@PH 2000/08/10 changed behaviour to return ALL input events
|
---|
173 | // recorded in the console.
|
---|
174 | fLoop = (iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_PEEK) != 0);
|
---|
175 |
|
---|
176 | // record key stroke
|
---|
177 | if (pConsoleInput->dwConsoleMode & ENABLE_PROCESSED_INPUT)
|
---|
178 | {
|
---|
179 | // filter special characters first
|
---|
180 | switch (InputRecord.Event.KeyEvent.uChar.AsciiChar)
|
---|
181 | {
|
---|
182 | case 0x00:
|
---|
183 | // Ascii values of 0x00 are sent e.g. for SHIFT-DOWN
|
---|
184 | // key events, etc.
|
---|
185 | break;
|
---|
186 |
|
---|
187 | case 0x03: // ctrl-c is filtered!
|
---|
188 | // @@@PH we're supposed to call a ctrl-c break handler here!
|
---|
189 | break;
|
---|
190 |
|
---|
191 | case 0x0d: // CR
|
---|
192 | // CR is automatically expanded to CRLF if in line input mode!
|
---|
193 | if (pConsoleInput->dwConsoleMode & ENABLE_LINE_INPUT)
|
---|
194 | {
|
---|
195 | *pszTarget = 0x0d; // CR
|
---|
196 | pszTarget++;
|
---|
197 | ulCounter++;
|
---|
198 | if (ulCounter < nNumberOfBytesToRead) // check for room
|
---|
199 | {
|
---|
200 | *pszTarget = 0x0a; // LF
|
---|
201 | pszTarget++;
|
---|
202 | ulCounter++;
|
---|
203 | }
|
---|
204 |
|
---|
205 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
206 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
207 | pszTarget-2,
|
---|
208 | 2,
|
---|
209 | &ulPostCounter, /* dummy result */
|
---|
210 | NULL, NULL);
|
---|
211 |
|
---|
212 | }
|
---|
213 |
|
---|
214 | break;
|
---|
215 |
|
---|
216 | case 0x08: // backspace
|
---|
217 | if (ulCounter > 0)
|
---|
218 | {
|
---|
219 | //@@@PH erase character on screen!
|
---|
220 | ulCounter--;
|
---|
221 | pszTarget--;
|
---|
222 | /* local echo enabled ? */
|
---|
223 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
224 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
225 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
226 | 1,
|
---|
227 | &ulPostCounter, /* dummy result */
|
---|
228 | NULL, NULL);
|
---|
229 | }
|
---|
230 | break;
|
---|
231 |
|
---|
232 | default:
|
---|
233 | // OK, for the rest ...
|
---|
234 | *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
---|
235 | dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n",
|
---|
236 | *pszTarget,
|
---|
237 | *pszTarget));
|
---|
238 |
|
---|
239 | pszTarget++;
|
---|
240 | ulCounter++;
|
---|
241 | /* local echo enabled ? */
|
---|
242 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
243 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
244 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
245 | 1,
|
---|
246 | &ulPostCounter, /* dummy result */
|
---|
247 | NULL, NULL);
|
---|
248 | }
|
---|
249 | }
|
---|
250 | else
|
---|
251 | {
|
---|
252 | *pszTarget = InputRecord.Event.KeyEvent.uChar.AsciiChar;
|
---|
253 | dprintf(("KERNEL32:CONIN$: Debug: recorded key (%c - %02xh)\n",
|
---|
254 | *pszTarget,
|
---|
255 | *pszTarget));
|
---|
256 |
|
---|
257 | pszTarget++;
|
---|
258 | ulCounter++;
|
---|
259 |
|
---|
260 | /* local echo enabled ? */
|
---|
261 | if (pConsoleInput->dwConsoleMode & ENABLE_ECHO_INPUT)
|
---|
262 | HMWriteFile(pConsoleGlobals->hConsoleBuffer,
|
---|
263 | &InputRecord.Event.KeyEvent.uChar.AsciiChar,
|
---|
264 | 1,
|
---|
265 | &ulPostCounter, /* dummy result */
|
---|
266 | NULL, NULL);
|
---|
267 | }
|
---|
268 |
|
---|
269 | // buffer filled?
|
---|
270 | if (ulCounter >= nNumberOfBytesToRead) /* at buffer's end ? */
|
---|
271 | fLoop = FALSE;
|
---|
272 | }
|
---|
273 | /* Note: other events are discarded */
|
---|
274 | }
|
---|
275 | }
|
---|
276 | while (rc == NO_ERROR);
|
---|
277 | }
|
---|
278 |
|
---|
279 | *lpNumberOfBytesRead = ulCounter; /* write result */
|
---|
280 |
|
---|
281 | return(TRUE); /* OK */
|
---|
282 | }
|
---|
283 |
|
---|
284 |
|
---|
285 | /*****************************************************************************
|
---|
286 | * Name :
|
---|
287 | * Purpose :
|
---|
288 | * Parameters:
|
---|
289 | * Variables :
|
---|
290 | * Result :
|
---|
291 | * Remark :
|
---|
292 | * Status :
|
---|
293 | *
|
---|
294 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
295 | *****************************************************************************/
|
---|
296 |
|
---|
297 | BOOL HMDeviceConsoleInClass::WriteFile(PHMHANDLEDATA pHMHandleData,
|
---|
298 | LPCVOID lpBuffer,
|
---|
299 | DWORD nNumberOfBytesToWrite,
|
---|
300 | LPDWORD lpNumberOfBytesWritten,
|
---|
301 | LPOVERLAPPED lpOverlapped,
|
---|
302 | LPOVERLAPPED_COMPLETION_ROUTINE lpCompletionRoutine)
|
---|
303 | {
|
---|
304 |
|
---|
305 | #ifdef DEBUG_LOCAL
|
---|
306 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:WriteFile %s(%08x,%08x,%08x,%08x,%08x)\n",
|
---|
307 | lpHMDeviceName,
|
---|
308 | pHMHandleData->hHMHandle,
|
---|
309 | lpBuffer,
|
---|
310 | nNumberOfBytesToWrite,
|
---|
311 | lpNumberOfBytesWritten,
|
---|
312 | lpOverlapped);
|
---|
313 | #endif
|
---|
314 |
|
---|
315 | SetLastError(ERROR_ACCESS_DENIED_W);
|
---|
316 | return FALSE;
|
---|
317 | }
|
---|
318 |
|
---|
319 |
|
---|
320 | /*****************************************************************************
|
---|
321 | * Name :
|
---|
322 | * Purpose :
|
---|
323 | * Parameters:
|
---|
324 | * Variables :
|
---|
325 | * Result :
|
---|
326 | * Remark :
|
---|
327 | * Status :
|
---|
328 | *
|
---|
329 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
330 | *****************************************************************************/
|
---|
331 |
|
---|
332 | DWORD HMDeviceConsoleInClass::_DeviceRequest (PHMHANDLEDATA pHMHandleData,
|
---|
333 | ULONG ulRequestCode,
|
---|
334 | ULONG arg1,
|
---|
335 | ULONG arg2,
|
---|
336 | ULONG arg3,
|
---|
337 | ULONG arg4)
|
---|
338 | {
|
---|
339 | switch (ulRequestCode)
|
---|
340 | {
|
---|
341 | case DRQ_FLUSHCONSOLEINPUTBUFFER:
|
---|
342 | return (HMDeviceConsoleInClass::
|
---|
343 | FlushConsoleInputBuffer(pHMHandleData));
|
---|
344 |
|
---|
345 | case DRQ_GETCONSOLEMODE:
|
---|
346 | return (HMDeviceConsoleInClass
|
---|
347 | ::GetConsoleMode(pHMHandleData,
|
---|
348 | (LPDWORD)arg1));
|
---|
349 |
|
---|
350 | case DRQ_GETNUMBEROFCONSOLEINPUTEVENTS:
|
---|
351 | return (HMDeviceConsoleInClass::
|
---|
352 | GetNumberOfConsoleInputEvents(pHMHandleData,
|
---|
353 | (LPDWORD)arg1));
|
---|
354 |
|
---|
355 | case DRQ_PEEKCONSOLEINPUTA:
|
---|
356 | return (HMDeviceConsoleInClass::
|
---|
357 | PeekConsoleInputA(pHMHandleData,
|
---|
358 | (PINPUT_RECORD)arg1,
|
---|
359 | (DWORD) arg2,
|
---|
360 | (LPDWORD) arg3));
|
---|
361 |
|
---|
362 | case DRQ_PEEKCONSOLEINPUTW:
|
---|
363 | return (HMDeviceConsoleInClass::
|
---|
364 | PeekConsoleInputW(pHMHandleData,
|
---|
365 | (PINPUT_RECORD)arg1,
|
---|
366 | (DWORD) arg2,
|
---|
367 | (LPDWORD) arg3));
|
---|
368 |
|
---|
369 |
|
---|
370 | case DRQ_READCONSOLEA:
|
---|
371 | return (HMDeviceConsoleInClass::
|
---|
372 | ReadConsoleA(pHMHandleData,
|
---|
373 | (CONST VOID*) arg1,
|
---|
374 | (DWORD) arg2,
|
---|
375 | (LPDWORD) arg3,
|
---|
376 | (LPVOID) arg4));
|
---|
377 |
|
---|
378 | case DRQ_READCONSOLEW:
|
---|
379 | return (HMDeviceConsoleInClass::
|
---|
380 | ReadConsoleW(pHMHandleData,
|
---|
381 | (CONST VOID*) arg1,
|
---|
382 | (DWORD) arg2,
|
---|
383 | (LPDWORD) arg3,
|
---|
384 | (LPVOID) arg4));
|
---|
385 |
|
---|
386 | case DRQ_READCONSOLEINPUTA:
|
---|
387 | return (HMDeviceConsoleInClass::
|
---|
388 | ReadConsoleInputA(pHMHandleData,
|
---|
389 | (PINPUT_RECORD)arg1,
|
---|
390 | (DWORD)arg2,
|
---|
391 | (LPDWORD)arg3));
|
---|
392 |
|
---|
393 | case DRQ_READCONSOLEINPUTW:
|
---|
394 | return (HMDeviceConsoleInClass::
|
---|
395 | ReadConsoleInputW(pHMHandleData,
|
---|
396 | (PINPUT_RECORD)arg1,
|
---|
397 | (DWORD)arg2,
|
---|
398 | (LPDWORD)arg3));
|
---|
399 |
|
---|
400 | case DRQ_SETCONSOLEMODE:
|
---|
401 | return (HMDeviceConsoleInClass
|
---|
402 | ::SetConsoleMode(pHMHandleData,
|
---|
403 | (DWORD)arg1));
|
---|
404 |
|
---|
405 | case DRQ_WRITECONSOLEINPUTA:
|
---|
406 | return (HMDeviceConsoleInClass::
|
---|
407 | WriteConsoleInputA(pHMHandleData,
|
---|
408 | (PINPUT_RECORD)arg1,
|
---|
409 | (DWORD)arg2,
|
---|
410 | (LPDWORD)arg3));
|
---|
411 |
|
---|
412 | case DRQ_WRITECONSOLEINPUTW:
|
---|
413 | return (HMDeviceConsoleInClass::
|
---|
414 | WriteConsoleInputW(pHMHandleData,
|
---|
415 | (PINPUT_RECORD)arg1,
|
---|
416 | (DWORD)arg2,
|
---|
417 | (LPDWORD)arg3));
|
---|
418 |
|
---|
419 | }
|
---|
420 |
|
---|
421 | #ifdef DEBUG_LOCAL
|
---|
422 | WriteLog("KERNEL32/CONSOLE:HMDeviceConsoleInClass:_DeviceRequest %s(%08x,%08x,%08x,%08x,%08x,%08x) unknown request\n",
|
---|
423 | lpHMDeviceName,
|
---|
424 | pHMHandleData->hHMHandle,
|
---|
425 | ulRequestCode,
|
---|
426 | arg1,
|
---|
427 | arg2,
|
---|
428 | arg3,
|
---|
429 | arg4);
|
---|
430 | #endif
|
---|
431 |
|
---|
432 | SetLastError(ERROR_INVALID_FUNCTION_W); /* request not implemented */
|
---|
433 | return(FALSE); /* we assume this indicates API call failed */
|
---|
434 | }
|
---|
435 |
|
---|
436 |
|
---|
437 | /*****************************************************************************
|
---|
438 | * Name : BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer
|
---|
439 | * Purpose : flushes all events from the input queue
|
---|
440 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
441 | * Variables :
|
---|
442 | * Result :
|
---|
443 | * Remark :
|
---|
444 | * Status : UNTESTED
|
---|
445 | *
|
---|
446 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
447 | *****************************************************************************/
|
---|
448 |
|
---|
449 | BOOL HMDeviceConsoleInClass::FlushConsoleInputBuffer(PHMHANDLEDATA pHMHandleData)
|
---|
450 | {
|
---|
451 | ULONG ulCounter; /* loop counter */
|
---|
452 |
|
---|
453 | #ifdef DEBUG_LOCAL2
|
---|
454 | WriteLog("KERNEL32/CONSOLE: CONIN$::FlushConsoleInputBuffer(%08x).\n",
|
---|
455 | pHMHandleData);
|
---|
456 | #endif
|
---|
457 |
|
---|
458 | //get all pending events
|
---|
459 | iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_PEEK);
|
---|
460 |
|
---|
461 | pConsoleInput->ulIndexFree = 0;
|
---|
462 | pConsoleInput->ulIndexEvent = 0;
|
---|
463 | pConsoleInput->ulEvents = 0;
|
---|
464 |
|
---|
465 | for (ulCounter = 0;
|
---|
466 | ulCounter < CONSOLE_INPUTQUEUESIZE;
|
---|
467 | ulCounter++)
|
---|
468 | pConsoleInput->arrInputRecord[ulCounter].EventType = 0x0000; /* free event */
|
---|
469 |
|
---|
470 | return (TRUE);
|
---|
471 | }
|
---|
472 |
|
---|
473 |
|
---|
474 | /*****************************************************************************
|
---|
475 | * Name : DWORD HMDeviceConsoleInClass::GetConsoleMode
|
---|
476 | * Purpose : queries the current console mode
|
---|
477 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
478 | * LPDWORD lpMode
|
---|
479 | * Variables :
|
---|
480 | * Result :
|
---|
481 |
|
---|
482 | * Remark :
|
---|
483 | * Status : UNTESTED
|
---|
484 | *
|
---|
485 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
486 | *****************************************************************************/
|
---|
487 |
|
---|
488 | DWORD HMDeviceConsoleInClass::GetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
---|
489 | LPDWORD lpMode)
|
---|
490 | {
|
---|
491 | #ifdef DEBUG_LOCAL2
|
---|
492 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetConsoleMode(%08x,%08x).\n",
|
---|
493 | pHMHandleData,
|
---|
494 | lpMode);
|
---|
495 | #endif
|
---|
496 |
|
---|
497 | *lpMode = pConsoleInput->dwConsoleMode; /* return current console mode */
|
---|
498 |
|
---|
499 | return (TRUE);
|
---|
500 | }
|
---|
501 |
|
---|
502 |
|
---|
503 | /*****************************************************************************
|
---|
504 | * Name : DWORD HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents
|
---|
505 | * Purpose : queries the current number of events in the input queue
|
---|
506 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
507 | * LPDWORD lpNumberOfEvents - return number of events
|
---|
508 | * Variables :
|
---|
509 | * Result :
|
---|
510 | * Remark :
|
---|
511 | * Status : UNTESTED
|
---|
512 | *
|
---|
513 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
514 | *****************************************************************************/
|
---|
515 |
|
---|
516 | BOOL HMDeviceConsoleInClass::GetNumberOfConsoleInputEvents(PHMHANDLEDATA pHMHandleData,
|
---|
517 | LPDWORD lpNumberOfEvents)
|
---|
518 | {
|
---|
519 | #ifdef DEBUG_LOCAL2
|
---|
520 | WriteLog("KERNEL32/CONSOLE: CONIN$::GetNumberOfConsoleInputEvents(%08x,%08x).\n",
|
---|
521 | pHMHandleData,
|
---|
522 | lpNumberOfEvents);
|
---|
523 | #endif
|
---|
524 |
|
---|
525 | //get all pending events and return number of events
|
---|
526 | *lpNumberOfEvents = iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_PEEK);
|
---|
527 |
|
---|
528 | return (TRUE);
|
---|
529 | }
|
---|
530 |
|
---|
531 |
|
---|
532 | /*****************************************************************************
|
---|
533 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputA
|
---|
534 | * Purpose : peeks events placed in the console input queue
|
---|
535 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
536 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
537 | * DWORD cInRecords - number of input records
|
---|
538 | * LPDWORD lpcRead - returns number of events stored
|
---|
539 | * Variables :
|
---|
540 | * Result : TRUE if successful, FALSE otherwise
|
---|
541 | * Remark : if queue is completely filled and no event is free,
|
---|
542 | * loop will scan over queue multiple times, until target
|
---|
543 | * buffer is filled. It does not check ulCounter to stop
|
---|
544 | * when one scan of the queue is complete.
|
---|
545 | * Status : UNTESTED
|
---|
546 | *
|
---|
547 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
548 | *****************************************************************************/
|
---|
549 |
|
---|
550 | DWORD HMDeviceConsoleInClass::PeekConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
---|
551 | PINPUT_RECORD pirBuffer,
|
---|
552 | DWORD cInRecords,
|
---|
553 | LPDWORD lpcRead)
|
---|
554 | {
|
---|
555 | ULONG ulCounter; /* loop counter */
|
---|
556 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
---|
557 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
---|
558 |
|
---|
559 | #ifdef DEBUG_LOCAL2
|
---|
560 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
---|
561 | pHMHandleData,
|
---|
562 | pirBuffer,
|
---|
563 | cInRecords,
|
---|
564 | lpcRead);
|
---|
565 | #endif
|
---|
566 |
|
---|
567 | if (iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_PEEK) == 0) /* if queue is currently empty */
|
---|
568 | {
|
---|
569 | *lpcRead = 0; /* no events read from queue */
|
---|
570 | return (TRUE); /* OK, we're done */
|
---|
571 | }
|
---|
572 |
|
---|
573 |
|
---|
574 | for (ulCounter = 0,
|
---|
575 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
---|
576 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
---|
577 |
|
---|
578 | ulCounter < cInRecords;
|
---|
579 |
|
---|
580 | ulCounter++,
|
---|
581 | ulCurrentEvent++,
|
---|
582 | pirEvent++,
|
---|
583 | pirBuffer++)
|
---|
584 | {
|
---|
585 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
---|
586 | {
|
---|
587 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
---|
588 | pirEvent = pConsoleInput->arrInputRecord;
|
---|
589 | }
|
---|
590 |
|
---|
591 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
---|
592 | break; /* leave loop then */
|
---|
593 |
|
---|
594 | memcpy(pirEvent, /* copy event data */
|
---|
595 | pirBuffer,
|
---|
596 | sizeof(INPUT_RECORD));
|
---|
597 | }
|
---|
598 |
|
---|
599 | *lpcRead = ulCounter; /* return number of events read */
|
---|
600 | return (TRUE); /* OK, we're done */
|
---|
601 | }
|
---|
602 |
|
---|
603 |
|
---|
604 | /*****************************************************************************
|
---|
605 | * Name : DWORD HMDeviceConsoleInClass::PeekConsoleInputW
|
---|
606 | * Purpose : peeks events placed in the console input queue
|
---|
607 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
608 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
609 | * DWORD cInRecords - number of input records
|
---|
610 | * LPDWORD lpcRead - returns number of events stored
|
---|
611 | * Variables :
|
---|
612 | * Result : TRUE if successful, FALSE otherwise
|
---|
613 | * Remark : if queue is completely filled and no event is free,
|
---|
614 | * loop will scan over queue multiple times, until target
|
---|
615 | * buffer is filled. It does not check ulCounter to stop
|
---|
616 | * when one scan of the queue is complete.
|
---|
617 | * Status : UNTESTED
|
---|
618 | *
|
---|
619 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
620 | *****************************************************************************/
|
---|
621 |
|
---|
622 | DWORD HMDeviceConsoleInClass::PeekConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
---|
623 | PINPUT_RECORD pirBuffer,
|
---|
624 | DWORD cInRecords,
|
---|
625 | LPDWORD lpcRead)
|
---|
626 | {
|
---|
627 | ULONG ulCounter; /* loop counter */
|
---|
628 | ULONG ulCurrentEvent; /* index of current event in the queue */
|
---|
629 | PINPUT_RECORD pirEvent; /* pointer to current queue element */
|
---|
630 |
|
---|
631 | #ifdef DEBUG_LOCAL2
|
---|
632 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::PeekConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
---|
633 | pHMHandleData,
|
---|
634 | pirBuffer,
|
---|
635 | cInRecords,
|
---|
636 | lpcRead);
|
---|
637 | #endif
|
---|
638 |
|
---|
639 | if (iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_PEEK) == 0) /* if queue is currently empty */
|
---|
640 | {
|
---|
641 | *lpcRead = 0; /* no events read from queue */
|
---|
642 | return (TRUE); /* OK, we're done */
|
---|
643 | }
|
---|
644 |
|
---|
645 |
|
---|
646 | for (ulCounter = 0,
|
---|
647 | ulCurrentEvent = pConsoleInput->ulIndexEvent,
|
---|
648 | pirEvent = &pConsoleInput->arrInputRecord[pConsoleInput->ulIndexEvent];
|
---|
649 |
|
---|
650 | ulCounter < cInRecords;
|
---|
651 |
|
---|
652 | ulCounter++,
|
---|
653 | ulCurrentEvent++,
|
---|
654 | pirEvent++,
|
---|
655 | pirBuffer++)
|
---|
656 | {
|
---|
657 | if (ulCurrentEvent > CONSOLE_INPUTQUEUESIZE) /* reaching after end of que*/
|
---|
658 | {
|
---|
659 | ulCurrentEvent = 0; /* then start over from beginning of queue */
|
---|
660 | pirEvent = pConsoleInput->arrInputRecord;
|
---|
661 | }
|
---|
662 |
|
---|
663 | if (pirEvent->EventType == 0x0000) /* no more events ? */
|
---|
664 | break; /* leave loop then */
|
---|
665 |
|
---|
666 | memcpy(pirEvent, /* copy event data */
|
---|
667 | pirBuffer,
|
---|
668 | sizeof(INPUT_RECORD));
|
---|
669 | }
|
---|
670 |
|
---|
671 | *lpcRead = ulCounter; /* return number of events read */
|
---|
672 | return (TRUE); /* OK, we're done */
|
---|
673 | }
|
---|
674 |
|
---|
675 |
|
---|
676 | /*****************************************************************************
|
---|
677 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleA
|
---|
678 | * Purpose : read a string from the console
|
---|
679 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
680 | * LPWORD lpwAttribute
|
---|
681 | * DWORD cWriteCells
|
---|
682 | * COORD dwWriteCoord
|
---|
683 | * LPDWORD lpcWritten
|
---|
684 | * Variables :
|
---|
685 | * Result :
|
---|
686 | * Remark :
|
---|
687 | * Status : UNTESTED
|
---|
688 | *
|
---|
689 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
690 | *****************************************************************************/
|
---|
691 |
|
---|
692 | DWORD HMDeviceConsoleInClass::ReadConsoleA(PHMHANDLEDATA pHMHandleData,
|
---|
693 | CONST VOID* lpvBuffer,
|
---|
694 | DWORD cchToRead,
|
---|
695 | LPDWORD lpcchRead,
|
---|
696 | LPVOID lpvReserved)
|
---|
697 | {
|
---|
698 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
699 |
|
---|
700 | #ifdef DEBUG_LOCAL2
|
---|
701 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleA(%08x,%08x,%u,%08x,%08x).\n",
|
---|
702 | pHMHandleData,
|
---|
703 | lpvBuffer,
|
---|
704 | cchToRead,
|
---|
705 | lpcchRead,
|
---|
706 | lpvReserved);
|
---|
707 | #endif
|
---|
708 |
|
---|
709 | /* simply forward the request to that routine */
|
---|
710 | return (HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
---|
711 | lpvBuffer,
|
---|
712 | cchToRead,
|
---|
713 | lpcchRead,
|
---|
714 | NULL, NULL));
|
---|
715 | }
|
---|
716 |
|
---|
717 | /*****************************************************************************
|
---|
718 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleW
|
---|
719 | * Purpose : write a string to the console
|
---|
720 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
721 | * LPWORD lpwAttribute
|
---|
722 | * DWORD cWriteCells
|
---|
723 | * COORD dwWriteCoord
|
---|
724 | * LPDWORD lpcWritten
|
---|
725 | * Variables :
|
---|
726 | * Result :
|
---|
727 | * Remark :
|
---|
728 | * Status : UNTESTED
|
---|
729 | *
|
---|
730 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
731 | *****************************************************************************/
|
---|
732 |
|
---|
733 | DWORD HMDeviceConsoleInClass::ReadConsoleW(PHMHANDLEDATA pHMHandleData,
|
---|
734 | CONST VOID* lpvBuffer,
|
---|
735 | DWORD cchToRead,
|
---|
736 | LPDWORD lpcchRead,
|
---|
737 | LPVOID lpvReserved)
|
---|
738 | {
|
---|
739 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
740 | DWORD dwResult;
|
---|
741 | LPSTR lpstrAscii;
|
---|
742 |
|
---|
743 | #ifdef DEBUG_LOCAL2
|
---|
744 | WriteLog("KERNEL32/CONSOLE: CONIN$::ReadConsoleW(%08x,%08x,%u,%08x,%08x).\n",
|
---|
745 | pHMHandleData,
|
---|
746 | lpvBuffer,
|
---|
747 | cchToRead,
|
---|
748 | lpcchRead,
|
---|
749 | lpvReserved);
|
---|
750 | #endif
|
---|
751 |
|
---|
752 | // create ascii buffer
|
---|
753 | lpstrAscii = (LPSTR)HEAP_malloc(cchToRead);
|
---|
754 | if (lpstrAscii == NULL)
|
---|
755 | return ERROR_NOT_ENOUGH_MEMORY;
|
---|
756 |
|
---|
757 | /* simply forward the request to that routine */
|
---|
758 | dwResult = HMDeviceConsoleInClass::ReadFile(pHMHandleData,
|
---|
759 | lpstrAscii,
|
---|
760 | cchToRead,
|
---|
761 | lpcchRead,
|
---|
762 | NULL, NULL);
|
---|
763 |
|
---|
764 | /* Ascii -> unicode translation */
|
---|
765 | if (dwResult == TRUE)
|
---|
766 | lstrcpynAtoW((LPWSTR)lpvBuffer, lpstrAscii, min(cchToRead, *lpcchRead+1));
|
---|
767 |
|
---|
768 | HEAP_free(lpstrAscii);
|
---|
769 |
|
---|
770 | return (dwResult); /* deliver return code */
|
---|
771 | }
|
---|
772 |
|
---|
773 |
|
---|
774 | /*****************************************************************************
|
---|
775 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputA
|
---|
776 | * Purpose : read events placed in the console input queue
|
---|
777 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
778 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
779 | * DWORD cInRecords - number of input records
|
---|
780 | * LPDWORD lpcRead - returns number of events stored
|
---|
781 | * Variables :
|
---|
782 | * Result : TRUE if successful, FALSE otherwise
|
---|
783 | * Remark :
|
---|
784 | * Status : UNTESTED
|
---|
785 | *
|
---|
786 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
787 | *****************************************************************************/
|
---|
788 |
|
---|
789 | DWORD HMDeviceConsoleInClass::ReadConsoleInputA(PHMHANDLEDATA pHMHandleData,
|
---|
790 | PINPUT_RECORD pirBuffer,
|
---|
791 | DWORD cInRecords,
|
---|
792 | LPDWORD lpcRead)
|
---|
793 | {
|
---|
794 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
---|
795 | APIRET rc; /* API returncode */
|
---|
796 |
|
---|
797 | #ifdef DEBUG_LOCAL2
|
---|
798 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputA(%08x,%08x,%08x,%08x).\n",
|
---|
799 | pHMHandleData,
|
---|
800 | pirBuffer,
|
---|
801 | cInRecords,
|
---|
802 | lpcRead);
|
---|
803 | #endif
|
---|
804 |
|
---|
805 | iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_WAIT);
|
---|
806 |
|
---|
807 | /* now read events into target buffer */
|
---|
808 | for (ulPostCounter = 0;
|
---|
809 | ulPostCounter < cInRecords;
|
---|
810 | ulPostCounter++,
|
---|
811 | pirBuffer++)
|
---|
812 | {
|
---|
813 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
---|
814 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
---|
815 | break;
|
---|
816 | }
|
---|
817 |
|
---|
818 | *lpcRead = ulPostCounter; /* return number of records read */
|
---|
819 | return (TRUE); /* OK */
|
---|
820 | }
|
---|
821 |
|
---|
822 |
|
---|
823 | /*****************************************************************************
|
---|
824 | * Name : DWORD HMDeviceConsoleInClass::ReadConsoleInputW
|
---|
825 | * Purpose : read events placed in the console input queue
|
---|
826 | * Parameters: PHMHANDLEDATA pHMHandleData - current handle data
|
---|
827 | * PINPUT_RECORD pirBuffer - target buffer for events
|
---|
828 | * DWORD cInRecords - number of input records
|
---|
829 | * LPDWORD lpcRead - returns number of events stored
|
---|
830 | * Variables :
|
---|
831 | * Result : TRUE if successful, FALSE otherwise
|
---|
832 | * Remark :
|
---|
833 | * Status : UNTESTED
|
---|
834 | *
|
---|
835 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
836 | *****************************************************************************/
|
---|
837 |
|
---|
838 | DWORD HMDeviceConsoleInClass::ReadConsoleInputW(PHMHANDLEDATA pHMHandleData,
|
---|
839 | PINPUT_RECORD pirBuffer,
|
---|
840 | DWORD cInRecords,
|
---|
841 | LPDWORD lpcRead)
|
---|
842 | {
|
---|
843 | ULONG ulPostCounter; /* semaphore post counter - ignored */
|
---|
844 | APIRET rc; /* API returncode */
|
---|
845 |
|
---|
846 | #ifdef DEBUG_LOCAL2
|
---|
847 | WriteLog("KERNEL32/CONSOLE: HMDeviceConsoleInClass::ReadConsoleInputW(%08x,%08x,%08x,%08x).\n",
|
---|
848 | pHMHandleData,
|
---|
849 | pirBuffer,
|
---|
850 | cInRecords,
|
---|
851 | lpcRead);
|
---|
852 | #endif
|
---|
853 |
|
---|
854 | iConsoleInputQueryEvents(pConsoleInput, QUERY_EVENT_WAIT);
|
---|
855 |
|
---|
856 | /* now read events into target buffer */
|
---|
857 | for (ulPostCounter = 0;
|
---|
858 | ulPostCounter < cInRecords;
|
---|
859 | ulPostCounter++,
|
---|
860 | pirBuffer++)
|
---|
861 | {
|
---|
862 | rc = iConsoleInputEventPop(pirBuffer); /* get event from queue */
|
---|
863 | if (rc != NO_ERROR) /* if read error occurs, break look */
|
---|
864 | break;
|
---|
865 | }
|
---|
866 |
|
---|
867 | *lpcRead = ulPostCounter; /* return number of records read */
|
---|
868 | return (TRUE); /* OK */
|
---|
869 | }
|
---|
870 |
|
---|
871 |
|
---|
872 | /*****************************************************************************
|
---|
873 | * Name : DWORD HMDeviceConsoleInClass::SetConsoleMode
|
---|
874 | * Purpose : sets the current console mode
|
---|
875 | * Parameters: PHMHANDLEDATA pHMHandleData - handle specific data
|
---|
876 | * DWORD dwMode - console mode
|
---|
877 | * Variables :
|
---|
878 | * Result :
|
---|
879 | * Remark :
|
---|
880 | * Status : UNTESTED
|
---|
881 | *
|
---|
882 | * Author : Patrick Haller [Wed, 1998/02/16 11:46]
|
---|
883 | *****************************************************************************/
|
---|
884 |
|
---|
885 | DWORD HMDeviceConsoleInClass::SetConsoleMode(PHMHANDLEDATA pHMHandleData,
|
---|
886 | DWORD dwMode)
|
---|
887 | {
|
---|
888 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
889 |
|
---|
890 | #ifdef DEBUG_LOCAL2
|
---|
891 | WriteLog("KERNEL32/CONSOLE: CONIN$::SetConsoleMode(%08x,%08x).\n",
|
---|
892 | pHMHandleData,
|
---|
893 | dwMode);
|
---|
894 | #endif
|
---|
895 |
|
---|
896 | pConsoleInput->dwConsoleMode = dwMode; /* set current console mode */
|
---|
897 |
|
---|
898 | return (TRUE);
|
---|
899 | }
|
---|
900 |
|
---|
901 |
|
---|
902 | /*****************************************************************************
|
---|
903 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputA
|
---|
904 | * Purpose : this writes event records directly into the queue
|
---|
905 | * Parameters: PHMHANDLEDATA pHMHandleData
|
---|
906 | * PINPUT_RECORD pirBuffer
|
---|
907 | * DWORD cInRecords
|
---|
908 | * LPDWORD lpcWritten
|
---|
909 | * Variables :
|
---|
910 | * Result :
|
---|
911 | * Remark :
|
---|
912 | * Status : NO_ERROR - API succeeded
|
---|
913 | * other - what is to be set in SetLastError
|
---|
914 | *
|
---|
915 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
916 | *****************************************************************************/
|
---|
917 |
|
---|
918 | DWORD HMDeviceConsoleInClass::WriteConsoleInputA (PHMHANDLEDATA pHMHandleData,
|
---|
919 | PINPUT_RECORD pirBuffer,
|
---|
920 | DWORD cInRecords,
|
---|
921 | LPDWORD lpcWritten)
|
---|
922 | {
|
---|
923 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
924 | APIRET rc; /* API returncode */
|
---|
925 | ULONG ulCounter; /* loop counter */
|
---|
926 |
|
---|
927 | #ifdef DEBUG_LOCAL2
|
---|
928 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputA(%08x,%08x,%u,%08x).\n",
|
---|
929 | pHMHandleData,
|
---|
930 | pirBuffer,
|
---|
931 | cInRecords,
|
---|
932 | lpcWritten);
|
---|
933 | #endif
|
---|
934 |
|
---|
935 | for (ulCounter = 0;
|
---|
936 | ulCounter < cInRecords;
|
---|
937 | ulCounter++,
|
---|
938 | pirBuffer++)
|
---|
939 | {
|
---|
940 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
---|
941 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
---|
942 | break;
|
---|
943 | }
|
---|
944 |
|
---|
945 | *lpcWritten = ulCounter; /* return number of events written */
|
---|
946 | return (TRUE); /* OK */
|
---|
947 | }
|
---|
948 |
|
---|
949 |
|
---|
950 | /*****************************************************************************
|
---|
951 | * Name : DWORD HMDeviceConsoleInClass::WriteConsoleInputW
|
---|
952 | * Purpose : this writes event records directly into the queue
|
---|
953 | * Parameters: PHMHANDLEDATA pHMHandleData
|
---|
954 | * PINPUT_RECORD pirBuffer
|
---|
955 | * DWORD cInRecords
|
---|
956 | * LPDWORD lpcWritten
|
---|
957 | * Variables :
|
---|
958 | * Result :
|
---|
959 | * Remark :
|
---|
960 | * Status : NO_ERROR - API succeeded
|
---|
961 | * other - what is to be set in SetLastError
|
---|
962 | *
|
---|
963 | * Author : Patrick Haller [Wed, 1998/02/11 20:44]
|
---|
964 | *****************************************************************************/
|
---|
965 |
|
---|
966 | DWORD HMDeviceConsoleInClass::WriteConsoleInputW (PHMHANDLEDATA pHMHandleData,
|
---|
967 | PINPUT_RECORD pirBuffer,
|
---|
968 | DWORD cInRecords,
|
---|
969 | LPDWORD lpcWritten)
|
---|
970 | {
|
---|
971 | PCONSOLEBUFFER pConsoleBuffer = (PCONSOLEBUFFER)pHMHandleData->lpHandlerData;
|
---|
972 | APIRET rc; /* API returncode */
|
---|
973 | ULONG ulCounter; /* loop counter */
|
---|
974 |
|
---|
975 | #ifdef DEBUG_LOCAL2
|
---|
976 | WriteLog("KERNEL32/CONSOLE: CONIN$::WriteConsoleInputW(%08x,%08x,%u,%08x).\n",
|
---|
977 | pHMHandleData,
|
---|
978 | pirBuffer,
|
---|
979 | cInRecords,
|
---|
980 | lpcWritten);
|
---|
981 | #endif
|
---|
982 |
|
---|
983 | for (ulCounter = 0;
|
---|
984 | ulCounter < cInRecords;
|
---|
985 | ulCounter++,
|
---|
986 | pirBuffer++)
|
---|
987 | {
|
---|
988 | rc = iConsoleInputEventPush(pirBuffer); /* push current event */
|
---|
989 | if (rc != NO_ERROR) /* oops ? queue full ? problem ? */
|
---|
990 | break;
|
---|
991 | }
|
---|
992 |
|
---|
993 | *lpcWritten = ulCounter; /* return number of events written */
|
---|
994 | return (TRUE); /* OK */
|
---|
995 | }
|
---|
996 |
|
---|
997 |
|
---|