Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

constubs.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1985 - 1999, Microsoft Corporation 00004 00005 Module Name: 00006 00007 constubs.c 00008 00009 Abstract: 00010 00011 Author: 00012 00013 KazuM Mar.05.1992 00014 00015 Revision History: 00016 00017 --*/ 00018 00019 #include "precomp.h" 00020 #pragma hdrstop 00021 00022 00023 #if defined(FE_SB) 00024 ULONG 00025 SrvGetConsoleCharType( 00026 IN OUT PCSR_API_MSG m, 00027 IN OUT PCSR_REPLY_STATUS ReplyStatus 00028 ) 00029 00030 /*++ 00031 00032 Routine Description: 00033 00034 This routine check character type. 00035 00036 Arguments: 00037 00038 m - message containing api parameters 00039 00040 ReplyStatus - Indicates whether to reply to the dll port. 00041 00042 Return Value: 00043 00044 --*/ 00045 00046 { 00047 NTSTATUS Status; 00048 PCONSOLE_CHAR_TYPE_MSG a = (PCONSOLE_CHAR_TYPE_MSG)&m->u.ApiMessageData; 00049 PCONSOLE_INFORMATION Console; 00050 PSCREEN_INFORMATION ScreenInfo; 00051 PHANDLE_DATA HandleData; 00052 SHORT RowIndex; 00053 PROW Row; 00054 PWCHAR Char; 00055 00056 Status = ApiPreamble(a->ConsoleHandle, 00057 &Console 00058 ); 00059 if (!NT_SUCCESS(Status)) { 00060 return Status; 00061 } 00062 00063 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00064 a->Handle, 00065 CONSOLE_OUTPUT_HANDLE, 00066 GENERIC_READ, 00067 &HandleData 00068 ); 00069 if (NT_SUCCESS(Status)) { 00070 00071 ScreenInfo = HandleData->Buffer.ScreenBuffer; 00072 00073 #if defined(DBG) && defined(DBG_KATTR) 00074 BeginKAttrCheck(ScreenInfo); 00075 #endif 00076 00077 if (a->coordCheck.X >= ScreenInfo->ScreenBufferSize.X || 00078 a->coordCheck.Y >= ScreenInfo->ScreenBufferSize.Y) { 00079 Status = STATUS_INVALID_PARAMETER; 00080 } 00081 else { 00082 RowIndex = (ScreenInfo->BufferInfo.TextInfo.FirstRow+a->coordCheck.Y) % ScreenInfo->ScreenBufferSize.Y; 00083 Row = &ScreenInfo->BufferInfo.TextInfo.Rows[RowIndex]; 00084 Char = &Row->CharRow.Chars[a->coordCheck.X]; 00085 if (!CONSOLE_IS_DBCS_OUTPUTCP(ScreenInfo->Console)) 00086 a->dwType = CHAR_TYPE_SBCS; 00087 else if (Row->CharRow.KAttrs[a->coordCheck.X] & ATTR_TRAILING_BYTE) 00088 a->dwType = CHAR_TYPE_TRAILING; 00089 else if (Row->CharRow.KAttrs[a->coordCheck.X] & ATTR_LEADING_BYTE) 00090 a->dwType = CHAR_TYPE_LEADING; 00091 else 00092 a->dwType = CHAR_TYPE_SBCS; 00093 } 00094 } 00095 00096 UnlockConsole(Console); 00097 return((ULONG) Status); 00098 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00099 } 00100 00101 ULONG 00102 SrvSetConsoleLocalEUDC( 00103 IN OUT PCSR_API_MSG m, 00104 IN OUT PCSR_REPLY_STATUS ReplyStatus 00105 ) 00106 00107 /*++ 00108 00109 Routine Description: 00110 00111 This routine sets Local EUDC Font. 00112 00113 Arguments: 00114 00115 m - message containing api parameters 00116 00117 ReplyStatus - Indicates whether to reply to the dll port. 00118 00119 Return Value: 00120 00121 --*/ 00122 00123 { 00124 PCONSOLE_LOCAL_EUDC_MSG a = (PCONSOLE_LOCAL_EUDC_MSG)&m->u.ApiMessageData; 00125 NTSTATUS Status; 00126 PCONSOLE_INFORMATION Console; 00127 PHANDLE_DATA HandleData; 00128 CHAR Source[4]; 00129 WCHAR Target[2]; 00130 00131 Status = ApiPreamble(a->ConsoleHandle, 00132 &Console 00133 ); 00134 if (!NT_SUCCESS(Status)) { 00135 return Status; 00136 } 00137 00138 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00139 a->Handle, 00140 CONSOLE_OUTPUT_HANDLE, 00141 GENERIC_WRITE, 00142 &HandleData 00143 ); 00144 if (!NT_SUCCESS(Status)) { 00145 UnlockConsole(Console); 00146 return((ULONG) Status); 00147 } 00148 00149 if (!CsrValidateMessageBuffer(m, &a->FontFace, ((a->FontSize.X + 7) / 8), a->FontSize.Y)) { 00150 UnlockConsole(Console); 00151 return STATUS_INVALID_PARAMETER; 00152 } 00153 00154 Source[0] = (char)(a->CodePoint >> 8) ; 00155 Source[1] = (char)(a->CodePoint & 0x00ff) ; 00156 Source[2] = 0 ; 00157 ConvertOutputToUnicode(Console->OutputCP,Source,2,Target,1); 00158 00159 if (IsEudcRange(Console,Target[0])) 00160 { 00161 Status = RegisterLocalEUDC(Console,Target[0],a->FontSize,a->FontFace); 00162 if (NT_SUCCESS(Status)) { 00163 ((PEUDC_INFORMATION)(Console->EudcInformation))->LocalVDMEudcMode = TRUE; 00164 } 00165 } 00166 else { 00167 UnlockConsole(Console); 00168 return (ULONG)STATUS_INVALID_PARAMETER; 00169 } 00170 00171 UnlockConsole(Console); 00172 return STATUS_SUCCESS; 00173 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00174 } 00175 00176 ULONG 00177 SrvSetConsoleCursorMode( 00178 IN OUT PCSR_API_MSG m, 00179 IN OUT PCSR_REPLY_STATUS ReplyStatus 00180 ) 00181 00182 /*++ 00183 00184 Routine Description: 00185 00186 This routine sets Cursor Mode. 00187 00188 Arguments: 00189 00190 m - message containing api parameters 00191 00192 ReplyStatus - Indicates whether to reply to the dll port. 00193 00194 Return Value: 00195 00196 --*/ 00197 00198 { 00199 PCONSOLE_CURSOR_MODE_MSG a = (PCONSOLE_CURSOR_MODE_MSG)&m->u.ApiMessageData; 00200 NTSTATUS Status; 00201 PCONSOLE_INFORMATION Console; 00202 PHANDLE_DATA HandleData; 00203 00204 Status = ApiPreamble(a->ConsoleHandle, 00205 &Console 00206 ); 00207 if (!NT_SUCCESS(Status)) { 00208 return Status; 00209 } 00210 00211 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00212 a->Handle, 00213 CONSOLE_OUTPUT_HANDLE, 00214 GENERIC_WRITE, 00215 &HandleData 00216 ); 00217 if (!NT_SUCCESS(Status)) { 00218 UnlockConsole(Console); 00219 return((ULONG) Status); 00220 } 00221 00222 HandleData->Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorBlink = (BOOLEAN)a->Blink ; 00223 HandleData->Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorDBEnable = (BOOLEAN)a->DBEnable ; 00224 00225 UnlockConsole(Console); 00226 return Status; 00227 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00228 } 00229 00230 00231 ULONG 00232 SrvGetConsoleCursorMode( 00233 IN OUT PCSR_API_MSG m, 00234 IN OUT PCSR_REPLY_STATUS ReplyStatus 00235 ) 00236 00237 /*++ 00238 00239 Routine Description: 00240 00241 This routine gets Cursor Mode. 00242 00243 Arguments: 00244 00245 m - message containing api parameters 00246 00247 ReplyStatus - Indicates whether to reply to the dll port. 00248 00249 Return Value: 00250 00251 --*/ 00252 00253 { 00254 PCONSOLE_CURSOR_MODE_MSG a = (PCONSOLE_CURSOR_MODE_MSG)&m->u.ApiMessageData; 00255 NTSTATUS Status; 00256 PCONSOLE_INFORMATION Console; 00257 PHANDLE_DATA HandleData; 00258 00259 Status = ApiPreamble(a->ConsoleHandle, 00260 &Console 00261 ); 00262 if (!NT_SUCCESS(Status)) { 00263 return Status; 00264 } 00265 00266 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00267 a->Handle, 00268 CONSOLE_OUTPUT_HANDLE, 00269 GENERIC_READ, 00270 &HandleData 00271 ); 00272 if (!NT_SUCCESS(Status)) { 00273 UnlockConsole(Console); 00274 return((ULONG) Status); 00275 } 00276 00277 a->Blink = HandleData->Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorBlink ; 00278 a->DBEnable = HandleData->Buffer.ScreenBuffer->BufferInfo.TextInfo.CursorDBEnable ; 00279 00280 UnlockConsole(Console); 00281 return Status; 00282 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00283 } 00284 00285 ULONG 00286 SrvRegisterConsoleOS2( 00287 IN OUT PCSR_API_MSG m, 00288 IN OUT PCSR_REPLY_STATUS ReplyStatus 00289 ) 00290 00291 /*++ 00292 00293 This function calls NEC PC-98 machine's only. 00294 00295 --*/ 00296 00297 { 00298 PCONSOLE_REGISTEROS2_MSG a = (PCONSOLE_REGISTEROS2_MSG)&m->u.ApiMessageData; 00299 NTSTATUS Status; 00300 PCONSOLE_INFORMATION Console; 00301 HANDLE hEvent = NULL; 00302 00303 Status = ApiPreamble(a->ConsoleHandle, 00304 &Console 00305 ); 00306 if (!NT_SUCCESS(Status)) { 00307 return Status; 00308 } 00309 #if defined(i386) 00310 { 00311 if (!a->fOs2Register) { 00312 Console->Flags &= ~ CONSOLE_OS2_REGISTERED; 00313 ResizeWindow(Console->CurrentScreenBuffer, &Console->Os2SavedWindowRect, FALSE); 00314 } 00315 else { 00316 Console->Flags |= CONSOLE_OS2_REGISTERED; 00317 Console->Os2SavedWindowRect = Console->CurrentScreenBuffer->Window; 00318 } 00319 } 00320 #endif // i386 00321 00322 UnlockConsole(Console); 00323 return Status; 00324 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00325 } 00326 00327 ULONG 00328 SrvSetConsoleOS2OemFormat( 00329 IN OUT PCSR_API_MSG m, 00330 IN OUT PCSR_REPLY_STATUS ReplyStatus 00331 ) 00332 00333 /*++ 00334 00335 This function calls NEC PC-98 machine's only. 00336 00337 --*/ 00338 00339 { 00340 PCONSOLE_SETOS2OEMFORMAT_MSG a = (PCONSOLE_SETOS2OEMFORMAT_MSG)&m->u.ApiMessageData; 00341 NTSTATUS Status; 00342 PCONSOLE_INFORMATION Console; 00343 00344 Status = ApiPreamble(a->ConsoleHandle, 00345 &Console 00346 ); 00347 if (!NT_SUCCESS(Status)) { 00348 return Status; 00349 } 00350 #if defined(i386) 00351 { 00352 if (!a->fOs2OemFormat) { 00353 Console->Flags &= ~CONSOLE_OS2_OEM_FORMAT; 00354 } 00355 else { 00356 Console->Flags |= CONSOLE_OS2_OEM_FORMAT; 00357 } 00358 } 00359 #endif // i386 00360 00361 UnlockConsole(Console); 00362 return Status; 00363 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00364 } 00365 00366 #if defined(FE_IME) 00367 ULONG 00368 SrvGetConsoleNlsMode( 00369 IN OUT PCSR_API_MSG m, 00370 IN OUT PCSR_REPLY_STATUS ReplyStatus 00371 ) 00372 00373 /*++ 00374 00375 Routine Description: 00376 00377 This routine gets NLS mode for input. 00378 00379 Arguments: 00380 00381 m - message containing api parameters 00382 00383 ReplyStatus - Indicates whether to reply to the dll port. 00384 00385 Return Value: 00386 00387 --*/ 00388 00389 { 00390 NTSTATUS Status; 00391 PCONSOLE_NLS_MODE_MSG a = (PCONSOLE_NLS_MODE_MSG)&m->u.ApiMessageData; 00392 PCONSOLE_INFORMATION Console; 00393 PHANDLE_DATA HandleData; 00394 HANDLE hEvent = NULL; 00395 00396 Status = ApiPreamble(a->ConsoleHandle, 00397 &Console 00398 ); 00399 if (!NT_SUCCESS(Status)) { 00400 return Status; 00401 } 00402 00403 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00404 a->Handle, 00405 CONSOLE_INPUT_HANDLE, 00406 GENERIC_READ, 00407 &HandleData 00408 ); 00409 if (!NT_SUCCESS(Status)) { 00410 goto SrvGetConsoleNlsModeFailure; 00411 } 00412 00413 Status = NtDuplicateObject(CONSOLE_CLIENTPROCESSHANDLE(), 00414 a->hEvent, 00415 NtCurrentProcess(), 00416 &hEvent, 00417 0, 00418 FALSE, 00419 DUPLICATE_SAME_ACCESS 00420 ); 00421 if (!NT_SUCCESS(Status)) { 00422 goto SrvGetConsoleNlsModeFailure; 00423 } 00424 00425 /* 00426 * Caller should set FALSE on a->Ready. 00427 */ 00428 if (a->Ready == FALSE) 00429 { 00430 a->Ready = HandleData->Buffer.InputBuffer->ImeMode.ReadyConversion; 00431 00432 if (a->Ready == FALSE) 00433 { 00434 /* 00435 * If not ready ImeMode.Conversion, 00436 * then get conversion status from ConIME. 00437 */ 00438 Status = QueueConsoleMessage(Console, 00439 CM_GET_NLSMODE, 00440 (WPARAM)hEvent, 00441 0L 00442 ); 00443 if (!NT_SUCCESS(Status)) { 00444 goto SrvGetConsoleNlsModeFailure; 00445 } 00446 } 00447 else 00448 { 00449 if (! HandleData->Buffer.InputBuffer->ImeMode.Disable) { 00450 a->NlsMode = ImmConversionToConsole( 00451 HandleData->Buffer.InputBuffer->ImeMode.Conversion ); 00452 } 00453 else { 00454 a->NlsMode = 0; 00455 } 00456 NtSetEvent(hEvent, NULL); 00457 NtClose(hEvent); 00458 } 00459 } 00460 else 00461 { 00462 if (! HandleData->Buffer.InputBuffer->ImeMode.Disable) { 00463 a->NlsMode = ImmConversionToConsole( 00464 HandleData->Buffer.InputBuffer->ImeMode.Conversion ); 00465 } 00466 else { 00467 a->NlsMode = 0; 00468 } 00469 NtSetEvent(hEvent, NULL); 00470 NtClose(hEvent); 00471 } 00472 00473 UnlockConsole(Console); 00474 return((ULONG) Status); 00475 00476 SrvGetConsoleNlsModeFailure: 00477 if (hEvent) { 00478 NtSetEvent(hEvent, NULL); 00479 NtClose(hEvent); 00480 } 00481 UnlockConsole(Console); 00482 return((ULONG) Status); 00483 00484 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00485 } 00486 00487 ULONG 00488 SrvSetConsoleNlsMode( 00489 IN OUT PCSR_API_MSG m, 00490 IN OUT PCSR_REPLY_STATUS ReplyStatus 00491 ) 00492 00493 /*++ 00494 00495 Routine Description: 00496 00497 This routine sets NLS mode for input. 00498 00499 Arguments: 00500 00501 m - message containing api parameters 00502 00503 ReplyStatus - Indicates whether to reply to the dll port. 00504 00505 Return Value: 00506 00507 --*/ 00508 00509 { 00510 PCONSOLE_NLS_MODE_MSG a = (PCONSOLE_NLS_MODE_MSG)&m->u.ApiMessageData; 00511 NTSTATUS Status; 00512 PCONSOLE_INFORMATION Console; 00513 PHANDLE_DATA HandleData; 00514 HANDLE hEvent = NULL; 00515 00516 Status = ApiPreamble(a->ConsoleHandle, 00517 &Console 00518 ); 00519 if (!NT_SUCCESS(Status)) { 00520 return Status; 00521 } 00522 00523 Status = DereferenceIoHandle(CONSOLE_PERPROCESSDATA(), 00524 a->Handle, 00525 CONSOLE_INPUT_HANDLE, 00526 GENERIC_WRITE, 00527 &HandleData 00528 ); 00529 if (!NT_SUCCESS(Status)) { 00530 goto SrvSetConsoleNlsModeFailure; 00531 } 00532 00533 Status = NtDuplicateObject(CONSOLE_CLIENTPROCESSHANDLE(), 00534 a->hEvent, 00535 NtCurrentProcess(), 00536 &hEvent, 00537 0, 00538 FALSE, 00539 DUPLICATE_SAME_ACCESS 00540 ); 00541 if (!NT_SUCCESS(Status)) { 00542 goto SrvSetConsoleNlsModeFailure; 00543 } 00544 00545 Status = QueueConsoleMessage(Console, 00546 CM_SET_NLSMODE, 00547 (WPARAM)hEvent, 00548 a->NlsMode 00549 ); 00550 if (!NT_SUCCESS(Status)) { 00551 goto SrvSetConsoleNlsModeFailure; 00552 } 00553 00554 UnlockConsole(Console); 00555 return Status; 00556 00557 SrvSetConsoleNlsModeFailure: 00558 if (hEvent) { 00559 NtSetEvent(hEvent, NULL); 00560 NtClose(hEvent); 00561 } 00562 UnlockConsole(Console); 00563 return Status; 00564 00565 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00566 } 00567 00568 ULONG 00569 SrvRegisterConsoleIME( 00570 IN OUT PCSR_API_MSG m, 00571 IN OUT PCSR_REPLY_STATUS ReplyStatus 00572 ) 00573 00574 /*++ 00575 00576 Routine Description: 00577 00578 This routine register console IME on the current desktop. 00579 00580 Arguments: 00581 00582 m - message containing api parameters 00583 00584 ReplyStatus - Indicates whether to reply to the dll port. 00585 00586 Return Value: 00587 00588 --*/ 00589 00590 { 00591 PCONSOLE_REGISTER_CONSOLEIME_MSG a = (PCONSOLE_REGISTER_CONSOLEIME_MSG)&m->u.ApiMessageData; 00592 NTSTATUS Status; 00593 PCSR_PROCESS Process; 00594 HDESK hdesk; 00595 HWINSTA hwinsta; 00596 UNICODE_STRING strDesktopName; 00597 00598 a->dwConsoleThreadId = 0; 00599 00600 if (!CsrValidateMessageBuffer(m, &a->Desktop, a->DesktopLength, sizeof(BYTE))) { 00601 return STATUS_INVALID_PARAMETER; 00602 } 00603 00604 // 00605 // Connect to the windowstation and desktop. 00606 // 00607 00608 if (!CsrImpersonateClient(NULL)) { 00609 return (ULONG)STATUS_BAD_IMPERSONATION_LEVEL; 00610 } 00611 00612 Process = (PCSR_PROCESS)(CSR_SERVER_QUERYCLIENTTHREAD()->Process); 00613 if (a->DesktopLength) 00614 RtlInitUnicodeString(&strDesktopName, a->Desktop); 00615 else 00616 RtlInitUnicodeString(&strDesktopName, L"Default"); 00617 hdesk = NtUserResolveDesktop( 00618 Process->ProcessHandle, 00619 &strDesktopName, FALSE, &hwinsta); 00620 00621 CsrRevertToSelf(); 00622 00623 if (hdesk == NULL) { 00624 return (ULONG)STATUS_UNSUCCESSFUL; 00625 } 00626 00627 Status = ConSrvRegisterConsoleIME(Process, 00628 hdesk, 00629 hwinsta, 00630 a->hWndConsoleIME, 00631 a->dwConsoleIMEThreadId, 00632 REGCONIME_REGISTER, 00633 &a->dwConsoleThreadId 00634 ); 00635 00636 00637 return ((ULONG)Status); 00638 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00639 } 00640 00641 ULONG 00642 SrvUnregisterConsoleIME( 00643 IN OUT PCSR_API_MSG m, 00644 IN OUT PCSR_REPLY_STATUS ReplyStatus 00645 ) 00646 00647 /*++ 00648 00649 Routine Description: 00650 00651 This routine unregister console IME on the current desktop. 00652 00653 Arguments: 00654 00655 m - message containing api parameters 00656 00657 ReplyStatus - Indicates whether to reply to the dll port. 00658 00659 Return Value: 00660 00661 --*/ 00662 00663 { 00664 PCONSOLE_UNREGISTER_CONSOLEIME_MSG a = (PCONSOLE_UNREGISTER_CONSOLEIME_MSG)&m->u.ApiMessageData; 00665 NTSTATUS Status; 00666 PCSR_PROCESS Process; 00667 PCONSOLE_PER_PROCESS_DATA ProcessData; 00668 00669 Process = (PCSR_PROCESS)(CSR_SERVER_QUERYCLIENTTHREAD()->Process); 00670 ProcessData = CONSOLE_FROMPROCESSPERPROCESSDATA(Process); 00671 00672 Status = ConSrvRegisterConsoleIME(Process, 00673 ProcessData->hDesk, 00674 ProcessData->hWinSta, 00675 NULL, 00676 a->dwConsoleIMEThreadId, 00677 REGCONIME_UNREGISTER, 00678 NULL 00679 ); 00680 00681 00682 return ((ULONG)Status); 00683 UNREFERENCED_PARAMETER(ReplyStatus); // get rid of unreferenced parameter warning message 00684 } 00685 #endif // FE_IME 00686 00687 #endif // FE_SB

Generated on Sat May 15 19:39:33 2004 for test by doxygen 1.3.7