| 1 | /* $Id: rtlstr.cpp,v 1.4 1999-06-10 17:06:46 phaller Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 5 | * Win32 NT Runtime / NTDLL for OS/2
|
|---|
| 6 | * Rtl string functions
|
|---|
| 7 | *
|
|---|
| 8 | * Copyright 1996-1998 Marcus Meissner
|
|---|
| 9 | * Copyright 1998, 1999 Patrick Haller (phaller@gmx.net)
|
|---|
| 10 | */
|
|---|
| 11 |
|
|---|
| 12 | #include "config.h"
|
|---|
| 13 |
|
|---|
| 14 | #include <stdlib.h>
|
|---|
| 15 | #include <string.h>
|
|---|
| 16 | #include <ctype.h>
|
|---|
| 17 |
|
|---|
| 18 | #include <os2win.h>
|
|---|
| 19 | #include <unicode.h>
|
|---|
| 20 |
|
|---|
| 21 | #include "ntdll.h"
|
|---|
| 22 | #include "windef.h"
|
|---|
| 23 |
|
|---|
| 24 | #ifdef HAVE_WCTYPE_H
|
|---|
| 25 | # include <wctype.h>
|
|---|
| 26 | #endif
|
|---|
| 27 | #include "wine/winestring.h"
|
|---|
| 28 | #include "winnls.h"
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 | /*
|
|---|
| 33 | * STRING FUNCTIONS
|
|---|
| 34 | */
|
|---|
| 35 |
|
|---|
| 36 | /**************************************************************************
|
|---|
| 37 | * RtlAnsiStringToUnicodeString [NTDLL.269]
|
|---|
| 38 | */
|
|---|
| 39 | DWORD WINAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING uni,
|
|---|
| 40 | PANSI_STRING ansi,
|
|---|
| 41 | BOOLEAN doalloc)
|
|---|
| 42 | {
|
|---|
| 43 | DWORD unilen = (ansi->Length+1)*sizeof(WCHAR);
|
|---|
| 44 |
|
|---|
| 45 | dprintf(("NTDLL: RtlAnsiStringToUnicodeString(%08xh,%08xh,%08xh)\n",
|
|---|
| 46 | uni,
|
|---|
| 47 | ansi,
|
|---|
| 48 | doalloc));
|
|---|
| 49 |
|
|---|
| 50 | if (unilen>0xFFFF)
|
|---|
| 51 | return STATUS_INVALID_PARAMETER_2;
|
|---|
| 52 |
|
|---|
| 53 | uni->Length = unilen;
|
|---|
| 54 | if (doalloc)
|
|---|
| 55 | {
|
|---|
| 56 | uni->MaximumLength = unilen;
|
|---|
| 57 | uni->Buffer = (WCHAR *)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,unilen);
|
|---|
| 58 | if (!uni->Buffer)
|
|---|
| 59 | return STATUS_NO_MEMORY;
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | if (unilen>uni->MaximumLength)
|
|---|
| 63 | return STATUS_BUFFER_OVERFLOW;
|
|---|
| 64 |
|
|---|
| 65 | AsciiToUnicodeN(ansi->Buffer,
|
|---|
| 66 | uni->Buffer,
|
|---|
| 67 | unilen/2);
|
|---|
| 68 |
|
|---|
| 69 | return STATUS_SUCCESS;
|
|---|
| 70 | }
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | /**************************************************************************
|
|---|
| 74 | * RtlOemStringToUnicodeString [NTDLL.447]
|
|---|
| 75 | */
|
|---|
| 76 | DWORD WINAPI RtlOemStringToUnicodeString(PUNICODE_STRING uni,
|
|---|
| 77 | PSTRING ansi,
|
|---|
| 78 | BOOLEAN doalloc)
|
|---|
| 79 | {
|
|---|
| 80 | DWORD unilen = (ansi->Length+1)*sizeof(WCHAR);
|
|---|
| 81 |
|
|---|
| 82 | dprintf(("NTDLL: RtlOemStringToUnicodeString(%08xh,%08xh,%08xh)\n",
|
|---|
| 83 | uni,
|
|---|
| 84 | ansi,
|
|---|
| 85 | doalloc));
|
|---|
| 86 |
|
|---|
| 87 | if (unilen>0xFFFF)
|
|---|
| 88 | return STATUS_INVALID_PARAMETER_2;
|
|---|
| 89 |
|
|---|
| 90 | uni->Length = unilen;
|
|---|
| 91 | if (doalloc)
|
|---|
| 92 | {
|
|---|
| 93 | uni->MaximumLength = unilen;
|
|---|
| 94 | uni->Buffer = (WCHAR *)HeapAlloc(GetProcessHeap(),
|
|---|
| 95 | HEAP_ZERO_MEMORY,
|
|---|
| 96 | unilen);
|
|---|
| 97 |
|
|---|
| 98 | if (!uni->Buffer)
|
|---|
| 99 | return STATUS_NO_MEMORY;
|
|---|
| 100 | }
|
|---|
| 101 |
|
|---|
| 102 | if (unilen>uni->MaximumLength)
|
|---|
| 103 | return STATUS_BUFFER_OVERFLOW;
|
|---|
| 104 |
|
|---|
| 105 | AsciiToUnicodeN(ansi->Buffer,
|
|---|
| 106 | uni->Buffer,
|
|---|
| 107 | unilen/2);
|
|---|
| 108 | return STATUS_SUCCESS;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 |
|
|---|
| 112 | /**************************************************************************
|
|---|
| 113 | * RtlMultiByteToUnicodeN [NTDLL.436]
|
|---|
| 114 | * FIXME: multibyte support
|
|---|
| 115 | */
|
|---|
| 116 | DWORD WINAPI RtlMultiByteToUnicodeN(LPWSTR unistr,
|
|---|
| 117 | DWORD unilen,
|
|---|
| 118 | LPDWORD reslen,
|
|---|
| 119 | LPSTR oemstr,
|
|---|
| 120 | DWORD oemlen)
|
|---|
| 121 | {
|
|---|
| 122 | DWORD len;
|
|---|
| 123 | LPWSTR x;
|
|---|
| 124 |
|
|---|
| 125 | dprintf(("NTDLL: RtlMultiByteToUnicodeN(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 126 | unistr,
|
|---|
| 127 | unilen,
|
|---|
| 128 | reslen,
|
|---|
| 129 | oemstr,
|
|---|
| 130 | oemlen));
|
|---|
| 131 |
|
|---|
| 132 | len = oemlen;
|
|---|
| 133 |
|
|---|
| 134 | if (unilen/2 < len)
|
|---|
| 135 | len = unilen/2;
|
|---|
| 136 |
|
|---|
| 137 | x=(LPWSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 138 | HEAP_ZERO_MEMORY,
|
|---|
| 139 | (len+1)*sizeof(WCHAR));
|
|---|
| 140 |
|
|---|
| 141 | AsciiToUnicodeN(oemstr,
|
|---|
| 142 | x,
|
|---|
| 143 | len+1);
|
|---|
| 144 |
|
|---|
| 145 | memcpy(unistr,
|
|---|
| 146 | x,
|
|---|
| 147 | len*2);
|
|---|
| 148 |
|
|---|
| 149 | if (reslen)
|
|---|
| 150 | *reslen = len*2;
|
|---|
| 151 |
|
|---|
| 152 | return 0;
|
|---|
| 153 | }
|
|---|
| 154 |
|
|---|
| 155 |
|
|---|
| 156 | /**************************************************************************
|
|---|
| 157 | * RtlOemToUnicodeN [NTDLL.448]
|
|---|
| 158 | */
|
|---|
| 159 | DWORD WINAPI RtlOemToUnicodeN(LPWSTR unistr,
|
|---|
| 160 | DWORD unilen,
|
|---|
| 161 | LPDWORD reslen,
|
|---|
| 162 | LPSTR oemstr,
|
|---|
| 163 | DWORD oemlen)
|
|---|
| 164 | {
|
|---|
| 165 | DWORD len;
|
|---|
| 166 | LPWSTR x;
|
|---|
| 167 |
|
|---|
| 168 | dprintf(("NTDLL: RtlOemToUnicodeN(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 169 | unistr,
|
|---|
| 170 | unilen,
|
|---|
| 171 | reslen,
|
|---|
| 172 | oemstr,
|
|---|
| 173 | oemlen));
|
|---|
| 174 |
|
|---|
| 175 | len = oemlen;
|
|---|
| 176 |
|
|---|
| 177 | if (unilen/2 < len)
|
|---|
| 178 | len = unilen/2;
|
|---|
| 179 |
|
|---|
| 180 | x=(LPWSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 181 | HEAP_ZERO_MEMORY,
|
|---|
| 182 | (len+1)*sizeof(WCHAR));
|
|---|
| 183 |
|
|---|
| 184 | AsciiToUnicodeN(oemstr,
|
|---|
| 185 | x,
|
|---|
| 186 | len+1);
|
|---|
| 187 |
|
|---|
| 188 | memcpy(unistr,
|
|---|
| 189 | x,
|
|---|
| 190 | len*2);
|
|---|
| 191 |
|
|---|
| 192 | if (reslen)
|
|---|
| 193 | *reslen = len*2;
|
|---|
| 194 |
|
|---|
| 195 | return 0;
|
|---|
| 196 | }
|
|---|
| 197 |
|
|---|
| 198 |
|
|---|
| 199 | /**************************************************************************
|
|---|
| 200 | * RtlInitAnsiString [NTDLL.399]
|
|---|
| 201 | */
|
|---|
| 202 | VOID WINAPI RtlInitAnsiString(PANSI_STRING target,
|
|---|
| 203 | LPCSTR source)
|
|---|
| 204 | {
|
|---|
| 205 | dprintf(("NTDLL: RtlInitAnsiString(%08xh, %08xh)\n",
|
|---|
| 206 | target,
|
|---|
| 207 | source));
|
|---|
| 208 |
|
|---|
| 209 | target->Length = target->MaximumLength = 0;
|
|---|
| 210 | target->Buffer = (LPSTR)source;
|
|---|
| 211 | if (!source)
|
|---|
| 212 | return;
|
|---|
| 213 |
|
|---|
| 214 | target->MaximumLength = lstrlenA(target->Buffer);
|
|---|
| 215 | target->Length = target->MaximumLength+1;
|
|---|
| 216 | }
|
|---|
| 217 |
|
|---|
| 218 |
|
|---|
| 219 | /**************************************************************************
|
|---|
| 220 | * RtlInitOemString
|
|---|
| 221 | */
|
|---|
| 222 | VOID WINAPI RtlInitOemString(POEM_STRING target,
|
|---|
| 223 | LPCSTR source)
|
|---|
| 224 | {
|
|---|
| 225 | dprintf(("NTDLL: RtlInitOemString(%08xh, %08xh)\n",
|
|---|
| 226 | target,
|
|---|
| 227 | source));
|
|---|
| 228 |
|
|---|
| 229 | target->Length = target->MaximumLength = 0;
|
|---|
| 230 | target->Buffer = (LPSTR)source;
|
|---|
| 231 | if (!source)
|
|---|
| 232 | return;
|
|---|
| 233 |
|
|---|
| 234 | target->MaximumLength = lstrlenA(target->Buffer);
|
|---|
| 235 | target->Length = target->MaximumLength+1;
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 |
|
|---|
| 239 |
|
|---|
| 240 | /**************************************************************************
|
|---|
| 241 | * RtlInitString [NTDLL.402]
|
|---|
| 242 | */
|
|---|
| 243 | VOID WINAPI RtlInitString(PSTRING target,
|
|---|
| 244 | LPCSTR source)
|
|---|
| 245 | {
|
|---|
| 246 | dprintf (("NTDLL: RtlInitString(%08xh, %08xh)\n",
|
|---|
| 247 | target,
|
|---|
| 248 | source));
|
|---|
| 249 |
|
|---|
| 250 | target->Length = target->MaximumLength = 0;
|
|---|
| 251 | target->Buffer = (LPSTR)source;
|
|---|
| 252 | if (!source)
|
|---|
| 253 | return;
|
|---|
| 254 |
|
|---|
| 255 | target->MaximumLength = lstrlenA(target->Buffer);
|
|---|
| 256 | target->Length = target->MaximumLength+1;
|
|---|
| 257 | }
|
|---|
| 258 |
|
|---|
| 259 |
|
|---|
| 260 | /**************************************************************************
|
|---|
| 261 | * RtlInitUnicodeString [NTDLL.403]
|
|---|
| 262 | */
|
|---|
| 263 | VOID WINAPI RtlInitUnicodeString(PUNICODE_STRING target,
|
|---|
| 264 | LPCWSTR source)
|
|---|
| 265 | {
|
|---|
| 266 | dprintf(("NTDLL: RtlInitUnicodeString(%08xh,%08xh)\n",
|
|---|
| 267 | target,
|
|---|
| 268 | source));
|
|---|
| 269 |
|
|---|
| 270 | target->Length = target->MaximumLength = 0;
|
|---|
| 271 | target->Buffer = (LPWSTR)source;
|
|---|
| 272 | if (!source)
|
|---|
| 273 | return;
|
|---|
| 274 |
|
|---|
| 275 | target->MaximumLength = lstrlenW(target->Buffer)*2;
|
|---|
| 276 | target->Length = target->MaximumLength+2;
|
|---|
| 277 | }
|
|---|
| 278 |
|
|---|
| 279 |
|
|---|
| 280 | /**************************************************************************
|
|---|
| 281 | * RtlFreeUnicodeString [NTDLL.377]
|
|---|
| 282 | */
|
|---|
| 283 | VOID WINAPI RtlFreeUnicodeString(PUNICODE_STRING str)
|
|---|
| 284 | {
|
|---|
| 285 | dprintf(("NTDLL: RtlFreeUnicodeString(%08xh)\n",
|
|---|
| 286 | str));
|
|---|
| 287 |
|
|---|
| 288 | if (str->Buffer)
|
|---|
| 289 | HeapFree(GetProcessHeap(),
|
|---|
| 290 | 0,
|
|---|
| 291 | str->Buffer);
|
|---|
| 292 | }
|
|---|
| 293 |
|
|---|
| 294 |
|
|---|
| 295 | /**************************************************************************
|
|---|
| 296 | * RtlFreeAnsiString [NTDLL.373]
|
|---|
| 297 | */
|
|---|
| 298 | VOID WINAPI RtlFreeAnsiString(PANSI_STRING AnsiString)
|
|---|
| 299 | {
|
|---|
| 300 | dprintf(("NTDLL: RtlFreeAnsiString(%08xh)\n",
|
|---|
| 301 | AnsiString));
|
|---|
| 302 |
|
|---|
| 303 | if( AnsiString->Buffer )
|
|---|
| 304 | HeapFree(GetProcessHeap(),
|
|---|
| 305 | 0,
|
|---|
| 306 | AnsiString->Buffer);
|
|---|
| 307 | }
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 | /**************************************************************************
|
|---|
| 311 | * RtlFreeOemString
|
|---|
| 312 | */
|
|---|
| 313 | VOID WINAPI RtlFreeOemString(POEM_STRING OemString)
|
|---|
| 314 | {
|
|---|
| 315 | dprintf(("NTDLL: RtlFreeOemString(%08xh)\n",
|
|---|
| 316 | OemString));
|
|---|
| 317 |
|
|---|
| 318 | if( OemString->Buffer )
|
|---|
| 319 | HeapFree(GetProcessHeap(),
|
|---|
| 320 | 0,
|
|---|
| 321 | OemString->Buffer);
|
|---|
| 322 | }
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 | /**************************************************************************
|
|---|
| 327 | * RtlUnicodeToOemN [NTDLL.515]
|
|---|
| 328 | */
|
|---|
| 329 | DWORD WINAPI RtlUnicodeToOemN(LPSTR oemstr,
|
|---|
| 330 | DWORD oemlen,
|
|---|
| 331 | LPDWORD reslen,
|
|---|
| 332 | LPWSTR unistr,
|
|---|
| 333 | DWORD unilen)
|
|---|
| 334 | {
|
|---|
| 335 | DWORD len;
|
|---|
| 336 | LPSTR x;
|
|---|
| 337 |
|
|---|
| 338 | dprintf(("NTDLL: RtlUnicodeToOemN(%08xh,%08xh,%08xh,%08xh,%08xh)\n",
|
|---|
| 339 | oemstr,
|
|---|
| 340 | oemlen,
|
|---|
| 341 | reslen,
|
|---|
| 342 | unistr,
|
|---|
| 343 | unilen));
|
|---|
| 344 |
|
|---|
| 345 | len = oemlen;
|
|---|
| 346 |
|
|---|
| 347 | if (unilen/2 < len)
|
|---|
| 348 | len = unilen/2;
|
|---|
| 349 |
|
|---|
| 350 | x=(LPSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 351 | HEAP_ZERO_MEMORY,
|
|---|
| 352 | len+1);
|
|---|
| 353 |
|
|---|
| 354 | UnicodeToAsciiN(unistr,
|
|---|
| 355 | x,
|
|---|
| 356 | len+1);
|
|---|
| 357 |
|
|---|
| 358 | memcpy(oemstr,
|
|---|
| 359 | x,
|
|---|
| 360 | len);
|
|---|
| 361 |
|
|---|
| 362 | if (reslen)
|
|---|
| 363 | *reslen = len;
|
|---|
| 364 |
|
|---|
| 365 | return 0;
|
|---|
| 366 | }
|
|---|
| 367 |
|
|---|
| 368 |
|
|---|
| 369 | /**************************************************************************
|
|---|
| 370 | * RtlUnicodeStringToOemString [NTDLL.511]
|
|---|
| 371 | */
|
|---|
| 372 | DWORD WINAPI RtlUnicodeStringToOemString(PANSI_STRING oem,
|
|---|
| 373 | PUNICODE_STRING uni,
|
|---|
| 374 | BOOLEAN alloc)
|
|---|
| 375 | {
|
|---|
| 376 | dprintf(("NTDLL: RtlUnicodeStringToOemString(%08xh,%08xh,%08xh)\n",
|
|---|
| 377 | oem,
|
|---|
| 378 | uni,
|
|---|
| 379 | alloc));
|
|---|
| 380 |
|
|---|
| 381 | if (alloc)
|
|---|
| 382 | {
|
|---|
| 383 | oem->Buffer = (LPSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 384 | HEAP_ZERO_MEMORY,
|
|---|
| 385 | uni->Length/2)+1;
|
|---|
| 386 | oem->MaximumLength = uni->Length/2+1;
|
|---|
| 387 | }
|
|---|
| 388 |
|
|---|
| 389 | oem->Length = uni->Length/2;
|
|---|
| 390 | UnicodeToAsciiN(uni->Buffer,
|
|---|
| 391 | oem->Buffer,
|
|---|
| 392 | oem->MaximumLength);
|
|---|
| 393 | return 0;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | /**************************************************************************
|
|---|
| 397 | * RtlUnicodeStringToAnsiString [NTDLL.507]
|
|---|
| 398 | */
|
|---|
| 399 | DWORD WINAPI RtlUnicodeStringToAnsiString(PANSI_STRING oem,
|
|---|
| 400 | PUNICODE_STRING uni,
|
|---|
| 401 | BOOLEAN alloc)
|
|---|
| 402 | {
|
|---|
| 403 | dprintf(("NTDLL: RtlUnicodeStringToAnsiString(%08xh,%08xh,%08xh)\n",
|
|---|
| 404 | oem,
|
|---|
| 405 | uni,
|
|---|
| 406 | alloc));
|
|---|
| 407 |
|
|---|
| 408 | if (alloc)
|
|---|
| 409 | {
|
|---|
| 410 | oem->Buffer = (LPSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 411 | HEAP_ZERO_MEMORY,
|
|---|
| 412 | uni->Length/2)+1;
|
|---|
| 413 | oem->MaximumLength = uni->Length/2+1;
|
|---|
| 414 | }
|
|---|
| 415 |
|
|---|
| 416 | oem->Length = uni->Length/2;
|
|---|
| 417 | UnicodeToAsciiN(uni->Buffer,
|
|---|
| 418 | oem->Buffer,
|
|---|
| 419 | oem->MaximumLength);
|
|---|
| 420 |
|
|---|
| 421 | return 0;
|
|---|
| 422 | }
|
|---|
| 423 |
|
|---|
| 424 | /**************************************************************************
|
|---|
| 425 | * RtlEqualUnicodeString [NTDLL]
|
|---|
| 426 | */
|
|---|
| 427 | DWORD WINAPI RtlEqualUnicodeString(PUNICODE_STRING s1,
|
|---|
| 428 | PUNICODE_STRING s2,
|
|---|
| 429 | DWORD x)
|
|---|
| 430 | {
|
|---|
| 431 | dprintf(("NTDLL: RtlEqualUnicodeString(%08xh,%08xh,%08xh)\n",
|
|---|
| 432 | s1,
|
|---|
| 433 | s2,
|
|---|
| 434 | x));
|
|---|
| 435 |
|
|---|
| 436 | if (s1->Length != s2->Length)
|
|---|
| 437 | return 1;
|
|---|
| 438 |
|
|---|
| 439 | return !lstrncmpW(s1->Buffer,
|
|---|
| 440 | s2->Buffer,
|
|---|
| 441 | s1->Length/2);
|
|---|
| 442 | }
|
|---|
| 443 |
|
|---|
| 444 |
|
|---|
| 445 | /**************************************************************************
|
|---|
| 446 | * RtlUpcaseUnicodeString [NTDLL.520]
|
|---|
| 447 | */
|
|---|
| 448 | DWORD WINAPI RtlUpcaseUnicodeString(PUNICODE_STRING dest,
|
|---|
| 449 | PUNICODE_STRING src,
|
|---|
| 450 | BOOLEAN doalloc)
|
|---|
| 451 | {
|
|---|
| 452 | LPWSTR s,t;
|
|---|
| 453 | DWORD i,len;
|
|---|
| 454 |
|
|---|
| 455 | dprintf(("NTDLL: RtlUpcaseUnicodeString(%08xh,%08xh,%08xh)\n",
|
|---|
| 456 | dest,
|
|---|
| 457 | src,
|
|---|
| 458 | doalloc));
|
|---|
| 459 |
|
|---|
| 460 | len = src->Length;
|
|---|
| 461 | if (doalloc)
|
|---|
| 462 | {
|
|---|
| 463 | dest->MaximumLength = len;
|
|---|
| 464 | dest->Buffer = (LPWSTR)HeapAlloc(GetProcessHeap(),
|
|---|
| 465 | HEAP_ZERO_MEMORY,
|
|---|
| 466 | len);
|
|---|
| 467 | if (!dest->Buffer)
|
|---|
| 468 | return STATUS_NO_MEMORY;
|
|---|
| 469 | }
|
|---|
| 470 |
|
|---|
| 471 | if (dest->MaximumLength < len)
|
|---|
| 472 | return STATUS_BUFFER_OVERFLOW;
|
|---|
| 473 |
|
|---|
| 474 | s=dest->Buffer;
|
|---|
| 475 | t=src->Buffer;
|
|---|
| 476 |
|
|---|
| 477 | /* len is in bytes */
|
|---|
| 478 | #if 0
|
|---|
| 479 | for (i = 0;
|
|---|
| 480 | i < len/2;
|
|---|
| 481 | i++)
|
|---|
| 482 | s[i] = towupper(t[i]);
|
|---|
| 483 | #endif
|
|---|
| 484 | return STATUS_SUCCESS;
|
|---|
| 485 | }
|
|---|
| 486 |
|
|---|
| 487 |
|
|---|
| 488 | /**************************************************************************
|
|---|
| 489 | * RtlxOemStringToUnicodeSize [NTDLL.549]
|
|---|
| 490 | */
|
|---|
| 491 | UINT WINAPI RtlxOemStringToUnicodeSize(PSTRING str)
|
|---|
| 492 | {
|
|---|
| 493 | dprintf(("NTDLL: RtlxOemStringToUnicodeSize(%08xh)\n",
|
|---|
| 494 | str));
|
|---|
| 495 |
|
|---|
| 496 | return str->Length*2+2;
|
|---|
| 497 | }
|
|---|
| 498 |
|
|---|
| 499 |
|
|---|
| 500 | /**************************************************************************
|
|---|
| 501 | * RtlxAnsiStringToUnicodeSize [NTDLL.548]
|
|---|
| 502 | */
|
|---|
| 503 | UINT WINAPI RtlxAnsiStringToUnicodeSize(PANSI_STRING str)
|
|---|
| 504 | {
|
|---|
| 505 | dprintf(("NTDLL: RtlxAnsiStringToUnicodeSize(%08xh)\n",
|
|---|
| 506 | str));
|
|---|
| 507 |
|
|---|
| 508 | return str->Length*2+2;
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 | /**************************************************************************
|
|---|
| 513 | * RtlIsTextUnicode [NTDLL.417]
|
|---|
| 514 | *
|
|---|
| 515 | * Apply various feeble heuristics to guess whether
|
|---|
| 516 | * the text buffer contains Unicode.
|
|---|
| 517 | * FIXME: should implement more tests.
|
|---|
| 518 | */
|
|---|
| 519 | DWORD WINAPI RtlIsTextUnicode(LPVOID buf,
|
|---|
| 520 | DWORD len,
|
|---|
| 521 | DWORD *pf)
|
|---|
| 522 | {
|
|---|
| 523 | LPWSTR s = (LPWSTR)buf;
|
|---|
| 524 | DWORD flags = -1,
|
|---|
| 525 | out_flags = 0;
|
|---|
| 526 |
|
|---|
| 527 | dprintf(("NTDLL: RtlIsTextUnicode(%08xh,%08xh,%08xh)\n",
|
|---|
| 528 | buf,
|
|---|
| 529 | len,
|
|---|
| 530 | pf));
|
|---|
| 531 |
|
|---|
| 532 | if (!len)
|
|---|
| 533 | goto out;
|
|---|
| 534 |
|
|---|
| 535 | if (pf)
|
|---|
| 536 | flags = *pf;
|
|---|
| 537 |
|
|---|
| 538 | /*
|
|---|
| 539 | * Apply various tests to the text string. According to the
|
|---|
| 540 | * docs, each test "passed" sets the corresponding flag in
|
|---|
| 541 | * the output flags. But some of the tests are mutually
|
|---|
| 542 | * exclusive, so I don't see how you could pass all tests ...
|
|---|
| 543 | */
|
|---|
| 544 |
|
|---|
| 545 | /* Check for an odd length ... pass if even. */
|
|---|
| 546 | if (!(len & 1))
|
|---|
| 547 | out_flags |= IS_TEXT_UNICODE_ODD_LENGTH;
|
|---|
| 548 |
|
|---|
| 549 | /* Check for the special unicode marker byte. */
|
|---|
| 550 | if (*s == 0xFEFF)
|
|---|
| 551 | out_flags |= IS_TEXT_UNICODE_SIGNATURE;
|
|---|
| 552 |
|
|---|
| 553 | /*
|
|---|
| 554 | * Check whether the string passed all of the tests.
|
|---|
| 555 | */
|
|---|
| 556 | flags &= ITU_IMPLEMENTED_TESTS;
|
|---|
| 557 | if ((out_flags & flags) != flags)
|
|---|
| 558 | len = 0;
|
|---|
| 559 |
|
|---|
| 560 | out:
|
|---|
| 561 | if (pf)
|
|---|
| 562 | *pf = out_flags;
|
|---|
| 563 |
|
|---|
| 564 | return len;
|
|---|
| 565 | }
|
|---|
| 566 |
|
|---|
| 567 |
|
|---|
| 568 | /******************************************************************************
|
|---|
| 569 | * RtlCompareUnicodeString [NTDLL]
|
|---|
| 570 | */
|
|---|
| 571 | DWORD WINAPI RtlCompareUnicodeString(PUNICODE_STRING String1,
|
|---|
| 572 | PUNICODE_STRING String2,
|
|---|
| 573 | BOOLEAN CaseInSensitive)
|
|---|
| 574 | {
|
|---|
| 575 | dprintf(("NTDLL: RtlCompareUnicodeString(%08xh,%08xh,%08xh) not implemented.\n",
|
|---|
| 576 | String1,
|
|---|
| 577 | String2,
|
|---|
| 578 | CaseInSensitive));
|
|---|
| 579 |
|
|---|
| 580 | return 0;
|
|---|
| 581 | }
|
|---|
| 582 |
|
|---|
| 583 |
|
|---|