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);
189static void test(
const char* psz,
const char* pszExpected,
const char* pszExpectedPartName)
201 if (pszExpectedPartName) {
202 _swprintf(wszTmp3,
L"%S", pszExpectedPartName);
205 test2(wszTmp1, p2, p3);
233 p->pszNextLastCDComponent = 0;
235 p->pszPDPlusSlash = 0;
239 bOK =
strlen(
p->szCD) >= 2 &&
p->szCD[1] ==
':';
240 check_result(bOK,
"Expected curdir to be a drive letter. It's not");
243 printf(
"Curdir is \"%s\"\n",
p->szCD);
247 bOK =
p->szCD[2] ==
'\\';
248 check_result(bOK,
"CD is missing a slash as its third character");
250 printf(
"CD is \"%s\"\n",
p->szCD);
259 strcat(
p->szCDPlusSlash,
"\\");
263 p->szCurDrive[2] = 0;
264 sprintf(
p->szCurDriveSlash,
"%s\\",
p->szCurDrive);
266 p->pszLastCDComponent =
strrchr(
p->szCD,
'\\');
267 if (
p->pszLastCDComponent)
270 memcpy(
p->szParentDir,
p->szCD,
p->pszLastCDComponent -
p->szCD);
271 p->szParentDir[
p->pszLastCDComponent -
p->szCD] = 0;
272 p->pszPD =
p->szParentDir;
273 if (
strlen(
p->szParentDir) == 2 &&
p->szParentDir[1] ==
':') {
278 strcpy(
p->szParentDirPlusSlash,
p->szParentDir);
279 if (
p->szParentDirPlusSlash[
strlen(
p->szParentDirPlusSlash)-1] !=
'\\') {
280 strcat(
p->szParentDirPlusSlash,
"\\");
282 p->pszPDPlusSlash =
p->szParentDirPlusSlash;
285 *
p->pszLastCDComponent = 0;
286 p->pszNextLastCDComponent =
strrchr(
p->szCD,
'\\');
287 *
p->pszLastCDComponent =
'\\';
288 if (
p->pszNextLastCDComponent) {
289 ++
p->pszNextLastCDComponent;
290 if (
p->pszNextLastCDComponent + 1 >=
p->pszLastCDComponent) {
291 p->pszNextLastCDComponent = 0;
293 const size_t siz =
p->pszLastCDComponent -
p->pszNextLastCDComponent;
294 memcpy(
p->szNextLastCDComponent,
p->pszNextLastCDComponent, siz);
295 p->szNextLastCDComponent[siz] = 0;
296 p->pszNextLastCDComponent =
p->szNextLastCDComponent;
300 if (
p->pszLastCDComponent &&
p->pszLastCDComponent[1] == 0) {
303 p->pszLastCDComponent = 0;
305 ++
p->pszLastCDComponent;
310#ifndef COMPILE_AS_ROSTEST
311static void InitFunctionPointer()
315 printf(
"Major failure. Couldn't even load ntdll!\n");
319 (RtlDosPathNameToNtPathName_U_t)
GetProcAddress(hDll,
"RtlDosPathNameToNtPathName_U");
321 printf(
"Major failure. Couldn't get RtlDosPathNameToNtPathName_U!\n");
326# if defined(PRINT_INFO)
327static DWORD get_win_ver()
329# ifdef COMPILE_AS_ROSTEST
341#ifdef COMPILE_AS_ROSTEST
347#if defined(PRINT_INFO)
348 const DWORD dwWinVer = get_win_ver();
349 const BYTE WinVerMaj = (
BYTE)dwWinVer;
356#ifndef COMPILE_AS_ROSTEST
357 InitFunctionPointer();
362#if defined(PRINT_INFO)
363 printf(
"WinVer: %d.%d\n", WinVerMaj, WinVerMin);
364 printf(
"pszLastCDComponent \"%s\"\n",
cd.pszLastCDComponent);
365 printf(
"pszNextLastCDComponent \"%s\"\n",
cd.pszNextLastCDComponent);
366 printf(
"pszParentDir \"%s\"\n",
cd.pszPD);
367 printf(
"pszParentDirPlusSlash \"%s\"\n",
cd.pszPDPlusSlash);
371#define PREP1 "\\\\.\\"
372#define PREP2 "\\\\?\\"
584 test(
PREP0 "C:" ,
"C:\\"+C_curdir , C_curdir);
611 if (WinVerMaj == 5) {
612 sprintf(szPrepend,
"%s\\??\\",
cd.szCurDrive);
615 sprintf(szExp,
"%s%s", szPrepend,
"C:");
616 test(
"\\??\\C:", szExp,
"C:");
618 sprintf(szExp,
"%s%s", szPrepend,
"C:\\");
624#ifndef COMPILE_AS_ROSTEST
static void InitDirComponents(DirComponents *p)
static void check_result(BOOLEAN bOK, const char *pszErr)
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
#define GetProcAddress(x, y)
DWORD WINAPI GetVersion(void)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
_ACRTIMP size_t __cdecl strlen(const char *)
_ACRTIMP char *__cdecl strrchr(const char *, int)
UNICODE_STRING * PUNICODE_STRING
struct _UNICODE_STRING UNICODE_STRING
#define memcpy(s1, s2, n)
#define _swprintf(buf, format,...)
VOID NTAPI RtlReleaseRelativeName(_In_ PRTL_RELATIVE_NAME_U RelativeName)
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
char szNextLastCDComponent[260]
char * pszLastCDComponent
char szParentDirPlusSlash[512]
const char * pszPDPlusSlash
const char * pszNextLastCDComponent
_In_ WDFDMATRANSACTION _In_ size_t MaximumLength
#define GetCurrentDirectory