ReactOS  0.4.14-dev-57-g333b8f1
arcname_tests.c File Reference
#include <stdio.h>
#include <tchar.h>
#include <conio.h>
#include <windows.h>
#include <winternl.h>
#include <ntstatus.h>
#include "arcname.h"
Include dependency graph for arcname_tests.c:

Go to the source code of this file.

Macros

#define WIN32_NO_STATUS
 
#define OBJ_NAME_PATH_SEPARATOR   ((WCHAR)L'\\')
 

Functions

int _tmain (int argc, _TCHAR *argv[])
 

Macro Definition Documentation

◆ OBJ_NAME_PATH_SEPARATOR

#define OBJ_NAME_PATH_SEPARATOR   ((WCHAR)L'\\')

Definition at line 25 of file arcname_tests.c.

◆ WIN32_NO_STATUS

#define WIN32_NO_STATUS

Definition at line 16 of file arcname_tests.c.

Function Documentation

◆ _tmain()

int _tmain ( int  argc,
_TCHAR argv[] 
)

Definition at line 27 of file arcname_tests.c.

28 {
29  WCHAR ArcPath[MAX_PATH] = L"multi(5)disk()rdisk(1)partition()\\ReactOS";
30  WCHAR NormalizedArcPathBuffer[MAX_PATH];
31  UNICODE_STRING NormalizedArcPath;
32  WCHAR NtPathBuffer[MAX_PATH];
33  UNICODE_STRING NtPath;
34 
35  NormalizedArcPath.Buffer = NormalizedArcPathBuffer;
36  NormalizedArcPath.Length = 0;
37  NormalizedArcPath.MaximumLength = sizeof(NormalizedArcPathBuffer);
38 
39  ArcPathNormalize(&NormalizedArcPath, ArcPath);
40  wprintf(L"ArcPath = '%s' ; Normalized = '%wZ'\n", ArcPath, &NormalizedArcPath);
41 
42  NtPath.Buffer = NtPathBuffer;
43  NtPath.Length = 0;
44  NtPath.MaximumLength = sizeof(NtPathBuffer);
45 
46  ArcPathToNtPath(&NtPath, NormalizedArcPath.Buffer);
47  // wprintf(L"ArcPath = '%s' ; NtPath = '%wZ'\n", ArcPath, &NtPath);
48  wprintf(L"NtPath = '%wZ'\n", &NtPath);
49  ArcPathToNtPath(&NtPath, L"ramdisk(0)"); // OK
50  wprintf(L"NtPath = '%wZ'\n", &NtPath);
51  ArcPathToNtPath(&NtPath, L"ramdisk(0)\\ReactOS\\system32\\ntoskrnl.exe"); // OK
52  wprintf(L"NtPath = '%wZ'\n", &NtPath);
53  ArcPathToNtPath(&NtPath, L"net(0)\\Foobar"); // OK but not supported
54  wprintf(L"NtPath = '%wZ'\n", &NtPath);
55  ArcPathToNtPath(&NtPath, L"net(0)disk(1)\\Foobar"); // Bad
56  wprintf(L"NtPath = '%wZ'\n", &NtPath);
57  ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)rdisk(3)"); // OK
58  wprintf(L"NtPath = '%wZ'\n", &NtPath);
59  ArcPathToNtPath(&NtPath, L"scsi(2)disk(1)fdisk(3)"); // OK
60  wprintf(L"NtPath = '%wZ'\n", &NtPath);
61  ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)"); // Bad: missing fdisk
62  wprintf(L"NtPath = '%wZ'\n", &NtPath);
63  ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)cdrom(0)"); // Bad: twice cdrom
64  wprintf(L"NtPath = '%wZ'\n", &NtPath);
65  ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)fdisk(0)"); // OK
66  wprintf(L"NtPath = '%wZ'\n", &NtPath);
67  ArcPathToNtPath(&NtPath, L"scsi(2)cdrom(1)rdisk(0)"); // Bad; cdrom controller and rdisk peripheral
68  wprintf(L"NtPath = '%wZ'\n", &NtPath);
69  ArcPathToNtPath(&NtPath, L"multi(2)cdrom(1)fdisk(0)"); // Bad: multi adapter cannot have cdrom controller
70  wprintf(L"NtPath = '%wZ'\n", &NtPath);
71  ArcPathToNtPath(&NtPath, L"multi(2)rdisk(1)cdrom(1)fdisk(0)"); // Bad: rdisk is not a controller
72  wprintf(L"NtPath = '%wZ'\n", &NtPath);
73  ArcPathToNtPath(&NtPath, L"multi(2)disk(1)cdrom(1)fdisk(0)"); // OK (disk(1) ignored)
74  wprintf(L"NtPath = '%wZ'\n", &NtPath);
75  ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)fdisk(0)"); // Same (and also fdisk is not considered as part of ARC path)
76  wprintf(L"NtPath = '%wZ'\n", &NtPath);
77  ArcPathToNtPath(&NtPath, L"multi(2)disk(1)rdisk(1)partition(3)"); // OK (disk(1) ignored)
78  wprintf(L"NtPath = '%wZ'\n", &NtPath);
79 
80  _getch();
81 
82  /* All these are OK */
83  ArcPathToNtPath(&NtPath, L"scsi(0)disk(3)rdisk(0)partition(1)\\OS.DIR");
84  wprintf(L"NtPath = '%wZ'\n", &NtPath);
85  ArcPathToNtPath(&NtPath, L"scsi(1)disk(3)rdisk(3)partition(2)\\OS\\ARCOS\\LOADER");
86  wprintf(L"NtPath = '%wZ'\n", &NtPath);
87 
88  _getch();
89 
90  /* All these are OK */
91  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(1)");
92  wprintf(L"NtPath = '%wZ'\n", &NtPath);
93  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(0)");
94  wprintf(L"NtPath = '%wZ'\n", &NtPath);
95  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)cdrom(3)");
96  wprintf(L"NtPath = '%wZ'\n", &NtPath);
97  ArcPathToNtPath(&NtPath, L"ramdisk(0)");
98  wprintf(L"NtPath = '%wZ'\n", &NtPath);
99  ArcPathToNtPath(&NtPath, L"net(0)");
100  wprintf(L"NtPath = '%wZ'\n", &NtPath);
101  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)");
102  wprintf(L"NtPath = '%wZ'\n", &NtPath);
103  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(0)");
104  wprintf(L"NtPath = '%wZ'\n", &NtPath);
105  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(3)");
106  wprintf(L"NtPath = '%wZ'\n", &NtPath);
107  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(1)partition(1)");
108  wprintf(L"NtPath = '%wZ'\n", &NtPath);
109  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)rdisk(0)partition(3)");
110  wprintf(L"NtPath = '%wZ'\n", &NtPath);
111  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)partition(0)");
112  wprintf(L"NtPath = '%wZ'\n", &NtPath);
113  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(0)partition(0)");
114  wprintf(L"NtPath = '%wZ'\n", &NtPath);
115  ArcPathToNtPath(&NtPath, L"multi(0)disk(0)fdisk(1)");
116  wprintf(L"NtPath = '%wZ'\n", &NtPath);
117  ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)");
118  wprintf(L"NtPath = '%wZ'\n", &NtPath);
119  ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(1)partition(0)");
120  wprintf(L"NtPath = '%wZ'\n", &NtPath);
121  ArcPathToNtPath(&NtPath, L"eisa(0)disk(0)fdisk(0)partition(0)");
122  wprintf(L"NtPath = '%wZ'\n", &NtPath);
123 
124  /* These are invalid storage ARC paths (but otherwise are valid ARC names) */
125  ArcPathToNtPath(&NtPath, L"multi(0)video(0)monitor(0)");
126  wprintf(L"NtPath = '%wZ'\n", &NtPath);
127  ArcPathToNtPath(&NtPath, L"multi(0)key(0)keyboard(0)");
128  wprintf(L"NtPath = '%wZ'\n", &NtPath);
129 
130  _getch();
131  return 0;
132 }
USHORT MaximumLength
Definition: env_spec_w32.h:370
BOOLEAN ArcPathToNtPath(OUT PUNICODE_STRING NtPath, IN PCWSTR ArcPath, IN PPARTLIST PartList OPTIONAL)
Definition: arcname.c:819
#define wprintf(...)
Definition: whoami.c:18
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
int _getch()
Definition: getch.c:16
BOOLEAN ArcPathNormalize(OUT PUNICODE_STRING NormalizedArcPath, IN PCWSTR ArcPath)
Definition: arcname.c:312