Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdio.h>
- void scream_and_die(const char* complaint, ...)
- {
- va_list args = NULL;
- char format[80];
- snprintf(format, sizeof(format), "%s: %%s (0x%x)\n",
- complaint, GetLastError());
- LPTSTR syserr = 0;
- FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_ALLOCATE_BUFFER, 0, GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&syserr, 0, 0);
- fprintf(stderr, format, syserr);
- exit(1);
- }
- int main()
- {
- const char* path = "P:\\";
- HANDLE handle = CreateFile (path, GENERIC_READ, 0, 0,
- OPEN_EXISTING,
- FILE_ATTRIBUTE_NORMAL | FILE_FLAG_BACKUP_SEMANTICS |
- FILE_FLAG_OPEN_REPARSE_POINT,
- 0);
- if (handle == INVALID_HANDLE_VALUE) {
- scream_and_die("Bad handle");
- }
- else {
- BY_HANDLE_FILE_INFORMATION fi;
- if (GetFileInformationByHandle(handle, &fi) &&
- (fi.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)) {
- char buf[32000];
- DWORD len;
- if (!DeviceIoControl(handle,
- FSCTL_GET_REPARSE_POINT, NULL, 0,
- buf, 32000, &len, NULL)) {
- scream_and_die("Failed to get reparse point");
- }
- else {
- printf("No error\n");
- }
- }
- else {
- printf("Reparse flag not set\n");
- }
- return 0;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement