1 /* 2 * PROJECT: ReactOS win32k.sys 3 * FILE: win32ss/user/ntuser/misc/rtlstr.c 4 * PURPOSE: Large Strings 5 * PROGRAMMER: 6 * 7 */ 8 9 /* INCLUDES ******************************************************************/ 10 11 #include <win32k.h> 12 13 /* FUNCTIONS *****************************************************************/ 14 15 VOID 16 NTAPI 17 RtlInitLargeAnsiString( 18 IN OUT PLARGE_ANSI_STRING DestinationString, 19 IN PCSZ SourceString, 20 IN INT Unknown) 21 { 22 USHORT DestSize; 23 24 if (SourceString) 25 { 26 DestSize = (USHORT)strlen(SourceString); 27 DestinationString->Length = DestSize; 28 DestinationString->MaximumLength = DestSize + sizeof(CHAR); 29 } 30 else 31 { 32 DestinationString->Length = 0; 33 DestinationString->MaximumLength = 0; 34 } 35 36 DestinationString->Buffer = (PCHAR)SourceString; 37 DestinationString->bAnsi = TRUE; 38 } 39 40 VOID 41 NTAPI 42 RtlInitLargeUnicodeString( 43 IN OUT PLARGE_UNICODE_STRING DestinationString, 44 IN PCWSTR SourceString, 45 IN INT Unknown) 46 { 47 USHORT DestSize; 48 49 if (SourceString) 50 { 51 DestSize = (USHORT)wcslen(SourceString) * sizeof(WCHAR); 52 DestinationString->Length = DestSize; 53 DestinationString->MaximumLength = DestSize + sizeof(WCHAR); 54 } 55 else 56 { 57 DestinationString->Length = 0; 58 DestinationString->MaximumLength = 0; 59 } 60 61 DestinationString->Buffer = (PWSTR)SourceString; 62 DestinationString->bAnsi = FALSE; 63 } 64 65 BOOL 66 NTAPI 67 RtlLargeStringToUnicodeString( 68 PUNICODE_STRING DestinationString, 69 PLARGE_STRING SourceString) 70 { 71 ANSI_STRING AnsiString; 72 73 /* Check parameters */ 74 if (!DestinationString || !SourceString) return FALSE; 75 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; 79 80 RtlInitUnicodeString(DestinationString, NULL); 81 82 if (SourceString->bAnsi) 83 { 84 RtlInitAnsiString(&AnsiString, (LPSTR)SourceString->Buffer); 85 return NT_SUCCESS(RtlAnsiStringToUnicodeString(DestinationString, &AnsiString, TRUE)); 86 } 87 else 88 { 89 return RtlCreateUnicodeString(DestinationString, SourceString->Buffer); 90 } 91 } 92 93