In Windows kernel programming, I want to iterate through each disk, then iterate through all volumes on those disks, and finally print out the file paths of all files on each volume. How can I do this?
VOID GetAllDisk2() {
NTSTATUS status;
PZZWSTR deviceNaems = NULL;
UNICODE_STRING str1;
DEVICE_OBJECT deviceObject;
FILE_OBJECT fileObject;
WCHAR wcstr[512];
ULONG index = 0;
ULONG ltmp1, ltmp2;
MM_COPY_ADDRESS mmAddress;
status = IoGetDeviceInterfaces(&DiskClassGuid, NULL, 0, &deviceNaems);
if (!NT_SUCCESS(status))
return;
str1.Buffer = wcstr;
str1.MaximumLength = sizeof(wcstr);
while (deviceNaems[index] != 0) {
ltmp1 = wcslen(deviceNaems + index);
str1.Length = sizeof(WCHAR) * ltmp1;
mmAddress.VirtualAddress = deviceNaems + index;
MmCopyMemory(wcstr, mmAddress, str1.Length, MM_COPY_MEMORY_VIRTUAL, <mp2);
status = IoGetDeviceObjectPointer(&str1, GENERIC_READ, &fileObject, &deviceObject);
if (NT_SUCCESS(status)) {
// TODO ============
}
index += ltmp1 + 1;
}
KdPrint(("End insert."));
}
I tried using IorDeviceInterfaces () to obtain all DeviceNames, and then obtained the DeviceObject and FileObject for.