I write a windows 10 driver.
following is the code, actually the code is a sample of docs.microsoft.com.
is there anyone know what shold i do to deal with this issue.
#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;
}
Help! if you have some suggestion, please let me know.
the error message is:
Driver.obj : error LNK2019: unresolved external symbol __CheckForDebuggerJustMyCode referenced in function DriverEntry
That's because the definition may be in a different source file or library. If a symbol is referred to but never defined, the linker generates an unresolved external symbol error. Here are some common problems that cause LNK2019:
The compiler can identify when a symbol isn't declared, but it can't tell when the symbol isn't defined. That's because the definition may be in a different source file or library. If a symbol is referred to but never defined, the linker generates an unresolved external symbol error. Here are some common problems that cause LNK2019:
Unless i and g are defined in one of the files included in the build, the linker generates LNK2019. You can fix the errors by including the source code file that contains the definitions as part of the compilation. Alternatively, you can pass .obj files or .lib files that contain the definitions to the linker.
Here are some common problems that cause LNK2019: The source file that contains the definition of the symbol isn't compiled In Visual Studio, make sure the source file that defines the symbol gets compiled as part of your project. Check the intermediate build output directory for a matching.obj file.
This is related to the new C++ Just My Code Stepping feature in Visual Studio 2017 15.8.
If you get the error open the Project Properties dialog box and set the "Configuration Properties -> C/C++ -> General -> Support Just My Code Debugging" option to no.
This is related to the new C++ Just My Code Stepping (JMC) feature in Visual Studio 2017 15.8. Because the feature depends on CRT (C Run-Time Libraries), if the project does not link to CRT, it may hit error LNK2019: unresolved external symbol __CheckForDebuggerJustMyCode
.
The workaround is to disable JMC via one of the following methods:
/JMC-
to "Configuration Properties" -> "C/C++" -> "Command line" -> "Additional Options"In Visual Studio 15.8 they introduced JustMyCode debugging, and it actually breaks compilation of a kernel drivers in debug configuration.
It looks like a bug, but the workaround is to compile in release mode for now.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With