MCPcopy Create free account
hub / github.com/bobranten/Ext4Fsd / Ext2MbsToUnicode

Function Ext2MbsToUnicode

Ext4Fsd/misc.c:65–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64
65ULONG
66Ext2MbsToUnicode(
67 struct nls_table * PageTable,
68 IN OUT PUNICODE_STRING Unicode,
69 IN PANSI_STRING Mbs )
70{
71 ULONG Length = 0;
72 int i, mbc = 0;
73 WCHAR uc;
74
75 /* Count the length of the resulting Unicode. */
76 for (i = 0; i < Mbs->Length; i += mbc) {
77
78 mbc = PageTable->char2uni(
79 (PUCHAR)&(Mbs->Buffer[i]),
80 Mbs->Length - i,
81 &uc
82 );
83
84 if (mbc <= 0) {
85
86 /* invalid character. */
87 if (mbc == 0 && Length > 0) {
88 break;
89 }
90 return 0;
91 }
92
93 Length += 2;
94 }
95
96 if (Unicode) {
97 if (Unicode->MaximumLength < Length) {
98
99 DbgBreak();
100 return 0;
101 }
102
103 Unicode->Length = 0;
104 mbc = 0;
105
106 for (i = 0; i < Mbs->Length; i += mbc) {
107
108 mbc = PageTable->char2uni(
109 (PUCHAR)&(Mbs->Buffer[i]),
110 Mbs->Length - i,
111 &uc
112 );
113 Unicode->Buffer[Unicode->Length/2] = uc;
114 Unicode->Length += 2;
115 }
116 }
117
118 return Length;
119}
120
121ULONG
122Ext2UnicodeToMbs (

Callers 2

Ext2OEMToUnicodeSizeFunction · 0.85
Ext2OEMToUnicodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected