xxxxx@amplisine.com wrote:
> How much coding have you done, prior to diving in to kernel code?
I’m a CpE grad student if that tells you anything.
Actually, it doesn’t. That acronym is grossly overloaded. But, it’s
not relevant.
Ok, with my files set back to *.cpp intellisense is complaining windot11.h. Specifically it says “extra text after expected end of number” anywhere there is a DEFINE_NWF_GUID. However, the main issue another LNK2019 (i.e. Code: LNK2019 Description: unresolved external symbol DriverEntry referenced in function FxDriverEntryWorker File: WdfDriverEntry.lib (stub.obj) Line:1 ).
To that end, DriverEntry looks like this:
///////driver.h///////
DRIVER_INITIALIZE DriverEntry;
//////driver.c////////
Use_decl_annotations
NTSTATUS
DriverEntry(
PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath
)
{
…
}
I’ve never done a mixed c and cpp environment. Please tell me more about the extern “C” calls I need to make. Thanks again for all the help.
C++ compilers have to add type information to all of the names they
create, partly to add some link-time type checking, partly to handle
overloads. In a C program, your declaration above would have created
the external name _DriverEntry, and that is exactly what the KMDF
framework is trying to link to. However, the name your C++ compiler
created for the linker is actually:
?DriverEntry@@YAJPEAU_DRIVER_OBJECT@@PEAU_UNICODE_STRING@@@Z
So, the name _DriverEntry is undefined, and the linker complains.
The typical driver doesn’t have any externally linked names, so this
hasn’t historically been a problem. With KMDF, however, things have
changed. DriverEntry gets referenced externally, PLUS all of the
callback names have typedefs that assume C linkage. You do that this way:
extern “C” {
DRIVER_INITIALIZE DriverEntry;
EVT_WDF_DRIVER_UNLOAD My_EvtDriverUnload;
EVT_WDF_DRIVER_DEVICE_ADD My_EvtDeviceAdd;
EVT_WDF_OBJECT_CONTEXT_CLEANUP My_EvtDeviceCleanup;
}
Or, if you find this more appealing:
extern “C” DRIVER_INITIALIZE DriverEntry;
extern “C” EVT_WDF_DRIVER_UNLOAD My_EvtDriverUnload;
extern “C” EVT_WDF_DRIVER_DEVICE_ADD My_EvtDeviceAdd;
extern “C” EVT_WDF_OBJECT_CONTEXT_CLEANUP My_EvtDeviceCleanup;
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.