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