ReactOS 0.4.16-dev-297-gc569aee
arcname.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

BOOLEAN ArcPathNormalize (OUT PUNICODE_STRING NormalizedArcPath, IN PCWSTR ArcPath)
 
BOOLEAN ArcPathToNtPath (OUT PUNICODE_STRING NtPath, IN PCWSTR ArcPath, IN PPARTLIST PartList OPTIONAL)
 

Function Documentation

◆ ArcPathNormalize()

BOOLEAN ArcPathNormalize ( OUT PUNICODE_STRING  NormalizedArcPath,
IN PCWSTR  ArcPath 
)

Definition at line 312 of file arcname.c.

315{
317 PCWSTR EndOfArcName;
318 PCWSTR p;
320
321 if (NormalizedArcPath->MaximumLength < sizeof(UNICODE_NULL))
322 return FALSE;
323
324 *NormalizedArcPath->Buffer = UNICODE_NULL;
325 NormalizedArcPath->Length = 0;
326
327 EndOfArcName = wcschr(ArcPath, OBJ_NAME_PATH_SEPARATOR);
328 if (!EndOfArcName)
329 EndOfArcName = ArcPath + wcslen(ArcPath);
330
331 while ((p = wcsstr(ArcPath, L"()")) && (p < EndOfArcName))
332 {
333#if 0
334 Status = RtlStringCbCopyNW(NormalizedArcPath->Buffer,
335 NormalizedArcPath->MaximumLength,
336 ArcPath, (p - ArcPath) * sizeof(WCHAR));
337#else
338 Status = RtlStringCbCatNW(NormalizedArcPath->Buffer,
339 NormalizedArcPath->MaximumLength,
340 ArcPath, (p - ArcPath) * sizeof(WCHAR));
341#endif
342 if (!NT_SUCCESS(Status))
343 return FALSE;
344
345 Status = RtlStringCbCatW(NormalizedArcPath->Buffer,
346 NormalizedArcPath->MaximumLength,
347 L"(0)");
348 if (!NT_SUCCESS(Status))
349 return FALSE;
350#if 0
351 NormalizedArcPath->Buffer += wcslen(NormalizedArcPath->Buffer);
352#endif
353 ArcPath = p + 2;
354 }
355
356 Status = RtlStringCbCatW(NormalizedArcPath->Buffer,
357 NormalizedArcPath->MaximumLength,
358 ArcPath);
359 if (!NT_SUCCESS(Status))
360 return FALSE;
361
362 PathLength = wcslen(NormalizedArcPath->Buffer);
364 {
365 return FALSE;
366 }
367
368 NormalizedArcPath->Length = (USHORT)PathLength * sizeof(WCHAR);
369 return TRUE;
370}
static USHORT PathLength
#define OBJ_NAME_PATH_SEPARATOR
Definition: arcname_tests.c:25
LONG NTSTATUS
Definition: precomp.h:26
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define wcschr
Definition: compat.h:17
Status
Definition: gdiplustypes.h:25
GLfloat GLfloat p
Definition: glext.h:8902
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
_CONST_RETURN wchar_t *__cdecl wcsstr(_In_z_ const wchar_t *_Str, _In_z_ const wchar_t *_SubStr)
#define UNICODE_NULL
#define UNICODE_STRING_MAX_CHARS
NTSTRSAFEAPI RtlStringCbCatW(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:636
NTSTRSAFEAPI RtlStringCbCatNW(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToAppend) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToAppend)
Definition: ntstrsafe.h:832
NTSTRSAFEAPI RtlStringCbCopyNW(_Out_writes_bytes_(cbDest) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_reads_bytes_(cbToCopy) STRSAFE_LPCWSTR pszSrc, _In_ size_t cbToCopy)
Definition: ntstrsafe.h:416
#define L(x)
Definition: ntvdm.h:50
unsigned short USHORT
Definition: pedump.c:61
const uint16_t * PCWSTR
Definition: typedefs.h:57
ULONG_PTR SIZE_T
Definition: typedefs.h:80
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by _tmain().

◆ ArcPathToNtPath()

BOOLEAN ArcPathToNtPath ( OUT PUNICODE_STRING  NtPath,
IN PCWSTR  ArcPath,
IN PPARTLIST PartList  OPTIONAL 
)

Definition at line 819 of file arcname.c.

823{
825 PCWSTR BeginOfPath;
826 UNICODE_STRING ArcName;
828
829 /* TODO: We should "normalize" the path, i.e. expand all the xxx() into xxx(0) */
830
831 if (NtPath->MaximumLength < sizeof(UNICODE_NULL))
832 return FALSE;
833
834 *NtPath->Buffer = UNICODE_NULL;
835 NtPath->Length = 0;
836
837 /*
838 * - First, check whether the ARC path is already inside \\ArcName
839 * and if so, map it to the corresponding NT path.
840 * - Only then, if we haven't found any ArcName, try to build a
841 * NT path by deconstructing the ARC path, using its disk and
842 * partition numbers. We may use here our disk/partition list.
843 *
844 * See also freeldr/arcname.c
845 *
846 * Note that it would be nice to maintain a cache of these mappings.
847 */
848
849 /*
850 * Initialize the ARC name to resolve, by cutting the ARC path at the first
851 * NT path separator. The ARC name therefore ends where the NT path part starts.
852 */
853 RtlInitUnicodeString(&ArcName, ArcPath);
854 BeginOfPath = wcschr(ArcName.Buffer, OBJ_NAME_PATH_SEPARATOR);
855 if (BeginOfPath)
856 ArcName.Length = (ULONG_PTR)BeginOfPath - (ULONG_PTR)ArcName.Buffer;
857
858 /* Resolve the ARC name via NT SymLinks. Note that NtPath is returned NULL-terminated. */
859 Status = ResolveArcNameNtSymLink(NtPath, &ArcName);
860 if (!NT_SUCCESS(Status))
861 {
862 /* We failed, attempt a manual resolution */
863 DPRINT1("ResolveArcNameNtSymLink(ArcName = '%wZ') for ArcPath = '%S' failed, Status 0x%08lx\n", &ArcName, ArcPath, Status);
864
865 /*
866 * We failed at directly resolving the ARC path, and we cannot perform
867 * a manual resolution because we don't have any disk/partition list,
868 * we therefore fail here.
869 */
870 if (!PartList)
871 {
872 DPRINT1("PartList == NULL, cannot perform a manual resolution\n");
873 return FALSE;
874 }
875
876 *NtPath->Buffer = UNICODE_NULL;
877 NtPath->Length = 0;
878
879 BeginOfPath = ArcPath;
880 Status = ResolveArcNameManually(NtPath, &BeginOfPath, PartList);
881 if (!NT_SUCCESS(Status))
882 {
883 /* We really failed this time, bail out */
884 DPRINT1("ResolveArcNameManually(ArcPath = '%S') failed, Status 0x%08lx\n", ArcPath, Status);
885 return FALSE;
886 }
887 }
888
889 /*
890 * We succeeded. Concatenate the rest of the system-specific path. We know the path is going
891 * to be inside the NT namespace, therefore we can use the path string concatenation function
892 * that uses '\\' as the path separator.
893 */
894 if (BeginOfPath && *BeginOfPath)
895 {
896 Status = ConcatPaths(NtPath->Buffer, NtPath->MaximumLength / sizeof(WCHAR), 1, BeginOfPath);
897 if (!NT_SUCCESS(Status))
898 {
899 /* Buffer not large enough, or whatever...: just bail out */
900 return FALSE;
901 }
902 }
903
904 PathLength = wcslen(NtPath->Buffer);
906 {
907 return FALSE;
908 }
909
910 NtPath->Length = (USHORT)PathLength * sizeof(WCHAR);
911
912 return TRUE;
913}
#define DPRINT1
Definition: precomp.h:8
static NTSTATUS ResolveArcNameManually(OUT PUNICODE_STRING NtName, IN OUT PCWSTR *ArcNamePath, IN PPARTLIST PartList)
Definition: arcname.c:689
static NTSTATUS ResolveArcNameNtSymLink(OUT PUNICODE_STRING NtName, IN PUNICODE_STRING ArcName)
Definition: arcname.c:599
#define ULONG_PTR
Definition: config.h:101
NTSTATUS ConcatPaths(IN OUT PWSTR PathBuffer, IN SIZE_T cchPathSize, IN ULONG NumberOfPathComponents, IN ...)
Definition: filesup.c:642
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
uint32_t ULONG_PTR
Definition: typedefs.h:65

Referenced by _tmain(), and EnumerateInstallations().