[FLTMGR]
[reactos.git] / reactos / drivers / filters / fltmgr / Lib.c
1 /*
2 * PROJECT: Filesystem Filter Manager
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: drivers/fs_minifilter/fltmgr/Lib.c
5 * PURPOSE: Miscellaneous library functions
6 * PROGRAMMERS: Ged Murphy (gedmurphy@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "fltmgr.h"
12
13 #define NDEBUG
14 #include <debug.h>
15
16
17 /* DATA *********************************************************************/
18
19
20
21 /* FUNCTIONS **********************************************/
22
23 VOID
24 FltpFreeUnicodeString(_In_ PUNICODE_STRING String)
25 {
26 /* Free up any existing buffer */
27 if (String->Buffer)
28 {
29 ExFreePoolWithTag(String->Buffer, FM_TAG_UNICODE_STRING);
30 }
31
32 /* Empty the string */
33 String->Buffer = NULL;
34 String->Length = 0;
35 String->MaximumLength = 0;
36 }
37
38 NTSTATUS
39 FltpReallocateUnicodeString(_In_ PUNICODE_STRING String,
40 _In_ SIZE_T NewLength,
41 _In_ BOOLEAN CopyExisting)
42 {
43 PWCH NewBuffer;
44
45 /* Don't bother reallocating if the buffer is smaller */
46 if (NewLength <= String->MaximumLength)
47 {
48 String->Length = 0;
49 return STATUS_SUCCESS;
50 }
51
52 /* Allocate a new buffer at the size requested */
53 NewBuffer = ExAllocatePoolWithTag(PagedPool, NewLength, FM_TAG_UNICODE_STRING);
54 if (NewBuffer == NULL) return STATUS_INSUFFICIENT_RESOURCES;
55
56 if (CopyExisting)
57 {
58 /* Copy the old data across */
59 RtlCopyMemory(NewBuffer, String->Buffer, String->Length);
60 }
61 else
62 {
63 /* Reset the length */
64 String->Length = 0;
65 }
66
67 /* Free any old buffer */
68 if (String->Buffer)
69 ExFreePoolWithTag(String->Buffer, FM_TAG_UNICODE_STRING);
70
71 /* Update the lengths */
72 String->Buffer = NewBuffer;
73 String->MaximumLength = NewLength;
74
75 return STATUS_SUCCESS;
76 }
77
78 NTSTATUS
79 FltpCopyUnicodeString(_In_ PUNICODE_STRING StringOne,
80 _In_ PUNICODE_STRING StringTwo)
81 {
82 return 0;
83 }