Created
May 19, 2024 11:56
-
-
Save rbmm/0054ece76b2ad94edc120b7b066b1f98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void PrintDevType(HANDLE hFile) | |
{ | |
IO_STATUS_BLOCK iosb; | |
FILE_FS_DEVICE_INFORMATION ffdi; | |
if (0 <= NtQueryVolumeInformationFile(hFile, &iosb, &ffdi, sizeof(ffdi), FileFsDeviceInformation)) | |
{ | |
DbgPrint("%x %x\n", ffdi.DeviceType, GetFileType(hFile)); | |
} | |
} | |
void PrintDevType(PCWSTR pszFile) | |
{ | |
HANDLE hFile; | |
IO_STATUS_BLOCK iosb; | |
UNICODE_STRING ObjectName; | |
OBJECT_ATTRIBUTES oa = { sizeof(oa), 0, &ObjectName, OBJ_CASE_INSENSITIVE }; | |
RtlInitUnicodeString(&ObjectName, pszFile); | |
if (0 <= NtOpenFile(&hFile, FILE_READ_ATTRIBUTES, &oa, &iosb, 0, 0)) | |
{ | |
PrintDevType(hFile); | |
NtClose(hFile); | |
} | |
} | |
PrintDevType(L"\\Device\\Null"); | |
PrintDevType(GetStdHandle(STD_OUTPUT_HANDLE)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment