- #include <stdio.h>
- #include <string.h>
- #include <wchar.h>
- #include <errno.h>
- #include <locale.h>
- #include <limits.h>
- //#include <windows.h>
- //#include <ntdef.h>
- //#include <w32api/wtypesbase.h>
- //#include <windef.h>
- #include <wdm.h>
- typedef unsigned int DWORD;
- typedef unsigned int HMODULE;
- #define MAX_PATH 260
- #include <sys/cygwin.h>
- 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;
- }
test-qfif1.c
Posted by Anonymous on Fri 17th Nov 2023 09:13
raw | new post
modification of post by Anonymous (view diff)
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.