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

Function Ext2UnicodeToMbs

Ext4Fsd/misc.c:121–179  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

119}
120
121ULONG
122Ext2UnicodeToMbs (
123 struct nls_table * PageTable,
124 IN OUT PANSI_STRING Mbs,
125 IN PUNICODE_STRING Unicode)
126{
127 ULONG Length = 0;
128 UCHAR mbs[0x10];
129 int i, mbc;
130
131 /* Count the length of the resulting mbc-8. */
132 for (i = 0; i < (Unicode->Length / 2); i++) {
133
134 RtlZeroMemory(mbs, 0x10);
135 mbc = PageTable->uni2char(
136 Unicode->Buffer[i],
137 mbs,
138 0x10
139 );
140
141 if (mbc <= 0) {
142
143 /* Invalid character. */
144 return 0;
145 }
146
147 Length += mbc;
148 }
149
150 if (Mbs) {
151
152 if (Mbs->MaximumLength < Length) {
153
154 DbgBreak();
155 return 0;
156 }
157
158 Mbs->Length = 0;
159
160 for (i = 0; i < (Unicode->Length / 2); i++) {
161
162 mbc = PageTable->uni2char(
163 Unicode->Buffer[i],
164 mbs,
165 0x10
166 );
167
168 RtlCopyMemory(
169 (PUCHAR)&(Mbs->Buffer[Mbs->Length]),
170 &mbs[0],
171 mbc
172 );
173
174 Mbs->Length += (USHORT)mbc;
175 }
176 }
177
178 return Length;

Callers 2

Ext2UnicodeToOEMSizeFunction · 0.85
Ext2UnicodeToOEMFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected