[FLTMGR] Stub FltGetFileNameInformationUnsafe()
[reactos.git] / drivers / storage / fdc / fdc / misc.c
1 /*
2 * PROJECT: ReactOS Floppy Disk Controller Driver
3 * LICENSE: GNU GPLv2 only as published by the Free Software Foundation
4 * FILE: drivers/storage/fdc/fdc/misc.c
5 * PURPOSE: Misc Routines
6 * PROGRAMMERS: Eric Kohl
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include "fdc.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16 /* FUNCTIONS ******************************************************************/
17
18 NTSTATUS
19 DuplicateUnicodeString(
20 IN ULONG Flags,
21 IN PCUNICODE_STRING SourceString,
22 OUT PUNICODE_STRING DestinationString)
23 {
24 USHORT DestMaxLength;
25
26 if (SourceString == NULL ||
27 DestinationString == NULL ||
28 SourceString->Length > SourceString->MaximumLength ||
29 (SourceString->Length == 0 && SourceString->MaximumLength > 0 && SourceString->Buffer == NULL) ||
30 Flags == RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING ||
31 Flags >= 4)
32 {
33 return STATUS_INVALID_PARAMETER;
34 }
35
36 if ((SourceString->Length == 0) &&
37 (Flags != (RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE |
38 RTL_DUPLICATE_UNICODE_STRING_ALLOCATE_NULL_STRING)))
39 {
40 DestinationString->Length = 0;
41 DestinationString->MaximumLength = 0;
42 DestinationString->Buffer = NULL;
43 }
44 else
45 {
46 DestMaxLength = SourceString->Length;
47
48 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
49 DestMaxLength += sizeof(UNICODE_NULL);
50
51 DestinationString->Buffer = ExAllocatePoolWithTag(PagedPool, DestMaxLength, FDC_TAG);
52 if (DestinationString->Buffer == NULL)
53 return STATUS_NO_MEMORY;
54
55 RtlCopyMemory(DestinationString->Buffer, SourceString->Buffer, SourceString->Length);
56 DestinationString->Length = SourceString->Length;
57 DestinationString->MaximumLength = DestMaxLength;
58
59 if (Flags & RTL_DUPLICATE_UNICODE_STRING_NULL_TERMINATE)
60 DestinationString->Buffer[DestinationString->Length / sizeof(WCHAR)] = 0;
61 }
62
63 return STATUS_SUCCESS;
64 }
65
66 /* EOF */