最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

c - How to iterate through each file on each volume of each disk? - Stack Overflow

matteradmin6PV0评论

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, &ltmp2);

        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.

Post a comment

comment list (0)

  1. No comments so far