00471 {
00472 HANDLE hSection;
00473 SIZE_T ulViewSize;
00474
NTSTATUS Status;
00475 PCONSOLE_STATE_INFO pStateInfo;
00476
PCONSOLE_PROCESS_HANDLE ProcessHandleRecord;
00477
PSCREEN_INFORMATION ScreenInfo;
00478 ULONG FontIndex;
00479 WINDOWPLACEMENT wp;
00480 COORD NewSize;
00481
WINDOW_LIMITS WindowLimits;
00482
00483
00484
00485
00486 ProcessHandleRecord = CONTAINING_RECORD(Console->ProcessHandleList.Blink,
00487
CONSOLE_PROCESS_HANDLE,
00488 ListLink);
00489
Status =
NtDuplicateObject(ProcessHandleRecord->
ProcessHandle,
00490 hClientSection,
00491 NtCurrentProcess(),
00492 &hSection,
00493 0,
00494 0,
00495 DUPLICATE_SAME_ACCESS);
00496
if (!
NT_SUCCESS(Status)) {
00497 KdPrint((
"CONSRV: error %x mapping client handle\n", Status));
00498
return;
00499 }
00500
00501
00502
00503
00504 pStateInfo =
NULL;
00505 ulViewSize = 0;
00506
Status =
NtMapViewOfSection(hSection,
00507 NtCurrentProcess(),
00508 &pStateInfo,
00509 0,
00510 0,
00511 NULL,
00512 &ulViewSize,
00513 ViewUnmap,
00514 0,
00515 PAGE_READONLY);
00516
if (!
NT_SUCCESS(Status)) {
00517 KdPrint((
"CONSRV: error %x mapping view of file\n", Status));
00518
NtClose(hSection);
00519
return;
00520 }
00521
00522
00523
00524
00525
if (ulViewSize <
sizeof(CONSOLE_STATE_INFO)) {
00526 KdPrint((
"CONSRV: sizeof(hSection) < sizeof(CONSOLE_STATE_INFO)\n"));
00527
NtUnmapViewOfSection(NtCurrentProcess(), pStateInfo);
00528
NtClose(hSection);
00529
return;
00530 }
00531
00532 ScreenInfo = Console->CurrentScreenBuffer;
00533
#if defined(FE_SB)
00534
if (Console->OutputCP != pStateInfo->CodePage)
00535 {
00536
UINT CodePage = Console->OutputCP;
00537
00538 Console->OutputCP = pStateInfo->CodePage;
00539
if (
CONSOLE_IS_DBCS_ENABLED())
00540 Console->fIsDBCSOutputCP = !!
IsAvailableFarEastCodePage(Console->OutputCP);
00541
else
00542 Console->fIsDBCSOutputCP =
FALSE;
00543 SetConsoleCPInfo(Console,TRUE);
00544
#if defined(FE_IME)
00545
SetImeOutputCodePage(Console, ScreenInfo, CodePage);
00546
#endif // FE_IME
00547
}
00548
if (Console->CP != pStateInfo->CodePage)
00549 {
00550
UINT CodePage = Console->CP;
00551
00552 Console->CP = pStateInfo->CodePage;
00553
if (
CONSOLE_IS_DBCS_ENABLED())
00554 Console->fIsDBCSCP = !!
IsAvailableFarEastCodePage(Console->CP);
00555
else
00556 Console->fIsDBCSCP =
FALSE;
00557 SetConsoleCPInfo(Console,FALSE);
00558
#if defined(FE_IME)
00559
SetImeCodePage(Console);
00560
#endif // FE_IME
00561
}
00562
#endif // FE_SB
00563
00564
00565
00566
00567
if (!(Console->Flags &
CONSOLE_VDM_REGISTERED) &&
00568 (pStateInfo->ScreenBufferSize.X != ScreenInfo->
ScreenBufferSize.X ||
00569 pStateInfo->ScreenBufferSize.Y != ScreenInfo->
ScreenBufferSize.Y)) {
00570
00571
PCOOKED_READ_DATA CookedReadData = Console->lpCookedReadData;
00572
00573
if (CookedReadData && CookedReadData->
NumberOfVisibleChars) {
00574
DeleteCommandLine(CookedReadData, FALSE);
00575 }
00576
ResizeScreenBuffer(ScreenInfo,
00577 pStateInfo->ScreenBufferSize,
00578 TRUE);
00579
if (CookedReadData && CookedReadData->
NumberOfVisibleChars) {
00580
RedrawCommandLine(CookedReadData);
00581 }
00582 }
00583
#if !defined(FE_SB)
00584
FontIndex =
FindCreateFont(pStateInfo->FontFamily,
00585 pStateInfo->FaceName,
00586 pStateInfo->FontSize,
00587 pStateInfo->FontWeight);
00588
#else
00589
FontIndex =
FindCreateFont(pStateInfo->FontFamily,
00590 pStateInfo->FaceName,
00591 pStateInfo->FontSize,
00592 pStateInfo->FontWeight,
00593 pStateInfo->CodePage);
00594
#endif
00595
00596
#if defined(FE_SB)
00597
#if defined(i386)
00598
if (! (Console->FullScreenFlags & CONSOLE_FULLSCREEN)) {
00599
SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
00600 }
00601
else {
00602
ChangeDispSettings(Console, Console->hWnd, 0);
00603
SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
00604
ConvertToFullScreen(Console);
00605
ChangeDispSettings(Console, Console->hWnd, CDS_FULLSCREEN);
00606 }
00607
#else // i386
00608
SetScreenBufferFont(ScreenInfo, FontIndex, pStateInfo->CodePage);
00609
#endif
00610
#else // FE_SB
00611
SetScreenBufferFont(ScreenInfo, FontIndex);
00612
#endif // FE_SB
00613
SetCursorInformation(ScreenInfo,
00614 pStateInfo->CursorSize,
00615 ScreenInfo->
BufferInfo.TextInfo.CursorVisible);
00616
00617
GetWindowLimits(ScreenInfo, &WindowLimits);
00618 NewSize.X =
min(pStateInfo->WindowSize.X, WindowLimits.
MaximumWindowSize.X);
00619 NewSize.Y =
min(pStateInfo->WindowSize.Y, WindowLimits.
MaximumWindowSize.Y);
00620
if (NewSize.X !=
CONSOLE_WINDOW_SIZE_X(ScreenInfo) ||
00621 NewSize.Y !=
CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) {
00622 wp.length =
sizeof(wp);
00623
GetWindowPlacement(Console->hWnd, &wp);
00624 wp.rcNormalPosition.right += (NewSize.X -
CONSOLE_WINDOW_SIZE_X(ScreenInfo)) *
00625
SCR_FONTSIZE(ScreenInfo).X;
00626 wp.rcNormalPosition.bottom += (NewSize.Y -
CONSOLE_WINDOW_SIZE_Y(ScreenInfo)) *
00627
SCR_FONTSIZE(ScreenInfo).Y;
00628 SetWindowPlacement(Console->hWnd, &wp);
00629 }
00630
00631
#ifdef i386
00632
if (
FullScreenInitialized) {
00633
if (pStateInfo->FullScreen ==
FALSE) {
00634
if (Console->FullScreenFlags & CONSOLE_FULLSCREEN) {
00635
ConvertToWindowed(Console);
00636
#if defined(FE_SB)
00637
00638
00639
00640
00641
00642
00643
00644
00645
00646
00647
00648
00649
00650
00651
00652
00653 Console->FullScreenFlags &= ~CONSOLE_FULLSCREEN;
00654
#else
00655
ASSERT(!(Console->FullScreenFlags & CONSOLE_FULLSCREEN_HARDWARE));
00656 Console->FullScreenFlags = 0;
00657
#endif
00658
00659
ChangeDispSettings(Console, Console->hWnd, 0);
00660 }
00661 }
else {
00662
if (Console->FullScreenFlags == 0) {
00663
ConvertToFullScreen(Console);
00664 Console->FullScreenFlags |= CONSOLE_FULLSCREEN;
00665
00666
ChangeDispSettings(Console, Console->hWnd, CDS_FULLSCREEN);
00667 }
00668 }
00669 }
00670
#endif
00671
if (pStateInfo->QuickEdit) {
00672 Console->Flags |=
CONSOLE_QUICK_EDIT_MODE;
00673 }
else {
00674 Console->Flags &= ~
CONSOLE_QUICK_EDIT_MODE;
00675 }
00676
if (pStateInfo->AutoPosition) {
00677 Console->Flags |=
CONSOLE_AUTO_POSITION;
00678 }
else {
00679 Console->Flags &= ~
CONSOLE_AUTO_POSITION;
00680
SetWindowPos(Console->hWnd, NULL,
00681 pStateInfo->WindowPosX,
00682 pStateInfo->WindowPosY,
00683 0, 0, SWP_NOZORDER | SWP_NOSIZE);
00684 }
00685
if (Console->InsertMode != pStateInfo->InsertMode) {
00686
SetCursorMode(ScreenInfo, FALSE);
00687 Console->InsertMode = (pStateInfo->InsertMode !=
FALSE);
00688
#ifdef FE_SB
00689
if (Console->lpCookedReadData) {
00690 ((
PCOOKED_READ_DATA)Console->lpCookedReadData)->InsertMode = Console->InsertMode;
00691 }
00692
#endif
00693
}
00694
00695 RtlCopyMemory(Console->ColorTable,
00696 pStateInfo->ColorTable,
00697
sizeof(Console->ColorTable));
00698
SetScreenColors(ScreenInfo,
00699 pStateInfo->ScreenAttributes,
00700 pStateInfo->PopupAttributes,
00701 TRUE);
00702
00703
ResizeCommandHistoryBuffers(Console, pStateInfo->HistoryBufferSize);
00704 Console->MaxCommandHistories = (
SHORT)pStateInfo->NumberOfHistoryBuffers;
00705
if (pStateInfo->HistoryNoDup) {
00706 Console->Flags |=
CONSOLE_HISTORY_NODUP;
00707 }
else {
00708 Console->Flags &= ~
CONSOLE_HISTORY_NODUP;
00709 }
00710
00711
#if defined(FE_IME)
00712
SetUndetermineAttribute(Console) ;
00713
#endif
00714
00715
NtUnmapViewOfSection(NtCurrentProcess(), pStateInfo);
00716
NtClose(hSection);
00717
00718
return;
00719 }