A
A
armadillo-cld2020-09-25 18:25:37
visual studio
armadillo-cld, 2020-09-25 18:25:37

How to fix Kernel Mode Driver compilation error?

I do everything according to this tutorial:
https://docs.microsoft.com/en-us/windows-hardware/...

The code

#include <ntddk.h>
#include <wdf.h>
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_DEVICE_ADD KmdfHelloWorldEvtDeviceAdd;

NTSTATUS
DriverEntry(
    _In_ PDRIVER_OBJECT     DriverObject,
    _In_ PUNICODE_STRING    RegistryPath
)
{
    // NTSTATUS variable to record success or failure
    NTSTATUS status = STATUS_SUCCESS;

    // Allocate the driver configuration object
    WDF_DRIVER_CONFIG config;

    // Print "Hello World" for DriverEntry
    KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: DriverEntry\n"));

    // Initialize the driver configuration object to register the
    // entry point for the EvtDeviceAdd callback, KmdfHelloWorldEvtDeviceAdd
    WDF_DRIVER_CONFIG_INIT(&config,
        KmdfHelloWorldEvtDeviceAdd
    );

    // Finally, create the driver object
    status = WdfDriverCreate(DriverObject,
        RegistryPath,
        WDF_NO_OBJECT_ATTRIBUTES,
        &config,
        WDF_NO_HANDLE
    );
    return status;
}

NTSTATUS
KmdfHelloWorldEvtDeviceAdd(
    _In_    WDFDRIVER       Driver,
    _Inout_ PWDFDEVICE_INIT DeviceInit
)
{
    // We're not using the driver object,
    // so we need to mark it as unreferenced
    UNREFERENCED_PARAMETER(Driver);

    NTSTATUS status;

    // Allocate the device object
    WDFDEVICE hDevice;

    // Print "Hello World"
    KdPrintEx((DPFLTR_IHVDRIVER_ID, DPFLTR_INFO_LEVEL, "KmdfHelloWorld: KmdfHelloWorldEvtDeviceAdd\n"));

    // Create the device object
    status = WdfDeviceCreate(&DeviceInit,
        WDF_NO_OBJECT_ATTRIBUTES,
        &hDevice
    );
    return status;
}



I click on "KMDF1 solution (projects 1 of 1)" with the right mouse button, "Properties", "Configuration" and click "Platform" on x64, "Configuration" - "Debug".
I also select next to the "Debugging tools" button in the main window "Debug" and "x64", press "CTRL + B" and it displays this:

PS: I tried with Debug and with Release
1>------ Сборка начата: проект: KMDF1, Конфигурация: Release x64 ------
1>Building 'KMDF1' with toolset 'WindowsKernelModeDriver10.0' and the 'Universal' target platform.
1>C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppBuild.targets(458,5): error MSB8040: для этого проекта требуются библиотеки с устранением рисков Spectre. Установите их с помощью установщика Visual Studio (вкладка "Отдельные компоненты") для всех используемых архитектур и наборов инструментов. Дополнительные сведения см. на странице https://aka.ms/Ofhn4c
1>Сборка проекта "KMDF1.vcxproj" завершена с ошибкой.
========== Сборка: успешно: 0, с ошибками: 1, без изменений: 0, пропущено: 0 ==========


I don’t know what the problem is anymore, I even had to reinstall Windows, it’s still the same thing. Why do I do it like everyone else, everyone compiles, but I don’t?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
armadillo-cld, 2020-09-25
@armadillo-cld

https://docs.microsoft.com/en-us/cpp/build/referen...
Just remove from "Project Properties" -> "C/C++" -> "Code Generation" -> "Spectre Mitigation" -> Disabled

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question