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

misc.c

Go to the documentation of this file.
00001 /*++ 00002 00003 Copyright (c) 1992 Microsoft Corporation 00004 00005 Module Name: 00006 00007 misc.c 00008 00009 Abstract: 00010 00011 This is the console fullscreen driver for the VGA card. 00012 00013 Environment: 00014 00015 kernel mode only 00016 00017 Notes: 00018 00019 Revision History: 00020 00021 --*/ 00022 00023 #include "stdarg.h" 00024 #include "stdio.h" 00025 #include "ntddk.h" 00026 #include "fsvga.h" 00027 #include "fsvgalog.h" 00028 00029 00030 int 00031 ConvertOutputToOem( 00032 IN LPWSTR Source, 00033 IN int SourceLength, // in chars 00034 OUT LPSTR Target, 00035 IN int TargetLength // in chars 00036 ) 00037 /* 00038 Converts SourceLength Unicode characters from Source into 00039 not more than TargetLength Codepage characters at Target. 00040 Returns the number characters put in Target. (0 if failure) 00041 00042 [ntcon\server\misc.c] 00043 */ 00044 00045 { 00046 NTSTATUS Status; 00047 int Length; 00048 UNICODE_STRING SourceUni; 00049 ANSI_STRING TargetAns; 00050 CHAR AnsBuf[256]; 00051 00052 SourceUni.MaximumLength = 00053 SourceUni.Length = SourceLength * sizeof(WCHAR); 00054 SourceUni.Buffer = Source; 00055 00056 TargetAns.Length = 0; 00057 TargetAns.MaximumLength = sizeof(AnsBuf); 00058 TargetAns.Buffer = AnsBuf; 00059 00060 // Can do this in place 00061 Status = RtlUnicodeStringToAnsiString(&TargetAns, 00062 &SourceUni, 00063 FALSE); 00064 if (NT_SUCCESS(Status)) { 00065 Length = strlen(AnsBuf); 00066 if (Length <= TargetLength) { 00067 RtlMoveMemory(Target, AnsBuf, Length); 00068 return Length; 00069 } 00070 else { 00071 return 0; 00072 } 00073 } else { 00074 return 0; 00075 } 00076 } 00077 00078 /***************************************************************************\ 00079 * TranslateOutputToOem 00080 * 00081 * routine to translate console PCHAR_INFO to the ASCII from Unicode 00082 * 00083 * [ntcon\server\fe\direct2.c] 00084 \***************************************************************************/ 00085 NTSTATUS 00086 TranslateOutputToOem( 00087 OUT PCHAR_IMAGE_INFO OutputBuffer, 00088 IN PCHAR_IMAGE_INFO InputBuffer, 00089 IN DWORD Length 00090 ) 00091 { 00092 CHAR AsciiDbcs[2]; 00093 ULONG NumBytes; 00094 00095 while (Length--) 00096 { 00097 if (InputBuffer->CharInfo.Attributes & COMMON_LVB_LEADING_BYTE) 00098 { 00099 if (Length >= 2) // Safe DBCS in buffer ? 00100 { 00101 Length--; 00102 NumBytes = sizeof(AsciiDbcs); 00103 NumBytes = ConvertOutputToOem(&InputBuffer->CharInfo.Char.UnicodeChar, 00104 1, 00105 &AsciiDbcs[0], 00106 NumBytes); 00107 OutputBuffer->CharInfo.Char.AsciiChar = AsciiDbcs[0]; 00108 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00109 OutputBuffer++; 00110 InputBuffer++; 00111 OutputBuffer->CharInfo.Char.AsciiChar = AsciiDbcs[1]; 00112 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00113 OutputBuffer++; 00114 InputBuffer++; 00115 } 00116 else 00117 { 00118 OutputBuffer->CharInfo.Char.AsciiChar = ' '; 00119 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes & ~COMMON_LVB_SBCSDBCS; 00120 OutputBuffer++; 00121 InputBuffer++; 00122 } 00123 } 00124 else if (! (InputBuffer->CharInfo.Attributes & COMMON_LVB_SBCSDBCS)) 00125 { 00126 ConvertOutputToOem(&InputBuffer->CharInfo.Char.UnicodeChar, 00127 1, 00128 &OutputBuffer->CharInfo.Char.AsciiChar, 00129 1); 00130 OutputBuffer->CharInfo.Attributes = InputBuffer->CharInfo.Attributes; 00131 OutputBuffer++; 00132 InputBuffer++; 00133 } 00134 } 00135 00136 return STATUS_SUCCESS; 00137 }

Generated on Sat May 15 19:40:49 2004 for test by doxygen 1.3.7