I am trying to write a library that’ll link to a driver, both using kmdf.
When I build the library as a static library and statically link it to the driver, it works fine.
However, when I build & link it as a dll (EXPORT_DRIVER), I get a bugcheck as soon as the dll calls any kmdf function.
Bug check is SYSTEM_THREAD_EXCEPTION_NOT_HANDLED, for exception c0000005.
Stack trace shows that the driver calls the dll, which in turn calls WdfObjectCreate, and then 0x0.
Faulting source code is:
WDFOBJECT* Object
561: )
562: {
563: return ((PFN_WDFOBJECTCREATE) WdfFunctions[WdfObjectCreateTableIndex])(WdfDriverGlobals, Attributes, Object);
564: }
WdfObjectCreate, according to the stack trace, is implemented at the dll image. I suppose that WdfFunctions is a vector in my dll that should be somehow initialized, but how?