1*6f19c83bSHermès Bélusca-Maïto /*
2*6f19c83bSHermès Bélusca-Maïto * PROJECT: ReactOS Setup Library
3*6f19c83bSHermès Bélusca-Maïto * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4*6f19c83bSHermès Bélusca-Maïto * PURPOSE: Tests for the arcname.c functions:
5*6f19c83bSHermès Bélusca-Maïto * ArcPathNormalize(), ArcPathToNtPath().
6*6f19c83bSHermès Bélusca-Maïto * COPYRIGHT: Copyright 2017-2018 Hermes Belusca-Maito
7*6f19c83bSHermès Bélusca-Maïto *
8*6f19c83bSHermès Bélusca-Maïto * You may need to fix the included headers before being able to
9*6f19c83bSHermès Bélusca-Maïto * compile this file (this file has only been compiled under VS).
10*6f19c83bSHermès Bélusca-Maïto */
11*6f19c83bSHermès Bélusca-Maïto
12*6f19c83bSHermès Bélusca-Maïto #include <stdio.h>
13*6f19c83bSHermès Bélusca-Maïto #include <tchar.h>
14*6f19c83bSHermès Bélusca-Maïto #include <conio.h>
15*6f19c83bSHermès Bélusca-Maïto
16*6f19c83bSHermès Bélusca-Maïto #define WIN32_NO_STATUS
17*6f19c83bSHermès Bélusca-Maïto #include <windows.h>
18*6f19c83bSHermès Bélusca-Maïto #include <winternl.h>
19*6f19c83bSHermès Bélusca-Maïto #undef WIN32_NO_STATUS
20*6f19c83bSHermès Bélusca-Maïto
21*6f19c83bSHermès Bélusca-Maïto #include <ntstatus.h>
22*6f19c83bSHermès Bélusca-Maïto
23*6f19c83bSHermès Bélusca-Maïto #include "arcname.h"
24*6f19c83bSHermès Bélusca-Maïto
25*6f19c83bSHermès Bélusca-Maïto #define OBJ_NAME_PATH_SEPARATOR ((WCHAR)L'\\')
26*6f19c83bSHermès Bélusca-Maïto
_tmain(int argc,_TCHAR * argv[])27*6f19c83bSHermès Bélusca-Maïto int _tmain(int argc, _TCHAR* argv[])
28*6f19c83bSHermès Bélusca-Maïto {
29*6f19c83bSHermès Bélusca-Maïto WCHAR ArcPath[MAX_PATH] = L"multi(5)disk()rdisk(1)partition()\\ReactOS";
30*6f19c83bSHermès Bélusca-Maïto WCHAR NormalizedArcPathBuffer[MAX_PATH];
31*6f19c83bSHermès Bélusca-Maïto UNICODE_STRING NormalizedArcPath;
32*6f19c83bSHermès Bélusca-Maïto WCHAR NtPathBuffer[MAX_PATH];
33*6f19c83bSHermès Bélusca-Maïto UNICODE_STRING NtPath;
34*6f19c83bSHermès Bélusca-Maïto
35*6f19c83bSHermès Bélusca-Maïto NormalizedArcPath.Buffer = NormalizedArcPathBuffer;
36*6f19c83bSHermès Bélusca-Maïto NormalizedArcPath.Length = 0;
37*6f19c83bSHermès Bélusca-Maïto NormalizedArcPath.MaximumLength = sizeof(NormalizedArcPathBuffer);
38*6f19c83bSHermès Bélusca-Maïto
39*6f19c83bSHermès Bélusca-Maïto ArcPathNormalize(&NormalizedArcPath, ArcPath);
40*6f19c83bSHermès Bélusca-Maïto wprintf(L"ArcPath = '%s' ; Normalized = '%wZ'\n", ArcPath, &NormalizedArcPath);
41*6f19c83bSHermès Bélusca-Maïto
42*6f19c83bSHermès Bélusca-Maïto NtPath.Buffer = NtPathBuffer;
43*6f19c83bSHermès Bélusca-Maïto NtPath.Length = 0;
44*6f19c83bSHermès Bélusca-Maïto NtPath.MaximumLength = sizeof(NtPathBuffer);
45*6f19c83bSHermès Bélusca-Maïto
46*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, NormalizedArcPath.Buffer);
47*6f19c83bSHermès Bélusca-Maïto // wprintf(L"ArcPath = '%s' ; NtPath = '%wZ'\n", ArcPath, &NtPath);
48*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
49*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"ramdisk(0)"); // OK
50*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
51*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"ramdisk(0)\\ReactOS\\system32\\ntoskrnl.exe"); // OK
52*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
53*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"net(0)\\Foobar"); // OK but not supported
54*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
55*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"net(0)disk(1)\\Foobar"); // Bad
56*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
57*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)rdisk(3)"); // OK
58*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
59*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)fdisk(3)"); // OK
60*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
61*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)"); // Bad: missing fdisk
62*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
63*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)cdrom(0)"); // Bad: twice cdrom
64*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
65*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)fdisk(0)"); // OK
66*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
67*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)rdisk(0)"); // Bad; cdrom controller and rdisk peripheral
68*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
69*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(2)cdrom(1)fdisk(0)"); // Bad: multi adapter cannot have cdrom controller
70*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
71*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(2)rdisk(1)cdrom(1)fdisk(0)"); // Bad: rdisk is not a controller
72*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
73*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(2)disk(1)cdrom(1)fdisk(0)"); // OK (disk(1) ignored)
74*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
75*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)fdisk(0)"); // Same (and also fdisk is not considered as part of ARC path)
76*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
77*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)partition(3)"); // OK (disk(1) ignored)
78*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
79*6f19c83bSHermès Bélusca-Maïto
80*6f19c83bSHermès Bélusca-Maïto _getch();
81*6f19c83bSHermès Bélusca-Maïto
82*6f19c83bSHermès Bélusca-Maïto /* All these are OK */
83*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(0)disk(3)rdisk(0)partition(1)\\OS.DIR");
84*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
85*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"scsi(1)disk(3)rdisk(3)partition(2)\\OS\\ARCOS\\LOADER");
86*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
87*6f19c83bSHermès Bélusca-Maïto
88*6f19c83bSHermès Bélusca-Maïto _getch();
89*6f19c83bSHermès Bélusca-Maïto
90*6f19c83bSHermès Bélusca-Maïto /* All these are OK */
91*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(1)");
92*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
93*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(0)");
94*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
95*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)cdrom(3)");
96*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
97*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"ramdisk(0)");
98*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
99*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"net(0)");
100*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
101*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)");
102*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
103*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(0)");
104*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
105*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(3)");
106*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
107*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(1)");
108*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
109*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(3)");
110*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
111*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)partition(0)");
112*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
113*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)partition(0)");
114*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
115*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)");
116*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
117*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)");
118*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
119*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(1)partition(0)");
120*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
121*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)partition(0)");
122*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
123*6f19c83bSHermès Bélusca-Maïto
124*6f19c83bSHermès Bélusca-Maïto /* These are invalid storage ARC paths (but otherwise are valid ARC names) */
125*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)video(0)monitor(0)");
126*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
127*6f19c83bSHermès Bélusca-Maïto ArcPathToNtPath(&NtPath, L"multi(0)key(0)keyboard(0)");
128*6f19c83bSHermès Bélusca-Maïto wprintf(L"NtPath = '%wZ'\n", &NtPath);
129*6f19c83bSHermès Bélusca-Maïto
130*6f19c83bSHermès Bélusca-Maïto _getch();
131*6f19c83bSHermès Bélusca-Maïto return 0;
132*6f19c83bSHermès Bélusca-Maïto }
133