| User-mode Driver Framework |
Website Links For Driver |
Information AboutUser-mode Driver Framework |
| CATEGORIES ABOUT USER-MODE DRIVER FRAMEWORK | |
| device drivers | |
| microsoft apis | |
|
Badly written drivers can cause severe damage to a system since all drivers have high privileges when accessing the kernel directly. The new User-Mode Drivers in Windows Vista are not able to access the kernel directly but instead accesses it through a dedicated API. If an error occurs the new framework allows for an immediate restart of the driver without impacting the system. Typically, devices are connected to the computer through a bus technology such as USB or Firewire . COM-STYLE ARCHITECTURE A UMDF Driver is a COM based DLL, but UMDF doesn't use the COM runtime library, using COM only as a programming pattern. UMDF does not use COM for loading, unloading, or controlling concurrency (that is, apartment-based concurrency mechanism). UMDF calls ''DllGetClassObject'' to get a pointer to an IClassFactory interface in the driver and then uses the CreateInstance method of the IClassFactory interface to create an instance of the driver object. The DLL provides routines that COM uses to get the IWDFDriver-based object:
DllMain UMDF driver is a Dynamic Link Library (DLL) that runs as an in-process COM server and contains the code for DllMain, which is a well-known entry point for a DLL. BOOL WINAPI DllMain( HINSTANCE ModuleHandle, DWORD Reason,
{ if (DLL_PROCESS_ATTACH == Reason) { WPP_INIT_TRACING(MYDRIVER_TRACING_ID); g_ModuleHandle = ModuleHandle; } else if (DLL_PROCESS_DETACH == Reason) { WPP_CLEANUP(); } return TRUE; }; UMDF supports IXX abstract classes with which any KMDF developer as following:
IUnknown interface COM interfaces are C++ Abstract Base Class es. These UDMF objects provide signatures for the routines (callback functions) they support in the form of abstract classes (interfaces), that are pure virtual functions. Any UDMF driver which support an interface must implement all the functions in that callback interface. And all COM objects support the interface IUnknown . IUnknown interface supports three methods: interface IUnknown { virtual ULONG AddRef(void) = 0;
virtual ULONG Release(void) = 0; }; IDriverEntry interface UMDF driver must support IDriverEntry interface, and need to implement '''OnAddDevice''' callbacks. class CMyDriver : public IDriverEntry, public CUnknown { virtual ULONG STDMETHODCALLTYPE AddRef(VOID){ return __super::AddRef(); } virtual ULONG STDMETHODCALLTYPE Release(VOID){ return __super::Release(); }
return __super::Release(InterfaceId, Object); }
... }
return; } ... }; IDevicePnpHardware interface Create CMyDevice class that inherits from IIDevicePnpHardware and CUnknown class. class CMyDevice : public CUnknown, public IDevicePnpHardware { private:
public:
{ return S_OK; }
{ return S_OK; } ... }; REFERENCES
SEE ALSO EXTERNAL LINKS
|
|
|