Skip to content

Instantly share code, notes, and snippets.

@rbmm
Created May 19, 2024 11:56
Show Gist options
  • Save rbmm/0054ece76b2ad94edc120b7b066b1f98 to your computer and use it in GitHub Desktop.
Save rbmm/0054ece76b2ad94edc120b7b066b1f98 to your computer and use it in GitHub Desktop.
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