Hi,
At the moment I’m porting a driver from C to C++ (which has been C++ in the old days of Compuware Driver::Works).
Work is done, but the interface to KMDF callbacks still looks clumsy.
At the moment I have a C/C++ mix like …
<c-cpp-mix>
// All Logic in my class
class MyDevice {
...
NTSTATUS EvtDeviceD0Entry(IN WDF_POWER_DEVICE_STATE PreviousState) ;
...
} ;
// The WDF DeviceContext just contains my device
typedef struct {
MyDevice mydevice ; // context wraps class
} MyDevice_CONTEXT;
WDF_DECLARE_CONTEXT_TYPE(MyDevice_CONTEXT);
// The Wdf callbacks are just a wrappers to methods of my device
NTSTATUS MyDevice__EvtDeviceD0Entry( IN WDFDEVICE wdfDevice,
IN WDF_POWER_DEVICE_STATE PreviousState);
{
MyDevice *mydevice = &(WdfObjectGet_MyDevicee_CONTEXT(wdfDevice)->mydevice) ;
return mydevice->EvtDeviceD0Entry(PreviousState) ;
}
</c-cpp-mix>
I was hoping for …
<pure-cpp>
// WDF defines adevice base class "WdfDevice"
class MyDevice: WdfDevice {
...
// mydevice implements the D0Entry callback
virtual NTSTATUS EvtDeviceD0Entry(IN WDF_POWER_DEVICE_STATE PreviousState) ;
...
}
</pure-cpp>
I remember seeing some MicroSoft docs showing C++ code examples, but somehow my Google Bubble is supressing these now.
I’d be happy to have a doc explaining current and future C++ support in KMDF.
thanks and kind regards,
Joerg Hoppe