Click here to Skip to main content
12,249,234 members (36,767 online)
Click here to Skip to main content

Stats

157.6K views
6.5K downloads
87 bookmarked
Posted

An UMDF Driver for a Virtual Smart Card Reader

, 30 Jan 2014 CPOL
A simple implementation of a driver for a virtual smart card reader, based on UMDF
exports.def
Win7_x64
WinXP_x86
Win7_x86
Win7
WinXP
BixVReader.inx
makefile
sources
BixVReader.inx
makefile
sources
BixVReader.dll
BixVReader.inf
BixVReader.dll
BixVReader.inf
BixVReader.dll
BixVReader.inf
#pragma once

#include <vector>
#include "reader.h"

//
// Class for the iotrace driver.
//
class CMyDevice;


class ATL_NO_VTABLE CMyDevice :
    public CComObjectRootEx<CComMultiThreadModel>,
    public IPnpCallbackHardware,
	public IPnpCallback,
	public IRequestCallbackCancel
{
public:
	~CMyDevice() {
        DeleteCriticalSection(&m_RequestLock);
	}

    DECLARE_NOT_AGGREGATABLE(CMyDevice)

    BEGIN_COM_MAP(CMyDevice)
        COM_INTERFACE_ENTRY(IPnpCallbackHardware)
        COM_INTERFACE_ENTRY(IPnpCallback)
		COM_INTERFACE_ENTRY(IRequestCallbackCancel)
    END_COM_MAP()

    CMyDevice(VOID)
    {
        InitializeCriticalSection(&m_RequestLock);
        m_pWdfDevice = NULL;
    }

	//
// Private data members.
//
private:

    CComPtr<IWDFDevice>     m_pWdfDevice;
	std::vector<Reader*> readers;
	int numInstances;

//
// Private methods.
//

private:


	HRESULT ConfigureQueue();

	//
// Public methods
//
public:

    CRITICAL_SECTION        m_RequestLock;

    //
    // The factory method used to create an instance of this driver.
    //
    
    static
    HRESULT CreateInstance(
        __in IWDFDriver *FxDriver,
        __in IWDFDeviceInitialize *FxDeviceInit
        );

//
// COM methods
//
public:

    //
    // IUnknown methods.
    //

	void  ProcessIoControl(__in IWDFIoQueue*     pQueue,
                                    __in IWDFIoRequest*   pRequest,
                                    __in ULONG            ControlCode,
                                         SIZE_T           InputBufferSizeInBytes,
                                         SIZE_T           OutputBufferSizeInBytes);

    STDMETHOD_ (HRESULT, OnPrepareHardware)(__in IWDFDevice* pWdfDevice);
    STDMETHOD_ (HRESULT, OnReleaseHardware)(__in IWDFDevice* pWdfDevice);
    STDMETHOD_ (HRESULT, OnD0Entry)(IN IWDFDevice*  pWdfDevice,IN WDF_POWER_DEVICE_STATE  previousState);
    STDMETHOD_ (HRESULT, OnD0Exit )(IN IWDFDevice*  pWdfDevice,IN WDF_POWER_DEVICE_STATE  newState);
    STDMETHOD_ (HRESULT, OnQueryRemove )(IN IWDFDevice*  pWdfDevice);
    STDMETHOD_ (HRESULT, OnQueryStop)(IN IWDFDevice*  pWdfDevice);
    STDMETHOD_ (void, OnSurpriseRemoval)(IN IWDFDevice*  pWdfDevice);
    STDMETHOD_ (void, OnCancel)(IN IWDFIoRequest*  pWdfRequest);

	void shutDown();
};

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Fabio Ottavi
Engineer
Italy Italy
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160426.1 | Last Updated 30 Jan 2014
Article Copyright 2010 by Fabio Ottavi
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid