none
Trivial question: Kernel library vs export dll - Same thing? RRS feed

  • Question

  • I've got a basic understanding question:

    Kernel export drivers (dlls) vs libs vs a 'static library', are they all the same thing in the context of a kernel driver?  It seems that Kernel export drivers are basically kernel dll's.  Is there a similar mapping to a 'static' vs dynamic library?

    Thanks!

    Friday, February 1, 2013 7:10 PM

Answers

  • Basically a kernel export driver is a kernel mode DLL.  Note in one sense all drivers are kernel mode DLL's, it is just that most only export DriverEntry.  Yes a static library is the same for both the kernel and the user space, but these are not the same as a DLL.  A DLL is a standalone shared module that is used by other modules, a static library is a collection of object files that are linked into a module by the linker becoming part of the module.   And of course the API's available for kernel versus user space are almost entirely different.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Friday, February 1, 2013 7:16 PM

All replies

  • Basically a kernel export driver is a kernel mode DLL.  Note in one sense all drivers are kernel mode DLL's, it is just that most only export DriverEntry.  Yes a static library is the same for both the kernel and the user space, but these are not the same as a DLL.  A DLL is a standalone shared module that is used by other modules, a static library is a collection of object files that are linked into a module by the linker becoming part of the module.   And of course the API's available for kernel versus user space are almost entirely different.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Friday, February 1, 2013 7:16 PM
  • Thanks!

    Friday, February 1, 2013 7:38 PM
  • One more question:  I see in VS2012 you can create an empty static library (for drivers), but it looks like it's a user mode library.  Do you know of a way to create a static kernel library?  

    For our driver, a static library is more appropriate than an export dll.

    Thanks again.

    Friday, February 1, 2013 8:08 PM
  • what makes you think it is for user mode? a static lib is a static lib. it is neither km or um because it is just code, but not an executable yet. it becomes an executable when linked with a km driver project.


    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, February 1, 2013 8:27 PM
  • There's nothing that makes me think it's not - it's more of a question than a statement.  I inferred that to ensure we only get kernel functions and not user-mode functions compiled in we need to ensure we set the project up as 'kernel'.  So from your suggestion, if I create a static lib it won't compile in any user mode calls (unless I accidentally add them)?

    Appreciate the education.

    Friday, February 1, 2013 9:51 PM
  • Libraries don't include anything you don't tell them to, they are just a collection of the object modules you specify.


    Don Burn Windows Filesystem and Driver Consulting Website: http://www.windrvr.com Blog: http://msmvps.com/blogs/WinDrvr

    Friday, February 1, 2013 10:19 PM
  • Thanks.  So there's no real concern that the "Platform Toolset" is different for a static lib than for the KMD it links to?  I'm referring to the configuration properties:

    http://msdn.microsoft.com/en-us/library/windows/hardware/hh454232(v=vs.85).aspx

    It looks like it's a no-op concern of mine, but wanted to ask before I was well down the path.

    Thanks.

    Friday, February 1, 2013 10:24 PM
  • what platform toolset are you seeing used in the project? not WindowsKernelModeDriver8.0?

    d -- This posting is provided "AS IS" with no warranties, and confers no rights.

    Friday, February 1, 2013 10:28 PM
  • For the KMD I've got WindowsKernelModeDriver like you pointed out, for the static empty lib that I intend to link to that KMD it is currently WindowsApplicationForDrivers8.0


    Friday, February 1, 2013 10:30 PM
  • Hmm, seems like I'm having a similar question over on NTDEV and a coworker pointed out this thread. It does seem like the compiler options you get when specifying a static kernel library in VS2012 are different than what you get with a driver, so code is not really just code, at the object level. Source code is compiled in a very specific environment of compiler options, and mixing chunks of code compiled with different options will sometimes cause bad things to happen (and sometimes it's harmless). You will also get differences at compile time, for example the VS2012 driver build options define "DEPRECATE_DDK_FUNCTIONS=1" and in the VS2012 static library build option that is not defined.

    Friday, February 1, 2013 11:21 PM