0

这就是我为创建文件所做的(在 C:\example.txt 中):

RtlInitUnicodeString(&uniName, L"\\DosDevices\\C:\\example.txt"); //L"\\SystemRoot\\drvhinf.txt");  // or L"\\SystemRoot\\example.txt" \\DosDevices\\C:\\WINDOWS\\example.txt
    InitializeObjectAttributes(&objAttr, &uniName,
        OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE,
        NULL, NULL);
    //////////////////////////////////

    ///////////////////////////////////
    //Load the buffer (ie. contents of text file to the console)
    ntstatus = ZwCreateFile(&handle,
        GENERIC_WRITE, //GENERIC_READ
        &objAttr, &ioStatusBlock,
        NULL,
        FILE_ATTRIBUTE_NORMAL,
        0,
        FILE_OPEN,
        FILE_SYNCHRONOUS_IO_NONALERT,
        NULL, 0);

但启动驱动程序后,我在 C 盘上找不到 example.txt。我在 Windows 7 上,我不知道是否应该使用其他文件路径。ZwCreateFile 也取得了成功。我究竟做错了什么?

4

1 回答 1

0

找到解决方案:将 FILE_OPEN 替换为 FILE_SUPERSEDE

于 2018-07-10T16:17:41.223 回答