00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
#include "precomp.h"
00022
#pragma hdrstop
00023
00024
#ifdef i386
00025
VOID
00026 ReverseMousePointer(
00027 IN
PSCREEN_INFORMATION ScreenInfo,
00028 IN PSMALL_RECT Region
00029 );
00030
#endif
00031
00032 ULONG
00033 SrvGetConsoleMode(
00034 IN OUT PCSR_API_MSG m,
00035 IN OUT PCSR_REPLY_STATUS ReplyStatus
00036 )
00037 {
00038
PCONSOLE_MODE_MSG a = (
PCONSOLE_MODE_MSG)&m->u.ApiMessageData;
00039
NTSTATUS Status;
00040
PCONSOLE_INFORMATION Console;
00041
PHANDLE_DATA HandleData;
00042
00043
Status =
ApiPreamble(a->
ConsoleHandle,
00044 &Console
00045 );
00046
if (!
NT_SUCCESS(
Status)) {
00047
return Status;
00048 }
00049
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00050 a->
Handle,
00051
CONSOLE_ANY_HANDLE,
00052 GENERIC_READ,
00053 &HandleData
00054 );
00055
if (
NT_SUCCESS(
Status)) {
00056
00057
00058
00059
00060
00061
if (HandleData->
HandleType &
CONSOLE_INPUT_HANDLE) {
00062 a->
Mode = HandleData->
Buffer.InputBuffer->InputMode;
00063
if (Console->
Flags &
CONSOLE_USE_PRIVATE_FLAGS) {
00064 a->
Mode |= ENABLE_PRIVATE_FLAGS;
00065
if (Console->
InsertMode) {
00066 a->
Mode |= ENABLE_INSERT_MODE;
00067 }
00068
if (Console->
Flags &
CONSOLE_QUICK_EDIT_MODE) {
00069 a->
Mode |= ENABLE_QUICK_EDIT_MODE;
00070 }
00071 }
00072 }
else {
00073 a->
Mode = HandleData->
Buffer.ScreenBuffer->OutputMode;
00074 }
00075 }
00076
UnlockConsole(Console);
00077
return((ULONG)
Status);
00078 UNREFERENCED_PARAMETER(ReplyStatus);
00079 }
00080
00081 ULONG
00082 SrvGetConsoleNumberOfFonts(
00083 IN OUT PCSR_API_MSG m,
00084 IN OUT PCSR_REPLY_STATUS ReplyStatus
00085 )
00086 {
00087
PCONSOLE_GETNUMBEROFFONTS_MSG a = (
PCONSOLE_GETNUMBEROFFONTS_MSG)&m->u.ApiMessageData;
00088
NTSTATUS Status;
00089
PCONSOLE_INFORMATION Console;
00090
00091
Status =
ApiPreamble(a->
ConsoleHandle,
00092 &Console
00093 );
00094
if (!
NT_SUCCESS(
Status)) {
00095
return Status;
00096 }
00097
if (Console->
FullScreenFlags & CONSOLE_FULLSCREEN) {
00098
Status = STATUS_FULLSCREEN_MODE;
00099 }
else {
00100
Status =
GetNumFonts(&a->
NumberOfFonts);
00101 }
00102
UnlockConsole(Console);
00103
return Status;
00104 UNREFERENCED_PARAMETER(ReplyStatus);
00105 }
00106
00107 ULONG
00108 SrvGetConsoleNumberOfInputEvents(
00109 IN OUT PCSR_API_MSG m,
00110 IN OUT PCSR_REPLY_STATUS ReplyStatus
00111 )
00112 {
00113
PCONSOLE_GETNUMBEROFINPUTEVENTS_MSG a = (
PCONSOLE_GETNUMBEROFINPUTEVENTS_MSG)&m->u.ApiMessageData;
00114
NTSTATUS Status;
00115
PCONSOLE_INFORMATION Console;
00116
PHANDLE_DATA HandleData;
00117
00118
Status =
ApiPreamble(a->
ConsoleHandle,
00119 &Console
00120 );
00121
if (!
NT_SUCCESS(
Status)) {
00122
return Status;
00123 }
00124
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00125 a->
InputHandle,
00126
CONSOLE_INPUT_HANDLE,
00127 GENERIC_READ,
00128 &HandleData
00129 );
00130
if (
NT_SUCCESS(
Status)) {
00131
Status =
GetNumberOfReadyEvents(HandleData->
Buffer.InputBuffer,
00132 &a->
ReadyEvents
00133 );
00134 }
00135
UnlockConsole(Console);
00136
return((ULONG)
Status);
00137 UNREFERENCED_PARAMETER(ReplyStatus);
00138 }
00139
00140 ULONG
00141 SrvGetConsoleScreenBufferInfo(
00142 IN OUT PCSR_API_MSG m,
00143 IN OUT PCSR_REPLY_STATUS ReplyStatus
00144 )
00145 {
00146
PCONSOLE_GETSCREENBUFFERINFO_MSG a = (
PCONSOLE_GETSCREENBUFFERINFO_MSG)&m->u.ApiMessageData;
00147
NTSTATUS Status;
00148
PCONSOLE_INFORMATION Console;
00149
PHANDLE_DATA HandleData;
00150
00151
Status =
ApiPreamble(a->
ConsoleHandle,
00152 &Console
00153 );
00154
if (!
NT_SUCCESS(
Status)) {
00155
return Status;
00156 }
00157
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00158 a->
OutputHandle,
00159
CONSOLE_OUTPUT_HANDLE,
00160 GENERIC_READ,
00161 &HandleData
00162 );
00163
if (
NT_SUCCESS(
Status)) {
00164
Status =
GetScreenBufferInformation(HandleData->
Buffer.ScreenBuffer,
00165 &a->
Size,
00166 &a->
CursorPosition,
00167 &a->
ScrollPosition,
00168 &a->
Attributes,
00169 &a->
CurrentWindowSize,
00170 &a->
MaximumWindowSize
00171 );
00172 }
00173
UnlockConsole(Console);
00174
return((ULONG)
Status);
00175 UNREFERENCED_PARAMETER(ReplyStatus);
00176 }
00177
00178 ULONG
00179 SrvGetConsoleCursorInfo(
00180 IN OUT PCSR_API_MSG m,
00181 IN OUT PCSR_REPLY_STATUS ReplyStatus
00182 )
00183 {
00184
PCONSOLE_GETCURSORINFO_MSG a = (
PCONSOLE_GETCURSORINFO_MSG)&m->u.ApiMessageData;
00185
NTSTATUS Status;
00186
PCONSOLE_INFORMATION Console;
00187
PHANDLE_DATA HandleData;
00188
00189
Status =
ApiPreamble(a->
ConsoleHandle,
00190 &Console
00191 );
00192
if (!
NT_SUCCESS(
Status)) {
00193
return Status;
00194 }
00195
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00196 a->
OutputHandle,
00197
CONSOLE_OUTPUT_HANDLE,
00198 GENERIC_READ,
00199 &HandleData
00200 );
00201
if (
NT_SUCCESS(
Status)) {
00202 a->
CursorSize = HandleData->
Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorSize;
00203 a->
Visible = (BOOLEAN) HandleData->
Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorVisible;
00204 }
00205
UnlockConsole(Console);
00206
return((ULONG)
Status);
00207 UNREFERENCED_PARAMETER(ReplyStatus);
00208 }
00209
00210 ULONG
00211 SrvGetConsoleMouseInfo(
00212 IN OUT PCSR_API_MSG m,
00213 IN OUT PCSR_REPLY_STATUS ReplyStatus
00214 )
00215 {
00216
PCONSOLE_GETMOUSEINFO_MSG a = (
PCONSOLE_GETMOUSEINFO_MSG)&m->u.ApiMessageData;
00217
NTSTATUS Status;
00218
PCONSOLE_INFORMATION Console;
00219
00220
Status =
ApiPreamble(a->
ConsoleHandle,
00221 &Console
00222 );
00223
if (!
NT_SUCCESS(
Status)) {
00224
return Status;
00225 }
00226
Status =
GetMouseButtons(&a->
NumButtons);
00227
UnlockConsole(Console);
00228
return Status;
00229 UNREFERENCED_PARAMETER(ReplyStatus);
00230 }
00231
00232 ULONG
00233 SrvGetConsoleFontInfo(
00234 IN OUT PCSR_API_MSG m,
00235 IN OUT PCSR_REPLY_STATUS ReplyStatus
00236 )
00237 {
00238
PCONSOLE_GETFONTINFO_MSG a = (
PCONSOLE_GETFONTINFO_MSG)&m->u.ApiMessageData;
00239
NTSTATUS Status;
00240
PCONSOLE_INFORMATION Console;
00241
PHANDLE_DATA HandleData;
00242
00243
Status =
ApiPreamble(a->
ConsoleHandle,
00244 &Console
00245 );
00246
if (!
NT_SUCCESS(
Status)) {
00247
return Status;
00248 }
00249
00250
if (!CsrValidateMessageBuffer(m, &a->
BufPtr, a->
NumFonts,
sizeof(*a->
BufPtr))) {
00251
UnlockConsole(Console);
00252
return STATUS_INVALID_PARAMETER;
00253 }
00254
00255
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00256 a->
OutputHandle,
00257
CONSOLE_OUTPUT_HANDLE,
00258 GENERIC_READ,
00259 &HandleData
00260 );
00261
if (
NT_SUCCESS(
Status)) {
00262
if (HandleData->
Buffer.ScreenBuffer->Console->FullScreenFlags & CONSOLE_FULLSCREEN) {
00263
Status = STATUS_FULLSCREEN_MODE;
00264 }
else {
00265
Status =
GetAvailableFonts(HandleData->
Buffer.ScreenBuffer,
00266 a->
MaximumWindow,
00267 a->
BufPtr,
00268 &a->
NumFonts
00269 );
00270 }
00271 }
00272
UnlockConsole(Console);
00273
return((ULONG)
Status);
00274 UNREFERENCED_PARAMETER(ReplyStatus);
00275 }
00276
00277 ULONG
00278 SrvGetConsoleFontSize(
00279 IN OUT PCSR_API_MSG m,
00280 IN OUT PCSR_REPLY_STATUS ReplyStatus
00281 )
00282 {
00283
PCONSOLE_GETFONTSIZE_MSG a = (
PCONSOLE_GETFONTSIZE_MSG)&m->u.ApiMessageData;
00284
NTSTATUS Status;
00285
PCONSOLE_INFORMATION Console;
00286
PHANDLE_DATA HandleData;
00287
00288
Status =
ApiPreamble(a->
ConsoleHandle,
00289 &Console
00290 );
00291
if (!
NT_SUCCESS(
Status)) {
00292
return Status;
00293 }
00294
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00295 a->
OutputHandle,
00296
CONSOLE_OUTPUT_HANDLE,
00297 GENERIC_READ,
00298 &HandleData
00299 );
00300
if (
NT_SUCCESS(
Status)) {
00301
if (HandleData->
Buffer.ScreenBuffer->Console->FullScreenFlags & CONSOLE_FULLSCREEN) {
00302
Status = STATUS_FULLSCREEN_MODE;
00303 }
else {
00304
Status =
GetFontSize(a->
FontIndex,
00305 &a->
FontSize
00306 );
00307 }
00308 }
00309
UnlockConsole(Console);
00310
return((ULONG)
Status);
00311 UNREFERENCED_PARAMETER(ReplyStatus);
00312 }
00313
00314 ULONG
00315 SrvGetConsoleCurrentFont(
00316 IN OUT PCSR_API_MSG m,
00317 IN OUT PCSR_REPLY_STATUS ReplyStatus
00318 )
00319 {
00320
PCONSOLE_GETCURRENTFONT_MSG a = (
PCONSOLE_GETCURRENTFONT_MSG)&m->u.ApiMessageData;
00321
NTSTATUS Status;
00322
PCONSOLE_INFORMATION Console;
00323
PHANDLE_DATA HandleData;
00324
00325
Status =
ApiPreamble(a->
ConsoleHandle,
00326 &Console
00327 );
00328
if (!
NT_SUCCESS(
Status)) {
00329
return Status;
00330 }
00331
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00332 a->
OutputHandle,
00333
CONSOLE_OUTPUT_HANDLE,
00334 GENERIC_READ,
00335 &HandleData
00336 );
00337
if (
NT_SUCCESS(
Status)) {
00338
if (HandleData->
Buffer.ScreenBuffer->Console->FullScreenFlags & CONSOLE_FULLSCREEN) {
00339
Status = STATUS_FULLSCREEN_MODE;
00340 }
else {
00341
Status =
GetCurrentFont(HandleData->
Buffer.ScreenBuffer,
00342 a->
MaximumWindow,
00343 &a->
FontIndex,
00344 &a->
FontSize
00345 );
00346 }
00347 }
00348
UnlockConsole(Console);
00349
return((ULONG)
Status);
00350 UNREFERENCED_PARAMETER(ReplyStatus);
00351 }
00352
00353 ULONG
00354 SrvSetConsoleMode(
00355 IN OUT PCSR_API_MSG m,
00356 IN OUT PCSR_REPLY_STATUS ReplyStatus
00357 )
00358 {
00359
PCONSOLE_MODE_MSG a = (
PCONSOLE_MODE_MSG)&m->u.ApiMessageData;
00360
NTSTATUS Status;
00361
PCONSOLE_INFORMATION Console;
00362
PHANDLE_DATA HandleData;
00363
00364
Status =
ApiPreamble(a->
ConsoleHandle,
00365 &Console
00366 );
00367
if (!
NT_SUCCESS(
Status)) {
00368
return Status;
00369 }
00370
try {
00371
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00372 a->
Handle,
00373
CONSOLE_ANY_HANDLE,
00374 GENERIC_WRITE,
00375 &HandleData
00376 );
00377
if (!
NT_SUCCESS(
Status)) {
00378 leave;
00379 }
00380
00381
if (HandleData->
HandleType &
CONSOLE_INPUT_HANDLE) {
00382
if (a->
Mode & ~(
INPUT_MODES |
PRIVATE_MODES)) {
00383
Status = STATUS_INVALID_PARAMETER;
00384 leave;
00385 }
00386
if ((a->
Mode & (ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT)) == ENABLE_ECHO_INPUT) {
00387
Status = STATUS_INVALID_PARAMETER;
00388 leave;
00389 }
00390
if (a->
Mode &
PRIVATE_MODES) {
00391 Console->
Flags |=
CONSOLE_USE_PRIVATE_FLAGS;
00392
if (a->
Mode & ENABLE_QUICK_EDIT_MODE) {
00393 Console->
Flags |=
CONSOLE_QUICK_EDIT_MODE;
00394 }
else {
00395 Console->
Flags &= ~
CONSOLE_QUICK_EDIT_MODE;
00396 }
00397
if (a->
Mode & ENABLE_INSERT_MODE) {
00398 Console->
InsertMode =
TRUE;
00399 }
else {
00400 Console->
InsertMode =
FALSE;
00401 }
00402 }
else {
00403 Console->
Flags &= ~
CONSOLE_USE_PRIVATE_FLAGS;
00404 }
00405
00406
#ifdef i386
00407
if (Console->
FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE &&
00408 Console->
CurrentScreenBuffer->
Flags &
CONSOLE_TEXTMODE_BUFFER &&
00409 (a->
Mode & ENABLE_MOUSE_INPUT) != (HandleData->
Buffer.InputBuffer->InputMode & ENABLE_MOUSE_INPUT)) {
00410
if (a->
Mode & ENABLE_MOUSE_INPUT) {
00411 HandleData->
Buffer.InputBuffer->InputMode |= ENABLE_MOUSE_INPUT;
00412 }
00413
#if defined(FE_SB)
00414
00415
00416
00417
if (Console->
OutputCP != 949) {
00418 ReverseMousePointer(Console->
CurrentScreenBuffer,
00419 &Console->
CurrentScreenBuffer->
Window);
00420 }
00421
#else
00422
ReverseMousePointer(Console->
CurrentScreenBuffer,
00423 &Console->
CurrentScreenBuffer->
Window);
00424
#endif
00425
}
00426
#endif
00427
HandleData->
Buffer.InputBuffer->InputMode = a->
Mode & ~
PRIVATE_MODES;
00428 }
00429
else {
00430
if (a->
Mode & ~
OUTPUT_MODES) {
00431
Status = STATUS_INVALID_PARAMETER;
00432 leave;
00433 }
00434 HandleData->
Buffer.ScreenBuffer->OutputMode = a->
Mode;
00435 }
00436 } finally {
00437
UnlockConsole(Console);
00438 }
00439
return Status;
00440 UNREFERENCED_PARAMETER(ReplyStatus);
00441 }
00442
00443 ULONG
00444 SrvGenerateConsoleCtrlEvent(
00445 IN OUT PCSR_API_MSG m,
00446 IN OUT PCSR_REPLY_STATUS ReplyStatus
00447 )
00448 {
00449
PCONSOLE_CTRLEVENT_MSG a = (
PCONSOLE_CTRLEVENT_MSG)&m->u.ApiMessageData;
00450
NTSTATUS Status;
00451
PCONSOLE_INFORMATION Console;
00452
00453
Status =
ApiPreamble(a->
ConsoleHandle,
00454 &Console
00455 );
00456
if (!
NT_SUCCESS(
Status)) {
00457
return Status;
00458 }
00459
try {
00460
00461
00462
00463
if (a->
ProcessGroupId) {
00464
PCONSOLE_PROCESS_HANDLE ProcessHandleRecord;
00465 PLIST_ENTRY ListHead, ListNext;
00466
00467
Status = STATUS_INVALID_PARAMETER;
00468 ListHead = &Console->
ProcessHandleList;
00469 ListNext = ListHead->Flink;
00470
while (ListNext != ListHead) {
00471 ProcessHandleRecord = CONTAINING_RECORD( ListNext,
CONSOLE_PROCESS_HANDLE, ListLink );
00472 ListNext = ListNext->Flink;
00473
if (ProcessHandleRecord->
Process->ProcessGroupId == a->
ProcessGroupId) {
00474
Status = STATUS_SUCCESS;
00475
break;
00476 }
00477 }
00478 }
00479
if (
NT_SUCCESS(
Status)) {
00480 Console->
LimitingProcessId = a->
ProcessGroupId;
00481
HandleCtrlEvent(Console, a->
CtrlEvent);
00482 }
00483
00484 } finally {
00485
UnlockConsole(Console);
00486 }
00487
return Status;
00488 UNREFERENCED_PARAMETER(ReplyStatus);
00489 }
00490
00491 ULONG
00492 SrvSetConsoleActiveScreenBuffer(
00493 IN OUT PCSR_API_MSG m,
00494 IN OUT PCSR_REPLY_STATUS ReplyStatus
00495 )
00496 {
00497
PCONSOLE_SETACTIVESCREENBUFFER_MSG a = (
PCONSOLE_SETACTIVESCREENBUFFER_MSG)&m->u.ApiMessageData;
00498
NTSTATUS Status;
00499
PCONSOLE_INFORMATION Console;
00500
PHANDLE_DATA HandleData;
00501
00502
Status =
ApiPreamble(a->
ConsoleHandle,
00503 &Console
00504 );
00505
if (!
NT_SUCCESS(
Status)) {
00506
return Status;
00507 }
00508
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00509 a->
OutputHandle,
00510
CONSOLE_GRAPHICS_OUTPUT_HANDLE |
CONSOLE_OUTPUT_HANDLE,
00511 GENERIC_WRITE,
00512 &HandleData
00513 );
00514
if (
NT_SUCCESS(
Status)) {
00515
Status =
SetActiveScreenBuffer(HandleData->
Buffer.ScreenBuffer);
00516 }
00517
UnlockConsole(Console);
00518
return((ULONG)
Status);
00519 UNREFERENCED_PARAMETER(ReplyStatus);
00520 }
00521
00522
00523 ULONG
00524 SrvFlushConsoleInputBuffer(
00525 IN OUT PCSR_API_MSG m,
00526 IN OUT PCSR_REPLY_STATUS ReplyStatus
00527 )
00528 {
00529
PCONSOLE_FLUSHINPUTBUFFER_MSG a = (
PCONSOLE_FLUSHINPUTBUFFER_MSG)&m->u.ApiMessageData;
00530
NTSTATUS Status;
00531
PCONSOLE_INFORMATION Console;
00532
PHANDLE_DATA HandleData;
00533
00534
Status =
ApiPreamble(a->
ConsoleHandle,
00535 &Console
00536 );
00537
if (!
NT_SUCCESS(
Status)) {
00538
return Status;
00539 }
00540
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00541 a->
InputHandle,
00542
CONSOLE_INPUT_HANDLE,
00543 GENERIC_WRITE,
00544 &HandleData
00545 );
00546
if (
NT_SUCCESS(
Status)) {
00547
Status =
FlushInputBuffer(HandleData->
Buffer.InputBuffer);
00548 }
00549
UnlockConsole(Console);
00550
return((ULONG)
Status);
00551 UNREFERENCED_PARAMETER(ReplyStatus);
00552 }
00553
00554 ULONG
00555 SrvGetLargestConsoleWindowSize(
00556 IN OUT PCSR_API_MSG m,
00557 IN OUT PCSR_REPLY_STATUS ReplyStatus
00558 )
00559 {
00560
PCONSOLE_GETLARGESTWINDOWSIZE_MSG a = (
PCONSOLE_GETLARGESTWINDOWSIZE_MSG)&m->u.ApiMessageData;
00561
NTSTATUS Status;
00562
PCONSOLE_INFORMATION Console;
00563
PHANDLE_DATA HandleData;
00564
PSCREEN_INFORMATION ScreenInfo;
00565
WINDOW_LIMITS WindowLimits;
00566
00567
Status =
ApiPreamble(a->
ConsoleHandle,
00568 &Console
00569 );
00570
if (!
NT_SUCCESS(
Status)) {
00571
return Status;
00572 }
00573
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00574 a->
OutputHandle,
00575
CONSOLE_OUTPUT_HANDLE,
00576 GENERIC_WRITE,
00577 &HandleData
00578 );
00579
if (
NT_SUCCESS(
Status)) {
00580 COORD FontSize;
00581
00582 ScreenInfo = HandleData->
Buffer.ScreenBuffer;
00583
if (ScreenInfo->
Console->
FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE) {
00584 a->
Size.X = 80;
00585
#if defined(FE_SB)
00586
a->
Size.Y = CONSOLE_IS_DBCS_OUTPUTCP(Console)?25:50;
00587
#else
00588
a->
Size.Y = 50;
00589
#endif
00590
}
else {
00591
if (ScreenInfo->
Flags &
CONSOLE_TEXTMODE_BUFFER) {
00592 FontSize =
SCR_FONTSIZE(ScreenInfo);
00593 }
else {
00594 FontSize.X = 1;
00595 FontSize.Y = 1;
00596 }
00597
GetWindowLimits(ScreenInfo, &WindowLimits);
00598 a->
Size.X = (
SHORT)(WindowLimits.
FullScreenSize.X / FontSize.X);
00599 a->
Size.Y = (
SHORT)(WindowLimits.
FullScreenSize.Y / FontSize.Y);
00600 }
00601 }
00602
UnlockConsole(Console);
00603
return((ULONG)
Status);
00604 UNREFERENCED_PARAMETER(ReplyStatus);
00605 }
00606
00607 ULONG
00608 SrvSetConsoleScreenBufferSize(
00609 IN OUT PCSR_API_MSG m,
00610 IN OUT PCSR_REPLY_STATUS ReplyStatus
00611 )
00612 {
00613
PCONSOLE_SETSCREENBUFFERSIZE_MSG a = (
PCONSOLE_SETSCREENBUFFERSIZE_MSG)&m->u.ApiMessageData;
00614
NTSTATUS Status;
00615
PCONSOLE_INFORMATION Console;
00616
PHANDLE_DATA HandleData;
00617
PSCREEN_INFORMATION ScreenInfo;
00618
WINDOW_LIMITS WindowLimits;
00619
00620
Status =
ApiPreamble(a->
ConsoleHandle,
00621 &Console
00622 );
00623
if (!
NT_SUCCESS(
Status)) {
00624
return Status;
00625 }
00626
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00627 a->
OutputHandle,
00628
CONSOLE_OUTPUT_HANDLE,
00629 GENERIC_WRITE,
00630 &HandleData
00631 );
00632
if (
NT_SUCCESS(
Status)) {
00633
00634 ScreenInfo = HandleData->
Buffer.ScreenBuffer;
00635
00636
00637
00638
00639
00640
GetWindowLimits(ScreenInfo, &WindowLimits);
00641
if (a->
Size.X <
CONSOLE_WINDOW_SIZE_X(ScreenInfo) ||
00642 a->
Size.Y <
CONSOLE_WINDOW_SIZE_Y(ScreenInfo) ||
00643 a->
Size.Y < WindowLimits.
MinimumWindowSize.Y ||
00644 a->
Size.X < WindowLimits.
MinimumWindowSize.X) {
00645
Status = STATUS_INVALID_PARAMETER;
00646 }
00647
else if (a->
Size.X == ScreenInfo->
ScreenBufferSize.X &&
00648 a->
Size.Y == ScreenInfo->
ScreenBufferSize.Y) {
00649
Status = STATUS_SUCCESS;
00650 }
else {
00651
Status =
ResizeScreenBuffer(ScreenInfo,
00652 a->
Size,
00653
TRUE);
00654 }
00655 }
00656
UnlockConsole(Console);
00657
return((ULONG)
Status);
00658 UNREFERENCED_PARAMETER(ReplyStatus);
00659 }
00660
00661 ULONG
00662 SrvSetConsoleCursorPosition(
00663 IN OUT PCSR_API_MSG m,
00664 IN OUT PCSR_REPLY_STATUS ReplyStatus
00665 )
00666 {
00667
PCONSOLE_SETCURSORPOSITION_MSG a = (
PCONSOLE_SETCURSORPOSITION_MSG)&m->u.ApiMessageData;
00668
NTSTATUS Status;
00669
PCONSOLE_INFORMATION Console;
00670
PHANDLE_DATA HandleData;
00671 COORD WindowOrigin;
00672
PSCREEN_INFORMATION ScreenInfo;
00673
00674
Status =
ApiPreamble(a->
ConsoleHandle,
00675 &Console
00676 );
00677
if (!
NT_SUCCESS(
Status)) {
00678
return Status;
00679 }
00680
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00681 a->
OutputHandle,
00682
CONSOLE_OUTPUT_HANDLE,
00683 GENERIC_WRITE,
00684 &HandleData
00685 );
00686
if (
NT_SUCCESS(
Status)) {
00687
00688 ScreenInfo = HandleData->
Buffer.ScreenBuffer;
00689
00690
if (a->
CursorPosition.X >= ScreenInfo->
ScreenBufferSize.X ||
00691 a->
CursorPosition.Y >= ScreenInfo->
ScreenBufferSize.Y ||
00692 a->
CursorPosition.X < 0 ||
00693 a->
CursorPosition.Y < 0) {
00694
Status = STATUS_INVALID_PARAMETER;
00695 }
else {
00696
Status =
SetCursorPosition(ScreenInfo,
00697 a->
CursorPosition,
00698
TRUE
00699 );
00700 }
00701
if (
NT_SUCCESS(
Status)) {
00702
#if defined(FE_IME)
00703
if (ScreenInfo->
Console->
Flags & CONSOLE_JUST_VDM_UNREGISTERED){
00704
if( ScreenInfo->
Console->
InputBuffer.ImeMode.Open ){
00705
SHORT ScrollY = 0;
00706
AdjustCursorPosition(ScreenInfo,a->
CursorPosition,
TRUE,&ScrollY);
00707 a->
CursorPosition.Y += ScrollY;
00708 }
00709 Console->
Flags &= ~CONSOLE_JUST_VDM_UNREGISTERED;
00710 }
00711
#endif
00712
WindowOrigin.X = 0;
00713 WindowOrigin.Y = 0;
00714
if (ScreenInfo->
Window.Left > a->
CursorPosition.X) {
00715 WindowOrigin.X = a->
CursorPosition.X - ScreenInfo->
Window.Left;
00716 }
00717
else if (ScreenInfo->
Window.Right < a->
CursorPosition.X) {
00718 WindowOrigin.X = a->
CursorPosition.X - ScreenInfo->
Window.Right;
00719 }
00720
if (ScreenInfo->
Window.Top > a->
CursorPosition.Y) {
00721 WindowOrigin.Y = a->
CursorPosition.Y - ScreenInfo->
Window.Top;
00722 }
00723
else if (ScreenInfo->
Window.Bottom < a->
CursorPosition.Y) {
00724 WindowOrigin.Y = a->
CursorPosition.Y - ScreenInfo->
Window.Bottom;
00725 }
00726
Status =
SetWindowOrigin(ScreenInfo,
00727
FALSE,
00728 WindowOrigin
00729 );
00730 }
00731 }
00732
UnlockConsole(Console);
00733
return((ULONG)
Status);
00734 UNREFERENCED_PARAMETER(ReplyStatus);
00735 }
00736
00737 ULONG
00738 SrvSetConsoleCursorInfo(
00739 IN OUT PCSR_API_MSG m,
00740 IN OUT PCSR_REPLY_STATUS ReplyStatus
00741 )
00742 {
00743
PCONSOLE_SETCURSORINFO_MSG a = (
PCONSOLE_SETCURSORINFO_MSG)&m->u.ApiMessageData;
00744
NTSTATUS Status;
00745
PCONSOLE_INFORMATION Console;
00746
PHANDLE_DATA HandleData;
00747
00748
Status =
ApiPreamble(a->
ConsoleHandle,
00749 &Console
00750 );
00751
if (!
NT_SUCCESS(
Status)) {
00752
return Status;
00753 }
00754
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00755 a->
OutputHandle,
00756
CONSOLE_OUTPUT_HANDLE,
00757 GENERIC_WRITE,
00758 &HandleData
00759 );
00760
if (
NT_SUCCESS(
Status)) {
00761
if (a->
CursorSize > 100 || a->
CursorSize == 0) {
00762
Status = STATUS_INVALID_PARAMETER;
00763 }
else {
00764
Status =
SetCursorInformation(HandleData->
Buffer.ScreenBuffer,a->
CursorSize,a->
Visible);
00765 }
00766 }
00767
UnlockConsole(Console);
00768
return((ULONG)
Status);
00769 UNREFERENCED_PARAMETER(ReplyStatus);
00770 }
00771
00772 ULONG
00773 SrvSetConsoleWindowInfo(
00774 IN OUT PCSR_API_MSG m,
00775 IN OUT PCSR_REPLY_STATUS ReplyStatus
00776 )
00777 {
00778
PCONSOLE_SETWINDOWINFO_MSG a = (
PCONSOLE_SETWINDOWINFO_MSG)&m->u.ApiMessageData;
00779
NTSTATUS Status;
00780
PCONSOLE_INFORMATION Console;
00781
PHANDLE_DATA HandleData;
00782
PSCREEN_INFORMATION ScreenInfo;
00783 COORD NewWindowSize;
00784
WINDOW_LIMITS WindowLimits;
00785
00786
Status =
ApiPreamble(a->
ConsoleHandle,
00787 &Console
00788 );
00789
if (!
NT_SUCCESS(
Status)) {
00790
return Status;
00791 }
00792
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00793 a->
OutputHandle,
00794
CONSOLE_OUTPUT_HANDLE,
00795 GENERIC_WRITE,
00796 &HandleData
00797 );
00798
if (
NT_SUCCESS(
Status)) {
00799 ScreenInfo = HandleData->
Buffer.ScreenBuffer;
00800
if (!a->
Absolute) {
00801 a->
Window.Left += ScreenInfo->
Window.Left;
00802 a->
Window.Right += ScreenInfo->
Window.Right;
00803 a->
Window.Top += ScreenInfo->
Window.Top;
00804 a->
Window.Bottom += ScreenInfo->
Window.Bottom;
00805 }
00806
if (a->
Window.Right < a->
Window.Left ||
00807 a->
Window.Bottom < a->
Window.Top) {
00808
Status = STATUS_INVALID_PARAMETER;
00809 }
else {
00810 NewWindowSize.X = (
SHORT)(
WINDOW_SIZE_X(&a->
Window));
00811 NewWindowSize.Y = (
SHORT)(
WINDOW_SIZE_Y(&a->
Window));
00812
GetWindowLimits(ScreenInfo, &WindowLimits);
00813
if ((NewWindowSize.X > WindowLimits.
MaximumWindowSize.X ||
00814 NewWindowSize.Y > WindowLimits.
MaximumWindowSize.Y) &&
00815 !(ScreenInfo->
Console->
FullScreenFlags & CONSOLE_FULLSCREEN)) {
00816
Status = STATUS_INVALID_PARAMETER;
00817 }
else {
00818
#ifdef i386
00819
if (ScreenInfo->
Console->
FullScreenFlags & CONSOLE_FULLSCREEN) {
00820 COORD NewOrigin;
00821
00822
if (NewWindowSize.X != (
SHORT)(
WINDOW_SIZE_X(&ScreenInfo->
Window)) ||
00823 NewWindowSize.Y != (
SHORT)(
WINDOW_SIZE_Y(&ScreenInfo->
Window))) {
00824 COORD WindowSize;
00825 ULONG ModeIndex;
00826
00827
#if defined(FE_SB)
00828
ModeIndex = MatchWindowSize(ScreenInfo->
Console->
OutputCP,NewWindowSize,&WindowSize);
00829
#else
00830
ModeIndex = MatchWindowSize(NewWindowSize,&WindowSize);
00831
#endif
00832
if (NewWindowSize.X != WindowSize.X ||
00833 NewWindowSize.Y != WindowSize.Y ||
00834 WindowSize.X > ScreenInfo->
ScreenBufferSize.X ||
00835 WindowSize.Y > ScreenInfo->
ScreenBufferSize.Y) {
00836
UnlockConsole(Console);
00837
return (ULONG) STATUS_FULLSCREEN_MODE;
00838 }
00839 ScreenInfo->
BufferInfo.TextInfo.ModeIndex = ModeIndex;
00840
ResizeWindow(ScreenInfo,
00841 &a->
Window,
00842
FALSE
00843 );
00844 ScreenInfo->
BufferInfo.TextInfo.WindowedWindowSize.X =
00845
CONSOLE_WINDOW_SIZE_X(ScreenInfo);
00846 ScreenInfo->
BufferInfo.TextInfo.WindowedWindowSize.Y =
00847
CONSOLE_WINDOW_SIZE_Y(ScreenInfo);
00848
if (ScreenInfo->
Console->
FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE &&
00849 (!(ScreenInfo->
Console->
Flags &
CONSOLE_VDM_REGISTERED)) ) {
00850 SetVideoMode(ScreenInfo);
00851
WriteToScreen(ScreenInfo,&ScreenInfo->
Window);
00852 }
00853 }
else {
00854 NewOrigin.X = a->
Window.Left;
00855 NewOrigin.Y = a->
Window.Top;
00856
SetWindowOrigin(ScreenInfo,
00857
TRUE,
00858 NewOrigin
00859 );
00860 }
00861 }
else
00862
#endif
00863
{
00864
Status =
ResizeWindow(ScreenInfo,
00865 &a->
Window,
00866
TRUE
00867 );
00868
if (
ACTIVE_SCREEN_BUFFER(ScreenInfo)) {
00869
SetWindowSize(ScreenInfo);
00870
WriteToScreen(ScreenInfo,&ScreenInfo->
Window);
00871 }
00872 }
00873 }
00874 }
00875 }
00876
UnlockConsole(Console);
00877
return((ULONG)
Status);
00878 UNREFERENCED_PARAMETER(ReplyStatus);
00879 }
00880
00881 ULONG
00882 SrvScrollConsoleScreenBuffer(
00883 IN OUT PCSR_API_MSG m,
00884 IN OUT PCSR_REPLY_STATUS ReplyStatus
00885 )
00886 {
00887
PCONSOLE_SCROLLSCREENBUFFER_MSG a = (
PCONSOLE_SCROLLSCREENBUFFER_MSG)&m->u.ApiMessageData;
00888
NTSTATUS Status;
00889
PCONSOLE_INFORMATION Console;
00890
PHANDLE_DATA HandleData;
00891 PSMALL_RECT ClipRect;
00892
00893
Status =
ApiPreamble(a->
ConsoleHandle,
00894 &Console
00895 );
00896
if (!
NT_SUCCESS(
Status)) {
00897
return Status;
00898 }
00899
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
00900 a->
OutputHandle,
00901
CONSOLE_OUTPUT_HANDLE,
00902 GENERIC_WRITE,
00903 &HandleData
00904 );
00905
if (
NT_SUCCESS(
Status)) {
00906
00907
if (a->
Clip) {
00908 ClipRect = &a->
ClipRectangle;
00909 }
00910
else {
00911 ClipRect =
NULL;
00912 }
00913
if (!a->
Unicode) {
00914
#if defined(FE_SB)
00915
a->
Fill.Char.UnicodeChar =
CharToWchar(Console,
00916 Console->
OutputCP,
00917 &a->
Fill.Char.AsciiChar);
00918
#else
00919
a->
Fill.Char.UnicodeChar =
CharToWchar(
00920 Console->
OutputCP, a->
Fill.Char.AsciiChar);
00921
#endif
00922
}
else if ((Console->
CurrentScreenBuffer->
Flags &
CONSOLE_OEMFONT_DISPLAY) &&
00923 !(Console->
FullScreenFlags & CONSOLE_FULLSCREEN)) {
00924
RealUnicodeToFalseUnicode(&a->
Fill.Char.UnicodeChar,
00925 1,
00926 Console->
OutputCP
00927 );
00928 }
00929
Status =
ScrollRegion(HandleData->
Buffer.ScreenBuffer,
00930 &a->
ScrollRectangle,
00931 ClipRect,
00932 a->
DestinationOrigin,
00933 a->
Fill
00934 );
00935 }
00936
UnlockConsole(Console);
00937
return((ULONG)
Status);
00938 UNREFERENCED_PARAMETER(ReplyStatus);
00939 }
00940
00941
VOID
00942 UpdatePopups(
00943 IN
PCONSOLE_INFORMATION Console,
00944 IN WORD NewAttributes,
00945 IN WORD NewPopupAttributes,
00946 IN WORD OldAttributes,
00947 IN WORD OldPopupAttributes
00948 )
00949
00950
00951
00952
00953
00954
00955
00956
00957
00958 {
00959 PLIST_ENTRY HistoryListHead, HistoryListNext;
00960 PLIST_ENTRY PopupListHead, PopupListNext;
00961
PCOMMAND_HISTORY History;
00962
PCLE_POPUP Popup;
00963
SHORT i,j;
00964 PCHAR_INFO OldContents;
00965 WORD InvertedOldPopupAttributes,InvertedNewPopupAttributes;
00966
00967 InvertedOldPopupAttributes = (WORD)(((OldPopupAttributes << 4) & 0xf0) |
00968 ((OldPopupAttributes >> 4) & 0x0f));
00969 InvertedNewPopupAttributes = (WORD)(((NewPopupAttributes << 4) & 0xf0) |
00970 ((NewPopupAttributes >> 4) & 0x0f));
00971 HistoryListHead = &Console->CommandHistoryList;
00972 HistoryListNext = HistoryListHead->Blink;
00973
while (HistoryListNext != HistoryListHead) {
00974
History = CONTAINING_RECORD( HistoryListNext,
COMMAND_HISTORY, ListLink );
00975 HistoryListNext = HistoryListNext->Blink;
00976
if (
History->Flags &
CLE_ALLOCATED && !
CLE_NO_POPUPS(
History)) {
00977 PopupListHead = &
History->PopupList;
00978 PopupListNext = PopupListHead->Blink;
00979
while (PopupListNext != PopupListHead) {
00980 Popup = CONTAINING_RECORD( PopupListNext,
CLE_POPUP, ListLink );
00981 PopupListNext = PopupListNext->Blink;
00982 OldContents = Popup->
OldContents;
00983
for (i=Popup->
Region.Left;i<=Popup->
Region.Right;i++) {
00984
for (j=Popup->
Region.Top;j<=Popup->
Region.Bottom;j++) {
00985
if (OldContents->Attributes == OldAttributes) {
00986 OldContents->Attributes = NewAttributes;
00987 }
else if (OldContents->Attributes == OldPopupAttributes) {
00988 OldContents->Attributes = NewPopupAttributes;
00989 }
else if (OldContents->Attributes == InvertedOldPopupAttributes) {
00990 OldContents->Attributes = InvertedNewPopupAttributes;
00991 }
00992 OldContents++;
00993 }
00994 }
00995 }
00996 }
00997 }
00998 }
00999
01000
01001
NTSTATUS
01002 SetScreenColors(
01003 IN
PSCREEN_INFORMATION ScreenInfo,
01004 IN WORD Attributes,
01005 IN WORD PopupAttributes,
01006 IN BOOL UpdateWholeScreen
01007 )
01008 {
01009
SHORT i,j;
01010
PROW Row;
01011 WORD DefaultAttributes,DefaultPopupAttributes;
01012
PCONSOLE_INFORMATION Console;
01013 COLORREF rgbBk;
01014 COLORREF rgbText;
01015
01016 Console = ScreenInfo->Console;
01017 rgbBk =
ConvertAttrToRGB(Console,
LOBYTE(Attributes >> 4));
01018 rgbBk = GetNearestColor(Console->
hDC, rgbBk);
01019 rgbText =
ConvertAttrToRGB(Console,
LOBYTE(Attributes));
01020 rgbText = GetNearestColor(Console->
hDC, rgbText);
01021
if (
ACTIVE_SCREEN_BUFFER(ScreenInfo)) {
01022 SetDCBrushColor(Console->
hDC, rgbBk);
01023 SetTextColor(Console->
hDC, rgbText);
01024 SetBkColor(Console->
hDC, rgbBk);
01025 Console->
LastAttributes = Attributes;
01026
SetConsoleBkColor(Console->
hWnd, rgbBk);
01027 }
01028
01029 DefaultAttributes = ScreenInfo->Attributes;
01030 DefaultPopupAttributes = ScreenInfo->PopupAttributes;
01031 ScreenInfo->Attributes = Attributes;
01032 ScreenInfo->PopupAttributes = PopupAttributes;
01033
#if defined(FE_IME)
01034
SetUndetermineAttribute( Console );
01035
#endif
01036
01037
if (UpdateWholeScreen && ScreenInfo->Flags &
CONSOLE_TEXTMODE_BUFFER) {
01038 WORD InvertedOldPopupAttributes,InvertedNewPopupAttributes;
01039
01040 InvertedOldPopupAttributes = (WORD)(((DefaultPopupAttributes << 4) & 0xf0) |
01041 ((DefaultPopupAttributes >> 4) & 0x0f));
01042 InvertedNewPopupAttributes = (WORD)(((PopupAttributes << 4) & 0xf0) |
01043 ((PopupAttributes >> 4) & 0x0f));
01044
01045
01046
01047
01048
for (i=0;i<ScreenInfo->ScreenBufferSize.Y;i++) {
01049 Row = &ScreenInfo->BufferInfo.TextInfo.Rows[i];
01050
for (j=0;j<Row->
AttrRow.
Length;j++) {
01051
if (Row->
AttrRow.
Attrs[j].
Attr == DefaultAttributes) {
01052 Row->
AttrRow.
Attrs[j].
Attr = Attributes;
01053 }
else if (Row->
AttrRow.
Attrs[j].
Attr == DefaultPopupAttributes) {
01054 Row->
AttrRow.
Attrs[j].
Attr = PopupAttributes;
01055 }
else if (Row->
AttrRow.
Attrs[j].
Attr == InvertedOldPopupAttributes) {
01056 Row->
AttrRow.
Attrs[j].
Attr = InvertedNewPopupAttributes;
01057 }
01058 }
01059 }
01060
01061
if (Console->
PopupCount)
01062
UpdatePopups(Console,
01063 Attributes,
01064 PopupAttributes,
01065 DefaultAttributes,
01066 DefaultPopupAttributes
01067 );
01068
01069 ScreenInfo->BufferInfo.TextInfo.Flags &= ~
TEXT_VALID_HINT;
01070
WriteToScreen(ScreenInfo,&ScreenInfo->Window);
01071 ScreenInfo->BufferInfo.TextInfo.Flags |=
TEXT_VALID_HINT;
01072 }
01073
01074
return STATUS_SUCCESS;
01075 }
01076
01077 ULONG
01078 SrvSetConsoleTextAttribute(
01079 IN OUT PCSR_API_MSG m,
01080 IN OUT PCSR_REPLY_STATUS ReplyStatus
01081 )
01082 {
01083
PCONSOLE_SETTEXTATTRIBUTE_MSG a = (
PCONSOLE_SETTEXTATTRIBUTE_MSG)&m->u.ApiMessageData;
01084
NTSTATUS Status;
01085
PCONSOLE_INFORMATION Console;
01086
PHANDLE_DATA HandleData;
01087
01088
Status =
ApiPreamble(a->
ConsoleHandle,
01089 &Console
01090 );
01091
if (!
NT_SUCCESS(
Status)) {
01092
return Status;
01093 }
01094
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
01095 a->
OutputHandle,
01096
CONSOLE_OUTPUT_HANDLE,
01097 GENERIC_WRITE,
01098 &HandleData
01099 );
01100
if (
NT_SUCCESS(
Status)) {
01101
01102
if (a->
Attributes & ~
VALID_TEXT_ATTRIBUTES) {
01103
Status = STATUS_INVALID_PARAMETER;
01104 }
else {
01105
Status =
SetScreenColors(HandleData->
Buffer.ScreenBuffer,
01106 a->
Attributes,
01107 HandleData->
Buffer.ScreenBuffer->PopupAttributes,
01108
FALSE
01109 );
01110 }
01111 }
01112
UnlockConsole(Console);
01113
return((ULONG)
Status);
01114 UNREFERENCED_PARAMETER(ReplyStatus);
01115 }
01116
01117 ULONG
01118 SrvSetConsoleFont(
01119 IN OUT PCSR_API_MSG m,
01120 IN OUT PCSR_REPLY_STATUS ReplyStatus
01121 )
01122 {
01123
PCONSOLE_SETFONT_MSG a = (
PCONSOLE_SETFONT_MSG)&m->u.ApiMessageData;
01124
NTSTATUS Status;
01125
PCONSOLE_INFORMATION Console;
01126
PHANDLE_DATA HandleData;
01127
PSCREEN_INFORMATION ScreenInfo;
01128
01129
Status =
ApiPreamble(a->
ConsoleHandle,
01130 &Console
01131 );
01132
if (!
NT_SUCCESS(
Status)) {
01133
return Status;
01134 }
01135
try {
01136
Status =
DereferenceIoHandle(
CONSOLE_PERPROCESSDATA(),
01137 a->
OutputHandle,
01138
CONSOLE_OUTPUT_HANDLE,
01139 GENERIC_WRITE,
01140 &HandleData
01141 );
01142
if (!
NT_SUCCESS(
Status)) {
01143 leave;
01144 }
01145
01146 ScreenInfo = HandleData->
Buffer.ScreenBuffer;
01147
if (ScreenInfo->
Console->
FullScreenFlags & CONSOLE_FULLSCREEN) {
01148
Status = STATUS_FULLSCREEN_MODE;
01149 }
else {
01150
#if defined(FE_SB)
01151
Status =
SetScreenBufferFont(ScreenInfo,a->
FontIndex,ScreenInfo->
Console->
OutputCP);
01152
#else
01153
Status =
SetScreenBufferFont(ScreenInfo,a->
FontIndex);
01154
#endif
01155
}
01156 } finally {
01157
UnlockConsole(Console);
01158 }
01159
return Status;
01160 UNREFERENCED_PARAMETER(ReplyStatus);
01161 }
01162
01163 ULONG
01164 SrvSetConsoleIcon(
01165 IN OUT PCSR_API_MSG m,
01166 IN OUT PCSR_REPLY_STATUS ReplyStatus
01167 )
01168 {
01169
PCONSOLE_SETICON_MSG a = (
PCONSOLE_SETICON_MSG)&m->u.ApiMessageData;
01170
NTSTATUS Status;
01171
PCONSOLE_INFORMATION Console;
01172 HANDLE hIcon;
01173
01174
Status =
ApiPreamble(a->
ConsoleHandle,
01175 &Console
01176 );
01177
if (!
NT_SUCCESS(
Status)) {
01178
return Status;
01179 }
01180
01181
if (a->
hIcon ==
NULL) {
01182 hIcon =
ghDefaultIcon;
01183 }
else {
01184 hIcon =
CopyIcon(a->
hIcon);
01185 }
01186
01187
if (hIcon ==
NULL) {
01188
Status = STATUS_INVALID_PARAMETER;
01189 }
else if (hIcon != Console->
hIcon) {
01190
PostMessage(Console->
hWnd, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
01191
if (Console->
hIcon !=
ghDefaultIcon) {
01192
DestroyIcon(Console->
hIcon);
01193 }
01194 Console->
hIcon = hIcon;
01195
01196
01197
01198
01199
if (hIcon !=
ghDefaultIcon) {
01200
01201
01202
01203
if (Console->
hSmIcon !=
NULL && Console->
hSmIcon !=
ghDefaultSmIcon) {
01204
DestroyIcon(Console->
hSmIcon);
01205 }
01206 Console->
hSmIcon =
NULL;
01207
PostMessage(Console->
hWnd, WM_SETICON, ICON_SMALL, (LPARAM)
NULL);
01208 }
else {
01209
01210
01211
01212
if (Console->
hSmIcon !=
ghDefaultSmIcon) {
01213
if (Console->
hSmIcon !=
NULL) {
01214
DestroyIcon(Console->
hSmIcon);
01215 }
01216 Console->
hSmIcon =
ghDefaultSmIcon;
01217
PostMessage(Console->
hWnd, WM_SETICON, ICON_SMALL, (LPARAM)
ghDefaultSmIcon);
01218 }
01219 }
01220 }
01221
UnlockConsole(Console);
01222
01223
return Status;
01224 UNREFERENCED_PARAMETER(ReplyStatus);
01225 }
01226
01227
01228 ULONG
01229 SrvSetConsoleCP(
01230 IN OUT PCSR_API_MSG m,
01231 IN OUT PCSR_REPLY_STATUS ReplyStatus
01232 )
01233 {
01234
PCONSOLE_SETCP_MSG a = (
PCONSOLE_SETCP_MSG)&m->u.ApiMessageData;
01235
NTSTATUS Status;
01236
PCONSOLE_INFORMATION Console;
01237 HANDLE hEvent =
NULL;
01238
01239
Status =
ApiPreamble(a->
ConsoleHandle,
01240 &Console
01241 );
01242
if (!
NT_SUCCESS(
Status)) {
01243
return Status;
01244 }
01245
if (a->hEvent) {
01246
Status =
NtDuplicateObject(
CONSOLE_CLIENTPROCESSHANDLE(),
01247 a->hEvent,
01248 NtCurrentProcess(),
01249 &hEvent,
01250 0,
01251
FALSE,
01252 DUPLICATE_SAME_ACCESS
01253 );
01254
if (!
NT_SUCCESS(
Status)) {
01255
goto SrvSetConsoleCPFailure;
01256 }
01257 }
01258
01259
if (!IsValidCodePage(a->
wCodePageID)) {
01260
Status = STATUS_INVALID_PARAMETER;
01261
goto SrvSetConsoleCPFailure;
01262 }
01263
if (
IsAvailableFarEastCodePage( a->
wCodePageID ) &&
01264
OEMCP != a->
wCodePageID )
01265 {
01266
Status = STATUS_INVALID_PARAMETER;
01267
goto SrvSetConsoleCPFailure;
01268 }
01269
01270
if ( (a->
Output && Console->
OutputCP != a->
wCodePageID) ||
01271 (!a->
Output && Console->
CP != a->
wCodePageID) ) {
01272
01273
UINT CodePage;
01274
01275
if (a->
Output) {
01276
01277
01278 CodePage = Console->
OutputCP;
01279
01280
01281 Console->
OutputCP = a->
wCodePageID;
01282
01283 Console->fIsDBCSOutputCP =
CONSOLE_IS_DBCS_ENABLED() &&
IsAvailableFarEastCodePage(Console->
OutputCP);
01284
01285
if (!
ReCreateDbcsScreenBuffer(Console, CodePage) ) {
01286 RIPMSG1(RIP_WARNING,
"SrvSetConsoleCP: ReCreateDbcsScreenBuffer failed. Restoring to CP=%d",
01287 CodePage);
01288 Console->
OutputCP = CodePage;
01289 Console->fIsDBCSOutputCP =
CONSOLE_IS_DBCS_ENABLED() &&
IsAvailableFarEastCodePage(CodePage);
01290
Status = STATUS_NO_MEMORY;
01291
goto SrvSetConsoleCPFailure;
01292 }
01293 SetConsoleCPInfo(Console,a->
Output);
01294
Status =
QueueConsoleMessage(Console,
01295 CM_SET_IME_CODEPAGE,
01296 (WPARAM)hEvent,
01297 MAKELPARAM(a->
Output,CodePage)
01298 );
01299
if (!
NT_SUCCESS(
Status)) {
01300
goto SrvSetConsoleCPFailure;
01301 }
01302
01303
01304
01305
#ifdef i386
01306
01307
if (Console->
FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE) {
01308 SetROMFontCodePage(Console->
OutputCP,
01309 Console->
CurrentScreenBuffer->
BufferInfo.TextInfo.ModeIndex);
01310 WriteRegionToScreenHW(Console->
CurrentScreenBuffer,
01311 &Console->
CurrentScreenBuffer->
Window);
01312 }
01313
#endif
01314
01315
01316 }
else {
01317
01318
01319 CodePage = Console->
CP;
01320
01321
01322 Console->
CP = a->
wCodePageID;
01323
01324 Console->fIsDBCSCP =
CONSOLE_IS_DBCS_ENABLED() &&
IsAvailableFarEastCodePage(Console->
CP);
01325
01326 SetConsoleCPInfo(Console,a->
Output);
01327
Status =
QueueConsoleMessage(Console,
01328 CM_SET_IME_CODEPAGE,
01329 (WPARAM)hEvent,
01330 MAKELPARAM(a->
Output,CodePage)
01331 );
01332
if (!
NT_SUCCESS(
Status)) {
01333
goto SrvSetConsoleCPFailure;
01334 }
01335 }
01336 }
01337
else {
01338
if (hEvent) {
01339
NtSetEvent(hEvent,
NULL);
01340
NtClose(hEvent);
01341 }
01342 }
01343
01344
UnlockConsole(Console);
01345
return STATUS_SUCCESS;
01346
01347 SrvSetConsoleCPFailure:
01348
if (hEvent) {
01349
NtSetEvent(hEvent,
NULL);
01350
NtClose(hEvent);
01351 }
01352
UnlockConsole(Console);
01353
return Status;
01354
01355 UNREFERENCED_PARAMETER(ReplyStatus);
01356 }
01357
01358 ULONG
01359 SrvGetConsoleCP(
01360 IN OUT PCSR_API_MSG m,
01361 IN OUT PCSR_REPLY_STATUS ReplyStatus
01362 )
01363 {
01364
PCONSOLE_GETCP_MSG a = (
PCONSOLE_GETCP_MSG)&m->u.ApiMessageData;
01365
NTSTATUS Status;
01366
PCONSOLE_INFORMATION Console;
01367
01368
Status =
ApiPreamble(a->
ConsoleHandle,
01369 &Console
01370 );
01371
if (!
NT_SUCCESS(
Status)) {
01372
return Status;
01373 }
01374
if (a->
Output) {
01375 a->
wCodePageID = Console->
OutputCP;
01376 }
else {
01377 a->
wCodePageID = Console->
CP;
01378 }
01379
UnlockConsole(Console);
01380
return STATUS_SUCCESS;
01381 UNREFERENCED_PARAMETER(ReplyStatus);
01382 }
01383
01384 ULONG
01385 SrvGetConsoleKeyboardLayoutName(
01386 IN OUT PCSR_API_MSG m,
01387 IN OUT PCSR_REPLY_STATUS ReplyStatus
01388 )
01389 {
01390
PCONSOLE_GETKEYBOARDLAYOUTNAME_MSG a = (
PCONSOLE_GETKEYBOARDLAYOUTNAME_MSG)&m->u.ApiMessageData;
01391
NTSTATUS Status;
01392
PCONSOLE_INFORMATION Console;
01393
01394
Status =
ApiPreamble(a->
ConsoleHandle,
01395 &Console
01396 );
01397
if (!
NT_SUCCESS(
Status)) {
01398
return Status;
01399 }
01400
if (Console->
hklActive ==
NULL) {
01401
01402
01403
01404
extern void GetNonBiDiKeyboardLayout(HKL * phklActive);
01405
01406 RIPMSG1(RIP_WARNING,
"SrvGetConsoleKeyboardLayoutName: hklActive is not initialized. pCon=%p", Console);
01407
01408
SystemParametersInfo(SPI_GETDEFAULTINPUTLANG, 0, &Console->
hklActive,
FALSE);
01409
GetNonBiDiKeyboardLayout(&Console->
hklActive);
01410 }
01411
ActivateKeyboardLayout(Console->
hklActive, 0);
01412
if (a->
bAnsi) {
01413 GetKeyboardLayoutNameA(a->
achLayout);
01414 }
else {
01415 GetKeyboardLayoutNameW(a->
awchLayout);
01416 }
01417
UnlockConsole(Console);
01418
return STATUS_SUCCESS;
01419 UNREFERENCED_PARAMETER(ReplyStatus);
01420 }
01421
01422
01423 ULONG
01424 SrvGetConsoleWindow(
01425 IN OUT PCSR_API_MSG m,
01426 IN OUT PCSR_REPLY_STATUS ReplyStatus
01427 )
01428 {
01429
PCONSOLE_GETCONSOLEWINDOW_MSG a = (
PCONSOLE_GETCONSOLEWINDOW_MSG)&m->u.ApiMessageData;
01430
NTSTATUS Status;
01431
PCONSOLE_INFORMATION Console;
01432
01433
Status =
ApiPreamble(a->
ConsoleHandle,
01434 &Console
01435 );
01436
if (!
NT_SUCCESS(
Status)) {
01437
return Status;
01438 }
01439
01440 a->
hwnd = Console->
hWnd;
01441
01442
UnlockConsole(Console);
01443
return STATUS_SUCCESS;
01444 UNREFERENCED_PARAMETER(ReplyStatus);
01445 }
01446
01447