| 119 | } |
| 120 | |
| 121 | ULONG |
| 122 | Ext2UnicodeToMbs ( |
| 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; |
no outgoing calls
no test coverage detected