windowswinapicrashcreatefilebsod

Why does this CreateFile() call cause a BSOD on Windows 8?


If I try to run this:

#include <Windows.h>

int main()
{
    CreateFile(
        TEXT("X:\\$MFT\\Folder"),
        FILE_READ_ATTRIBUTES,
        FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
        NULL,
        OPEN_EXISTING,
        0,
        NULL);
    return 0;
}

the system deadlocks (and on Windows 8, subsequently BSODs) on any further attempt to access X:.
(Update: X: was just a placeholder; you can replace it with any valid drive.)

It took me a while to track it down, and now I have -- but I'm baffled: what is the cause?


Solution

  • This is an NTFS bug.

    Since it is now finally publicly known, I'm undeleting this question and posting this as an answer.