#include #include #include #include #include #include #include #include int main (int argc, char **argv) { WCHAR pathbuf[1024]; /* Should be big enough for this test */ WCHAR *path; UNICODE_STRING upath; OBJECT_ATTRIBUTES attr, attr2; NTSTATUS status; HANDLE h; IO_STATUS_BLOCK io; FILE_NETWORK_OPEN_INFORMATION fnoi; if (argc < 2) { fprintf (stderr, "Usage: %s path\n", argv[0]); return 1; } setlocale (LC_ALL, ""); while (--argc > 0) { if (cygwin_conv_path (CCP_POSIX_TO_WIN_W, *++argv, pathbuf + 6, 1024 * sizeof (WCHAR))) { fprintf (stderr, "%s: Path conversion failed: %s\n", strerror (errno)); continue; } if (pathbuf[6] == L'\\' && pathbuf[7] == L'\\') path = wcsncpy (pathbuf, L"\\??\\UNC", 7); else path = wcsncpy (pathbuf + 2, L"\\??\\", 4); RtlInitUnicodeString (&upath, path); InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, NULL, NULL); status = NtQueryFullAttributesFile (&attr, &fnoi); if (!NT_SUCCESS (status)) printf ("NtQueryFullAttributesFile(%ls) by name failed,\n" "status code 0x%08lx\n", path, status); else printf ("NtQueryFullAttributesFile(%ls) by name works\n", path); status = NtOpenFile (&h, READ_CONTROL | FILE_READ_ATTRIBUTES, &attr, &io, FILE_SHARE_VALID_FLAGS, 0); if (!NT_SUCCESS (status)) { fprintf (stderr, "NtOpenFile(%ls) failed, status code 0x%08lx\n", path, status); continue; } RtlInitUnicodeString (&upath, L""); InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, h, NULL); status = NtQueryFullAttributesFile (&attr, &fnoi); if (!NT_SUCCESS (status)) printf ("NtQueryFullAttributesFile(%ls) by handle failed,\n" "status code 0x%08lx\n", path, status); else printf ("NtQueryFullAttributesFile(%ls) by handle works\n", path); NtClose (h); } return 0; }