34#define COMPILE_AS_ROSTEST
36#ifndef COMPILE_AS_ROSTEST
54#ifndef COMPILE_AS_ROSTEST
70 HANDLE ContainingDirectory;
83#ifdef COMPILE_AS_ROSTEST
84 ok(bOK,
"%s.\n", pszErr);
87 printf(
"\a** %s.\n", pszErr);
93#ifndef COMPILE_AS_ROSTEST
98 wszTmp[pucs->
Length/2] = 0;
99 printf(
"%-12s: \"%S\"\n", pszDesc, wszTmp);
117 check_result(bOK,
"RtlDosPathNameToNtPathName_U failed");
119 printf(
"input: \"%S\"\n", pwsz);
123#if !defined(COMPILE_AS_ROSTEST) && defined(PRINT_INFO)
124 printf(
"--------------------------\n");
125 printf(
"in : \"%S\"\n", pwsz);
126 prucs(
"NtName", &NtName);
127 printf(
"PartName : \"%S\"\n", PartName ? PartName :
L"(null)");
132 bOK = NtName.
Length >= 8 &&
134 check_result(bOK,
"NtName does not start with \"\\??\\\"");
141 const size_t lenExp =
wcslen(pwszExpected);
142 const size_t lenAct = (NtName.
Length - 8) / 2;
143 bOK = (lenExp == lenAct) &&
144 memcmp(pwszActual, pwszExpected, lenExp * 2) == 0;
148 printf(
"input: : %2Iu chars \"%S\"\n",
wcslen(pwsz), pwsz);
149 printf(
"Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpected);
150 printf(
"Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? pwszActual :
L"(null)");
157 const size_t lenAct = (NtName.
Length - 8) / 2;
159 printf(
"input: : %2Iu chars \"%S\"\n",
wcslen(pwsz), pwsz);
160 printf(
"Actual : %2Iu chars \"%S\"\n", lenAct, pwszActual);
163 if (pwszExpectedPartName) {
164 const size_t lenExp =
wcslen(pwszExpectedPartName);
165 const size_t lenAct = PartName ?
wcslen(PartName) : 0;
166 bOK = (lenExp == lenAct) &&
167 wcscmp(PartName, pwszExpectedPartName) == 0;
170 printf(
"input: : %2Iu chars \"%S\"\n",
wcslen(pwsz), pwsz);
171 printf(
"Expected: %2Iu chars \"%S\"\n", lenExp, pwszExpectedPartName);
172 printf(
"Actual : %2Iu chars \"%S\"\n", lenAct, lenAct ? PartName :
L"(null)");
179 printf(
"input: : %2Iu chars \"%S\"\n",
wcslen(pwsz), pwsz);
180 printf(
"Actual : %2Iu chars %S\n",
wcslen(PartName), PartName);
185static void test(
const char* psz,
const char* pszExpected,
const char* pszExpectedPartName)
197 if (pszExpectedPartName) {
198 swprintf(wszTmp3,
L"%S", pszExpectedPartName);
201 test2(wszTmp1, p2, p3);
229 p->pszNextLastCDComponent = 0;
231 p->pszPDPlusSlash = 0;
235 bOK =
strlen(
p->szCD) >= 2 &&
p->szCD[1] ==
':';
236 check_result(bOK,
"Expected curdir to be a drive letter. It's not");
239 printf(
"Curdir is \"%s\"\n",
p->szCD);
243 bOK =
p->szCD[2] ==
'\\';
244 check_result(bOK,
"CD is missing a slash as its third character");
246 printf(
"CD is \"%s\"\n",
p->szCD);
255 strcat(
p->szCDPlusSlash,
"\\");
259 p->szCurDrive[2] = 0;
260 sprintf(
p->szCurDriveSlash,
"%s\\",
p->szCurDrive);
262 p->pszLastCDComponent =
strrchr(
p->szCD,
'\\');
263 if (
p->pszLastCDComponent)
266 memcpy(
p->szParentDir,
p->szCD,
p->pszLastCDComponent -
p->szCD);
267 p->szParentDir[
p->pszLastCDComponent -
p->szCD] = 0;
268 p->pszPD =
p->szParentDir;
269 if (
strlen(
p->szParentDir) == 2 &&
p->szParentDir[1] ==
':') {
274 strcpy(
p->szParentDirPlusSlash,
p->szParentDir);
275 if (
p->szParentDirPlusSlash[
strlen(
p->szParentDirPlusSlash)-1] !=
'\\') {
276 strcat(
p->szParentDirPlusSlash,
"\\");
278 p->pszPDPlusSlash =
p->szParentDirPlusSlash;
281 *
p->pszLastCDComponent = 0;
282 p->pszNextLastCDComponent =
strrchr(
p->szCD,
'\\');
283 *
p->pszLastCDComponent =
'\\';
284 if (
p->pszNextLastCDComponent) {
285 ++
p->pszNextLastCDComponent;
286 if (
p->pszNextLastCDComponent + 1 >=
p->pszLastCDComponent) {
287 p->pszNextLastCDComponent = 0;
289 const size_t siz =
p->pszLastCDComponent -
p->pszNextLastCDComponent;
290 memcpy(
p->szNextLastCDComponent,
p->pszNextLastCDComponent, siz);
291 p->szNextLastCDComponent[siz] = 0;
292 p->pszNextLastCDComponent =
p->szNextLastCDComponent;
296 if (
p->pszLastCDComponent &&
p->pszLastCDComponent[1] == 0) {
299 p->pszLastCDComponent = 0;
301 ++
p->pszLastCDComponent;
306#ifndef COMPILE_AS_ROSTEST
307static void InitFunctionPointer()
311 printf(
"Major failure. Couldn't even load ntdll!\n");
315 (RtlDosPathNameToNtPathName_U_t)
GetProcAddress(hDll,
"RtlDosPathNameToNtPathName_U");
317 printf(
"Major failure. Couldn't get RtlDosPathNameToNtPathName_U!\n");
322# if defined(PRINT_INFO)
323static DWORD get_win_ver()
325# ifdef COMPILE_AS_ROSTEST
337#ifdef COMPILE_AS_ROSTEST
343#if defined(PRINT_INFO)
344 const DWORD dwWinVer = get_win_ver();
345 const BYTE WinVerMaj = (
BYTE)dwWinVer;
352#ifndef COMPILE_AS_ROSTEST
353 InitFunctionPointer();
358#if defined(PRINT_INFO)
359 printf(
"WinVer: %d.%d\n", WinVerMaj, WinVerMin);
360 printf(
"pszLastCDComponent \"%s\"\n",
cd.pszLastCDComponent);
361 printf(
"pszNextLastCDComponent \"%s\"\n",
cd.pszNextLastCDComponent);
362 printf(
"pszParentDir \"%s\"\n",
cd.pszPD);
363 printf(
"pszParentDirPlusSlash \"%s\"\n",
cd.pszPDPlusSlash);
367#define PREP1 "\\\\.\\"
368#define PREP2 "\\\\?\\"
580 test(
PREP0 "C:" ,
"C:\\"+C_curdir , C_curdir);
607 if (WinVerMaj == 5) {
608 sprintf(szPrepend,
"%s\\??\\",
cd.szCurDrive);
611 sprintf(szExp,
"%s%s", szPrepend,
"C:");
612 test(
"\\??\\C:", szExp,
"C:");
614 sprintf(szExp,
"%s%s", szPrepend,
"C:\\");
620#ifndef COMPILE_AS_ROSTEST
static void InitDirComponents(DirComponents *p)
static void check_result(BOOLEAN bOK, const char *pszErr)
char * strcat(char *DstString, const char *SrcString)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
#define GetProcAddress(x, y)
UNICODE_STRING * PUNICODE_STRING
struct _UNICODE_STRING UNICODE_STRING
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define memcpy(s1, s2, n)
#define sprintf(buf, format,...)
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
struct _RTLP_CURDIR_REF * PRTLP_CURDIR_REF
struct _RTL_RELATIVE_NAME_U RTL_RELATIVE_NAME_U
struct _RTLP_CURDIR_REF RTLP_CURDIR_REF
struct _RTL_RELATIVE_NAME_U * PRTL_RELATIVE_NAME_U
_In_ ULONG _In_ ULONG _In_ ULONG Length
DWORD WINAPI GetVersion()
_Check_return_ _CRTIMP int __cdecl wcscmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_CRT_RESTORE_GCC_WARNINGS _CRT_DISABLE_GCC_WARNINGS _Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
char szNextLastCDComponent[260]
char * pszLastCDComponent
char szParentDirPlusSlash[512]
const char * pszPDPlusSlash
const char * pszNextLastCDComponent
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
#define GetCurrentDirectory