ReactOS
0.4.16-dev-340-g0540c21
prefxsup.c
Go to the documentation of this file.
1
/*
2
* PROJECT: ReactOS Named Pipe FileSystem
3
* LICENSE: BSD - See COPYING.ARM in the top level directory
4
* FILE: drivers/filesystems/npfs/prefxsup.c
5
* PURPOSE: Pipes Prefixes Support
6
* PROGRAMMERS: ReactOS Portable Systems Group
7
*/
8
9
/* INCLUDES *******************************************************************/
10
11
#include "
npfs.h
"
12
13
// File ID number for NPFS bugchecking support
14
#define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_PREFXSUP)
15
16
/* FUNCTIONS ******************************************************************/
17
18
PNP_FCB
19
NTAPI
20
NpFindPrefix
(
IN
PUNICODE_STRING
Name
,
21
IN
ULONG
CaseInsensitiveIndex
,
22
IN
PUNICODE_STRING
Prefix
)
23
{
24
PUNICODE_PREFIX_TABLE_ENTRY
Entry
;
25
PNP_FCB
Fcb
;
26
PAGED_CODE
();
27
28
Entry
=
RtlFindUnicodePrefix
(&
NpVcb
->
PrefixTable
,
29
Name
,
30
CaseInsensitiveIndex
);
31
if
(!
Entry
)
NpBugCheck
(0, 0, 0);
32
33
Fcb
=
CONTAINING_RECORD
(
Entry
,
NP_FCB
,
PrefixTableEntry
);
34
35
Prefix
->
Length
=
Name
->Length -
Fcb
->FullName.Length;
36
Prefix
->
MaximumLength
=
Prefix
->
Length
;
37
Prefix
->
Buffer
= &
Name
->Buffer[
Fcb
->FullName.Length /
sizeof
(
WCHAR
)];
38
39
if
((
Prefix
->
Length
) && (
Prefix
->
Buffer
[0] ==
OBJ_NAME_PATH_SEPARATOR
))
40
{
41
Prefix
->
Length
-=
sizeof
(
WCHAR
);
42
Prefix
->
MaximumLength
-=
sizeof
(
WCHAR
);
43
++
Prefix
->
Buffer
;
44
}
45
46
return
Fcb
;
47
}
48
49
NTSTATUS
50
NTAPI
51
NpFindRelativePrefix
(
IN
PNP_DCB
Dcb
,
52
IN
PUNICODE_STRING
Name
,
53
IN
ULONG
CaseInsensitiveIndex
,
54
IN
PUNICODE_STRING
Prefix
,
55
OUT
PNP_FCB
*FoundFcb)
56
{
57
PWCHAR
Buffer
;
58
PNP_FCB
Fcb
;
59
UNICODE_STRING
RootName;
60
USHORT
Length
,
MaximumLength
;
61
PAGED_CODE
();
62
63
Length
=
Name
->Length;
64
MaximumLength
=
Length
+
sizeof
(
OBJ_NAME_PATH_SEPARATOR
) +
sizeof
(
UNICODE_NULL
);
65
if
(
MaximumLength
<
Length
)
return
STATUS_INVALID_PARAMETER
;
66
67
ASSERT
(
Dcb
->NodeType ==
NPFS_NTC_ROOT_DCB
);
68
69
Buffer
=
ExAllocatePoolWithTag
(
PagedPool
,
MaximumLength
,
NPFS_NAME_BLOCK_TAG
);
70
if
(!
Buffer
)
71
{
72
return
STATUS_INSUFFICIENT_RESOURCES
;
73
}
74
75
*
Buffer
=
OBJ_NAME_PATH_SEPARATOR
;
76
RtlCopyMemory
(
Buffer
+ 1,
Name
->Buffer,
Length
);
77
Buffer
[(
Length
/
sizeof
(
WCHAR
)) + 1] =
UNICODE_NULL
;
78
79
RootName.
Length
=
Length
+
sizeof
(
OBJ_NAME_PATH_SEPARATOR
);
80
RootName.
MaximumLength
=
MaximumLength
;
81
RootName.
Buffer
=
Buffer
;
82
83
Fcb
=
NpFindPrefix
(&RootName,
CaseInsensitiveIndex
,
Prefix
);
84
85
ExFreePool
(
Buffer
);
86
87
Prefix
->
Buffer
= &
Name
->Buffer[(
Length
-
Prefix
->
Length
) /
sizeof
(
WCHAR
)];
88
*FoundFcb =
Fcb
;
89
90
return
STATUS_SUCCESS
;
91
}
92
93
/* EOF */
PAGED_CODE
#define PAGED_CODE()
Definition:
Bus_PDO_EvalMethod.c:87
OBJ_NAME_PATH_SEPARATOR
#define OBJ_NAME_PATH_SEPARATOR
Definition:
arcname_tests.c:25
NTSTATUS
LONG NTSTATUS
Definition:
precomp.h:26
Fcb
_In_ PFCB Fcb
Definition:
cdprocs.h:159
Buffer
Definition:
bufpool.h:45
Dcb
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT _Inout_ PVCB _Outptr_result_maybenull_ PDCB * Dcb
Definition:
create.c:4140
NPFS_NTC_ROOT_DCB
#define NPFS_NTC_ROOT_DCB
Definition:
npfs.h:113
NpVcb
PNP_VCB NpVcb
Definition:
strucsup.c:19
NpBugCheck
#define NpBugCheck(p1, p2, p3)
Definition:
npfs.h:106
NPFS_NAME_BLOCK_TAG
#define NPFS_NAME_BLOCK_TAG
Definition:
npfs.h:59
ExAllocatePoolWithTag
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition:
env_spec_w32.h:350
ExFreePool
#define ExFreePool(addr)
Definition:
env_spec_w32.h:352
PagedPool
#define PagedPool
Definition:
env_spec_w32.h:308
ASSERT
#define ASSERT(a)
Definition:
mode.c:44
npfs.h
NpFindRelativePrefix
NTSTATUS NTAPI NpFindRelativePrefix(IN PNP_DCB Dcb, IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix, OUT PNP_FCB *FoundFcb)
Definition:
prefxsup.c:51
NpFindPrefix
PNP_FCB NTAPI NpFindPrefix(IN PUNICODE_STRING Name, IN ULONG CaseInsensitiveIndex, IN PUNICODE_STRING Prefix)
Definition:
prefxsup.c:20
UNICODE_NULL
#define UNICODE_NULL
Length
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition:
ntddpcm.h:102
USHORT
unsigned short USHORT
Definition:
pedump.c:61
STATUS_SUCCESS
#define STATUS_SUCCESS
Definition:
shellext.h:65
Entry
base of all file and directory entries
Definition:
entries.h:83
NameRec_
Definition:
apinames.c:49
_NP_DCB
Definition:
npfs.h:211
_NP_FCB
Definition:
npfs.h:229
_NP_VCB::PrefixTable
UNICODE_PREFIX_TABLE PrefixTable
Definition:
npfs.h:282
_STRING::Length
unsigned short Length
Definition:
sprintf.c:451
_STRING::Buffer
void * Buffer
Definition:
sprintf.c:453
_STRING::MaximumLength
unsigned short MaximumLength
Definition:
sprintf.c:452
_UNICODE_PREFIX_TABLE_ENTRY
Definition:
rtltypes.h:640
_UNICODE_STRING
Definition:
env_spec_w32.h:368
_UNICODE_STRING::Length
USHORT Length
Definition:
env_spec_w32.h:369
_UNICODE_STRING::MaximumLength
USHORT MaximumLength
Definition:
env_spec_w32.h:370
_UNICODE_STRING::Buffer
PWSTR Buffer
Definition:
env_spec_w32.h:371
NTAPI
#define NTAPI
Definition:
typedefs.h:36
RtlCopyMemory
#define RtlCopyMemory(Destination, Source, Length)
Definition:
typedefs.h:263
IN
#define IN
Definition:
typedefs.h:39
PWCHAR
uint16_t * PWCHAR
Definition:
typedefs.h:56
CONTAINING_RECORD
#define CONTAINING_RECORD(address, type, field)
Definition:
typedefs.h:260
ULONG
uint32_t ULONG
Definition:
typedefs.h:59
OUT
#define OUT
Definition:
typedefs.h:40
STATUS_INVALID_PARAMETER
#define STATUS_INVALID_PARAMETER
Definition:
udferr_usr.h:135
STATUS_INSUFFICIENT_RESOURCES
#define STATUS_INSUFFICIENT_RESOURCES
Definition:
udferr_usr.h:158
RtlFindUnicodePrefix
PUNICODE_PREFIX_TABLE_ENTRY NTAPI RtlFindUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable, PUNICODE_STRING FullName, ULONG CaseInsensitiveIndex)
Definition:
unicodeprefix.c:149
MaximumLength
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
Definition:
wdfdmatransaction.h:498
CaseInsensitiveIndex
_In_ PUNICODE_STRING _In_ ULONG CaseInsensitiveIndex
Definition:
rtlfuncs.h:1699
Prefix
_In_ __drv_aliasesMem PSTRING Prefix
Definition:
rtlfuncs.h:1647
PrefixTableEntry
_In_ __drv_aliasesMem PSTRING _Out_ PPREFIX_TABLE_ENTRY PrefixTableEntry
Definition:
rtlfuncs.h:1648
WCHAR
__wchar_t WCHAR
Definition:
xmlstorage.h:180
drivers
filesystems
npfs
prefxsup.c
Generated on Thu Dec 12 2024 06:05:28 for ReactOS by
1.9.6