2 * Win32 kernel functions
4 * Copyright 1995 Martin von Loewis and Cameron Heide
5 * Copyright 1997 Karl Garrison
6 * Copyright 1998 John Richardson
7 * Copyright 1998 Marcus Meissner
11 * - Completely lacks SCREENBUFFER interface.
12 * - No abstraction for something other than xterm.
13 * - Key input translation shouldn't use VkKeyScan and MapVirtualKey, since
14 * they are window (USER) driver dependend.
15 * - Output sometimes is buffered (We switched off buffering by ~ICANON ?)
17 /* Reference applications:
18 * - IDA (interactive disassembler) full version 3.75. Works.
19 * - LYNX/W32. Works mostly, some keys crash it.
26 #include <sys/ioctl.h>
27 #include <sys/types.h>
32 #include <sys/errno.h>
47 #include "server/request.h"
50 /* The CONSOLE kernel32 Object */
51 typedef struct _CONSOLE
{
54 CONSOLE_CURSOR_INFO cinfo
;
56 int master
; /* xterm side of pty */
58 int hread
, hwrite
; /* server handles (hack) */
59 int pid
; /* xterm's pid, -1 if no xterm */
60 LPSTR title
; /* title of console */
61 INPUT_RECORD
*irs
; /* buffered input records */
62 int nrofirs
;/* nr of buffered input records */
63 THREAD_QUEUE wait_queue
;
66 static void CONSOLE_AddWait(K32OBJ
*ptr
, DWORD thread_id
);
67 static void CONSOLE_RemoveWait(K32OBJ
*ptr
, DWORD thread_id
);
68 static BOOL32
CONSOLE_Satisfied(K32OBJ
*ptr
, DWORD thread_id
);
69 static BOOL32
CONSOLE_Signaled(K32OBJ
*ptr
, DWORD thread_id
);
70 static void CONSOLE_Destroy( K32OBJ
*obj
);
71 static BOOL32
CONSOLE_Write(K32OBJ
*ptr
, LPCVOID lpBuffer
,
72 DWORD nNumberOfChars
, LPDWORD lpNumberOfChars
,
73 LPOVERLAPPED lpOverlapped
);
74 static BOOL32
CONSOLE_Read(K32OBJ
*ptr
, LPVOID lpBuffer
,
75 DWORD nNumberOfChars
, LPDWORD lpNumberOfChars
,
76 LPOVERLAPPED lpOverlapped
);
78 const K32OBJ_OPS CONSOLE_Ops
=
80 CONSOLE_Signaled
, /* signaled */
81 CONSOLE_Satisfied
, /* satisfied */
82 CONSOLE_AddWait
, /* add_wait */
83 CONSOLE_RemoveWait
, /* remove_wait */
84 CONSOLE_Read
, /* read */
85 CONSOLE_Write
, /* write */
86 CONSOLE_Destroy
/* destroy */
89 /***********************************************************************
92 static void CONSOLE_Destroy(K32OBJ
*obj
)
94 CONSOLE
*console
= (CONSOLE
*)obj
;
95 assert(obj
->type
== K32OBJ_CONSOLE
);
97 obj
->type
= K32OBJ_UNKNOWN
;
100 HeapFree( SystemHeap
, 0, console
->title
);
101 console
->title
= NULL
;
102 /* if there is a xterm, kill it. */
103 if (console
->pid
!= -1)
104 kill(console
->pid
, SIGTERM
);
105 HeapFree(SystemHeap
, 0, console
);
109 /***********************************************************************
113 * lpOverlapped is ignored
115 static BOOL32
CONSOLE_Read(K32OBJ
*ptr
, LPVOID lpBuffer
, DWORD nNumberOfChars
,
116 LPDWORD lpNumberOfChars
, LPOVERLAPPED lpOverlapped
)
118 CONSOLE
*console
= (CONSOLE
*)ptr
;
121 TRACE(console
, "%p %p %ld\n", ptr
, lpBuffer
, nNumberOfChars
);
122 *lpNumberOfChars
= 0;
123 if ((result
= read(console
->infd
, lpBuffer
, nNumberOfChars
)) == -1) {
127 *lpNumberOfChars
= result
;
132 /***********************************************************************
136 * lpOverlapped is ignored
138 static BOOL32
CONSOLE_Write(K32OBJ
*ptr
, LPCVOID lpBuffer
,
139 DWORD nNumberOfChars
,
140 LPDWORD lpNumberOfChars
, LPOVERLAPPED lpOverlapped
)
142 CONSOLE
*console
= (CONSOLE
*)ptr
;
145 TRACE(console
, "%p %p %ld\n", ptr
, lpBuffer
, nNumberOfChars
);
146 *lpNumberOfChars
= 0;
148 * I assume this loop around EAGAIN is here because
149 * win32 doesn't have interrupted system calls
154 result
= write(console
->outfd
, lpBuffer
, nNumberOfChars
);
156 *lpNumberOfChars
= result
;
159 if (errno
!= EINTR
) {
166 /****************************************************************************
167 * CONSOLE_add_input_record [internal]
169 * Adds an INPUT_RECORD to the CONSOLEs input queue.
172 CONSOLE_add_input_record(CONSOLE
*console
,INPUT_RECORD
*inp
) {
173 console
->irs
= HeapReAlloc(GetProcessHeap(),0,console
->irs
,sizeof(INPUT_RECORD
)*(console
->nrofirs
+1));
174 console
->irs
[console
->nrofirs
++]=*inp
;
177 /****************************************************************************
178 * XTERM_string_to_IR [internal]
180 * Transfers a string read from XTERM to INPUT_RECORDs and adds them to the
181 * queue. Does translation of vt100 style function keys and xterm-mouse clicks.
184 CONSOLE_string_to_IR(CONSOLE
*console
,unsigned char *buf
,int len
) {
188 for (j
=0;j
<len
;j
++) {
189 unsigned char inchar
= buf
[j
];
191 if (inchar
!=27) { /* no escape -> 'normal' keyboard event */
192 ir
.EventType
= 1; /* Key_event */
194 ir
.Event
.KeyEvent
.bKeyDown
= 1;
195 ir
.Event
.KeyEvent
.wRepeatCount
= 0;
197 ir
.Event
.KeyEvent
.dwControlKeyState
= 0;
199 ir
.Event
.KeyEvent
.dwControlKeyState
|=LEFT_ALT_PRESSED
;
202 ir
.Event
.KeyEvent
.wVirtualKeyCode
= VkKeyScan16(inchar
);
203 if (ir
.Event
.KeyEvent
.wVirtualKeyCode
& 0x0100)
204 ir
.Event
.KeyEvent
.dwControlKeyState
|=SHIFT_PRESSED
;
205 if (ir
.Event
.KeyEvent
.wVirtualKeyCode
& 0x0200)
206 ir
.Event
.KeyEvent
.dwControlKeyState
|=LEFT_CTRL_PRESSED
;
207 if (ir
.Event
.KeyEvent
.wVirtualKeyCode
& 0x0400)
208 ir
.Event
.KeyEvent
.dwControlKeyState
|=LEFT_ALT_PRESSED
;
209 ir
.Event
.KeyEvent
.wVirtualScanCode
= MapVirtualKey16(
210 ir
.Event
.KeyEvent
.wVirtualKeyCode
& 0x00ff,
211 0 /* VirtualKeyCodes to ScanCode */
214 ir
.Event
.KeyEvent
.uChar
.AsciiChar
= '\r';
215 ir
.Event
.KeyEvent
.wVirtualKeyCode
= 0x0d;
216 ir
.Event
.KeyEvent
.wVirtualScanCode
= 0x1c;
218 ir
.Event
.KeyEvent
.uChar
.AsciiChar
= inchar
;
220 /* FIXME: find good values for ^X */
221 ir
.Event
.KeyEvent
.wVirtualKeyCode
= 0xdead;
222 ir
.Event
.KeyEvent
.wVirtualScanCode
= 0xbeef;
226 CONSOLE_add_input_record(console
,&ir
);
227 ir
.Event
.KeyEvent
.bKeyDown
= 0;
228 CONSOLE_add_input_record(console
,&ir
);
232 if ((j
==len
-1) || (buf
[j
+1]!='[')) {/* add ESCape on its own */
233 ir
.EventType
= 1; /* Key_event */
234 ir
.Event
.KeyEvent
.bKeyDown
= 1;
235 ir
.Event
.KeyEvent
.wRepeatCount
= 0;
237 ir
.Event
.KeyEvent
.wVirtualKeyCode
= VkKeyScan16(27);
238 ir
.Event
.KeyEvent
.wVirtualScanCode
= MapVirtualKey16(
239 ir
.Event
.KeyEvent
.wVirtualKeyCode
,0
241 ir
.Event
.KeyEvent
.dwControlKeyState
= 0;
242 ir
.Event
.KeyEvent
.uChar
.AsciiChar
= 27;
243 CONSOLE_add_input_record(console
,&ir
);
244 ir
.Event
.KeyEvent
.bKeyDown
= 0;
245 CONSOLE_add_input_record(console
,&ir
);
248 for (k
=j
;k
<len
;k
++) {
249 if (((buf
[k
]>='A') && (buf
[k
]<='Z')) ||
250 ((buf
[k
]>='a') && (buf
[k
]<='z')) ||
256 int subid
,scancode
=0;
258 ir
.EventType
= 1; /* Key_event */
259 ir
.Event
.KeyEvent
.bKeyDown
= 1;
260 ir
.Event
.KeyEvent
.wRepeatCount
= 0;
261 ir
.Event
.KeyEvent
.dwControlKeyState
= 0;
263 ir
.Event
.KeyEvent
.wVirtualKeyCode
= 0xad; /* FIXME */
264 ir
.Event
.KeyEvent
.wVirtualScanCode
= 0xad; /* FIXME */
265 ir
.Event
.KeyEvent
.uChar
.AsciiChar
= 0;
269 sscanf(&buf
[j
+2],"%d",&subid
);
271 case 2:/*INS */scancode
= 0xe052;break;
272 case 3:/*DEL */scancode
= 0xe053;break;
273 case 6:/*PGDW*/scancode
= 0xe051;break;
274 case 5:/*PGUP*/scancode
= 0xe049;break;
275 case 11:/*F1 */scancode
= 0x003b;break;
276 case 12:/*F2 */scancode
= 0x003c;break;
277 case 13:/*F3 */scancode
= 0x003d;break;
278 case 14:/*F4 */scancode
= 0x003e;break;
279 case 15:/*F5 */scancode
= 0x003f;break;
280 case 17:/*F6 */scancode
= 0x0040;break;
281 case 18:/*F7 */scancode
= 0x0041;break;
282 case 19:/*F8 */scancode
= 0x0042;break;
283 case 20:/*F9 */scancode
= 0x0043;break;
284 case 21:/*F10 */scancode
= 0x0044;break;
285 case 23:/*F11 */scancode
= 0x00d9;break;
286 case 24:/*F12 */scancode
= 0x00da;break;
287 /* FIXME: Shift-Fx */
289 FIXME(console
,"parse ESC[%d~\n",subid
);
293 case 'A': /* Cursor Up */scancode
= 0xe048;break;
294 case 'B': /* Cursor Down */scancode
= 0xe050;break;
295 case 'D': /* Cursor Left */scancode
= 0xe04b;break;
296 case 'C': /* Cursor Right */scancode
= 0xe04d;break;
297 case 'F': /* End */scancode
= 0xe04f;break;
298 case 'H': /* Home */scancode
= 0xe047;break;
300 /* Mouse Button Press (ESCM<button+'!'><x+'!'><y+'!'>) or
301 * Release (ESCM#<x+'!'><y+'!'>
304 ir
.EventType
= MOUSE_EVENT
;
305 ir
.Event
.MouseEvent
.dwMousePosition
.x
= buf
[k
+2]-'!';
306 ir
.Event
.MouseEvent
.dwMousePosition
.y
= buf
[k
+3]-'!';
308 ir
.Event
.MouseEvent
.dwButtonState
= 0;
310 ir
.Event
.MouseEvent
.dwButtonState
= 1<<(buf
[k
+1]-' ');
311 ir
.Event
.MouseEvent
.dwEventFlags
= 0; /* FIXME */
312 CONSOLE_add_input_record(console
,&ir
);
319 ir
.Event
.KeyEvent
.wVirtualScanCode
= scancode
;
320 ir
.Event
.KeyEvent
.wVirtualKeyCode
= MapVirtualKey16(scancode
,1);
321 CONSOLE_add_input_record(console
,&ir
);
322 ir
.Event
.KeyEvent
.bKeyDown
= 0;
323 CONSOLE_add_input_record(console
,&ir
);
330 /****************************************************************************
331 * CONSOLE_get_input (internal)
333 * Reads (nonblocking) as much input events as possible and stores them
334 * in an internal queue.
335 * (not necessarily XTERM dependend, but UNIX filedescriptor...)
338 CONSOLE_get_input(CONSOLE
*console
) {
339 char *buf
= HeapAlloc(GetProcessHeap(),0,1);
349 FD_SET(console
->infd
,&infds
);
350 memset(&tv
,0,sizeof(tv
));
351 if (select(console
->infd
+1,&infds
,NULL
,NULL
,&tv
)<1)
352 break; /* no input there */
354 if (!FD_ISSET(console
->infd
,&infds
))
356 if (!CONSOLE_Read((K32OBJ
*)console
,&inchar
,1,&res
,NULL
))
358 buf
= HeapReAlloc(GetProcessHeap(),0,buf
,len
+1);
361 CONSOLE_string_to_IR(console
,buf
,len
);
362 HeapFree(GetProcessHeap(),0,buf
);
365 /****************************************************************************
366 * CONSOLE_drain_input (internal)
368 * Drains 'n' console input events from the queue.
371 CONSOLE_drain_input(CONSOLE
*console
,int n
) {
372 assert(n
<=console
->nrofirs
);
375 memcpy( &console
->irs
[0],
377 console
->nrofirs
*sizeof(INPUT_RECORD
)
379 console
->irs
= HeapReAlloc(
383 console
->nrofirs
*sizeof(INPUT_RECORD
)
388 /***********************************************************************
389 * CONSOLE_async_handler [internal]
392 CONSOLE_async_handler(int unixfd
,void *private) {
393 CONSOLE
*console
= (CONSOLE
*)private;
395 SYNC_WakeUp(&console
->wait_queue
,INFINITE32
);
398 /***********************************************************************
399 * CONSOLE_Signaled [internal]
401 * Checks if we can read something. (Hmm, what about writing ?)
404 CONSOLE_Signaled(K32OBJ
*ptr
,DWORD tid
) {
405 CONSOLE
*console
=(CONSOLE
*)ptr
;
407 if (ptr
->type
!= K32OBJ_CONSOLE
)
409 CONSOLE_get_input(console
);
410 if (console
->nrofirs
!=0)
416 /***********************************************************************
417 * CONSOLE_AddWait [internal]
419 * Add thread to our waitqueue (so we can signal it if we have input).
421 static void CONSOLE_AddWait(K32OBJ
*ptr
, DWORD thread_id
)
423 CONSOLE
*console
= (CONSOLE
*)ptr
;
425 /* register our unix filedescriptors for async IO */
426 if (!console
->wait_queue
)
427 ASYNC_RegisterFD(console
->infd
,CONSOLE_async_handler
,console
);
428 THREAD_AddQueue( &console
->wait_queue
, THREAD_ID_TO_THDB(thread_id
) );
431 /***********************************************************************
432 * CONSOLE_RemoveWait [internal]
434 * Remove thread from our waitqueue.
436 static void CONSOLE_RemoveWait(K32OBJ
*ptr
, DWORD thread_id
)
438 CONSOLE
*console
= (CONSOLE
*)ptr
;
440 THREAD_RemoveQueue( &console
->wait_queue
, THREAD_ID_TO_THDB(thread_id
) );
441 if (!console
->wait_queue
)
442 ASYNC_UnregisterFD(console
->infd
,CONSOLE_async_handler
);
445 /***********************************************************************
446 * CONSOLE_Satisfied [internal]
448 * Condition from last Signaled is satisfied and will be used now.
450 static BOOL32
CONSOLE_Satisfied(K32OBJ
*ptr
, DWORD thread_id
)
456 /******************************************************************************
457 * SetConsoleCtrlHandler [KERNEL32.459] Adds function to calling process list
460 * func [I] Address of handler function
461 * add [I] Handler to add or remove
468 * James Sutherland (JamesSutherland@gmx.de)
469 * Added global variables console_ignore_ctrl_c and handlers[]
470 * Does not yet do any error checking, or set LastError if failed.
471 * This doesn't yet matter, since these handlers are not yet called...!
473 static unsigned int console_ignore_ctrl_c
= 0;
474 static HANDLER_ROUTINE
*handlers
[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
475 BOOL32 WINAPI
SetConsoleCtrlHandler( HANDLER_ROUTINE
*func
, BOOL32 add
)
477 unsigned int alloc_loop
= sizeof(handlers
)/sizeof(HANDLER_ROUTINE
*);
478 unsigned int done
= 0;
479 FIXME(console
, "(%p,%i) - no error checking or testing yet\n", func
, add
);
482 console_ignore_ctrl_c
= add
;
488 if (!handlers
[alloc_loop
] && !done
)
490 handlers
[alloc_loop
] = func
;
494 FIXME(console
, "Out of space on CtrlHandler table\n");
500 if (handlers
[alloc_loop
] == func
&& !done
)
502 handlers
[alloc_loop
] = 0;
506 WARN(console
, "Attempt to remove non-installed CtrlHandler %p\n",
514 /******************************************************************************
515 * GenerateConsoleCtrlEvent [KERNEL32.275] Simulate a CTRL-C or CTRL-BREAK
518 * dwCtrlEvent [I] Type of event
519 * dwProcessGroupID [I] Process group ID to send event to
522 * Doesn't yet work...!
526 * Failure: False (and *should* [but doesn't] set LastError)
528 BOOL32 WINAPI
GenerateConsoleCtrlEvent( DWORD dwCtrlEvent
,
529 DWORD dwProcessGroupID
)
531 if (dwCtrlEvent
!= CTRL_C_EVENT
&& dwCtrlEvent
!= CTRL_BREAK_EVENT
)
533 ERR( console
, "invalid event %d for PGID %ld\n",
534 (unsigned short)dwCtrlEvent
, dwProcessGroupID
);
537 if (dwProcessGroupID
== GetCurrentProcessId() )
539 FIXME( console
, "Attempt to send event %d to self - stub\n",
540 (unsigned short)dwCtrlEvent
);
543 FIXME( console
,"event %d to external PGID %ld - not implemented yet\n",
544 (unsigned short)dwCtrlEvent
, dwProcessGroupID
);
549 /******************************************************************************
550 * CreateConsoleScreenBuffer [KERNEL32.151] Creates a console screen buffer
553 * dwDesiredAccess [I] Access flag
554 * dwShareMode [I] Buffer share mode
555 * sa [I] Security attributes
556 * dwFlags [I] Type of buffer to create
557 * lpScreenBufferData [I] Reserved
560 * Should call SetLastError
563 * Success: Handle to new console screen buffer
564 * Failure: INVALID_HANDLE_VALUE
566 HANDLE32 WINAPI
CreateConsoleScreenBuffer( DWORD dwDesiredAccess
,
567 DWORD dwShareMode
, LPSECURITY_ATTRIBUTES sa
,
568 DWORD dwFlags
, LPVOID lpScreenBufferData
)
570 FIXME(console
, "(%ld,%ld,%p,%ld,%p): stub\n",dwDesiredAccess
,
571 dwShareMode
, sa
, dwFlags
, lpScreenBufferData
);
572 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
573 return INVALID_HANDLE_VALUE32
;
577 /***********************************************************************
578 * GetConsoleScreenBufferInfo (KERNEL32.190)
580 BOOL32 WINAPI
GetConsoleScreenBufferInfo( HANDLE32 hConsoleOutput
,
581 LPCONSOLE_SCREEN_BUFFER_INFO csbi
)
585 csbi
->dwCursorPosition
.x
= 0;
586 csbi
->dwCursorPosition
.y
= 0;
587 csbi
->wAttributes
= 0;
588 csbi
->srWindow
.Left
= 0;
589 csbi
->srWindow
.Right
= 79;
590 csbi
->srWindow
.Top
= 0;
591 csbi
->srWindow
.Bottom
= 23;
592 csbi
->dwMaximumWindowSize
.x
= 80;
593 csbi
->dwMaximumWindowSize
.y
= 24;
598 /******************************************************************************
599 * SetConsoleActiveScreenBuffer [KERNEL32.623] Sets buffer to current console
605 BOOL32 WINAPI
SetConsoleActiveScreenBuffer(
606 HANDLE32 hConsoleOutput
) /* [in] Handle to console screen buffer */
608 FIXME(console
, "(%x): stub\n", hConsoleOutput
);
613 /***********************************************************************
614 * GetLargestConsoleWindowSize (KERNEL32.226)
616 DWORD WINAPI
GetLargestConsoleWindowSize( HANDLE32 hConsoleOutput
)
618 return (DWORD
)MAKELONG(80,24);
621 /***********************************************************************
622 * FreeConsole (KERNEL32.267)
624 BOOL32 WINAPI
FreeConsole(VOID
)
627 PDB32
*pdb
= PROCESS_Current();
632 console
= (CONSOLE
*)pdb
->console
;
634 if (console
== NULL
) {
635 SetLastError(ERROR_INVALID_PARAMETER
);
639 HANDLE_CloseAll( pdb
, &console
->header
);
641 K32OBJ_DecCount( &console
->header
);
649 * It looks like the openpty that comes with glibc in RedHat 5.0
650 * is buggy (second call returns what looks like a dup of 0 and 1
651 * instead of a new pty), this is a generic replacement.
653 static int CONSOLE_openpty(CONSOLE
*console
, char *name
,
654 struct termios
*term
, struct winsize
*winsize
)
659 struct set_console_fd_request req
;
661 strcpy (pts_name
, "/dev/ptyXY");
663 for (ptr1
= "pqrstuvwxyzPQRST"; *ptr1
!= 0; ptr1
++) {
665 for (ptr2
= "0123456789abcdef"; *ptr2
!= 0; ptr2
++) {
668 if ((fdm
= open(pts_name
, O_RDWR
)) < 0) {
675 if ((fds
= open(pts_name
, O_RDWR
)) < 0) {
679 console
->master
= fdm
;
680 console
->infd
= console
->outfd
= fds
;
681 req
.handle
= console
->hread
;
682 CLIENT_SendRequest( REQ_SET_CONSOLE_FD
, dup(fds
), 1, &req
, sizeof(req
) );
683 CLIENT_WaitReply( NULL
, NULL
, 0 );
684 req
.handle
= console
->hwrite
;
685 CLIENT_SendRequest( REQ_SET_CONSOLE_FD
, dup(fds
), 1, &req
, sizeof(req
) );
686 CLIENT_WaitReply( NULL
, NULL
, 0 );
689 tcsetattr(console
->infd
, TCSANOW
, term
);
691 ioctl(console
->outfd
, TIOCSWINSZ
, winsize
);
693 strcpy(name
, pts_name
);
700 /*************************************************************************
701 * CONSOLE_make_complex [internal]
703 * Turns a CONSOLE kernel object into a complex one.
704 * (switches from output/input using the terminal where WINE was started to
707 * This makes simple commandline tools pipeable, while complex commandline
708 * tools work without getting messed up by debugoutput.
710 * All other functions should work indedependend from this call.
712 * To test for complex console: pid == -1 -> simple, otherwise complex.
714 static BOOL32
CONSOLE_make_complex(CONSOLE
*console
)
723 if (console
->pid
!= -1)
724 return TRUE
; /* already complex */
726 MSG("Console: Making console complex (creating an xterm)...\n");
728 if (tcgetattr(0, &term
) < 0) return FALSE
;
729 term
.c_lflag
= ~(ECHO
|ICANON
);
730 if (CONSOLE_openpty(console
, NULL
, &term
, NULL
) < 0) return FALSE
;
732 if ((xpid
=fork()) == 0) {
733 tcsetattr(console
->infd
, TCSADRAIN
, &term
);
734 sprintf(buf
, "-Sxx%d", console
->master
);
735 /* "-fn vga" for VGA font. Harmless if vga is not present:
736 * xterm: unable to open font "vga", trying "fixed"....
738 execlp("xterm", "xterm", buf
, "-fn","vga",NULL
);
739 ERR(console
, "error creating AllocConsole xterm\n");
744 /* most xterms like to print their window ID when used with -S;
745 * read it and continue before the user has a chance...
747 for (i
=0; c
!='\n'; (status
=read(console
->infd
, &c
, 1)), i
++) {
748 if (status
== -1 && c
== '\0') {
749 /* wait for xterm to be created */
753 ERR(console
, "can't read xterm WID\n");
754 kill(console
->pid
, SIGKILL
);
758 /* enable mouseclicks */
759 sprintf(buf
,"%c[?1001s%c[?1000h",27,27);
760 CONSOLE_Write(&console
->header
,buf
,strlen(buf
),&xlen
,NULL
);
765 /***********************************************************************
766 * CONSOLE_GetConsoleHandle
767 * returns a 16-bit style console handle
768 * note: only called from _lopen
770 HFILE32
CONSOLE_GetConsoleHandle(VOID
)
772 PDB32
*pdb
= PROCESS_Current();
773 HFILE32 handle
= HFILE_ERROR32
;
776 if (pdb
->console
!= NULL
) {
777 CONSOLE
*console
= (CONSOLE
*)pdb
->console
;
778 handle
= (HFILE32
)HANDLE_Alloc(pdb
, &console
->header
, 0, TRUE
, -1);
784 /***********************************************************************
785 * AllocConsole (KERNEL32.103)
787 * creates an xterm with a pty to our program
789 BOOL32 WINAPI
AllocConsole(VOID
)
791 struct create_console_request req
;
792 struct create_console_reply reply
;
794 PDB32
*pdb
= PROCESS_Current();
796 HANDLE32 hIn
, hOut
, hErr
;
798 SYSTEM_LOCK(); /* FIXME: really only need to lock the process */
800 SetLastError(ERROR_CANNOT_MAKE
); /* this might not be the right
801 error, but it's a good guess :) */
803 console
= (CONSOLE
*)pdb
->console
;
805 /* don't create a console if we already have one */
806 if (console
!= NULL
) {
807 SetLastError(ERROR_ACCESS_DENIED
);
812 if (!(console
= (CONSOLE
*)HeapAlloc( SystemHeap
, 0, sizeof(*console
))))
818 console
->header
.type
= K32OBJ_CONSOLE
;
819 console
->header
.refcount
= 1;
821 console
->title
= NULL
;
822 console
->nrofirs
= 0;
823 console
->wait_queue
= NULL
;
824 console
->irs
= HeapAlloc(GetProcessHeap(),0,1);;
825 console
->mode
= ENABLE_PROCESSED_INPUT
828 /* FIXME: we shouldn't probably use hardcoded UNIX values here. */
831 console
->hread
= console
->hwrite
= -1;
833 CLIENT_SendRequest( REQ_CREATE_CONSOLE
, -1, 1, &req
, sizeof(req
) );
834 if (CLIENT_WaitReply( &len
, NULL
, 1, &reply
, sizeof(reply
) ) != ERROR_SUCCESS
)
836 K32OBJ_DecCount(&console
->header
);
840 CHECK_LEN( len
, sizeof(reply
) );
841 console
->hread
= reply
.handle_read
;
842 console
->hwrite
= reply
.handle_write
;
844 if ((hIn
= HANDLE_Alloc(pdb
,&console
->header
, 0, TRUE
,
845 reply
.handle_read
)) == INVALID_HANDLE_VALUE32
)
847 CLIENT_CloseHandle( reply
.handle_write
);
848 K32OBJ_DecCount(&console
->header
);
853 if ((hOut
= HANDLE_Alloc(pdb
,&console
->header
, 0, TRUE
,
854 reply
.handle_write
)) == INVALID_HANDLE_VALUE32
)
857 K32OBJ_DecCount(&console
->header
);
862 if (!DuplicateHandle( GetCurrentProcess(), hOut
,
863 GetCurrentProcess(), &hErr
,
864 0, TRUE
, DUPLICATE_SAME_ACCESS
))
868 K32OBJ_DecCount(&console
->header
);
873 if (pdb
->console
) K32OBJ_DecCount( pdb
->console
);
874 pdb
->console
= (K32OBJ
*)console
;
875 K32OBJ_IncCount( pdb
->console
);
877 /* NT resets the STD_*_HANDLEs on console alloc */
878 SetStdHandle(STD_INPUT_HANDLE
, hIn
);
879 SetStdHandle(STD_OUTPUT_HANDLE
, hOut
);
880 SetStdHandle(STD_ERROR_HANDLE
, hErr
);
882 SetLastError(ERROR_SUCCESS
);
884 SetConsoleTitle32A("Wine Console");
889 /******************************************************************************
890 * GetConsoleCP [KERNEL32.295] Returns the OEM code page for the console
895 UINT32 WINAPI
GetConsoleCP(VOID
)
901 /***********************************************************************
902 * GetConsoleOutputCP (KERNEL32.189)
904 UINT32 WINAPI
GetConsoleOutputCP(VOID
)
906 return GetConsoleCP();
909 /***********************************************************************
910 * GetConsoleMode (KERNEL32.188)
912 BOOL32 WINAPI
GetConsoleMode(HANDLE32 hcon
,LPDWORD mode
)
914 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
917 FIXME(console
,"(%d,%p), no console handle passed!\n",hcon
,mode
);
920 *mode
= console
->mode
;
921 K32OBJ_DecCount(&console
->header
);
926 /******************************************************************************
927 * SetConsoleMode [KERNEL32.628] Sets input mode of console's input buffer
930 * hcon [I] Handle to console input or screen buffer
931 * mode [I] Input or output mode to set
937 BOOL32 WINAPI
SetConsoleMode( HANDLE32 hcon
, DWORD mode
)
939 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
942 FIXME(console
,"(%d,%ld), no console handle passed!\n",hcon
,mode
);
945 FIXME(console
,"(0x%08x,0x%08lx): stub\n",hcon
,mode
);
946 console
->mode
= mode
;
947 K32OBJ_DecCount(&console
->header
);
952 /***********************************************************************
953 * GetConsoleTitleA (KERNEL32.191)
955 DWORD WINAPI
GetConsoleTitle32A(LPSTR title
,DWORD size
)
957 PDB32
*pdb
= PROCESS_Current();
958 CONSOLE
*console
= (CONSOLE
*)pdb
->console
;
960 if(console
&& console
->title
) {
961 lstrcpyn32A(title
,console
->title
,size
);
962 return strlen(title
);
968 /******************************************************************************
969 * GetConsoleTitle32W [KERNEL32.192] Retrieves title string for console
972 * title [O] Address of buffer for title
973 * size [I] Size of buffer
976 * Success: Length of string copied
979 DWORD WINAPI
GetConsoleTitle32W( LPWSTR title
, DWORD size
)
981 PDB32
*pdb
= PROCESS_Current();
982 CONSOLE
*console
= (CONSOLE
*)pdb
->console
;
983 if(console
&& console
->title
)
985 lstrcpynAtoW(title
,console
->title
,size
);
986 return (lstrlen32W(title
));
992 /***********************************************************************
993 * WriteConsoleA (KERNEL32.729)
995 BOOL32 WINAPI
WriteConsole32A( HANDLE32 hConsoleOutput
,
997 DWORD nNumberOfCharsToWrite
,
998 LPDWORD lpNumberOfCharsWritten
,
1001 /* FIXME: should I check if this is a console handle? */
1002 return WriteFile(hConsoleOutput
, lpBuffer
, nNumberOfCharsToWrite
,
1003 lpNumberOfCharsWritten
, NULL
);
1008 if (bufused==curbufsize-1) \
1009 buffer = HeapReAlloc(GetProcessHeap(),0,buffer,(curbufsize+=100));\
1010 buffer[bufused++]=c;
1011 #define SADD(s) { char *x=s;while (*x) {CADD(*x);x++;}}
1013 /***********************************************************************
1014 * WriteConsoleOutputA (KERNEL32.732)
1016 BOOL32 WINAPI
WriteConsoleOutput32A( HANDLE32 hConsoleOutput
,
1017 LPCHAR_INFO lpBuffer
,
1019 COORD dwBufferCoord
,
1020 LPSMALL_RECT lpWriteRegion
)
1022 int i
,j
,off
=0,lastattr
=-1;
1023 char sbuf
[20],*buffer
=NULL
;
1024 int bufused
=0,curbufsize
= 100;
1026 const int colormap
[8] = {
1030 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hConsoleOutput
, K32OBJ_CONSOLE
, 0, NULL
);
1033 FIXME(console
,"(%d,...): no console handle!\n",hConsoleOutput
);
1036 CONSOLE_make_complex(console
);
1037 buffer
= HeapAlloc(GetProcessHeap(),0,100);;
1040 TRACE(console
,"wr: top = %d, bottom=%d, left=%d,right=%d\n",
1042 lpWriteRegion
->Bottom
,
1043 lpWriteRegion
->Left
,
1044 lpWriteRegion
->Right
1047 for (i
=lpWriteRegion
->Top
;i
<=lpWriteRegion
->Bottom
;i
++) {
1048 sprintf(sbuf
,"%c[%d;%dH",27,i
+1,lpWriteRegion
->Left
+1);
1050 for (j
=lpWriteRegion
->Left
;j
<=lpWriteRegion
->Right
;j
++) {
1051 if (lastattr
!=lpBuffer
[off
].Attributes
) {
1052 lastattr
= lpBuffer
[off
].Attributes
;
1053 sprintf(sbuf
,"%c[0;%s3%d;4%dm",
1055 (lastattr
& FOREGROUND_INTENSITY
)?"1;":"",
1056 colormap
[lastattr
&7],
1057 colormap
[(lastattr
&0x70)>>4]
1059 /* FIXME: BACKGROUND_INTENSITY */
1062 CADD(lpBuffer
[off
].Char
.AsciiChar
);
1066 sprintf(sbuf
,"%c[0m",27);SADD(sbuf
);
1067 WriteFile(hConsoleOutput
,buffer
,bufused
,&res
,NULL
);
1068 HeapFree(GetProcessHeap(),0,buffer
);
1069 K32OBJ_DecCount(&console
->header
);
1073 /***********************************************************************
1074 * WriteConsoleW (KERNEL32.577)
1076 BOOL32 WINAPI
WriteConsole32W( HANDLE32 hConsoleOutput
,
1078 DWORD nNumberOfCharsToWrite
,
1079 LPDWORD lpNumberOfCharsWritten
,
1083 LPSTR xstring
=HeapAlloc( GetProcessHeap(), 0, nNumberOfCharsToWrite
);
1085 lstrcpynWtoA( xstring
, lpBuffer
,nNumberOfCharsToWrite
);
1087 /* FIXME: should I check if this is a console handle? */
1088 ret
= WriteFile(hConsoleOutput
, xstring
, nNumberOfCharsToWrite
,
1089 lpNumberOfCharsWritten
, NULL
);
1090 HeapFree( GetProcessHeap(), 0, xstring
);
1095 /***********************************************************************
1096 * ReadConsoleA (KERNEL32.419)
1098 BOOL32 WINAPI
ReadConsole32A( HANDLE32 hConsoleInput
,
1100 DWORD nNumberOfCharsToRead
,
1101 LPDWORD lpNumberOfCharsRead
,
1104 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hConsoleInput
, K32OBJ_CONSOLE
, 0, NULL
);
1105 int i
,charsread
= 0;
1106 LPSTR xbuf
= (LPSTR
)lpBuffer
;
1109 SetLastError(ERROR_INVALID_HANDLE
);
1110 FIXME(console
,"(%d,...), no console handle!\n",hConsoleInput
);
1113 TRACE(console
,"(%d,%p,%ld,%p,%p)\n",
1114 hConsoleInput
,lpBuffer
,nNumberOfCharsToRead
,
1115 lpNumberOfCharsRead
,lpReserved
1117 CONSOLE_get_input(console
);
1119 /* FIXME: should this drain everything from the input queue and just
1120 * put the keypresses in the buffer? Needs further thought.
1122 for (i
=0;(i
<console
->nrofirs
)&&(charsread
<nNumberOfCharsToRead
);i
++) {
1123 if (console
->irs
[i
].EventType
!= KEY_EVENT
)
1125 if (!console
->irs
[i
].Event
.KeyEvent
.bKeyDown
)
1127 *xbuf
++ = console
->irs
[i
].Event
.KeyEvent
.uChar
.AsciiChar
;
1130 CONSOLE_drain_input(console
,i
);
1131 if (lpNumberOfCharsRead
)
1132 *lpNumberOfCharsRead
= charsread
;
1133 K32OBJ_DecCount(&console
->header
);
1137 /***********************************************************************
1138 * ReadConsoleW (KERNEL32.427)
1140 BOOL32 WINAPI
ReadConsole32W( HANDLE32 hConsoleInput
,
1142 DWORD nNumberOfCharsToRead
,
1143 LPDWORD lpNumberOfCharsRead
,
1147 LPSTR buf
= (LPSTR
)HeapAlloc(GetProcessHeap(), 0, nNumberOfCharsToRead
);
1149 ret
= ReadConsole32A(
1152 nNumberOfCharsToRead
,
1153 lpNumberOfCharsRead
,
1157 lstrcpynAtoW(lpBuffer
,buf
,nNumberOfCharsToRead
);
1158 HeapFree( GetProcessHeap(), 0, buf
);
1163 /******************************************************************************
1164 * ReadConsoleInput32A [KERNEL32.569] Reads data from a console
1167 * hConsoleInput [I] Handle to console input buffer
1168 * lpBuffer [O] Address of buffer for read data
1169 * nLength [I] Number of records to read
1170 * lpNumberOfEventsRead [O] Address of number of records read
1176 BOOL32 WINAPI
ReadConsoleInput32A(HANDLE32 hConsoleInput
,
1177 LPINPUT_RECORD lpBuffer
,
1178 DWORD nLength
, LPDWORD lpNumberOfEventsRead
)
1180 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hConsoleInput
, K32OBJ_CONSOLE
, 0, NULL
);
1182 TRACE(console
, "(%d,%p,%ld,%p)\n",hConsoleInput
, lpBuffer
, nLength
,
1183 lpNumberOfEventsRead
);
1185 FIXME(console
, "(%d,%p,%ld,%p), No console handle!\n",hConsoleInput
,
1186 lpBuffer
, nLength
, lpNumberOfEventsRead
);
1189 CONSOLE_get_input(console
);
1190 if (nLength
>console
->nrofirs
)
1191 nLength
= console
->nrofirs
;
1192 memcpy(lpBuffer
,console
->irs
,sizeof(INPUT_RECORD
)*nLength
);
1193 if (lpNumberOfEventsRead
)
1194 *lpNumberOfEventsRead
= nLength
;
1195 CONSOLE_drain_input(console
,nLength
);
1196 K32OBJ_DecCount(&console
->header
);
1200 /***********************************************************************
1201 * SetConsoleTitle32A (KERNEL32.476)
1203 * Sets the console title.
1205 * We do not necessarily need to create a complex console for that,
1206 * but should remember the title and set it on creation of the latter.
1207 * (not fixed at this time).
1209 BOOL32 WINAPI
SetConsoleTitle32A(LPCSTR title
)
1211 PDB32
*pdb
= PROCESS_Current();
1214 char titleformat
[]="\033]2;%s\a"; /*this should work for xterms*/
1218 TRACE(console
,"(%s)\n",title
);
1220 console
= (CONSOLE
*)pdb
->console
;
1223 if(console
->title
) /* Free old title, if there is one */
1224 HeapFree( SystemHeap
, 0, console
->title
);
1225 console
->title
= (LPSTR
)HeapAlloc(SystemHeap
, 0,strlen(title
)+1);
1226 if(console
->title
) strcpy(console
->title
,title
);
1227 titlestring
= HeapAlloc(GetProcessHeap(), 0,strlen(title
)+strlen(titleformat
)+1);
1229 K32OBJ_DecCount(&console
->header
);
1233 sprintf(titlestring
,titleformat
,title
);
1234 /* FIXME: hmm, should use WriteFile probably... */
1235 CONSOLE_Write(&console
->header
,titlestring
,strlen(titlestring
),&written
,NULL
);
1236 if (written
== strlen(titlestring
))
1238 HeapFree( GetProcessHeap(), 0, titlestring
);
1239 K32OBJ_DecCount(&console
->header
);
1244 /******************************************************************************
1245 * SetConsoleTitle32W [KERNEL32.477] Sets title bar string for console
1248 * title [I] Address of new title
1251 * This should not be calling the A version
1257 BOOL32 WINAPI
SetConsoleTitle32W( LPCWSTR title
)
1261 LPSTR titleA
= HEAP_strdupWtoA( GetProcessHeap(), 0, title
);
1262 ret
= SetConsoleTitle32A(titleA
);
1263 HeapFree( GetProcessHeap(), 0, titleA
);
1267 /***********************************************************************
1268 * ReadConsoleInput32W (KERNEL32.570)
1270 BOOL32 WINAPI
ReadConsoleInput32W(HANDLE32 hConsoleInput
,
1271 LPINPUT_RECORD lpBuffer
,
1272 DWORD nLength
, LPDWORD lpNumberOfEventsRead
)
1274 FIXME(console
, "(%d,%p,%ld,%p): stub\n",hConsoleInput
, lpBuffer
, nLength
,
1275 lpNumberOfEventsRead
);
1279 /***********************************************************************
1280 * FlushConsoleInputBuffer (KERNEL32.132)
1282 BOOL32 WINAPI
FlushConsoleInputBuffer(HANDLE32 hConsoleInput
)
1284 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hConsoleInput
, K32OBJ_CONSOLE
, 0, NULL
);
1288 CONSOLE_drain_input(console
,console
->nrofirs
);
1289 K32OBJ_DecCount(&console
->header
);
1294 /******************************************************************************
1295 * SetConsoleCursorPosition [KERNEL32.627]
1296 * Sets the cursor position in console
1299 * hConsoleOutput [I] Handle of console screen buffer
1300 * dwCursorPosition [I] New cursor position coordinates
1304 BOOL32 WINAPI
SetConsoleCursorPosition( HANDLE32 hcon
, COORD pos
)
1308 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
1311 FIXME(console
,"(%d,...), no console handle!\n",hcon
);
1314 CONSOLE_make_complex(console
);
1315 TRACE(console
, "%d (%dx%d)\n", hcon
, pos
.x
, pos
.y
);
1316 /* x are columns, y rows */
1317 sprintf(xbuf
,"%c[%d;%dH", 0x1B, pos
.y
+1, pos
.x
+1);
1318 /* FIXME: store internal if we start using own console buffers */
1319 WriteFile(hcon
,xbuf
,strlen(xbuf
),&xlen
,NULL
);
1320 K32OBJ_DecCount(&console
->header
);
1324 /***********************************************************************
1325 * GetNumberOfConsoleInputEvents (KERNEL32.246)
1327 BOOL32 WINAPI
GetNumberOfConsoleInputEvents(HANDLE32 hcon
,LPDWORD nrofevents
)
1329 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
1332 FIXME(console
,"(%d,%p), no console handle!\n",hcon
,nrofevents
);
1335 CONSOLE_get_input(console
);
1336 *nrofevents
= console
->nrofirs
;
1337 K32OBJ_DecCount(&console
->header
);
1341 /***********************************************************************
1342 * GetNumberOfConsoleMouseButtons (KERNEL32.358)
1344 BOOL32 WINAPI
GetNumberOfConsoleMouseButtons(LPDWORD nrofbuttons
)
1346 FIXME(console
,"(%p): stub\n", nrofbuttons
);
1351 /***********************************************************************
1352 * PeekConsoleInputA (KERNEL32.550)
1354 * Gets 'cInRecords' first events (or less) from input queue.
1356 * Does not need a complex console.
1358 BOOL32 WINAPI
PeekConsoleInput32A(HANDLE32 hConsoleInput
,
1359 LPINPUT_RECORD pirBuffer
,
1363 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hConsoleInput
, K32OBJ_CONSOLE
, 0, NULL
);
1366 FIXME(console
,"(%d,%p,%ld,%p), No console handle passed!\n",hConsoleInput
, pirBuffer
, cInRecords
, lpcRead
);
1369 TRACE(console
,"(%d,%p,%ld,%p)\n",hConsoleInput
, pirBuffer
, cInRecords
, lpcRead
);
1370 CONSOLE_get_input(console
);
1371 if (cInRecords
>console
->nrofirs
)
1372 cInRecords
= console
->nrofirs
;
1374 memcpy(pirBuffer
,console
->irs
,cInRecords
*sizeof(INPUT_RECORD
));
1376 *lpcRead
= cInRecords
;
1377 K32OBJ_DecCount(&console
->header
);
1381 /***********************************************************************
1382 * PeekConsoleInputW (KERNEL32.551)
1384 BOOL32 WINAPI
PeekConsoleInput32W(HANDLE32 hConsoleInput
,
1385 LPINPUT_RECORD pirBuffer
,
1389 /* FIXME: Hmm. Fix this if we get UNICODE input. */
1390 return PeekConsoleInput32A(hConsoleInput
,pirBuffer
,cInRecords
,lpcRead
);
1394 /******************************************************************************
1395 * GetConsoleCursorInfo32 [KERNEL32.296] Gets size and visibility of console
1398 * hcon [I] Handle to console screen buffer
1399 * cinfo [O] Address of cursor information
1405 BOOL32 WINAPI
GetConsoleCursorInfo32( HANDLE32 hcon
,
1406 LPCONSOLE_CURSOR_INFO cinfo
)
1408 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
1411 FIXME(console
, "(%x,%p), no console handle!\n", hcon
, cinfo
);
1414 TRACE(console
, "(%x,%p)\n", hcon
, cinfo
);
1417 *cinfo
= console
->cinfo
;
1418 K32OBJ_DecCount(&console
->header
);
1423 /******************************************************************************
1424 * SetConsoleCursorInfo32 [KERNEL32.626] Sets size and visibility of cursor
1430 BOOL32 WINAPI
SetConsoleCursorInfo32(
1431 HANDLE32 hcon
, /* [in] Handle to console screen buffer */
1432 LPCONSOLE_CURSOR_INFO cinfo
) /* [in] Address of cursor information */
1436 CONSOLE
*console
= (CONSOLE
*)HANDLE_GetObjPtr( PROCESS_Current(), hcon
, K32OBJ_CONSOLE
, 0, NULL
);
1438 TRACE(console
, "(%x,%ld,%i): stub\n", hcon
,cinfo
->dwSize
,cinfo
->bVisible
);
1441 CONSOLE_make_complex(console
);
1442 sprintf(buf
,"%c[?25%c",27,cinfo
->bVisible
?'h':'l');
1443 WriteFile(hcon
,buf
,strlen(buf
),&xlen
,NULL
);
1444 console
->cinfo
= *cinfo
;
1445 K32OBJ_DecCount(&console
->header
);
1450 /******************************************************************************
1451 * SetConsoleWindowInfo [KERNEL32.634] Sets size and position of console
1457 BOOL32 WINAPI
SetConsoleWindowInfo(
1458 HANDLE32 hcon
, /* [in] Handle to console screen buffer */
1459 BOOL32 bAbsolute
, /* [in] Coordinate type flag */
1460 LPSMALL_RECT window
) /* [in] Address of new window rectangle */
1462 FIXME(console
, "(%x,%d,%p): stub\n", hcon
, bAbsolute
, window
);
1467 /******************************************************************************
1468 * SetConsoleTextAttribute32 [KERNEL32.631] Sets colors for text
1470 * Sets the foreground and background color attributes of characters
1471 * written to the screen buffer.
1477 BOOL32 WINAPI
SetConsoleTextAttribute32(HANDLE32 hConsoleOutput
,WORD wAttr
)
1479 const int colormap
[8] = {
1486 TRACE(console
,"(%d,%d)\n",hConsoleOutput
,wAttr
);
1487 sprintf(buffer
,"%c[0;%s3%d;4%dm",
1489 (wAttr
& FOREGROUND_INTENSITY
)?"1;":"",
1491 colormap
[(wAttr
&0x70)>>4]
1493 WriteFile(hConsoleOutput
,buffer
,strlen(buffer
),&xlen
,NULL
);
1498 /******************************************************************************
1499 * SetConsoleScreenBufferSize [KERNEL32.630] Changes size of console
1502 * hConsoleOutput [I] Handle to console screen buffer
1503 * dwSize [I] New size in character rows and cols
1509 BOOL32 WINAPI
SetConsoleScreenBufferSize( HANDLE32 hConsoleOutput
,
1512 FIXME(console
, "(%d,%dx%d): stub\n",hConsoleOutput
,dwSize
.x
,dwSize
.y
);
1517 /******************************************************************************
1518 * FillConsoleOutputCharacterA [KERNEL32.242]
1521 * hConsoleOutput [I] Handle to screen buffer
1522 * cCharacter [I] Character to write
1523 * nLength [I] Number of cells to write to
1524 * dwCoord [I] Coords of first cell
1525 * lpNumCharsWritten [O] Pointer to number of cells written
1531 BOOL32 WINAPI
FillConsoleOutputCharacterA(
1532 HANDLE32 hConsoleOutput
,
1536 LPDWORD lpNumCharsWritten
)
1541 SetConsoleCursorPosition(hConsoleOutput
,dwCoord
);
1542 for(count
=0;count
<nLength
;count
++)
1543 WriteFile(hConsoleOutput
,&cCharacter
,1,&xlen
,NULL
);
1544 *lpNumCharsWritten
= nLength
;
1549 /******************************************************************************
1550 * FillConsoleOutputCharacterW [KERNEL32.243] Writes characters to console
1553 * hConsoleOutput [I] Handle to screen buffer
1554 * cCharacter [I] Character to write
1555 * nLength [I] Number of cells to write to
1556 * dwCoord [I] Coords of first cell
1557 * lpNumCharsWritten [O] Pointer to number of cells written
1563 BOOL32 WINAPI
FillConsoleOutputCharacterW(HANDLE32 hConsoleOutput
,
1567 LPDWORD lpNumCharsWritten
)
1572 SetConsoleCursorPosition(hConsoleOutput
,dwCoord
);
1573 /* FIXME: not quite correct ... but the lower part of UNICODE char comes
1576 for(count
=0;count
<nLength
;count
++)
1577 WriteFile(hConsoleOutput
,&cCharacter
,1,&xlen
,NULL
);
1578 *lpNumCharsWritten
= nLength
;
1583 /******************************************************************************
1584 * FillConsoleOutputAttribute [KERNEL32.241] Sets attributes for console
1587 * hConsoleOutput [I] Handle to screen buffer
1588 * wAttribute [I] Color attribute to write
1589 * nLength [I] Number of cells to write to
1590 * dwCoord [I] Coords of first cell
1591 * lpNumAttrsWritten [O] Pointer to number of cells written
1597 BOOL32 WINAPI
FillConsoleOutputAttribute( HANDLE32 hConsoleOutput
,
1598 WORD wAttribute
, DWORD nLength
, COORD dwCoord
,
1599 LPDWORD lpNumAttrsWritten
)
1601 FIXME(console
, "(%d,%d,%ld,%dx%d,%p): stub\n", hConsoleOutput
,
1602 wAttribute
,nLength
,dwCoord
.x
,dwCoord
.y
,lpNumAttrsWritten
);
1603 *lpNumAttrsWritten
= nLength
;
1607 /******************************************************************************
1608 * ReadConsoleOutputCharacter32A [KERNEL32.573]
1613 BOOL32 WINAPI
ReadConsoleOutputCharacter32A(HANDLE32 hConsoleOutput
,
1614 LPSTR lpstr
, DWORD dword
, COORD coord
, LPDWORD lpdword
)
1616 FIXME(console
, "(%d,%p,%ld,%dx%d,%p): stub\n", hConsoleOutput
,lpstr
,
1617 dword
,coord
.x
,coord
.y
,lpdword
);
1618 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1623 /******************************************************************************
1624 * ScrollConsoleScreenBuffer [KERNEL32.612]
1629 BOOL32 WINAPI
ScrollConsoleScreenBuffer( HANDLE32 hConsoleOutput
,
1630 LPSMALL_RECT lpScrollRect
, LPSMALL_RECT lpClipRect
,
1631 COORD dwDestOrigin
, LPCHAR_INFO lpFill
)
1633 FIXME(console
, "(%d,%p,%p,%dx%d,%p): stub\n", hConsoleOutput
,lpScrollRect
,
1634 lpClipRect
,dwDestOrigin
.x
,dwDestOrigin
.y
,lpFill
);
1635 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);