2 * PROJECT: ReactOS win32k.sys
3 * FILE: subsystems/win32/win32k/misc/rtlstr.c
4 * PURPOSE: Large Strings
9 /* INCLUDES ******************************************************************/
13 /* FUNCTIONS *****************************************************************/
17 RtlInitLargeAnsiString(
18 IN OUT PLARGE_ANSI_STRING DestinationString
,
26 DestSize
= (USHORT
)strlen(SourceString
);
27 DestinationString
->Length
= DestSize
;
28 DestinationString
->MaximumLength
= DestSize
+ sizeof(CHAR
);
32 DestinationString
->Length
= 0;
33 DestinationString
->MaximumLength
= 0;
36 DestinationString
->Buffer
= (PCHAR
)SourceString
;
37 DestinationString
->bAnsi
= TRUE
;
42 RtlInitLargeUnicodeString(
43 IN OUT PLARGE_UNICODE_STRING DestinationString
,
44 IN PCWSTR SourceString
,
51 DestSize
= (USHORT
)wcslen(SourceString
) * sizeof(WCHAR
);
52 DestinationString
->Length
= DestSize
;
53 DestinationString
->MaximumLength
= DestSize
+ sizeof(WCHAR
);
57 DestinationString
->Length
= 0;
58 DestinationString
->MaximumLength
= 0;
61 DestinationString
->Buffer
= (PWSTR
)SourceString
;
62 DestinationString
->bAnsi
= FALSE
;
67 RtlLargeStringToUnicodeString(
68 PUNICODE_STRING DestinationString
,
69 PLARGE_STRING SourceString
)
71 ANSI_STRING AnsiString
;
73 /* Check parameters */
74 if (!DestinationString
|| !SourceString
) return FALSE
;
76 /* Check if size if ok */
77 // We can't do this atm and truncate the string instead.
78 //if (SourceString->Length > 0xffff) return FALSE;
80 RtlInitUnicodeString(DestinationString
, NULL
);
82 if (SourceString
->bAnsi
)
84 RtlInitAnsiString(&AnsiString
, (LPSTR
)SourceString
->Buffer
);
85 return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString
, &AnsiString
, TRUE
));
89 return RtlCreateUnicodeString(DestinationString
, SourceString
->Buffer
);