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