00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
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,
00034 OUT LPSTR Target,
00035 IN
int TargetLength
00036 )
00037
00038
00039
00040
00041
00042
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
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
00080
00081
00082
00083
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)
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 }