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

dbcs.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1985 - 1999, Microsoft Corporation 00004 00005 Module Name: 00006 00007 dbcs.c 00008 00009 Abstract: 00010 00011 Author: 00012 00013 KazuM May.11.1992 00014 00015 Revision History: 00016 00017 --*/ 00018 00019 #include "precomp.h" 00020 #pragma hdrstop 00021 00022 #if defined(FE_SB) 00023 #include "conime.h" 00024 00025 #if !defined(BUILD_WOW6432) 00026 00027 BOOL 00028 APIENTRY 00029 GetConsoleNlsMode( 00030 IN HANDLE hConsoleHandle, 00031 OUT LPDWORD lpNlsMode 00032 ) 00033 00034 /*++ 00035 00036 Parameters: 00037 00038 hConsoleHandle - Supplies a console input or output handle. 00039 00040 lpNlsMode - Supplies a pointer to the NLS mode. 00041 00042 Return Value: 00043 00044 TRUE - The operation was successful. 00045 00046 FALSE/NULL - The operation failed. Extended error status is available 00047 using GetLastError. 00048 00049 00050 --*/ 00051 00052 { 00053 00054 #if defined(FE_IME) 00055 CONSOLE_API_MSG m; 00056 PCONSOLE_NLS_MODE_MSG a = &m.u.GetConsoleNlsMode; 00057 NTSTATUS Status; 00058 00059 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00060 a->Handle = hConsoleHandle; 00061 a->Ready = FALSE; 00062 00063 Status = NtCreateEvent(&(a->hEvent), 00064 EVENT_ALL_ACCESS, 00065 NULL, 00066 SynchronizationEvent, 00067 (BOOLEAN)FALSE 00068 ); 00069 if (!NT_SUCCESS(Status)) { 00070 SET_LAST_NT_ERROR(Status); 00071 return FALSE; 00072 } 00073 00074 CsrClientCallServer( (PCSR_API_MSG)&m, 00075 NULL, 00076 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00077 ConsolepGetNlsMode 00078 ), 00079 sizeof( *a ) 00080 ); 00081 00082 if (NT_SUCCESS( m.ReturnValue )) { 00083 Status = NtWaitForSingleObject(a->hEvent, FALSE, NULL); 00084 00085 if (a->Ready == FALSE) 00086 { 00087 /* 00088 * If not ready conversion status on this console, 00089 * then one more try get status. 00090 */ 00091 CsrClientCallServer( (PCSR_API_MSG)&m, 00092 NULL, 00093 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00094 ConsolepGetNlsMode 00095 ), 00096 sizeof( *a ) 00097 ); 00098 if (! NT_SUCCESS( m.ReturnValue )) { 00099 SET_LAST_NT_ERROR (m.ReturnValue); 00100 NtClose(a->hEvent); 00101 return FALSE; 00102 } 00103 else 00104 { 00105 Status = NtWaitForSingleObject(a->hEvent, FALSE, NULL); 00106 } 00107 } 00108 00109 NtClose(a->hEvent); 00110 00111 try { 00112 *lpNlsMode = a->NlsMode; 00113 } except( EXCEPTION_EXECUTE_HANDLER ) { 00114 SET_LAST_ERROR (ERROR_INVALID_ACCESS); 00115 return FALSE; 00116 } 00117 return TRUE; 00118 } else { 00119 SET_LAST_NT_ERROR (m.ReturnValue); 00120 NtClose(a->hEvent); 00121 return FALSE; 00122 } 00123 #else 00124 return FALSE; 00125 #endif 00126 00127 } 00128 00129 BOOL 00130 APIENTRY 00131 SetConsoleNlsMode( 00132 IN HANDLE hConsoleHandle, 00133 IN DWORD dwNlsMode 00134 ) 00135 00136 /*++ 00137 00138 Parameters: 00139 00140 hConsoleHandle - Supplies a console input or output handle. 00141 00142 dwNlsMode - Supplies NLS mode. 00143 00144 Return Value: 00145 00146 TRUE - The operation was successful. 00147 00148 FALSE/NULL - The operation failed. Extended error status is available 00149 using GetLastError. 00150 00151 --*/ 00152 00153 { 00154 00155 #if defined(FE_IME) 00156 CONSOLE_API_MSG m; 00157 PCONSOLE_NLS_MODE_MSG a = &m.u.SetConsoleNlsMode; 00158 NTSTATUS Status; 00159 00160 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00161 a->Handle = hConsoleHandle; 00162 a->NlsMode = dwNlsMode; 00163 00164 Status = NtCreateEvent(&(a->hEvent), 00165 EVENT_ALL_ACCESS, 00166 NULL, 00167 SynchronizationEvent, 00168 (BOOLEAN)FALSE 00169 ); 00170 if (!NT_SUCCESS(Status)) { 00171 SET_LAST_NT_ERROR(Status); 00172 return FALSE; 00173 } 00174 00175 CsrClientCallServer( (PCSR_API_MSG)&m, 00176 NULL, 00177 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00178 ConsolepSetNlsMode 00179 ), 00180 sizeof( *a ) 00181 ); 00182 if (NT_SUCCESS( m.ReturnValue )) { 00183 Status = NtWaitForSingleObject(a->hEvent, FALSE, NULL); 00184 NtClose(a->hEvent); 00185 if (Status != 0) { 00186 SET_LAST_NT_ERROR(Status); 00187 return FALSE; 00188 } 00189 return TRUE; 00190 } else { 00191 SET_LAST_NT_ERROR (m.ReturnValue); 00192 NtClose(a->hEvent); 00193 return FALSE; 00194 } 00195 #else 00196 return FALSE; 00197 #endif 00198 00199 } 00200 00201 BOOL 00202 APIENTRY 00203 GetConsoleCharType( 00204 IN HANDLE hConsoleHandle, 00205 IN COORD coordCheck, 00206 OUT PDWORD pdwType 00207 ) 00208 00209 /*++ 00210 00211 Parameters: 00212 00213 hConsoleHandle - Supplies a console input or output handle. 00214 00215 coordCheck - set check position to these coordinates 00216 00217 pdwType - receive character type 00218 00219 Return Value: 00220 00221 TRUE - The operation was successful. 00222 00223 FALSE/NULL - The operation failed. Extended error status is available 00224 using GetLastError. 00225 00226 00227 --*/ 00228 00229 { 00230 00231 CONSOLE_API_MSG m; 00232 PCONSOLE_CHAR_TYPE_MSG a = &m.u.GetConsoleCharType; 00233 00234 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00235 a->Handle = hConsoleHandle; 00236 a->coordCheck = coordCheck; 00237 CsrClientCallServer( (PCSR_API_MSG)&m, 00238 NULL, 00239 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00240 ConsolepCharType 00241 ), 00242 sizeof( *a ) 00243 ); 00244 if (NT_SUCCESS( m.ReturnValue )) { 00245 try { 00246 *pdwType = a->dwType; 00247 } except( EXCEPTION_EXECUTE_HANDLER ) { 00248 SET_LAST_ERROR (ERROR_INVALID_ACCESS); 00249 return FALSE; 00250 } 00251 return TRUE; 00252 } else { 00253 SET_LAST_NT_ERROR (m.ReturnValue); 00254 return FALSE; 00255 } 00256 00257 } 00258 00259 BOOL 00260 APIENTRY 00261 SetConsoleLocalEUDC( 00262 IN HANDLE hConsoleHandle, 00263 IN WORD wCodePoint, 00264 IN COORD cFontSize, 00265 IN PCHAR lpSB 00266 ) 00267 00268 /*++ 00269 00270 Parameters: 00271 00272 hConsoleHandle - Supplies a console input or output handle. 00273 00274 wCodePoint - Code point of font by Shift JIS code. 00275 00276 cFontSize - FontSize of Font 00277 00278 lpSB - Pointer of font bitmap Buffer 00279 00280 Return Value: 00281 00282 TRUE - The operation was successful. 00283 00284 FALSE/NULL - The operation failed. Extended error status is available 00285 using GetLastError. 00286 00287 --*/ 00288 00289 { 00290 00291 CONSOLE_API_MSG m; 00292 PCONSOLE_LOCAL_EUDC_MSG a = &m.u.SetConsoleLocalEUDC; 00293 PCSR_CAPTURE_HEADER CaptureBuffer; 00294 ULONG DataLength; 00295 00296 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00297 a->Handle = hConsoleHandle; 00298 a->CodePoint = wCodePoint; 00299 a->FontSize = cFontSize; 00300 00301 DataLength = ((cFontSize.X + 7) / 8) * cFontSize.Y; 00302 00303 CaptureBuffer = CsrAllocateCaptureBuffer( 1, 00304 DataLength 00305 ); 00306 if (CaptureBuffer == NULL) { 00307 SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY); 00308 return FALSE; 00309 } 00310 CsrCaptureMessageBuffer( CaptureBuffer, 00311 lpSB, 00312 DataLength, 00313 (PVOID *) &a->FontFace 00314 ); 00315 00316 CsrClientCallServer( (PCSR_API_MSG)&m, 00317 CaptureBuffer, 00318 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00319 ConsolepSetLocalEUDC 00320 ), 00321 sizeof( *a ) 00322 ); 00323 CsrFreeCaptureBuffer( CaptureBuffer ); 00324 00325 if (NT_SUCCESS( m.ReturnValue )) { 00326 return TRUE; 00327 } else { 00328 SET_LAST_NT_ERROR (m.ReturnValue); 00329 return FALSE; 00330 } 00331 00332 } 00333 00334 BOOL 00335 APIENTRY 00336 SetConsoleCursorMode( 00337 IN HANDLE hConsoleHandle, 00338 IN BOOL Blink, 00339 IN BOOL DBEnable 00340 ) 00341 00342 /*++ 00343 00344 Parameters: 00345 00346 hConsoleHandle - Supplies a console input or output handle. 00347 00348 Blink - Blinking enable/disable switch. 00349 00350 DBEnable - Double Byte width enable/disable switch. 00351 00352 Return Value: 00353 00354 TRUE - The operation was successful. 00355 00356 FALSE/NULL - The operation failed. Extended error status is available 00357 using GetLastError. 00358 00359 --*/ 00360 00361 { 00362 00363 CONSOLE_API_MSG m; 00364 PCONSOLE_CURSOR_MODE_MSG a = &m.u.SetConsoleCursorMode; 00365 00366 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00367 a->Handle = hConsoleHandle; 00368 a->Blink = Blink; 00369 a->DBEnable = DBEnable; 00370 CsrClientCallServer( (PCSR_API_MSG)&m, 00371 NULL, 00372 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00373 ConsolepSetCursorMode 00374 ), 00375 sizeof( *a ) 00376 ); 00377 if (NT_SUCCESS( m.ReturnValue )) { 00378 return TRUE; 00379 } else { 00380 SET_LAST_NT_ERROR (m.ReturnValue); 00381 return FALSE; 00382 } 00383 00384 } 00385 00386 BOOL 00387 APIENTRY 00388 GetConsoleCursorMode( 00389 IN HANDLE hConsoleHandle, 00390 OUT PBOOL pbBlink, 00391 OUT PBOOL pbDBEnable 00392 ) 00393 00394 /*++ 00395 00396 Parameters: 00397 00398 hConsoleHandle - Supplies a console input or output handle. 00399 00400 Blink - Blinking enable/disable switch. 00401 00402 DBEnable - Double Byte width enable/disable switch. 00403 00404 Return Value: 00405 00406 TRUE - The operation was successful. 00407 00408 FALSE/NULL - The operation failed. Extended error status is available 00409 using GetLastError. 00410 00411 --*/ 00412 00413 { 00414 00415 CONSOLE_API_MSG m; 00416 PCONSOLE_CURSOR_MODE_MSG a = &m.u.GetConsoleCursorMode; 00417 00418 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00419 a->Handle = hConsoleHandle; 00420 CsrClientCallServer( (PCSR_API_MSG)&m, 00421 NULL, 00422 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00423 ConsolepGetCursorMode 00424 ), 00425 sizeof( *a ) 00426 ); 00427 if (NT_SUCCESS( m.ReturnValue )) { 00428 try { 00429 *pbBlink = a->Blink; 00430 *pbDBEnable = a->DBEnable; 00431 } except( EXCEPTION_EXECUTE_HANDLER ) { 00432 SET_LAST_ERROR (ERROR_INVALID_ACCESS); 00433 return FALSE; 00434 } 00435 return TRUE; 00436 } else { 00437 SET_LAST_NT_ERROR (m.ReturnValue); 00438 return FALSE; 00439 } 00440 00441 } 00442 00443 00444 BOOL 00445 APIENTRY 00446 RegisterConsoleOS2( 00447 IN BOOL fOs2Register 00448 ) 00449 00450 /*++ 00451 00452 Description: 00453 00454 This routine registers the OS/2 with the console. 00455 00456 Parameters: 00457 00458 Return Value: 00459 00460 TRUE - The operation was successful. 00461 00462 FALSE/NULL - The operation failed. Extended error status is available 00463 using GetLastError. 00464 00465 --*/ 00466 00467 { 00468 CONSOLE_API_MSG m; 00469 PCONSOLE_REGISTEROS2_MSG a = &m.u.RegisterConsoleOS2; 00470 NTSTATUS Status; 00471 00472 00473 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00474 a->fOs2Register = fOs2Register; 00475 00476 CsrClientCallServer( (PCSR_API_MSG)&m, 00477 NULL, 00478 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00479 ConsolepRegisterOS2 00480 ), 00481 sizeof( *a ) 00482 ); 00483 if (!NT_SUCCESS( m.ReturnValue)) { 00484 SET_LAST_NT_ERROR(m.ReturnValue); 00485 return FALSE; 00486 } 00487 else { 00488 return TRUE; 00489 } 00490 } 00491 00492 BOOL 00493 APIENTRY 00494 SetConsoleOS2OemFormat( 00495 IN BOOL fOs2OemFormat 00496 ) 00497 00498 /*++ 00499 00500 Description: 00501 00502 This routine sets the OS/2 OEM Format with the console. 00503 00504 Parameters: 00505 00506 Return Value: 00507 00508 TRUE - The operation was successful. 00509 00510 FALSE/NULL - The operation failed. Extended error status is available 00511 using GetLastError. 00512 00513 --*/ 00514 00515 { 00516 CONSOLE_API_MSG m; 00517 PCONSOLE_SETOS2OEMFORMAT_MSG a = &m.u.SetConsoleOS2OemFormat; 00518 00519 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00520 a->fOs2OemFormat = fOs2OemFormat; 00521 CsrClientCallServer( (PCSR_API_MSG)&m, 00522 NULL, 00523 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00524 ConsolepSetOS2OemFormat 00525 ), 00526 sizeof( *a ) 00527 ); 00528 if (!NT_SUCCESS( m.ReturnValue)) { 00529 SET_LAST_NT_ERROR(m.ReturnValue); 00530 return FALSE; 00531 } 00532 else { 00533 return TRUE; 00534 } 00535 } 00536 00537 #endif 00538 00539 #if defined(FE_IME) 00540 00541 #if !defined(BUILD_WOW6432) 00542 00543 BOOL 00544 APIENTRY 00545 RegisterConsoleIMEInternal( 00546 IN HWND hWndConsoleIME, 00547 IN DWORD dwConsoleIMEThreadId, 00548 IN DWORD DesktopLength, 00549 IN LPWSTR Desktop, 00550 OUT DWORD *dwConsoleThreadId 00551 ) 00552 { 00553 00554 CONSOLE_API_MSG m; 00555 PCONSOLE_REGISTER_CONSOLEIME_MSG a = &m.u.RegisterConsoleIME; 00556 PCSR_CAPTURE_HEADER CaptureBuffer = NULL; 00557 00558 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00559 a->hWndConsoleIME = hWndConsoleIME; 00560 a->dwConsoleIMEThreadId = dwConsoleIMEThreadId; 00561 a->DesktopLength = DesktopLength; 00562 00563 CaptureBuffer = CsrAllocateCaptureBuffer( 1, 00564 DesktopLength 00565 ); 00566 if (CaptureBuffer == NULL) { 00567 SET_LAST_ERROR(ERROR_NOT_ENOUGH_MEMORY); 00568 return FALSE; 00569 } 00570 00571 CsrCaptureMessageBuffer( CaptureBuffer, 00572 Desktop, 00573 a->DesktopLength, 00574 (PVOID *) &a->Desktop 00575 ); 00576 00577 // 00578 // Connect to the server process 00579 // 00580 00581 CsrClientCallServer( (PCSR_API_MSG)&m, 00582 CaptureBuffer, 00583 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00584 ConsolepRegisterConsoleIME 00585 ), 00586 sizeof( *a ) 00587 ); 00588 00589 //HS Jan.20 if (CaptureBuffer) { 00590 CsrFreeCaptureBuffer( CaptureBuffer ); 00591 //HS Jan.20 } 00592 00593 if (!NT_SUCCESS( m.ReturnValue)) { 00594 SET_LAST_NT_ERROR(m.ReturnValue); 00595 return FALSE; 00596 } 00597 else { 00598 try { 00599 if (dwConsoleThreadId != NULL) 00600 *dwConsoleThreadId = a->dwConsoleThreadId; 00601 } except( EXCEPTION_EXECUTE_HANDLER ) { 00602 SET_LAST_ERROR (ERROR_INVALID_ACCESS); 00603 return FALSE; 00604 } 00605 return TRUE; 00606 } 00607 00608 } 00609 00610 #endif 00611 00612 #if !defined(BUILD_WOW64) 00613 00614 BOOL 00615 APIENTRY 00616 RegisterConsoleIME( 00617 IN HWND hWndConsoleIME, 00618 OUT DWORD *dwConsoleThreadId 00619 ) 00620 00621 /*++ 00622 00623 Description: 00624 00625 This routine register the Console IME on the current desktop. 00626 00627 Parameters: 00628 00629 Return Value: 00630 00631 TRUE - The operation was successful. 00632 00633 FALSE - The operation failed. 00634 00635 --*/ 00636 00637 { 00638 STARTUPINFOW StartupInfo; 00639 DWORD dwDesktopLength; 00640 GetStartupInfoW(&StartupInfo); 00641 00642 if (StartupInfo.lpDesktop != NULL && *StartupInfo.lpDesktop != 0) { 00643 dwDesktopLength = (USHORT)((wcslen(StartupInfo.lpDesktop)+1)*sizeof(WCHAR)); 00644 dwDesktopLength = (USHORT)(min(dwDesktopLength,MAX_TITLE_LENGTH)); 00645 } else { 00646 dwDesktopLength = 0; 00647 } 00648 00649 return RegisterConsoleIMEInternal(hWndConsoleIME, 00650 GetCurrentThreadId(), 00651 dwDesktopLength, 00652 StartupInfo.lpDesktop, 00653 dwConsoleThreadId); 00654 } 00655 00656 #endif 00657 00658 #if !defined(BUILD_WOW6432) 00659 00660 BOOL 00661 APIENTRY 00662 UnregisterConsoleIMEInternal( 00663 IN DWORD dwConsoleIMEThtreadId 00664 ) 00665 { 00666 CONSOLE_API_MSG m; 00667 PCONSOLE_UNREGISTER_CONSOLEIME_MSG a = &m.u.UnregisterConsoleIME; 00668 00669 a->ConsoleHandle = GET_CONSOLE_HANDLE; 00670 a->dwConsoleIMEThreadId = dwConsoleIMEThtreadId; 00671 00672 // 00673 // Connect to the server process 00674 // 00675 00676 CsrClientCallServer( (PCSR_API_MSG)&m, 00677 NULL, 00678 CSR_MAKE_API_NUMBER( CONSRV_SERVERDLL_INDEX, 00679 ConsolepUnregisterConsoleIME 00680 ), 00681 sizeof( *a ) 00682 ); 00683 00684 if (!NT_SUCCESS( m.ReturnValue)) { 00685 SET_LAST_NT_ERROR(m.ReturnValue); 00686 return FALSE; 00687 } 00688 else { 00689 return TRUE; 00690 } 00691 } 00692 00693 #endif 00694 00695 #if !defined(BUILD_WOW64) 00696 00697 BOOL 00698 APIENTRY 00699 UnregisterConsoleIME( 00700 ) 00701 00702 /*++ 00703 00704 Description: 00705 00706 This routine unregister the Console IME on the current desktop. 00707 00708 Parameters: 00709 00710 Return Value: 00711 00712 TRUE - The operation was successful. 00713 00714 FALSE - The operation failed. 00715 00716 --*/ 00717 00718 { 00719 00720 return UnregisterConsoleIMEInternal(GetCurrentThreadId()); 00721 00722 } 00723 00724 NTSTATUS 00725 MyRegOpenKey( 00726 IN HANDLE hKey, 00727 IN LPWSTR lpSubKey, 00728 OUT PHANDLE phResult 00729 ) 00730 { 00731 OBJECT_ATTRIBUTES Obja; 00732 UNICODE_STRING SubKey; 00733 00734 // 00735 // Convert the subkey to a counted Unicode string. 00736 // 00737 00738 RtlInitUnicodeString( &SubKey, lpSubKey ); 00739 00740 // 00741 // Initialize the OBJECT_ATTRIBUTES structure and open the key. 00742 // 00743 00744 InitializeObjectAttributes( 00745 &Obja, 00746 &SubKey, 00747 OBJ_CASE_INSENSITIVE, 00748 hKey, 00749 NULL 00750 ); 00751 00752 return NtOpenKey( 00753 phResult, 00754 KEY_READ, 00755 &Obja 00756 ); 00757 } 00758 00759 NTSTATUS 00760 MyRegQueryValue( 00761 IN HANDLE hKey, 00762 IN LPWSTR lpValueName, 00763 IN DWORD dwValueLength, 00764 OUT LPBYTE lpData 00765 ) 00766 { 00767 UNICODE_STRING ValueName; 00768 ULONG BufferLength; 00769 ULONG ResultLength; 00770 PKEY_VALUE_FULL_INFORMATION KeyValueInformation; 00771 NTSTATUS Status; 00772 00773 // 00774 // Convert the subkey to a counted Unicode string. 00775 // 00776 00777 RtlInitUnicodeString( &ValueName, lpValueName ); 00778 00779 BufferLength = sizeof(KEY_VALUE_FULL_INFORMATION) + dwValueLength + ValueName.Length;; 00780 KeyValueInformation = LocalAlloc(LPTR,BufferLength); 00781 if (KeyValueInformation == NULL) 00782 return STATUS_NO_MEMORY; 00783 00784 Status = NtQueryValueKey( 00785 hKey, 00786 &ValueName, 00787 KeyValueFullInformation, 00788 KeyValueInformation, 00789 BufferLength, 00790 &ResultLength 00791 ); 00792 if (NT_SUCCESS(Status)) { 00793 ASSERT(KeyValueInformation->DataLength <= dwValueLength); 00794 RtlMoveMemory(lpData, 00795 (PBYTE)KeyValueInformation + KeyValueInformation->DataOffset, 00796 KeyValueInformation->DataLength); 00797 if (KeyValueInformation->Type == REG_SZ) { 00798 if (KeyValueInformation->DataLength + sizeof(WCHAR) > dwValueLength) { 00799 KeyValueInformation->DataLength -= sizeof(WCHAR); 00800 } 00801 lpData[KeyValueInformation->DataLength++] = 0; 00802 lpData[KeyValueInformation->DataLength] = 0; 00803 } 00804 } 00805 LocalFree(KeyValueInformation); 00806 return Status; 00807 } 00808 00809 VOID 00810 GetCommandLineString( 00811 IN LPWSTR CommandLine, 00812 IN DWORD dwSize 00813 ) 00814 { 00815 NTSTATUS Status; 00816 HANDLE hkRegistry; 00817 WCHAR awchBuffer[ 512 ]; 00818 DWORD dwRet; 00819 00820 dwRet = GetSystemDirectoryW(CommandLine, dwSize); 00821 if (dwRet) 00822 { 00823 CommandLine[dwRet++] = L'\\'; 00824 CommandLine[dwRet] = L'\0'; 00825 dwSize -= dwRet; 00826 00827 } 00828 else 00829 { 00830 CommandLine[0] = L'\0'; 00831 } 00832 00833 Status = MyRegOpenKey(NULL, 00834 MACHINE_REGISTRY_CONSOLE, 00835 &hkRegistry); 00836 if (NT_SUCCESS( Status )) 00837 { 00838 Status = MyRegQueryValue(hkRegistry, 00839 MACHINE_REGISTRY_CONSOLEIME, 00840 sizeof(awchBuffer), (PBYTE)&awchBuffer); 00841 if (NT_SUCCESS( Status )) 00842 { 00843 dwRet = wcslen(awchBuffer); 00844 if (dwRet < dwSize) 00845 { 00846 wcscat(CommandLine, awchBuffer); 00847 } 00848 else 00849 { 00850 CommandLine[0] = L'\0'; 00851 goto ErrorExit; 00852 } 00853 } 00854 else 00855 { 00856 goto ErrorExit; 00857 } 00858 00859 NtClose(hkRegistry); 00860 } 00861 else 00862 { 00863 goto ErrorExit; 00864 } 00865 00866 return; 00867 00868 ErrorExit: 00869 wcscat(CommandLine, L"conime.exe"); 00870 return; 00871 } 00872 00873 00874 DWORD 00875 ConsoleIMERoutine( 00876 IN LPVOID lpThreadParameter 00877 ) 00878 00879 /*++ 00880 00881 Routine Description: 00882 00883 This thread is created when the create input thread. 00884 It invokes the console IME process. 00885 00886 Arguments: 00887 00888 lpThreadParameter - not use. 00889 00890 Return Value: 00891 00892 STATUS_SUCCESS - function was successful 00893 00894 --*/ 00895 00896 { 00897 NTSTATUS Status; 00898 BOOL fRet; 00899 static BOOL fInConIMERoutine = FALSE; 00900 00901 DWORD fdwCreate; 00902 STARTUPINFOW StartupInfo; 00903 STARTUPINFOW StartupInfoConsole; 00904 WCHAR CommandLine[MAX_PATH*2]; 00905 PROCESS_INFORMATION ProcessInformation; 00906 HANDLE hEvent; 00907 DWORD dwWait; 00908 00909 Status = STATUS_SUCCESS; 00910 00911 // 00912 // Prevent the user from launching multiple applets attached 00913 // to a single console 00914 // 00915 00916 if (fInConIMERoutine) { 00917 return (ULONG)STATUS_UNSUCCESSFUL; 00918 } 00919 00920 fInConIMERoutine = TRUE; 00921 00922 // 00923 // Create event 00924 // 00925 hEvent = CreateEventW(NULL, // Security attributes 00926 FALSE, // Manual reset 00927 FALSE, // Initial state 00928 CONSOLEIME_EVENT); // Event object name 00929 if (hEvent == NULL) 00930 { 00931 goto ErrorExit; 00932 } 00933 if (GetLastError() == ERROR_ALREADY_EXISTS) 00934 { 00935 goto ErrorExit; 00936 } 00937 00938 // 00939 // Get Console IME process name and event name 00940 // 00941 00942 GetCommandLineString(CommandLine, sizeof(CommandLine)/sizeof(WCHAR)); 00943 00944 GetStartupInfoW(&StartupInfoConsole); 00945 RtlZeroMemory(&StartupInfo, sizeof(StartupInfo)); 00946 StartupInfo.cb = sizeof(StartupInfo); 00947 StartupInfo.wShowWindow = SW_HIDE; 00948 StartupInfo.dwFlags = STARTF_FORCEONFEEDBACK; 00949 StartupInfo.lpDesktop = StartupInfoConsole.lpDesktop; 00950 00951 // 00952 // create Console IME process 00953 // 00954 00955 fdwCreate = NORMAL_PRIORITY_CLASS | CREATE_DEFAULT_ERROR_MODE | CREATE_NEW_PROCESS_GROUP; 00956 fRet = CreateProcessW(NULL, // Application name 00957 CommandLine, // Command line 00958 NULL, // process security attributes 00959 NULL, // thread security attributes 00960 FALSE, // inherit handles 00961 fdwCreate, // create flags 00962 NULL, // environment 00963 NULL, // current directory 00964 &StartupInfo, // Start up information 00965 &ProcessInformation // process information 00966 ); 00967 if (! fRet) 00968 { 00969 Status = GetLastError(); 00970 } 00971 else 00972 { 00973 dwWait = WaitForSingleObject(hEvent, 10 * 1000); // wait 10 sec for console IME process 00974 if (dwWait == WAIT_TIMEOUT) 00975 { 00976 TerminateProcess(ProcessInformation.hProcess, 0); 00977 } 00978 CloseHandle(ProcessInformation.hThread) ; 00979 CloseHandle(ProcessInformation.hProcess) ; 00980 } 00981 00982 CloseHandle(hEvent); 00983 00984 ErrorExit: 00985 00986 fInConIMERoutine = FALSE; 00987 00988 return Status; 00989 } 00990 00991 #endif 00992 00993 #endif // FE_IME 00994 00995 00996 #else // FE_SB 00997 00998 // Followings are stub functions for FE Console Support 00999 01000 01001 #if !defined(BUILD_WOW6432) 01002 01003 BOOL 01004 APIENTRY 01005 GetConsoleNlsMode( 01006 IN HANDLE hConsoleHandle, 01007 OUT LPDWORD lpNlsMode 01008 ) 01009 01010 /*++ 01011 01012 Parameters: 01013 01014 hConsoleHandle - Supplies a console input or output handle. 01015 01016 lpNlsMode - Supplies a pointer to the NLS mode. 01017 01018 Return Value: 01019 01020 TRUE - The operation was successful. 01021 01022 FALSE/NULL - The operation failed. Extended error status is available 01023 using GetLastError. 01024 01025 01026 --*/ 01027 01028 { 01029 return FALSE; 01030 } 01031 01032 BOOL 01033 APIENTRY 01034 SetConsoleNlsMode( 01035 IN HANDLE hConsoleHandle, 01036 IN DWORD dwNlsMode 01037 ) 01038 01039 /*++ 01040 01041 Parameters: 01042 01043 hConsoleHandle - Supplies a console input or output handle. 01044 01045 dwNlsMode - Supplies NLS mode. 01046 01047 Return Value: 01048 01049 TRUE - The operation was successful. 01050 01051 FALSE/NULL - The operation failed. Extended error status is available 01052 using GetLastError. 01053 01054 --*/ 01055 01056 { 01057 return FALSE; 01058 } 01059 01060 BOOL 01061 APIENTRY 01062 GetConsoleCharType( 01063 IN HANDLE hConsoleHandle, 01064 IN COORD coordCheck, 01065 OUT PDWORD pdwType 01066 ) 01067 01068 /*++ 01069 01070 Parameters: 01071 01072 hConsoleHandle - Supplies a console input or output handle. 01073 01074 coordCheck - set check position to these coordinates 01075 01076 pdwType - receive character type 01077 01078 Return Value: 01079 01080 TRUE - The operation was successful. 01081 01082 FALSE/NULL - The operation failed. Extended error status is available 01083 using GetLastError. 01084 01085 01086 --*/ 01087 01088 { 01089 return FALSE; 01090 } 01091 01092 BOOL 01093 APIENTRY 01094 SetConsoleLocalEUDC( 01095 IN HANDLE hConsoleHandle, 01096 IN WORD wCodePoint, 01097 IN COORD cFontSize, 01098 IN PCHAR lpSB 01099 ) 01100 01101 /*++ 01102 01103 Parameters: 01104 01105 hConsoleHandle - Supplies a console input or output handle. 01106 01107 wCodePoint - Code point of font by Shift JIS code. 01108 01109 cFontSize - FontSize of Font 01110 01111 lpSB - Pointer of font bitmap Buffer 01112 01113 Return Value: 01114 01115 TRUE - The operation was successful. 01116 01117 FALSE/NULL - The operation failed. Extended error status is available 01118 using GetLastError. 01119 01120 --*/ 01121 01122 { 01123 return FALSE; 01124 } 01125 01126 BOOL 01127 APIENTRY 01128 SetConsoleCursorMode( 01129 IN HANDLE hConsoleHandle, 01130 IN BOOL Blink, 01131 IN BOOL DBEnable 01132 ) 01133 01134 /*++ 01135 01136 Parameters: 01137 01138 hConsoleHandle - Supplies a console input or output handle. 01139 01140 Blink - Blinking enable/disable switch. 01141 01142 DBEnable - Double Byte width enable/disable switch. 01143 01144 Return Value: 01145 01146 TRUE - The operation was successful. 01147 01148 FALSE/NULL - The operation failed. Extended error status is available 01149 using GetLastError. 01150 01151 --*/ 01152 01153 { 01154 return FALSE; 01155 } 01156 01157 BOOL 01158 APIENTRY 01159 GetConsoleCursorMode( 01160 IN HANDLE hConsoleHandle, 01161 OUT PBOOL pbBlink, 01162 OUT PBOOL pbDBEnable 01163 ) 01164 01165 /*++ 01166 01167 Parameters: 01168 01169 hConsoleHandle - Supplies a console input or output handle. 01170 01171 Blink - Blinking enable/disable switch. 01172 01173 DBEnable - Double Byte width enable/disable switch. 01174 01175 Return Value: 01176 01177 TRUE - The operation was successful. 01178 01179 FALSE/NULL - The operation failed. Extended error status is available 01180 using GetLastError. 01181 01182 --*/ 01183 01184 { 01185 return FALSE; 01186 } 01187 01188 BOOL 01189 APIENTRY 01190 RegisterConsoleOS2( 01191 IN BOOL fOs2Register 01192 ) 01193 01194 /*++ 01195 01196 Description: 01197 01198 This routine registers the OS/2 with the console. 01199 01200 Parameters: 01201 01202 Return Value: 01203 01204 TRUE - The operation was successful. 01205 01206 FALSE/NULL - The operation failed. Extended error status is available 01207 using GetLastError. 01208 01209 --*/ 01210 01211 { 01212 return FALSE; 01213 } 01214 01215 BOOL 01216 APIENTRY 01217 SetConsoleOS2OemFormat( 01218 IN BOOL fOs2OemFormat 01219 ) 01220 01221 /*++ 01222 01223 Description: 01224 01225 This routine sets the OS/2 OEM Format with the console. 01226 01227 Parameters: 01228 01229 Return Value: 01230 01231 TRUE - The operation was successful. 01232 01233 FALSE/NULL - The operation failed. Extended error status is available 01234 using GetLastError. 01235 01236 --*/ 01237 01238 { 01239 return FALSE; 01240 } 01241 01242 #endif 01243 01244 #if defined(FE_IME) 01245 01246 #if !defined(BUILD_WOW64) 01247 01248 BOOL 01249 APIENTRY 01250 RegisterConsoleIME( 01251 IN HWND hWndConsoleIME, 01252 OUT DWORD *dwConsoleThreadId 01253 ) 01254 01255 /*++ 01256 01257 Description: 01258 01259 This routine register the Console IME on the current desktop. 01260 01261 Parameters: 01262 01263 Return Value: 01264 01265 TRUE - The operation was successful. 01266 01267 FALSE - The operation failed. 01268 01269 --*/ 01270 01271 { 01272 01273 return FALSE; 01274 01275 } 01276 01277 BOOL 01278 APIENTRY 01279 UnregisterConsoleIME( 01280 ) 01281 01282 /*++ 01283 01284 Description: 01285 01286 This routine unregister the Console IME on the current desktop. 01287 01288 Parameters: 01289 01290 Return Value: 01291 01292 TRUE - The operation was successful. 01293 01294 FALSE - The operation failed. 01295 01296 --*/ 01297 01298 { 01299 01300 return FALSE; 01301 01302 } 01303 01304 #endif 01305 01306 #endif // FE_IME 01307 01308 #endif // FE_SB

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