ReactOS 0.4.15-dev-8241-g63935f8
pathcch.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS PSDK
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: "Secure" shell path manipulation functions
5 * COPYRIGHT: MinGW-64 and Microsoft Corporation.
6 */
7
13#pragma once
14
15
16#ifndef WINBASEAPI
17#ifndef _KERNEL32_
18#define WINBASEAPI DECLSPEC_IMPORT
19#else
20#define WINBASEAPI
21#endif
22#endif
23
24
25#ifndef WINPATHCCHAPI
26#ifndef STATIC_PATHCCH
27#define WINPATHCCHAPI WINBASEAPI
28#else
29#define WINPATHCCHAPI
30#endif
31#endif
32
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
38// typedef enum PATHCCH_OPTIONS
39#define PATHCCH_NONE 0x00
40#define PATHCCH_ALLOW_LONG_PATHS 0x01
41#define PATHCCH_FORCE_ENABLE_LONG_NAME_PROCESS 0x02
42#define PATHCCH_FORCE_DISABLE_LONG_NAME_PROCESS 0x04
43#define PATHCCH_DO_NOT_NORMALIZE_SEGMENTS 0x08
44#define PATHCCH_ENSURE_IS_EXTENDED_LENGTH_PATH 0x10
45#define PATHCCH_ENSURE_TRAILING_SLASH 0x20
46// DEFINE_ENUM_FLAG_OPERATORS(PATHCCH_OPTIONS)
47
48#define VOLUME_PREFIX L"\\\\?\\Volume"
49#define VOLUME_PREFIX_LEN (ARRAYSIZE(VOLUME_PREFIX) - 1)
50
51#define PATHCCH_MAX_CCH 0x8000
52
57 _In_ PCWSTR pszPathIn,
58 _In_ /* PATHCCH_OPTIONS */ ULONG dwFlags,
59 _Outptr_ PWSTR* ppszPathOut);
60
65 _In_opt_ PCWSTR pszPathIn,
66 _In_opt_ PCWSTR pszMore,
67 _In_ /* PATHCCH_OPTIONS */ ULONG dwFlags,
68 _Outptr_ PWSTR* ppszPathOut);
69
74 _Inout_updates_(cchPath) PWSTR pszPath,
75 _In_ size_t cchPath);
76
81 _Inout_updates_(cchPath) PWSTR pszPath,
82 _In_ size_t cchPath,
83 _Outptr_opt_result_buffer_(*pcchRemaining) PWSTR* ppszEnd,
84 _Out_opt_ size_t* pcchRemaining);
85
90 _Inout_updates_(cchPath) PWSTR pszPath,
91 _In_ size_t cchPath,
92 _In_ PCWSTR pszExt);
93
98 _Inout_updates_(cchPath) PWSTR pszPath,
99 _In_ size_t cchPath,
100 _In_opt_ PCWSTR pszMore);
101
106 _Inout_updates_(cchPath) PWSTR pszPath,
107 _In_ size_t cchPath,
108 _In_opt_ PCWSTR pszMore,
109 _In_ /* PATHCCH_OPTIONS */ ULONG dwFlags);
110
115 _Out_writes_(cchPathOut) PWSTR pszPathOut,
116 _In_ size_t cchPathOut,
117 _In_ PCWSTR pszPathIn);
118
123 _Out_writes_(cchPathOut) PWSTR pszPathOut,
124 _In_ size_t cchPathOut,
125 _In_ PCWSTR pszPathIn,
126 _In_ /* PATHCCH_OPTIONS */ ULONG dwFlags);
127
132 _Out_writes_(cchPathOut) PWSTR pszPathOut,
133 _In_ size_t cchPathOut,
134 _In_opt_ PCWSTR pszPathIn,
135 _In_opt_ PCWSTR pszMore);
136
141 _Out_writes_(cchPathOut) PWSTR pszPathOut,
142 _In_ size_t cchPathOut,
143 _In_opt_ PCWSTR pszPathIn,
144 _In_opt_ PCWSTR pszMore,
145 _In_ /* PATHCCH_OPTIONS */ ULONG dwFlags);
146
151 _In_reads_(cchPath) PCWSTR pszPath,
152 _In_ size_t cchPath,
153 _Outptr_ PCWSTR* ppszExt);
154
156BOOL
159 _In_opt_ PCWSTR pszPath);
160
165 _Inout_updates_(cchPath) PWSTR pszPath,
166 _In_ size_t cchPath);
167
172 _Inout_updates_(cchPath) PWSTR pszPath,
173 _In_ size_t cchPath,
174 _Outptr_opt_result_buffer_(*pcchRemaining) PWSTR* ppszEnd,
175 _Out_opt_ size_t* pcchRemaining);
176
181 _Inout_updates_(cchPath) PWSTR pszPath,
182 _In_ size_t cchPath);
183
188 _Inout_updates_(cchPath) PWSTR pszPath,
189 _In_ size_t cchPath);
190
195 _Inout_updates_(cchPath) PWSTR pszPath,
196 _In_ size_t cchPath,
197 _In_ PCWSTR pszExt);
198
203 _In_ PCWSTR pszPath,
204 _Outptr_ PCWSTR* ppszRootEnd);
205
210 _Inout_updates_(cchPath) PWSTR pszPath,
211 _In_ size_t cchPath);
212
217 _Inout_updates_(cchPath) PWSTR pszPath,
218 _In_ size_t cchPath);
219
221BOOL
224 _In_ PCWSTR pszPath,
225 _Outptr_opt_ PCWSTR* ppszServer);
226
227
228#ifndef PATHCCH_NO_DEPRECATE
229
230#undef PathAddBackslash
231#undef PathAddBackslashA
232#undef PathAddBackslashW
233
234#undef PathAddExtension
235#undef PathAddExtensionA
236#undef PathAddExtensionW
237
238#undef PathAppend
239#undef PathAppendA
240#undef PathAppendW
241
242#undef PathCanonicalize
243#undef PathCanonicalizeA
244#undef PathCanonicalizeW
245
246#undef PathCombine
247#undef PathCombineA
248#undef PathCombineW
249
250#undef PathRenameExtension
251#undef PathRenameExtensionA
252#undef PathRenameExtensionW
253
254
255#ifdef DEPRECATE_SUPPORTED
256
257// #pragma deprecated(PathIsRelativeWorker)
258// #pragma deprecated(StrIsEqualWorker)
259// #pragma deprecated(FindPreviousBackslashWorker)
260// #pragma deprecated(IsHexDigitWorker)
261// #pragma deprecated(StringIsGUIDWorker)
262// #pragma deprecated(PathIsVolumeGUIDWorker)
263// #pragma deprecated(IsValidExtensionWorker)
264
265#pragma deprecated(PathAddBackslash)
266#pragma deprecated(PathAddBackslashA)
267#pragma deprecated(PathAddBackslashW)
268
269#pragma deprecated(PathAddExtension)
270#pragma deprecated(PathAddExtensionA)
271#pragma deprecated(PathAddExtensionW)
272
273#pragma deprecated(PathAppend)
274#pragma deprecated(PathAppendA)
275#pragma deprecated(PathAppendW)
276
277#pragma deprecated(PathCanonicalize)
278#pragma deprecated(PathCanonicalizeA)
279#pragma deprecated(PathCanonicalizeW)
280
281#pragma deprecated(PathCombine)
282#pragma deprecated(PathCombineA)
283#pragma deprecated(PathCombineW)
284
285#pragma deprecated(PathRenameExtension)
286#pragma deprecated(PathRenameExtensionA)
287#pragma deprecated(PathRenameExtensionW)
288
289#else // !DEPRECATE_SUPPORTED
290
291// #define PathIsRelativeWorker PathIsRelativeWorker_is_internal_to_pathcch;
292// #define StrIsEqualWorker StrIsEqualWorker_is_internal_to_pathcch;
293// #define FindPreviousBackslashWorker FindPreviousBackslashWorker_is_internal_to_pathcch;
294// #define IsHexDigitWorker IsHexDigitWorker_is_internal_to_pathcch;
295// #define StringIsGUIDWorker StringIsGUIDWorker_is_internal_to_pathcch;
296// #define PathIsVolumeGUIDWorker PathIsVolumeGUIDWorker_is_internal_to_pathcch;
297// #define IsValidExtensionWorker IsValidExtensionWorker_is_internal_to_pathcch;
298
299#define PathAddBackslash PathAddBackslash_instead_use_PathCchAddBackslash;
300#define PathAddBackslashA PathAddBackslash_instead_use_PathCchAddBackslash;
301#define PathAddBackslashW PathAddBackslash_instead_use_PathCchAddBackslash;
302
303#define PathAddExtension PathAddExtension_instead_use_PathCchAddExtension;
304#define PathAddExtensionA PathAddExtension_instead_use_PathCchAddExtension;
305#define PathAddExtensionW PathAddExtension_instead_use_PathCchAddExtension;
306
307#define PathAppend PathAppend_instead_use_PathCchAppend;
308#define PathAppendA PathAppend_instead_use_PathCchAppend;
309#define PathAppendW PathAppend_instead_use_PathCchAppend;
310
311#define PathCanonicalize PathCanonicalize_instead_use_PathCchCanonicalize;
312#define PathCanonicalizeA PathCanonicalize_instead_use_PathCchCanonicalize;
313#define PathCanonicalizeW PathCanonicalize_instead_use_PathCchCanonicalize;
314
315#define PathCombine PathCombine_instead_use_PathCchCombine;
316#define PathCombineA PathCombine_instead_use_PathCchCombine;
317#define PathCombineW PathCombine_instead_use_PathCchCombine;
318
319#define PathRenameExtension PathRenameExtension_instead_use_PathCchRenameExtension;
320#define PathRenameExtensionA PathRenameExtension_instead_use_PathCchRenameExtension;
321#define PathRenameExtensionW PathRenameExtension_instead_use_PathCchRenameExtension;
322
323#endif // DEPRECATE_SUPPORTED
324
325#endif // PATHCCH_NO_DEPRECATE
326
327#ifdef __cplusplus
328}
329#endif
330
331
332/* C++ non-const overloads */
333#ifdef __cplusplus
334
335__inline HRESULT
337 _In_reads_(cchPath) PWSTR pszPath,
338 _In_ size_t cchPath,
339 _Outptr_ PWSTR* ppszExt)
340{
341 return PathCchFindExtension(const_cast<PCWSTR>(pszPath), cchPath, const_cast<PCWSTR*>(ppszExt));
342}
343
344__inline HRESULT
346 _In_ PWSTR pszPath,
347 _Outptr_ PWSTR* ppszRootEnd)
348{
349 return PathCchSkipRoot(const_cast<PCWSTR>(pszPath), const_cast<PCWSTR*>(ppszRootEnd));
350}
351
352__inline BOOL
354 _In_ PWSTR pszPath,
355 _Outptr_opt_ PWSTR* ppszServer)
356{
357 return PathIsUNCEx(const_cast<PCWSTR>(pszPath), const_cast<PCWSTR*>(ppszServer));
358}
359
360#endif // __cplusplus
#define APIENTRY
Definition: api.h:79
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _Outptr_opt_result_buffer_(size)
Definition: ms_sal.h:457
#define _Out_opt_
Definition: ms_sal.h:346
#define _Inout_updates_(size)
Definition: ms_sal.h:387
#define _Outptr_opt_
Definition: ms_sal.h:429
#define _Outptr_
Definition: ms_sal.h:427
#define _Out_writes_(size)
Definition: ms_sal.h:348
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
#define _In_reads_(size)
Definition: ms_sal.h:319
WINPATHCCHAPI HRESULT APIENTRY PathCchCombine(_Out_writes_(cchPathOut) PWSTR pszPathOut, _In_ size_t cchPathOut, _In_opt_ PCWSTR pszPathIn, _In_opt_ PCWSTR pszMore)
WINPATHCCHAPI HRESULT APIENTRY PathCchAddBackslashEx(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _Outptr_opt_result_buffer_(*pcchRemaining) PWSTR *ppszEnd, _Out_opt_ size_t *pcchRemaining)
WINPATHCCHAPI HRESULT APIENTRY PathCchFindExtension(_In_reads_(cchPath) PCWSTR pszPath, _In_ size_t cchPath, _Outptr_ PCWSTR *ppszExt)
WINPATHCCHAPI HRESULT APIENTRY PathCchAppendEx(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _In_opt_ PCWSTR pszMore, _In_ ULONG dwFlags)
WINPATHCCHAPI HRESULT APIENTRY PathCchAddExtension(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _In_ PCWSTR pszExt)
WINPATHCCHAPI HRESULT APIENTRY PathAllocCanonicalize(_In_ PCWSTR pszPathIn, _In_ ULONG dwFlags, _Outptr_ PWSTR *ppszPathOut)
WINPATHCCHAPI HRESULT APIENTRY PathCchRemoveBackslashEx(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _Outptr_opt_result_buffer_(*pcchRemaining) PWSTR *ppszEnd, _Out_opt_ size_t *pcchRemaining)
WINPATHCCHAPI HRESULT APIENTRY PathCchRemoveExtension(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI HRESULT APIENTRY PathCchStripPrefix(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI HRESULT APIENTRY PathCchSkipRoot(_In_ PCWSTR pszPath, _Outptr_ PCWSTR *ppszRootEnd)
WINPATHCCHAPI HRESULT APIENTRY PathCchRenameExtension(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _In_ PCWSTR pszExt)
WINPATHCCHAPI HRESULT APIENTRY PathCchCanonicalizeEx(_Out_writes_(cchPathOut) PWSTR pszPathOut, _In_ size_t cchPathOut, _In_ PCWSTR pszPathIn, _In_ ULONG dwFlags)
WINPATHCCHAPI HRESULT APIENTRY PathCchRemoveFileSpec(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI HRESULT APIENTRY PathCchAppend(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath, _In_opt_ PCWSTR pszMore)
#define WINPATHCCHAPI
Definition: pathcch.h:27
WINPATHCCHAPI HRESULT APIENTRY PathCchCombineEx(_Out_writes_(cchPathOut) PWSTR pszPathOut, _In_ size_t cchPathOut, _In_opt_ PCWSTR pszPathIn, _In_opt_ PCWSTR pszMore, _In_ ULONG dwFlags)
WINPATHCCHAPI HRESULT APIENTRY PathCchAddBackslash(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI HRESULT APIENTRY PathCchStripToRoot(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI BOOL APIENTRY PathCchIsRoot(_In_opt_ PCWSTR pszPath)
WINPATHCCHAPI HRESULT APIENTRY PathCchRemoveBackslash(_Inout_updates_(cchPath) PWSTR pszPath, _In_ size_t cchPath)
WINPATHCCHAPI HRESULT APIENTRY PathAllocCombine(_In_opt_ PCWSTR pszPathIn, _In_opt_ PCWSTR pszMore, _In_ ULONG dwFlags, _Outptr_ PWSTR *ppszPathOut)
WINPATHCCHAPI BOOL APIENTRY PathIsUNCEx(_In_ PCWSTR pszPath, _Outptr_opt_ PCWSTR *ppszServer)
WINPATHCCHAPI HRESULT APIENTRY PathCchCanonicalize(_Out_writes_(cchPathOut) PWSTR pszPathOut, _In_ size_t cchPathOut, _In_ PCWSTR pszPathIn)
uint16_t * PWSTR
Definition: typedefs.h:56
const uint16_t * PCWSTR
Definition: typedefs.h:57
uint32_t ULONG
Definition: typedefs.h:59
_In_ PCCERT_CONTEXT _In_ DWORD dwFlags
Definition: wincrypt.h:1176