Migrated to new Version of Flavio's Windows driver

This commit is contained in:
Frank Morgner
2014-03-24 08:23:53 +01:00
parent e15307d662
commit bef01d2a31
37 changed files with 4388 additions and 3445 deletions

View File

@@ -0,0 +1,84 @@
[Driver]
NumReaders=12
[Reader0]
RPC_TYPE=0
VENDOR_NAME=VirtualCard
VENDOR_IFD_TYPE=BixReader
DECIVE_UNIT=0
[Reader1]
RPC_TYPE=1
VENDOR_NAME=VirtualCard
VENDOR_IFD_TYPE=BixReader
DECIVE_UNIT=1
[Reader2]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35963
DECIVE_UNIT=2
[Reader3]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35964
DECIVE_UNIT=3
[Reader4]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35965
DECIVE_UNIT=4
[Reader5]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35966
DECIVE_UNIT=5
[Reader6]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35967
DECIVE_UNIT=6
[Reader7]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35968
DECIVE_UNIT=7
[Reader8]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35969
DECIVE_UNIT=8
[Reader9]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35970
DECIVE_UNIT=9
[Reader10]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35971
DECIVE_UNIT=10
[Reader11]
RPC_TYPE=2
VENDOR_NAME=Virtual Smart Card Architecture
VENDOR_IFD_TYPE=Virtual PCD
TCP_PORT=35972
DECIVE_UNIT=11

View File

@@ -1,100 +1,100 @@
// Microsoft Visual C++ generated resource script. // Microsoft Visual C++ generated resource script.
// //
#include "resource.h" #include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS #define APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 2 resource. // Generated from the TEXTINCLUDE 2 resource.
// //
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS #undef APSTUDIO_READONLY_SYMBOLS
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// Italian (Italy) resources // Italian (Italy) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA) #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ITA)
#ifdef _WIN32 #ifdef _WIN32
LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN LANGUAGE LANG_ITALIAN, SUBLANG_ITALIAN
#pragma code_page(1252) #pragma code_page(1252)
#endif //_WIN32 #endif //_WIN32
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Version // Version
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 6,0,6000,16384 FILEVERSION 6,0,6000,16384
PRODUCTVERSION 6,0,6000,16384 PRODUCTVERSION 6,0,6000,16384
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x9L FILEFLAGS 0x9L
#else #else
FILEFLAGS 0x8L FILEFLAGS 0x8L
#endif #endif
FILEOS 0x40004L FILEOS 0x40004L
FILETYPE 0x2L FILETYPE 0x2L
FILESUBTYPE 0x0L FILESUBTYPE 0x0L
BEGIN BEGIN
BLOCK "StringFileInfo" BLOCK "StringFileInfo"
BEGIN BEGIN
BLOCK "001004b0" BLOCK "001004b0"
BEGIN BEGIN
VALUE "CompanyName", "Windows (R) Codename Longhorn DDK provider" VALUE "CompanyName", "Windows (R) Codename Longhorn DDK provider"
VALUE "FileDescription", "Virtual Smart Card Driver" VALUE "FileDescription", "Bix Virtual Smart Card Driver"
VALUE "FileVersion", "6.0.6000.16384" VALUE "FileVersion", "6.0.6000.16384"
VALUE "InternalName", "vpcd" VALUE "InternalName", "BixVReader"
VALUE "LegalCopyright", "© Microsoft Corporation. All rights reserved." VALUE "LegalCopyright", "© Microsoft Corporation. All rights reserved."
VALUE "OriginalFilename", "vpcd.dll" VALUE "OriginalFilename", "BixVReader.dll"
VALUE "ProductName", "Windows (R) Codename Longhorn DDK driver" VALUE "ProductName", "Windows (R) Codename Longhorn DDK driver"
VALUE "ProductVersion", "6.0.6000.16384" VALUE "ProductVersion", "6.0.6000.16384"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
BEGIN BEGIN
VALUE "Translation", 0x10, 1200 VALUE "Translation", 0x10, 1200
END END
END END
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// TEXTINCLUDE // TEXTINCLUDE
// //
1 TEXTINCLUDE 1 TEXTINCLUDE
BEGIN BEGIN
"resource.h\0" "resource.h\0"
END END
2 TEXTINCLUDE 2 TEXTINCLUDE
BEGIN BEGIN
"\0" "\0"
END END
3 TEXTINCLUDE 3 TEXTINCLUDE
BEGIN BEGIN
"\r\n" "\r\n"
"\0" "\0"
END END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
#endif // Italian (Italy) resources #endif // Italian (Italy) resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED #ifndef APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Generated from the TEXTINCLUDE 3 resource. // Generated from the TEXTINCLUDE 3 resource.
// //
P P
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED #endif // not APSTUDIO_INVOKED

View File

@@ -1,134 +1,138 @@
#include "internal.h"
#include "internal.h"
class CVirtualSmartCardDriverModule : public CAtlDllModuleT<CVirtualSmartCardDriverModule> {} _AtlModule;
class CVirtualSmartCardDriverModule : public CAtlDllModuleT<CVirtualSmartCardDriverModule> {} _AtlModule;
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// //
// // DllMain
// DllMain //
// // This is the main DLL Entry Point.
// This is the main DLL Entry Point. //
// // Parameters:
// Parameters: // hInstance - Handle to the DLL module
// hInstance - Handle to the DLL module // dwReason - Indicates why the DLL entry point is being called
// dwReason - Indicates why the DLL entry point is being called // lpReserved - Additional information based on dwReason
// lpReserved - Additional information based on dwReason //
// // Return Values:
// Return Values: // TRUE = initialization succeeds
// TRUE = initialization succeeds // FALSE = initialization fails
// FALSE = initialization fails //
// /////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance,
extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason,
DWORD dwReason, LPVOID lpReserved)
LPVOID lpReserved) {
{ inFunc
(lpReserved); (lpReserved);
switch (dwReason) switch (dwReason)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hInstance); DisableThreadLibraryCalls(hInstance);
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
_AtlModule.Term(); _AtlModule.Term();
break; break;
default: default:
break; break;
} }
// Call the ATL module class so it can initialize // Call the ATL module class so it can initialize
return _AtlModule.DllMain(dwReason, lpReserved); return _AtlModule.DllMain(dwReason, lpReserved);
} }
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
// //
// DllCanUnloadNow // DllCanUnloadNow
// //
// Used to determine whether the DLL can be unloaded by OLE // Used to determine whether the DLL can be unloaded by OLE
// //
// Parameters: // Parameters:
// void - (unused argument) // void - (unused argument)
// //
// Return Values: // Return Values:
// S_OK: DLL can be unloaded // S_OK: DLL can be unloaded
// S_FALSE: DLL cannot be unloaded now // S_FALSE: DLL cannot be unloaded now
// //
///////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////
STDAPI DllCanUnloadNow(void) STDAPI DllCanUnloadNow(void)
{ {
return _AtlModule.DllCanUnloadNow(); inFunc
} return _AtlModule.DllCanUnloadNow();
}
/////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// DllGetClassObject //
// // DllGetClassObject
// Returns a class factory to create an object of the requested type //
// // Returns a class factory to create an object of the requested type
// Parameters: //
// rclsid - CLSID that will associate the correct data and code // Parameters:
// riid - Reference to the IID the caller will use // rclsid - CLSID that will associate the correct data and code
// ppv - pointer to an interface pointer requested in riid // riid - Reference to the IID the caller will use
// // ppv - pointer to an interface pointer requested in riid
// Return Values: //
// S_OK: The object was retrieved successfully. // Return Values:
// CLASS_E_CLASSNOTAVAILABLE: The DLL does not support the class // S_OK: The object was retrieved successfully.
// // CLASS_E_CLASSNOTAVAILABLE: The DLL does not support the class
///////////////////////////////////////////////////////////////////////// //
/////////////////////////////////////////////////////////////////////////
STDAPI DllGetClassObject(__in REFCLSID rclsid, __in REFIID riid, __deref_out LPVOID* ppv)
{ STDAPI DllGetClassObject(__in REFCLSID rclsid, __in REFIID riid, __deref_out LPVOID* ppv)
return _AtlModule.DllGetClassObject(rclsid, riid, ppv); {
} inFunc
return _AtlModule.DllGetClassObject(rclsid, riid, ppv);
///////////////////////////////////////////////////////////////////////// }
//
// DllRegisterServer /////////////////////////////////////////////////////////////////////////
// //
// Adds entries to the system registry // DllRegisterServer
// //
// Parameters: // Adds entries to the system registry
// void - (unused argument) //
// // Parameters:
// Return Values: // void - (unused argument)
// S_OK: The registry entries were created successfully //
// SELFREG_E_TYPELIB: The server was unable to complete the // Return Values:
// registration of all the type libraries used by its classes // S_OK: The registry entries were created successfully
// SELFREG_E_CLASS: The server was unable to complete the // SELFREG_E_TYPELIB: The server was unable to complete the
// registration of all the object classes // registration of all the type libraries used by its classes
// // SELFREG_E_CLASS: The server was unable to complete the
///////////////////////////////////////////////////////////////////////// // registration of all the object classes
STDAPI DllRegisterServer(void) //
{ /////////////////////////////////////////////////////////////////////////
return S_OK; STDAPI DllRegisterServer(void)
} {
inFunc
///////////////////////////////////////////////////////////////////////// return S_OK;
// }
// DllUnregisterServer
// /////////////////////////////////////////////////////////////////////////
// Removes entries from the system registry //
// // DllUnregisterServer
// Parameters: //
// void - (unused argument) // Removes entries from the system registry
// //
// Return Values: // Parameters:
// S_OK: The registry entries were removed successfully // void - (unused argument)
// S_FALSE: Unregistration of known entries was successful, but //
// other entries still exist for this server's classes // Return Values:
// SELFREG_E_TYPELIB: The server was unable to remove the entries // S_OK: The registry entries were removed successfully
// of all the type libraries used by its classes // S_FALSE: Unregistration of known entries was successful, but
// SELFREG_E_CLASS: The server was unable to to remove the entries // other entries still exist for this server's classes
// of all the object classes // SELFREG_E_TYPELIB: The server was unable to remove the entries
// // of all the type libraries used by its classes
///////////////////////////////////////////////////////////////////////// // SELFREG_E_CLASS: The server was unable to to remove the entries
STDAPI DllUnregisterServer(void) // of all the object classes
{ //
return S_OK; /////////////////////////////////////////////////////////////////////////
} STDAPI DllUnregisterServer(void)
{
inFunc
return S_OK;
}

View File

@@ -0,0 +1,264 @@
#include "internal.h"
#include "VirtualSCReader.h"
#include "reader.h"
#include "device.h"
#include <winscard.h>
#include "memory.h"
#include <Sddl.h>
#include "sectionLocker.h"
BOOL CreateMyDACL(SECURITY_ATTRIBUTES * pSA)
{
TCHAR * szSD = TEXT("D:") // Discretionary ACL
TEXT("(D;OICI;GA;;;BG)") // Deny access to
// built-in guests
TEXT("(D;OICI;GA;;;AN)") // Deny access to
// anonymous logon
TEXT("(A;OICI;GRGWGX;;;AU)") // Allow
// read/write/execute
// to authenticated
// users
TEXT("(A;OICI;GA;;;BA)"); // Allow full control
// to administrators
if (NULL == pSA)
return FALSE;
return ConvertStringSecurityDescriptorToSecurityDescriptor(
szSD,
SDDL_REVISION_1,
&(pSA->lpSecurityDescriptor),
NULL);
}
PipeReader::PipeReader() {
rpcType=0;
state=SCARD_ABSENT;
InitializeCriticalSection(&eventSection);
InitializeCriticalSection(&dataSection);
}
void PipeReader::init(wchar_t *section) {
wchar_t temp[300];
swprintf(temp,L"SCardSimulatorDriver%i",instance);
GetPrivateProfileStringW(section,L"PIPE_NAME",temp,pipeName,300,L"BixVReader.ini");
swprintf(temp,L"SCardSimulatorDriverEvents%i",instance);
GetPrivateProfileStringW(section,L"PIPE_EVENT_NAME",temp,pipeEventName,300,L"BixVReader.ini");
}
bool PipeReader::CheckATR() {
//SectionLocker lock(dataSection);
if (pipe==NULL)
return false;
DWORD read=0;
DWORD command=1;
if (!WriteFile(pipe,&command,sizeof(DWORD),&read,NULL)) {
return false;
}
FlushFileBuffers(pipe);
DWORD size=0;
if (!ReadFile(pipe,&size,sizeof(DWORD),&read,NULL)) {
return false;
}
if (size==0)
return false;
BYTE ATR[100];
if (!ReadFile(pipe,ATR,size,&read,NULL)) {
return false;
}
return true;
}
bool PipeReader::QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen) {
//SectionLocker lock(dataSection);
if (pipe==NULL)
return false;
DWORD command=2;
DWORD read=0;
if (!WriteFile(pipe,&command,sizeof(DWORD),&read,NULL)) {
pipe=NULL;
return false;
}
DWORD dwAPDUlen=(DWORD)APDUlen;
if (!WriteFile(pipe,&dwAPDUlen,sizeof(DWORD),&read,NULL)) {
pipe=NULL;
return false;
}
if (!WriteFile(pipe,APDU,APDUlen,&read,NULL)) {
pipe=NULL;
return false;
}
FlushFileBuffers(pipe);
DWORD dwRespLen=0;
if (!ReadFile(pipe,&dwRespLen,sizeof(DWORD),&read,NULL)) {
pipe=NULL;
return false;
}
if (!ReadFile(pipe,Resp,dwRespLen,&read,NULL)) {
pipe=NULL;
return false;
}
(*Resplen)=(int)dwRespLen;
return true;
}
bool PipeReader::QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset) {
//SectionLocker lock(dataSection);
if (pipe==NULL)
return false;
DWORD command=reset ? 0 : 1;
DWORD read=0;
if (!WriteFile(pipe,&command,sizeof(DWORD),&read,NULL)) {
pipe=NULL;
return false;
}
FlushFileBuffers(pipe);
DWORD size=0;
if (!ReadFile(pipe,&size,sizeof(DWORD),&read,NULL)) {
pipe=NULL;
return false;
}
if (size==0)
return false;
if (!ReadFile(pipe,ATR,size,&read,NULL)) {
pipe=NULL;
return false;
}
(*ATRsize)=size;
return true;
}
DWORD PipeReader::startServer() {
SECURITY_ATTRIBUTES sa;
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
CreateMyDACL(&sa);
wchar_t temp[300];
swprintf(temp,L"\\\\.\\pipe\\%s",pipeName);
HANDLE _pipe=CreateNamedPipe(temp,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,PIPE_UNLIMITED_INSTANCES,0,0,0,&sa);
swprintf(temp,L"\\\\.\\pipe\\%s",pipeEventName);
HANDLE _eventpipe=CreateNamedPipe(temp,PIPE_ACCESS_DUPLEX|FILE_FLAG_OVERLAPPED,PIPE_TYPE_BYTE,PIPE_UNLIMITED_INSTANCES,0,0,0,&sa);
wchar_t log[300];
swprintf(log,L"[BixVReader]Pipe created:%s:%08x",pipeName,_pipe);
OutputDebugString(log);
while (true) {
//__try {
BOOL ris=ConnectNamedPipe(_pipe,NULL);
if (ris==0) {
swprintf(log,L"[BixVReader]Pipe NOT connected:%x",GetLastError());
OutputDebugString(log);
}
else {
swprintf(log,L"[BixVReader]Pipe connected");
OutputDebugString(log);
}
ris=ConnectNamedPipe(_eventpipe,NULL);
if (ris==0) {
swprintf(log,L"[BixVReader]Event Pipe NOT connected:%x",GetLastError());
OutputDebugString(log);
}
else {
swprintf(log,L"[BixVReader]Event Pipe connected");
OutputDebugString(log);
}
pipe=_pipe;
eventpipe=_eventpipe;
if (waitInsertIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
// if I'm waiting for card insertion, verify if there's a card present
if (initProtocols()) {
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
waitInsertIpr=NULL;
state=SCARD_SWALLOWED;
}
}
while (true) {
// wait for a command
DWORD command=0;
DWORD read=0;
if (!ReadFile(eventpipe,&command,sizeof(DWORD),&read,NULL)) {
state=SCARD_ABSENT;
OutputDebugString(L"[BixVReader]Pipe error");
powered=0;
pipe=NULL;
eventpipe=NULL;
if (waitRemoveIpr!=NULL) {// card inserted
SectionLocker lock(device->m_RequestLock);
OutputDebugString(L"[BixVReader]complete Wait Remove");
if (waitRemoveIpr->UnmarkCancelable()==S_OK) {
OutputDebugString(L"[BixVReader]Wait Remove Unmarked");
waitRemoveIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]Wait Remove Completed");
}
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {// card removed
SectionLocker lock(device->m_RequestLock);
OutputDebugString(L"[BixVReader]cancel Wait Remove");
if (waitInsertIpr->UnmarkCancelable()==S_OK) {
OutputDebugString(L"[BixVReader]Wait Insert Unmarked");
waitInsertIpr->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
OutputDebugString(L"[BixVReader]Wait Insert Cancelled");
}
waitInsertIpr=NULL;
}
DisconnectNamedPipe(_pipe);
DisconnectNamedPipe(_eventpipe);
break;
}
OutputDebugString(L"[BixVReader]Pipe data");
if (command==0)
powered=0;
if (command==0 && waitRemoveIpr!=NULL) {// card removed
SectionLocker lock(device->m_RequestLock);
state=SCARD_ABSENT;
if (waitRemoveIpr->UnmarkCancelable()==S_OK) {
waitRemoveIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
}
waitRemoveIpr=NULL;
}
else if (command==1 && waitInsertIpr!=NULL) {// card inserted
SectionLocker lock(device->m_RequestLock);
state=SCARD_SWALLOWED;
initProtocols();
if (waitInsertIpr->UnmarkCancelable()==S_OK) {
waitInsertIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
}
waitInsertIpr=NULL;
}
}
//}
//__except(EXCEPTION_EXECUTE_HANDLER) {
// wchar_t log[300];
// DWORD err=GetExceptionCode();
// swprintf(log,L"Exception:%08X",err);
// OutputDebugString(log);
//}
}
OutputDebugString(L"[BixVReader]Pipe quit!!!");
return 0;
}
void PipeReader::shutdown() {
state=SCARD_ABSENT;
if (waitRemoveIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitRemoveIpr->UnmarkCancelable()==S_OK)
waitRemoveIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitInsertIpr=NULL;
}
}

View File

@@ -1,126 +1,124 @@
#include "internal.h"
#include "Device.h"
#include "internal.h" #include "Queue.h"
#include "Device.h" #include "SectionLocker.h"
#include "Queue.h"
/////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// //
// // CMyQueue::CMyQueue
// CMyQueue::CMyQueue //
// // Object constructor function
// Object constructor function //
// // Initialize member variables
// Initialize member variables //
// /////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// CMyQueue::CMyQueue() :
CMyQueue::CMyQueue() : m_pParentDevice(NULL)
m_pParentDevice(NULL) {
{ }
state=0;
} /////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////// // CMyQueue::~CMyQueue
// //
// CMyQueue::~CMyQueue // Object destructor function
// //
// Object destructor function //
// /////////////////////////////////////////////////////////////////////////
// CMyQueue::~CMyQueue()
///////////////////////////////////////////////////////////////////////// {
CMyQueue::~CMyQueue() // Release the reference that was incremented in CreateInstance()
{ SAFE_RELEASE(m_pParentDevice);
// Release the reference that was incremented in CreateInstance() }
SAFE_RELEASE(m_pParentDevice);
} /////////////////////////////////////////////////////////////////////////
//
///////////////////////////////////////////////////////////////////////// // CMyQueue::CreateInstance
// //
// CMyQueue::CreateInstance // This function supports the COM factory creation system
// //
// This function supports the COM factory creation system // Parameters:
// // parentDevice - A pointer to the CWSSDevice object
// Parameters: // ppUkwn - pointer to a pointer to the queue to be returned
// parentDevice - A pointer to the CWSSDevice object //
// ppUkwn - pointer to a pointer to the queue to be returned // Return Values:
// // S_OK: The queue was created successfully
// Return Values: //
// S_OK: The queue was created successfully /////////////////////////////////////////////////////////////////////////
// HRESULT CMyQueue::CreateInstance(__in IWDFDevice* pWdfDevice, CMyDevice* pMyDevice)
///////////////////////////////////////////////////////////////////////// {
HRESULT CMyQueue::CreateInstance(__in IWDFDevice* pWdfDevice, CMyDevice* pMyDevice) inFunc
{ SectionLogger a(__FUNCTION__);
inFunc; CComObject<CMyQueue>* pMyQueue = NULL;
CComObject<CMyQueue>* pMyQueue = NULL;
if(NULL == pMyDevice)
if(NULL == pMyDevice) {
{ return E_INVALIDARG;
return E_INVALIDARG; }
}
HRESULT hr = CComObject<CMyQueue>::CreateInstance(&pMyQueue);
HRESULT hr = CComObject<CMyQueue>::CreateInstance(&pMyQueue);
if(SUCCEEDED(hr))
if(SUCCEEDED(hr)) {
{ // AddRef the object
// AddRef the object pMyQueue->AddRef();
pMyQueue->AddRef();
// Store the parent device object
// Store the parent device object pMyQueue->m_pParentDevice = pMyDevice;
pMyQueue->m_pParentDevice = pMyDevice;
// Increment the reference for the lifetime of the CMyQueue object.
// Increment the reference for the lifetime of the CMyQueue object. pMyQueue->m_pParentDevice->AddRef();
pMyQueue->m_pParentDevice->AddRef();
CComPtr<IUnknown> spIUnknown;
CComPtr<IUnknown> spIUnknown; hr = pMyQueue->QueryInterface(IID_IUnknown, (void**)&spIUnknown);
hr = pMyQueue->QueryInterface(IID_IUnknown, (void**)&spIUnknown);
if(SUCCEEDED(hr))
if(SUCCEEDED(hr)) {
{ // Create the framework queue
// Create the framework queue CComPtr<IWDFIoQueue> spDefaultQueue;
CComPtr<IWDFIoQueue> spDefaultQueue; hr = pWdfDevice->CreateIoQueue( spIUnknown,
hr = pWdfDevice->CreateIoQueue( spIUnknown, TRUE, // DefaultQueue
TRUE, // DefaultQueue WdfIoQueueDispatchParallel, // Parallel queue handling
WdfIoQueueDispatchParallel, // Parallel queue handling FALSE, // PowerManaged
FALSE, // PowerManaged TRUE, // AllowZeroLengthRequests
TRUE, // AllowZeroLengthRequests &spDefaultQueue
&spDefaultQueue );
); if (FAILED(hr))
if (FAILED(hr)) {
{ OutputDebugString (L"[BixVReader]IoQueue NOT Created\n");
OutputDebugString (L"IoQueue NOT Created\n"); }
} else
else OutputDebugString (L"[BixVReader]IoQueue Created\n");
OutputDebugString (L"IoQueue Created\n");
}
}
// Release the pMyQueue pointer when done. Note: UMDF holds a reference to it above
// Release the pMyQueue pointer when done. Note: UMDF holds a reference to it above SAFE_RELEASE(pMyQueue);
SAFE_RELEASE(pMyQueue); }
}
return hr;
return hr; }
} /////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// //
// // CMyQueue::OnDeviceIoControl
// CMyQueue::OnDeviceIoControl //
// // This method is called when an IOCTL is sent to the device
// This method is called when an IOCTL is sent to the device //
// // Parameters:
// Parameters: // pQueue - pointer to an IO queue
// pQueue - pointer to an IO queue // pRequest - pointer to an IO request
// pRequest - pointer to an IO request // ControlCode - The IOCTL to process
// ControlCode - The IOCTL to process // InputBufferSizeInBytes - the size of the input buffer
// InputBufferSizeInBytes - the size of the input buffer // OutputBufferSizeInBytes - the size of the output buffer
// OutputBufferSizeInBytes - the size of the output buffer //
// /////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////// STDMETHODIMP_ (void) CMyQueue::OnDeviceIoControl(
STDMETHODIMP_ (void) CMyQueue::OnDeviceIoControl( __in IWDFIoQueue* pQueue,
__in IWDFIoQueue* pQueue, __in IWDFIoRequest* pRequest,
__in IWDFIoRequest* pRequest, __in ULONG ControlCode,
__in ULONG ControlCode, SIZE_T InputBufferSizeInBytes,
SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes
SIZE_T OutputBufferSizeInBytes )
) {
{ m_pParentDevice->ProcessIoControl(pQueue,pRequest,ControlCode,InputBufferSizeInBytes,OutputBufferSizeInBytes);
m_pParentDevice->ProcessIoControl(pQueue,pRequest,ControlCode,InputBufferSizeInBytes,OutputBufferSizeInBytes); }
}

View File

@@ -1,37 +1,36 @@
#pragma once #pragma once
class ATL_NO_VTABLE CMyQueue : class ATL_NO_VTABLE CMyQueue :
public CComObjectRootEx<CComMultiThreadModel>, public CComObjectRootEx<CComMultiThreadModel>,
public IQueueCallbackDeviceIoControl public IQueueCallbackDeviceIoControl
{ {
public: public:
virtual ~CMyQueue(); virtual ~CMyQueue();
DECLARE_NOT_AGGREGATABLE(CMyQueue) DECLARE_NOT_AGGREGATABLE(CMyQueue)
BEGIN_COM_MAP(CMyQueue) BEGIN_COM_MAP(CMyQueue)
COM_INTERFACE_ENTRY(IQueueCallbackDeviceIoControl) COM_INTERFACE_ENTRY(IQueueCallbackDeviceIoControl)
END_COM_MAP() END_COM_MAP()
static HRESULT CreateInstance(__in IWDFDevice* pWdfDevice, CMyDevice* pMyDevice); static HRESULT CreateInstance(__in IWDFDevice* pWdfDevice, CMyDevice* pMyDevice);
protected: protected:
CMyQueue(); CMyQueue();
// COM Interface methods // COM Interface methods
public: public:
int state; // IQueueCallbackDeviceIoControl
// IQueueCallbackDeviceIoControl STDMETHOD_ (void, OnDeviceIoControl)(
STDMETHOD_ (void, OnDeviceIoControl)( __in IWDFIoQueue* pQueue,
__in IWDFIoQueue* pQueue, __in IWDFIoRequest* pRequest,
__in IWDFIoRequest* pRequest, __in ULONG ControlCode,
__in ULONG ControlCode, SIZE_T InputBufferSizeInBytes,
SIZE_T InputBufferSizeInBytes, SIZE_T OutputBufferSizeInBytes
SIZE_T OutputBufferSizeInBytes );
);
private:
private: CMyDevice* m_pParentDevice; // Parent device object
CMyDevice* m_pParentDevice; // Parent device object };
};

View File

@@ -0,0 +1,426 @@
#include "internal.h"
#include "VirtualSCReader.h"
#include "reader.h"
#include "device.h"
#include <winscard.h>
#include "memory.h"
#include <Sddl.h>
#include "SectionLocker.h"
void Reader::init(wchar_t *section) {
section;
state=SCARD_ABSENT;
}
void Reader::IoSmartCardIsPresent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
OutputDebugString(L"[BixVReader][IPRE]IOCTL_SMARTCARD_IS_PRESENT");
if (CheckATR()) {
// there's a smart card present, so complete the request
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
}
else {
// there's no smart card present, so leave the request pending; it will be completed later
SectionLocker lock(device->m_RequestLock);
waitInsertIpr=pRequest;
IRequestCallbackCancel *callback;
device->QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
pRequest->MarkCancelable(callback);
callback->Release();
}
}
void Reader::IoSmartCardGetState(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
OutputDebugString(L"[BixVReader][GSTA]IOCTL_SMARTCARD_GET_STATE");
wchar_t log[300];
swprintf(log,L"[BixVReader]STATE:%08X",state);
OutputDebugString(log);
setInt(device,pRequest,state);
}
void Reader::IoSmartCardIsAbsent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
OutputDebugString(L"[BixVReader][IABS]IOCTL_SMARTCARD_IS_ABSENT");
if (!CheckATR()) {
// there's no smart card present, so complete the request
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
}
else {
SectionLocker lock(device->m_RequestLock);
// there's a smart card present, so leave the request pending; it will be completed later
waitRemoveIpr=pRequest;
IRequestCallbackCancel *callback;
device->QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
pRequest->MarkCancelable(callback);
callback->Release();
}
}
void Reader::IoSmartCardPower(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
OutputDebugString(L"[BixVReader][POWR]IOCTL_SMARTCARD_POWER");
DWORD code=getInt(pRequest);
if (code==SCARD_COLD_RESET) {
OutputDebugString(L"[BixVReader][POWR]SCARD_COLD_RESET");
protocol=0;
powered=1;
state=SCARD_NEGOTIABLE;
}
else if (code==SCARD_WARM_RESET) {
OutputDebugString(L"[BixVReader][POWR]SCARD_WARM_RESET");
protocol=0;
powered=1;
state=SCARD_NEGOTIABLE;
}
else if (code==SCARD_POWER_DOWN) {
OutputDebugString(L"[BixVReader][POWR]SCARD_POWER_DOWN");
protocol=0;
powered=0;
state=SCARD_SWALLOWED;
}
if (code==SCARD_COLD_RESET || code==SCARD_WARM_RESET) {
BYTE ATR[100];
DWORD ATRsize;
if (!QueryATR(ATR,&ATRsize,true))
{
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
setBuffer(device,pRequest,ATR,ATRsize);
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
}
}
void Reader::IoSmartCardSetProtocol(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
UNREFERENCED_PARAMETER(instance);
DWORD requestedProtocol=getInt(pRequest);
wchar_t log[300];
swprintf(log,L"[BixVReader][SPRT]IOCTL_SMARTCARD_SET_PROTOCOL:%08X",requestedProtocol);
OutputDebugString(log);
BYTE ATR[100];
DWORD ATRsize;
state=SCARD_SPECIFIC;
if (!QueryATR(ATR,&ATRsize,true))
{
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
if (((requestedProtocol & SCARD_PROTOCOL_T1) != 0) &&
((availableProtocol & SCARD_PROTOCOL_T1) != 0)) {
protocol = SCARD_PROTOCOL_T1;
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]PROTOCOL SET: T1");
return;
}
if (((requestedProtocol & SCARD_PROTOCOL_T0) != 0) &&
((availableProtocol & SCARD_PROTOCOL_T0) != 0)) {
protocol = SCARD_PROTOCOL_T0;
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]PROTOCOL SET: T0");
return;
}
if (((requestedProtocol & (SCARD_PROTOCOL_DEFAULT)) != 0) &&
((availableProtocol & SCARD_PROTOCOL_T1) != 0)) {
protocol = SCARD_PROTOCOL_T1;
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]PROTOCOL SET: T1");
return;
}
if (((requestedProtocol & (SCARD_PROTOCOL_DEFAULT)) != 0) &&
((availableProtocol & SCARD_PROTOCOL_T0) != 0)) {
protocol = SCARD_PROTOCOL_T0;
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]PROTOCOL SET: T0");
return;
}
{
state=SCARD_NEGOTIABLE;
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
}
void Reader::IoSmartCardSetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
UNREFERENCED_PARAMETER(instance);
OutputDebugString(L"[BixVReader][SATT]IOCTL_SMARTCARD_SET_ATTRIBUTE");
IWDFMemory *inmem=NULL;
pRequest->GetInputMemory(&inmem);
SIZE_T size;
BYTE *data=(BYTE *)inmem->GetDataBuffer(&size);
DWORD minCode=*(DWORD*)(data);
bool handled=false;
if (minCode==SCARD_ATTR_DEVICE_IN_USE) {
SectionLocker lock(device->m_RequestLock);
OutputDebugString(L"[BixVReader][SATT]SCARD_ATTR_DEVICE_IN_USE");
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
handled=true;
}
inmem->Release();
if (!handled) {
SectionLocker lock(device->m_RequestLock);
wchar_t log[300];
swprintf(log,L"[BixVReader][SATT]ERROR_NOT_SUPPORTED:%08X",minCode);
OutputDebugString(log);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
}
void Reader::IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
OutputDebugString(L"[BixVReader][TRSM]IOCTL_SMARTCARD_TRANSMIT");
BYTE APDU[1000];
int APDUSize;
getBuffer(pRequest,APDU,&APDUSize);
if (((SCARD_IO_REQUEST*)APDU)->dwProtocol!=protocol) {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0);
return;
}
BYTE Resp[1000];
int RespSize;
if (!QueryTransmit(APDU+sizeof(SCARD_IO_REQUEST),APDUSize-sizeof(SCARD_IO_REQUEST),Resp+sizeof(SCARD_IO_REQUEST),&RespSize))
{
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
((SCARD_IO_REQUEST*)Resp)->cbPciLength=sizeof(SCARD_IO_REQUEST);
((SCARD_IO_REQUEST*)Resp)->dwProtocol=protocol;
setBuffer(device,pRequest,Resp,RespSize+sizeof(SCARD_IO_REQUEST));
}
void Reader::IoSmartCardGetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
wchar_t log[300]=L"";
char temp[300];
DWORD code=getInt(pRequest);
swprintf(log,L"[BixVReader][GATT] - code %0X",code);
OutputDebugString(log);
switch(code) {
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA009):
// custom attribute; RPC_TYPE
OutputDebugString(L"[BixVReader][GATT]RPC_TYPE");
setInt(device,pRequest,rpcType);
return;
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA00a):
// custom attribute; PipeName
if (rpcType==0) {
PipeReader *pipe=(PipeReader *)this;
OutputDebugString(L"[BixVReader][GATT]PIPE_NAME");
sprintf(temp,"%S",pipe->pipeName);
setString(device,pRequest,(char*)temp,(int)outBufSize);
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
return;
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA00b):
// custom attribute; EventPipeName
if (rpcType==0) {
PipeReader *pipe=(PipeReader *)this;
OutputDebugString(L"[BixVReader][GATT]EVENT_PIPE_NAME");
sprintf(temp,"%S",pipe->pipeEventName);
setString(device,pRequest,(char*)temp,(int)outBufSize);
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
return;
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA00c):
// custom attribute; TCP port
if (rpcType==1) {
TcpIpReader *tcpIp=(TcpIpReader *)this;
OutputDebugString(L"[BixVReader][GATT]PORT");
setInt(device,pRequest,tcpIp->port);
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
return;
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA00d):
// custom attribute; TCP event port
if (rpcType==1) {
TcpIpReader *tcpIp=(TcpIpReader *)this;
OutputDebugString(L"[BixVReader][GATT]EVENT_PORT");
setInt(device,pRequest,tcpIp->eventPort);
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
return;
case SCARD_ATTR_VALUE(SCARD_CLASS_VENDOR_DEFINED, 0xA00e):
// custom attribute; TCP base port
if (rpcType==1) {
TcpIpReader *tcpIp=(TcpIpReader *)this;
OutputDebugString(L"[BixVReader][GATT]BASE_PORT");
setInt(device,pRequest,tcpIp->portBase);
tcpIp;
}
else {
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
return;
case SCARD_ATTR_CHARACTERISTICS:
// 0x00000000 No special characteristics
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_CHARACTERISTICS");
setInt(device,pRequest,0);
return;
case SCARD_ATTR_VENDOR_NAME:
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_VENDOR_NAME");
setString(device,pRequest,vendorName,(int)outBufSize);
return;
case SCARD_ATTR_VENDOR_IFD_TYPE:
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_VENDOR_IFD_TYPE");
setString(device,pRequest,vendorIfdType,(int)outBufSize);
return;
case SCARD_ATTR_DEVICE_UNIT:
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_DEVICE_UNIT");
setInt(device,pRequest,deviceUnit);
return;
case SCARD_ATTR_ATR_STRING:
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_ATR_STRING");
BYTE ATR[100];
DWORD ATRsize;
if (!QueryATR(ATR,&ATRsize))
{
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
setBuffer(device,pRequest,ATR,ATRsize);
return;
case SCARD_ATTR_CURRENT_PROTOCOL_TYPE:
OutputDebugString(L"[BixVReader][GATT]SCARD_ATTR_CURRENT_PROTOCOL_TYPE");
setInt(device,pRequest,protocol); // T=0 or T=1
return;
default: {
swprintf(log,L"[BixVReader][GATT]ERROR_NOT_SUPPORTED:%08X",code);
OutputDebugString(log);
SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
}
}
bool Reader::CheckATR() {
return false;
}
bool Reader::QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen) {
APDU;
APDUlen;
Resp;
Resplen;
return false;
}
bool Reader::QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset) {
ATR;
ATRsize;
reset;
return false;
}
bool Reader::initProtocols() {
// ask ATR to determine available protocols
BYTE ATR[100];
DWORD ATRsize=100;
availableProtocol=0;
if (QueryATR(ATR,&ATRsize,true))
{
availableProtocol=0;
int iNumHistBytes=0;
int iTotHistBytes=0;
int y=0;
int block=1;
bool isHist=false;
char let='A';
for (unsigned int i=0;i<ATRsize && ! isHist;i++) {
if (i==0) {
// we are in TS
}
else if (i==1) {
// we are in T0; read number of historical bytes
let='A';
y=ATR[i] >> 4;
iTotHistBytes=ATR[i] & 0xF;
}
else {
while ((y & 1)==0) {
let++;
y>>=1;
if (y==0) {
isHist=true;
iNumHistBytes=1;
i--;
goto end;
}
}
// we are in T(let)(block)
y=y & 0xE;
if (let=='D') {
// check available protocol(s)
int protocol=(ATR[i] & 0x0f);
availableProtocol|=1 << protocol;
// prepare for next block
let='A';
y=ATR[i] >> 4;
block++;
}
}
end:
;
}
//support at least T=0
if (availableProtocol==0)
availableProtocol=1;
return true;
}
return false;
}
DWORD Reader::startServer() {
return 0;
}
void Reader::shutdown() {
}

View File

@@ -0,0 +1,104 @@
#pragma once
#include <Winsock2.h>
class CMyDevice;
class Reader {
public:
CMyDevice *device;
CComPtr<IWDFIoRequest> waitRemoveIpr;
CComPtr<IWDFIoRequest> waitInsertIpr;
inbuf;
outbuf;
HANDLE serverThread;
char vendorName[300];
char vendorIfdType[300];
int deviceUnit;
int powered;
int instance;
int rpcType;
int state;
DWORD protocol; // T0 or T1 - protocol in use
DWORD availableProtocol; // T0, T1 or Both - protocols available
void IoSmartCardGetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardIsPresent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardGetState(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardIsAbsent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardPower(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardSetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardSetProtocol(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
bool initProtocols();
virtual bool QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen);
virtual bool QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset=false);
virtual bool CheckATR();
virtual DWORD startServer();
virtual void shutdown();
virtual void init(wchar_t *section);
};
class PipeReader : public Reader {
public:
wchar_t pipeName[300];
wchar_t pipeEventName[300];
HANDLE pipe;
HANDLE eventpipe;
PipeReader();
bool QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen);
bool QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset=false);
bool CheckATR();
DWORD startServer();
void shutdown();
void init(wchar_t *section);
CRITICAL_SECTION eventSection;
CRITICAL_SECTION dataSection;
};
class TcpIpReader : public Reader {
public:
static int portBase;
int port;
int eventPort;
SOCKET socket;
SOCKET AcceptSocket;
SOCKET eventsocket;
bool breakSocket;
TcpIpReader();
bool QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen);
bool QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset=false);
bool CheckATR();
DWORD startServer();
void shutdown();
void init(wchar_t *section);
CRITICAL_SECTION eventSection;
CRITICAL_SECTION dataSection;
};
class VpcdReader : public Reader {
public:
static int portBase;
short port;
void *ctx;
bool breakSocket;
bool cardPresent;
VpcdReader();
bool QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen);
bool QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset=false);
bool CheckATR();
DWORD startServer();
void shutdown();
void init(wchar_t *section);
void signalRemoval(void);
void signalInsertion(void);
};

View File

@@ -0,0 +1,306 @@
#include "internal.h"
#include "VirtualSCReader.h"
#include "reader.h"
#include "device.h"
#include <winscard.h>
#include "memory.h"
#include <Sddl.h>
#include "sectionLocker.h"
int TcpIpReader::portBase;
TcpIpReader::TcpIpReader() {
rpcType=1;
state=SCARD_ABSENT;
}
void TcpIpReader::init(wchar_t *section) {
portBase=GetPrivateProfileInt(L"Driver",L"RPC_PORT_BASE",29500,L"BixVReader.ini");
port=GetPrivateProfileInt(section,L"TCP_PORT",portBase+(instance<<1),L"BixVReader.ini");
eventPort=GetPrivateProfileInt(section,L"TCP_EVENT_PORT",portBase+1+(instance<<1),L"BixVReader.ini");
InitializeCriticalSection(&eventSection);
InitializeCriticalSection(&dataSection);
}
bool TcpIpReader::CheckATR() {
//SectionLocker lock(dataSection);
if (AcceptSocket==NULL)
return false;
int read=0;
DWORD command=1;
if ((read=send(AcceptSocket,(char*)&command,sizeof(DWORD),NULL))<=0) {
return false;
}
DWORD size=0;
if ((read=recv(AcceptSocket,(char*)&size,sizeof(DWORD),MSG_WAITALL))<=0) {
return false;
}
if (size==0)
return false;
BYTE ATR[100];
if ((read=recv(AcceptSocket,(char*)ATR,size,MSG_WAITALL))<=0) {
return false;
}
return true;
}
bool TcpIpReader::QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen) {
//SectionLocker lock(dataSection);
if (AcceptSocket==NULL)
return false;
DWORD command=2;
DWORD read=0;
if ((read=send(AcceptSocket,(char*)&command,sizeof(DWORD),NULL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
DWORD dwAPDUlen=(DWORD)APDUlen;
if ((read=send(AcceptSocket,(char*)&dwAPDUlen,sizeof(DWORD),NULL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
if ((read=send(AcceptSocket,(char*)APDU,APDUlen,NULL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
DWORD dwRespLen=0;
if ((read=recv(AcceptSocket,(char*)&dwRespLen,sizeof(DWORD),MSG_WAITALL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
if ((read=recv(AcceptSocket,(char*)Resp,dwRespLen,MSG_WAITALL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
(*Resplen)=(int)dwRespLen;
return true;
}
bool TcpIpReader::QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset) {
//SectionLocker lock(dataSection);
if (AcceptSocket==NULL)
return false;
int read=0;
DWORD command=reset ? 0 : 1;
if ((read=send(AcceptSocket,(char*)&command,sizeof(DWORD),NULL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
DWORD size=0;
if ((read=recv(AcceptSocket,(char*)&size,sizeof(DWORD),MSG_WAITALL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
if (size==0)
return false;
if ((read=recv(AcceptSocket,(char*)ATR,size,MSG_WAITALL))<=0) {
::shutdown(AcceptSocket,SD_BOTH);
AcceptSocket=NULL;
return false;
}
(*ATRsize)=size;
return true;
}
DWORD TcpIpReader::startServer() {
breakSocket=false;
wchar_t log[300];
while (true) {
//__try {
fd_set readfds;
FD_ZERO(&readfds);
// Set server socket to set
FD_SET(socket, &readfds);
// Timeout parameter
timeval tv = { 0 };
tv.tv_sec = 5;
while(true) {
if (breakSocket)
return 0;
FD_SET(socket, &readfds);
int ret = select(0, &readfds, NULL, NULL, &tv);
if (ret > 0)
break;
if (ret<0) {
wchar_t log[100];
DWORD err=WSAGetLastError();
swprintf(log,L"[BixVReader]wsa err:%x",err);
OutputDebugString(log);
if (err==0x2736) {
socket=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,0);
sockaddr_in Service;
Service.sin_family = AF_INET;
Service.sin_addr.s_addr = inet_addr("127.0.0.1");
Service.sin_port = htons((u_short)(port));
bind(socket, (SOCKADDR *) &Service, sizeof (Service));
listen(socket, 1);
FD_ZERO(&readfds);
// Set server socket to set
FD_SET(socket, &readfds);
}
}
}
SOCKET AcceptEventSocket;
AcceptSocket = accept(socket, NULL, NULL);
closesocket(socket);
socket=NULL;
if (AcceptSocket == INVALID_SOCKET)
return 0;
swprintf(log,L"[BixVReader]Socket connected:%i",AcceptSocket);
OutputDebugString(log);
FD_ZERO(&readfds);
// Set server socket to set
FD_SET(eventsocket, &readfds);
while(true) {
if (breakSocket)
return 0;
FD_SET(eventsocket, &readfds);
int ret = select(0, &readfds, NULL, NULL, &tv);
if (ret > 0)
break;
if (ret<0) {
DWORD err=WSAGetLastError();
swprintf(log,L"[BixVReader]wsa err:%x",err);
OutputDebugString(log);
if (err==0x2736) {
eventsocket=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,NULL,0,0);
sockaddr_in eventService;
eventService.sin_family = AF_INET;
eventService.sin_addr.s_addr = inet_addr("127.0.0.1");
eventService.sin_port = htons((u_short)(eventPort));
bind(eventsocket, (SOCKADDR *) &eventService, sizeof (eventService));
listen(eventsocket, 1);
FD_ZERO(&readfds);
// Set server socket to set
FD_SET(eventsocket, &readfds);
}
}
}
AcceptEventSocket = accept(eventsocket, NULL, NULL);
closesocket(eventsocket);
eventsocket=NULL;
if (AcceptEventSocket == INVALID_SOCKET)
return 0;
swprintf(log,L"[BixVReader]Event Socket connected:%i",AcceptEventSocket);
OutputDebugString(log);
if (waitInsertIpr!=NULL) {
// if I'm waiting for card insertion, verify if there's a card present
if (initProtocols()) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
waitInsertIpr=NULL;
state=SCARD_SWALLOWED;
}
}
while (true) {
// wait for a command
DWORD command=0;
int read=0;
if ((read=recv(AcceptEventSocket,(char*)&command,sizeof(DWORD),MSG_WAITALL))<=0) {
state=SCARD_ABSENT;
OutputDebugString(L"[BixVReader]Socket error");
powered=0;
::shutdown(AcceptSocket,SD_BOTH);
::shutdown(AcceptEventSocket,SD_BOTH);
if (waitRemoveIpr!=NULL) {// card inserted
OutputDebugString(L"[BixVReader]complete Wait Remove");
SectionLocker lock(device->m_RequestLock);
if (waitRemoveIpr->UnmarkCancelable()==S_OK) {
OutputDebugString(L"[BixVReader]Wait Remove Unmarked");
waitRemoveIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
OutputDebugString(L"[BixVReader]Wait Remove Completed");
}
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {// card removed
OutputDebugString(L"[BixVReader]cancel Wait Remove");
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK) {
OutputDebugString(L"[BixVReader]Wait Insert Unmarked");
waitInsertIpr->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
OutputDebugString(L"[BixVReader]Wait Insert Cancelled");
}
waitInsertIpr=NULL;
}
break;
}
OutputDebugString(L"[BixVReader]Socket data");
if (command==0)
powered=0;
if (command==0 && waitRemoveIpr!=NULL) {// card removed
SectionLocker lock(device->m_RequestLock);
state=SCARD_ABSENT;
if (waitRemoveIpr->UnmarkCancelable()==S_OK)
waitRemoveIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
waitRemoveIpr=NULL;
}
else if (command==1 && waitInsertIpr!=NULL) {// card inserted
SectionLocker lock(device->m_RequestLock);
state=SCARD_SWALLOWED;
initProtocols();
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
waitInsertIpr=NULL;
}
}
//}
//__except(EXCEPTION_EXECUTE_HANDLER) {
// wchar_t log[300];
// DWORD err=GetExceptionCode();
// swprintf(log,L"Exception:%08X",err);
// OutputDebugString(log);
//}
}
OutputDebugString(L"[BixVReader]Socket quit!!!");
return 0;
}
void TcpIpReader::shutdown() {
state=SCARD_ABSENT;
breakSocket=true;
{
//SectionLocker lock(dataSection);
closesocket(eventsocket);
closesocket(socket);
}
WaitForSingleObject(serverThread,10000);
serverThread=NULL;
eventsocket=NULL;
socket=NULL;
if (waitRemoveIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitRemoveIpr->UnmarkCancelable()==S_OK)
waitRemoveIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitInsertIpr=NULL;
}
}

View File

@@ -1,20 +1,20 @@
import "wudfddi.idl"; import "wudfddi.idl";
[ [
uuid(8B9C88E9-7E63-46c7-832B-D48D0290E4BF), uuid(8B9C88E9-7E63-46c7-832B-D48D0290E4BF),
version(1.0), version(1.0),
helpstring("VirtualSCReader Driver Type Library") helpstring("VirtualSCReader Driver Type Library")
] ]
library VirtualSCReaderDriverLib library VirtualSCReaderDriverLib
{ {
importlib("stdole2.tlb"); importlib("stdole2.tlb");
[ [
uuid(d4112073-d09b-458f-a5aa-35ef21eef5de), uuid(d4112073-d09b-458f-a5aa-35ef21eef5de),
//uuid(10654262-B9BD-4636-8890-F66362CCC207), //uuid(10654262-B9BD-4636-8890-F66362CCC207),
helpstring("VirtualSCReader Class") helpstring("VirtualSCReader Class")
] ]
coclass VirtualSCReaderDriver coclass VirtualSCReaderDriver
{ {
[default] interface IDriverEntry; [default] interface IDriverEntry;
}; };
}; };

View File

@@ -0,0 +1,147 @@
#include "internal.h"
#include "VirtualSCReader.h"
#include "reader.h"
#include "device.h"
#include <winscard.h>
#include "memory.h"
#include <Sddl.h>
#include "sectionLocker.h"
#include "../../src/vpcd/vpcd.h"
int VpcdReader::portBase;
VpcdReader::VpcdReader() {
rpcType=2;
state=SCARD_ABSENT;
cardPresent = false;
}
void VpcdReader::init(wchar_t *section) {
portBase=GetPrivateProfileInt(L"Driver",L"RPC_PORT_BASE",VPCDPORT,L"BixVReader.ini");
port=(short) GetPrivateProfileInt(section,L"TCP_PORT",portBase+instance,L"BixVReader.ini");
}
bool VpcdReader::CheckATR() {
bool r = false;
struct vicc_ctx *vicc_ctx = (struct vicc_ctx *) ctx;
if (vicc_present((struct vicc_ctx *) ctx) == 1) {
signalInsertion();
r = true;
} else {
signalRemoval();
}
return r;
}
bool VpcdReader::QueryTransmit(BYTE *APDU,int APDUlen,BYTE *Resp,int *Resplen) {
unsigned char *rapdu = NULL;
ssize_t rapdu_len;
bool r = false;
if (APDU && APDUlen && Resp && Resplen) {
rapdu_len = vicc_transmit((struct vicc_ctx *) ctx, APDUlen, APDU, &rapdu);
if (rapdu_len > 0) {
memcpy(Resp, rapdu, rapdu_len);
*Resplen = rapdu_len;
free(rapdu);
r = true;
} else {
signalRemoval();
}
}
return r;
}
bool VpcdReader::QueryATR(BYTE *ATR,DWORD *ATRsize,bool reset) {
unsigned char *atr = NULL;
int atr_len;
bool r = false;
if (ATR && ATRsize) {
atr_len = vicc_getatr((struct vicc_ctx *) ctx, &atr);
if (atr_len > 0) {
/* TODO do length checking on length of ATR when ATRsize is
* correctly initialized by Reader.cpp */
memcpy(ATR, atr, atr_len);
*ATRsize = atr_len;
free(atr);
r = true;
if (reset)
vicc_reset((struct vicc_ctx *) ctx);
} else {
signalRemoval();
}
}
return r;
}
DWORD VpcdReader::startServer() {
breakSocket = false;
ctx = vicc_init(NULL, port);
while (!breakSocket) {
CheckATR();
Sleep(1000);
}
return 0;
}
void VpcdReader::shutdown() {
breakSocket=true;
WaitForSingleObject(serverThread,10000);
serverThread=NULL;
vicc_exit((struct vicc_ctx *) ctx);
state=SCARD_ABSENT;
ctx = NULL;
if (waitRemoveIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitRemoveIpr->UnmarkCancelable()==S_OK)
waitRemoveIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitInsertIpr=NULL;
}
}
void VpcdReader::signalRemoval(void) {
if (cardPresent) {
cardPresent = false;
state=SCARD_ABSENT;
if (waitRemoveIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitRemoveIpr->UnmarkCancelable()==S_OK) {
waitRemoveIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
}
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK) {
waitInsertIpr->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
}
waitInsertIpr=NULL;
}
}
}
void VpcdReader::signalInsertion(void) {
if (!cardPresent) {
cardPresent = true;
if (waitInsertIpr!=NULL) {
if (initProtocols()) {
SectionLocker lock(device->m_RequestLock);
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->CompleteWithInformation(STATUS_SUCCESS, 0);
waitInsertIpr=NULL;
state=SCARD_SWALLOWED;
}
}
}
}

View File

@@ -1,80 +1,80 @@
; ;
; VirtualCardReader.inf ; VirtualCardReader.inf
; ;
[Version] [Version]
Signature="$Windows NT$" Signature="$Windows NT$"
Class=SmartCardReader Class=SmartCardReader
ClassGuid={50dd5230-ba8a-11d1-bf5d-0000f805f530} ClassGuid={50dd5230-ba8a-11d1-bf5d-0000f805f530}
Provider=%MSFTUMDF% Provider=%MSFTUMDF%
CatalogFile=WUDF.cat CatalogFile=WUDF.cat
DriverVer=11/22/2010,6.1.7600.16385 DriverVer=11/22/2010,6.1.7600.16385
[Manufacturer] [Manufacturer]
%MSFTUMDF%=Microsoft,NT$ARCH$ %MSFTUMDF%=Microsoft,NT$ARCH$
[Microsoft.NT$ARCH$] [Microsoft.NT$ARCH$]
%ReaderDeviceName%=VReader_Install,root\vpcd %ReaderDeviceName%=VReader_Install,root\BixVirtualReader
; =================== Virtual Reader Device ================================== ; =================== Virtual Reader Device ==================================
[VReader_Install.NT] [VReader_Install.NT]
CopyFiles=UMDriverCopy CopyFiles=UMDriverCopy
[VReader_Install.NT.hw] [VReader_Install.NT.hw]
[VReader_Install.NT.Services] [VReader_Install.NT.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
[VReader_Install.NT.CoInstallers] [VReader_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles CopyFiles=CoInstallers_CopyFiles
[VReader_Install.NT.Wdf] [VReader_Install.NT.Wdf]
UmdfService=vpcd,UMDFVReader_Install UmdfService=BixVReader,UMDFVReader_Install
UmdfServiceOrder=vpcd UmdfServiceOrder=BixVReader
UmdfKernelModeClientPolicy=AllowKernelModeClients UmdfKernelModeClientPolicy=AllowKernelModeClients
; =================== UMDF Service Install section =================== ; =================== UMDF Service Install section ===================
[UMDFVReader_Install] [UMDFVReader_Install]
UmdfLibraryVersion=$UMDFVERSION$ UmdfLibraryVersion=$UMDFVERSION$
ServiceBinary=%12%\UMDF\vpcd.dll ServiceBinary=%12%\UMDF\BixVReader.dll
DriverCLSID={d4112073-d09b-458f-a5aa-35ef21eef5de} DriverCLSID={d4112073-d09b-458f-a5aa-35ef21eef5de}
[WUDFRD_ServiceInstall] [WUDFRD_ServiceInstall]
DisplayName = %WudfRdDisplayName% DisplayName = %WudfRdDisplayName%
ServiceType = 1 ServiceType = 1
StartType = 3 StartType = 3
ErrorControl = 1 ErrorControl = 1
ServiceBinary = %12%\WUDFRd.sys ServiceBinary = %12%\WUDFRd.sys
LoadOrderGroup = Base LoadOrderGroup = Base
[SourceDisksFiles] [SourceDisksFiles]
vpcd.dll=1 BixVReader.dll=1
WudfUpdate_01009.dll=1 WudfUpdate_01009.dll=1
[SourceDisksNames] [SourceDisksNames]
1 = %MediaDescription% 1 = %MediaDescription%
[CoInstallers_CopyFiles] [CoInstallers_CopyFiles]
WudfUpdate_$UMDFCOINSTALLERVERSION$.dll WudfUpdate_$UMDFCOINSTALLERVERSION$.dll
[CoInstallers_AddReg] [CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WUDFUpdate_$UMDFCOINSTALLERVERSION$.dll" HKR,,CoInstallers32,0x00010000,"WUDFUpdate_$UMDFCOINSTALLERVERSION$.dll"
[DestinationDirs] [DestinationDirs]
UMDriverCopy=12,UMDF ; copy to driversMdf UMDriverCopy=12,UMDF ; copy to driversMdf
CoInstallers_CopyFiles=11 CoInstallers_CopyFiles=11
[UMDriverCopy] [UMDriverCopy]
vpcd.dll BixVReader.dll
; =================== Generic ================================== ; =================== Generic ==================================
[Strings] [Strings]
MSFTUMDF="Virtual Smart Card Architecture" MSFTUMDF="Fabio Ottavi - developer"
MediaDescription="Virtual PCD Media" MediaDescription="Bix Virtual Card Reader disk 1"
WudfRdDisplayName="UMDF Virtual Smart Card Reader for ScardVisual" WudfRdDisplayName="Bix UMDF Virtual Smart Card Reader for ScardVisual"
ReaderDeviceName="Virtual PCD" ReaderDeviceName="Bix Virtual Smart Card Reader"

View File

@@ -0,0 +1,7 @@
#
# Build using BUILD.EXE (Do not edit this section of this file, edit SOURCES)
#
MINIMUM_NT_TARGET_VERSION=0x501
!INCLUDE $(NTMAKEENV)\makefile.def

View File

@@ -1,8 +1,8 @@
.SUFFIXES: .inx .SUFFIXES: .inx
STAMP=stampinf STAMP=stampinf
.inx{$(OBJ_PATH)\$(O)}.inf: .inx{$(OBJ_PATH)\$(O)}.inf:
copy $(@B).inx $@ copy $(@B).inx $@
$(STAMP) -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -u $(UMDF_VERSION_MAJOR).$(UMDF_VERSION_MINOR).0 $(STAMP) -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -u $(UMDF_VERSION_MAJOR).$(UMDF_VERSION_MINOR).0

View File

@@ -1,71 +1,79 @@
# #
# UMDF_VERSION_MAJOR controls the headers that the driver uses. # UMDF_VERSION_MAJOR controls the headers that the driver uses.
# UMDF_VERSION_MAJOR + UMDF_VERSION_MINOR control which version # UMDF_VERSION_MAJOR + UMDF_VERSION_MINOR control which version
# of UMDF the driver is bound to in the INF and which # of UMDF the driver is bound to in the INF and which
# update coinstaller it requires (through stampinf). # update coinstaller it requires (through stampinf).
# #
UMDF_VERSION_MAJOR=1 UMDF_VERSION_MAJOR=1
UMDF_VERSION_MINOR=9 UMDF_VERSION_MINOR=9
KMDF_VERSION_MAJOR=1 KMDF_VERSION_MAJOR=1
KMDF_VERSION_MINOR=9 KMDF_VERSION_MINOR=9
TARGETNAME=vpcd TARGETNAME=BixVReader
TARGETTYPE=DYNLINK TARGETTYPE=DYNLINK
USE_ATL = 1 USE_ATL = 1
ATL_VER = 71 USE_STL = 1
USE_MSVCRT = 1 ATL_VER = 71
USE_MSVCRT = 1
C_DEFINES = $(C_DEFINES) /D_UNICODE /DUNICODE USE_NATIVE_EH = 1
WIN32_WINNT_VERSION=$(LATEST_WIN32_WINNT_VERSION) C_DEFINES = $(C_DEFINES) /D_UNICODE /DUNICODE
_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WIN7)
NTDDI_VERSION=$(LATEST_NTDDI_VERSION) WIN32_WINNT_VERSION=$(LATEST_WIN32_WINNT_VERSION)
_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WIN7)
DLLENTRY=_DllMainCRTStartup NTDDI_VERSION=$(LATEST_NTDDI_VERSION)
DLLDEF=exports.def
DLLENTRY=_DllMainCRTStartup
SOURCES=\ DLLDEF=..\exports.def
vpcd.rc \
driver.cpp \ SOURCES=\
device.cpp \ ..\BixVReader.rc \
queue.cpp \ ..\driver.cpp \
memory.cpp \ ..\device.cpp \
DllMain.cpp \ ..\reader.cpp \
VirtualSCReader.idl ..\pipereader.cpp \
..\tcpipreader.cpp \
INCLUDES= $(INCLUDES); \ ..\..\..\src\vpcd\vpcd.c \
$(SDK_INC_PATH); \ ..\vpcdreader.cpp \
$(DDK_INC_PATH); \ ..\queue.cpp \
$(UMDF_INC_PATH)\10; ..\memory.cpp \
..\sectionLocker.cpp \
MSC_WARNING_LEVEL=/W4 /WX ..\DllMain.cpp \
..\VirtualSCReader.idl
TARGETLIBS=\
$(SDK_LIB_PATH)\strsafe.lib \ INCLUDES= $(INCLUDES); \
$(SDK_LIB_PATH)\kernel32.lib \ $(SDK_INC_PATH); \
$(SDK_LIB_PATH)\ole32.lib \ $(DDK_INC_PATH); \
$(SDK_LIB_PATH)\oleaut32.lib \ $(UMDF_INC_PATH)\10;
$(SDK_LIB_PATH)\uuid.lib \
$(SDK_LIB_PATH)\user32.lib \ MSC_WARNING_LEVEL=/W4 /WX
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\shlwapi.lib \ TARGETLIBS=\
$(SDK_LIB_PATH)\ws2_32.lib $(SDK_LIB_PATH)\strsafe.lib \
$(SDK_LIB_PATH)\kernel32.lib \
NTTARGETFILE1=$(OBJ_PATH)\$(O)\vpcd.inf $(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\uuid.lib \
# $(SDK_LIB_PATH)\user32.lib \
# This sets up the WPP preprocessor and tells it to scan internal.h to find $(SDK_LIB_PATH)\advapi32.lib \
# the trace function definition that's in there. $(SDK_LIB_PATH)\shlwapi.lib \
# $(SDK_LIB_PATH)\Ws2_32.lib \
#RUN_WPP= $(SOURCES) -dll -scan:internal.h NTTARGETFILE1=$(OBJ_PATH)\$(O)\BixVReader.inf
TARGET_DESTINATION=wudf #
# This sets up the WPP preprocessor and tells it to scan internal.h to find
# the trace function definition that's in there.
#
#RUN_WPP= $(SOURCES) -dll -scan:internal.h
TARGET_DESTINATION=wudf

View File

@@ -0,0 +1,80 @@
;
; VirtualCardReader.inf
;
[Version]
Signature="$Windows NT$"
Class=SmartCardReader
ClassGuid={50dd5230-ba8a-11d1-bf5d-0000f805f530}
Provider=%MSFTUMDF%
CatalogFile=WUDF.cat
DriverVer=11/22/2010,6.1.7600.16385
[Manufacturer]
%MSFTUMDF%=Microsoft,NT$ARCH$
[Microsoft.NT$ARCH$]
%ReaderDeviceName%=VReader_Install,root\BixVirtualReader
; =================== Virtual Reader Device ==================================
[VReader_Install.NT]
CopyFiles=UMDriverCopy
[VReader_Install.NT.hw]
[VReader_Install.NT.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall
[VReader_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles
[VReader_Install.NT.Wdf]
UmdfService=BixVReader,UMDFVReader_Install
UmdfServiceOrder=BixVReader
UmdfKernelModeClientPolicy=AllowKernelModeClients
; =================== UMDF Service Install section ===================
[UMDFVReader_Install]
UmdfLibraryVersion=$UMDFVERSION$
ServiceBinary=%12%\UMDF\BixVReader.dll
DriverCLSID={d4112073-d09b-458f-a5aa-35ef21eef5de}
[WUDFRD_ServiceInstall]
DisplayName = %WudfRdDisplayName%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WUDFRd.sys
LoadOrderGroup = Base
[SourceDisksFiles]
BixVReader.dll=1
WudfUpdate_01009.dll=1
[SourceDisksNames]
1 = %MediaDescription%
[CoInstallers_CopyFiles]
WudfUpdate_$UMDFCOINSTALLERVERSION$.dll
[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WUDFUpdate_$UMDFCOINSTALLERVERSION$.dll"
[DestinationDirs]
UMDriverCopy=12,UMDF ; copy to driversMdf
CoInstallers_CopyFiles=11
[UMDriverCopy]
BixVReader.dll
; =================== Generic ==================================
[Strings]
MSFTUMDF="Fabio Ottavi - developer"
MediaDescription="Bix Virtual Card Reader disk 1"
WudfRdDisplayName="Bix UMDF Virtual Smart Card Reader for ScardVisual"
ReaderDeviceName="Bix Virtual Smart Card Reader"

View File

@@ -0,0 +1,7 @@
#
# Build using BUILD.EXE (Do not edit this section of this file, edit SOURCES)
#
MINIMUM_NT_TARGET_VERSION=0x501
!INCLUDE $(NTMAKEENV)\makefile.def

View File

@@ -0,0 +1,8 @@
.SUFFIXES: .inx
STAMP=stampinf
.inx{$(OBJ_PATH)\$(O)}.inf:
copy $(@B).inx $@
$(STAMP) -f $@ -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -u $(UMDF_VERSION_MAJOR).$(UMDF_VERSION_MINOR).0

View File

@@ -0,0 +1,79 @@
#
# UMDF_VERSION_MAJOR controls the headers that the driver uses.
# UMDF_VERSION_MAJOR + UMDF_VERSION_MINOR control which version
# of UMDF the driver is bound to in the INF and which
# update coinstaller it requires (through stampinf).
#
UMDF_VERSION_MAJOR=1
UMDF_VERSION_MINOR=9
KMDF_VERSION_MAJOR=1
KMDF_VERSION_MINOR=9
TARGETNAME=BixVReader
TARGETTYPE=DYNLINK
USE_ATL = 1
USE_STL = 1
ATL_VER = 71
USE_MSVCRT = 1
USE_NATIVE_EH = 1
C_DEFINES = $(C_DEFINES) /D_UNICODE /DUNICODE
WIN32_WINNT_VERSION=$(LATEST_WIN32_WINNT_VERSION)
_NT_TARGET_VERSION=$(_NT_TARGET_VERSION_WINXP)
NTDDI_VERSION=$(LATEST_NTDDI_VERSION)
DLLENTRY=_DllMainCRTStartup
DLLDEF=..\exports.def
SOURCES=\
..\BixVReader.rc \
..\driver.cpp \
..\device.cpp \
..\reader.cpp \
..\pipereader.cpp \
..\tcpipreader.cpp \
..\..\..\src\vpcd\vpcd.c \
..\vpcdreader.cpp \
..\queue.cpp \
..\memory.cpp \
..\sectionLocker.cpp \
..\DllMain.cpp \
..\VirtualSCReader.idl
INCLUDES= $(INCLUDES); \
$(SDK_INC_PATH); \
$(DDK_INC_PATH); \
$(UMDF_INC_PATH)\10;
MSC_WARNING_LEVEL=/W4 /WX
TARGETLIBS=\
$(SDK_LIB_PATH)\strsafe.lib \
$(SDK_LIB_PATH)\kernel32.lib \
$(SDK_LIB_PATH)\ole32.lib \
$(SDK_LIB_PATH)\oleaut32.lib \
$(SDK_LIB_PATH)\uuid.lib \
$(SDK_LIB_PATH)\user32.lib \
$(SDK_LIB_PATH)\advapi32.lib \
$(SDK_LIB_PATH)\shlwapi.lib \
$(SDK_LIB_PATH)\Ws2_32.lib \
NTTARGETFILE1=$(OBJ_PATH)\$(O)\BixVReader.inf
#
# This sets up the WPP preprocessor and tells it to scan internal.h to find
# the trace function definition that's in there.
#
#RUN_WPP= $(SOURCES) -dll -scan:internal.h
TARGET_DESTINATION=wudf

View File

@@ -0,0 +1,331 @@
#include "internal.h"
#include "VirtualSCReader.h"
#include "queue.h"
#include "device.h"
#include "driver.h"
#include <stdio.h>
#include <winscard.h>
#include "memory.h"
#include "SectionLocker.h"
HRESULT
CMyDevice::CreateInstance(
__in IWDFDriver *FxDriver,
__in IWDFDeviceInitialize * FxDeviceInit
)
/*++
Routine Description:
This method creates and initializs an instance of the virtual smart card reader driver's
device callback object.
Arguments:
FxDeviceInit - the settings for the device.
Device - a location to store the referenced pointer to the device object.
Return Value:
Status
--*/
{
inFunc
SectionLogger a(__FUNCTION__);
CComObject<CMyDevice>* device = NULL;
HRESULT hr;
OutputDebugString(L"[BixVReader]CreateInstance"); //
// Allocate a new instance of the device class.
//
hr = CComObject<CMyDevice>::CreateInstance(&device);
if (device==NULL)
{
return E_OUTOFMEMORY;
}
//
// Initialize the instance.
//
device->AddRef();
OutputDebugString(L"[BixVReader]SetLockingConstraint"); //
FxDeviceInit->SetLockingConstraint(WdfDeviceLevel);
CComPtr<IUnknown> spCallback;
OutputDebugString(L"[BixVReader]QueryInterface"); //
hr = device->QueryInterface(IID_IUnknown, (void**)&spCallback);
CComPtr<IWDFDevice> spIWDFDevice;
if (SUCCEEDED(hr))
{
OutputDebugString(L"[BixVReader]CreateDevice"); //
hr = FxDriver->CreateDevice(FxDeviceInit, spCallback, &spIWDFDevice);
}
device->numInstances=GetPrivateProfileInt(L"Driver",L"NumReaders",1,L"BixVReader.ini");
WSADATA wsaData;
int iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
if (iResult != NO_ERROR) {
OutputDebugString(L"[BixVReader]Error at WSAStartup()\n");
}
for (int i=0;i<device->numInstances;i++) {
OutputDebugString(L"[BixVReader]CreateDeviceInterface"); //
wchar_t name[10];
swprintf(name,L"DEV%i",i);
if (spIWDFDevice->CreateDeviceInterface(&SmartCardReaderGuid,name)!=0)
OutputDebugString(L"[BixVReader]CreateDeviceInterface Failed");
}
SAFE_RELEASE(device);
return hr;
}
void CMyDevice::ProcessIoControl(__in IWDFIoQueue* pQueue,
__in IWDFIoRequest* pRequest,
__in ULONG ControlCode,
SIZE_T inBufSize,
SIZE_T outBufSize)
{
inFunc
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pQueue);
wchar_t log[300];
swprintf(log,L"[BixVReader][IOCT]IOCTL %08X - In %i Out %i",ControlCode,inBufSize,outBufSize);
OutputDebugString(log);
//SectionLocker lock(m_RequestLock);
int instance=0;
{
CComPtr<IWDFFile> pFileObject;
pRequest->GetFileObject(&pFileObject);
if (pFileObject != NULL)
{
DWORD logLen=300;
pFileObject->RetrieveFileName(log,&logLen);
instance=_wtoi(log+(logLen-2));
}
}
Reader &reader=*readers[instance];
if (ControlCode==IOCTL_SMARTCARD_GET_ATTRIBUTE) {
reader.IoSmartCardGetAttribute(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_IS_PRESENT) {
reader.IoSmartCardIsPresent(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_GET_STATE) {
reader.IoSmartCardGetState(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_IS_ABSENT) {
reader.IoSmartCardIsAbsent(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_POWER) {
reader.IoSmartCardPower(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_SET_ATTRIBUTE) {
reader.IoSmartCardSetAttribute(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_SET_PROTOCOL) {
reader.IoSmartCardSetProtocol(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_TRANSMIT) {
reader.IoSmartCardTransmit(pRequest,inBufSize,outBufSize);
return;
}
swprintf(log,L"[BixVReader][IOCT]ERROR_NOT_SUPPORTED:%08X",ControlCode);
OutputDebugString(log);
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
return;
}
DWORD WINAPI ServerFunc(Reader *reader) {
return reader->startServer();
}
/////////////////////////////////////////////////////////////////////////
//
// CMyDevice::OnPrepareHardware
//
// Called by UMDF to prepare the hardware for use.
//
// Parameters:
// pWdfDevice - pointer to an IWDFDevice object representing the
// device
//
// Return Values:
// S_OK: success
//
/////////////////////////////////////////////////////////////////////////
HRESULT CMyDevice::OnPrepareHardware(
__in IWDFDevice* pWdfDevice
)
{
inFunc
SectionLogger a(__FUNCTION__);
// Store the IWDFDevice pointer
m_pWdfDevice = pWdfDevice;
// Configure the default IO Queue
HRESULT hr = CMyQueue::CreateInstance(m_pWdfDevice, this);
return hr;
}
/////////////////////////////////////////////////////////////////////////
//
// CMyDevice::OnReleaseHardware
//
// Called by WUDF to uninitialize the hardware.
//
// Parameters:
// pWdfDevice - pointer to an IWDFDevice object for the device
//
// Return Values:
// S_OK:
//
/////////////////////////////////////////////////////////////////////////
HRESULT CMyDevice::OnReleaseHardware(
__in IWDFDevice* pWdfDevice
)
{
inFunc
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
// Release the IWDFDevice handle, if it matches
if (pWdfDevice == m_pWdfDevice.p)
{
m_pWdfDevice.Release();
}
return S_OK;
}
HRESULT CMyDevice::OnD0Entry(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE previousState) {
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
UNREFERENCED_PARAMETER(previousState);
numInstances=GetPrivateProfileInt(L"Driver",L"NumReaders",1,L"BixVReader.ini");
readers.resize(numInstances);
for (int i=0;i<numInstances;i++) {
wchar_t section[300];
char sectionA[300];
swprintf(section,L"Reader%i",i);
sprintf(sectionA,"Reader%i",i);
int rpcType=GetPrivateProfileInt(section,L"RPC_TYPE",0,L"BixVReader.ini");
if (rpcType==0)
readers[i]=new PipeReader();
else if (rpcType==1)
readers[i]=new TcpIpReader();
else if (rpcType==2)
readers[i]=new VpcdReader();
readers[i]->instance=i;
readers[i]->device=this;
GetPrivateProfileStringA(sectionA,"VENDOR_NAME","Bix",readers[i]->vendorName,sizeof readers[i]->vendorName,"BixVReader.ini");
GetPrivateProfileStringA(sectionA,"VENDOR_IFD_TYPE","VIRTUAL_CARD_READER",readers[i]->vendorIfdType,sizeof readers[i]->vendorIfdType,"BixVReader.ini");
readers[i]->deviceUnit=GetPrivateProfileInt(section,L"DEVICE_UNIT",i,L"BixVReader.ini");
readers[i]->protocol=0;
readers[i]->init(section);
DWORD pipeThreadID;
readers[i]->serverThread=CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ServerFunc,readers[i],0,&pipeThreadID);
}
return S_OK;
}
HRESULT CMyDevice::OnD0Exit(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE newState) {
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
UNREFERENCED_PARAMETER(newState);
// dovrei fermare tutti i thread in ascolto dei lettori
shutDown();
return S_OK;
}
void CMyDevice::shutDown() {
SectionLogger a(__FUNCTION__);
for (int i=0;i<numInstances;i++) {
readers[i]->shutdown();
delete readers[i];
}
numInstances=0;
}
HRESULT CMyDevice::OnQueryRemove(IN IWDFDevice* pWdfDevice) {
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
OutputDebugString(L"[BixVReader]OnQueryRemove");
shutDown();
return S_OK;
}
HRESULT CMyDevice::OnQueryStop(IN IWDFDevice* pWdfDevice) {
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
OutputDebugString(L"[BixVReader]OnQueryStop");
shutDown();
return S_OK;
}
void CMyDevice::OnSurpriseRemoval(IN IWDFDevice* pWdfDevice) {
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pWdfDevice);
OutputDebugString(L"[BixVReader]OnSurpriseRemoval");
shutDown();
}
STDMETHODIMP_ (void) CMyDevice::OnCancel(IN IWDFIoRequest* pWdfRequest) {
SectionLogger a(__FUNCTION__);
wchar_t log[300];
SectionLocker lock(m_RequestLock);
int instance=0;
{
CComPtr<IWDFFile> pFileObject;
pWdfRequest->GetFileObject(&pFileObject);
if (pFileObject != NULL)
{
DWORD logLen=300;
pFileObject->RetrieveFileName(log,&logLen);
instance=_wtoi(log+(logLen-2));
}
}
Reader &reader=*readers[instance];
if (pWdfRequest==reader.waitRemoveIpr) {
OutputDebugString(L"[BixVReader]Cancel Remove");
reader.waitRemoveIpr=NULL;
}
else if (pWdfRequest==reader.waitInsertIpr) {
OutputDebugString(L"[BixVReader]Cancel Insert");
reader.waitInsertIpr=NULL;
}
pWdfRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
}

View File

@@ -1,112 +1,98 @@
#pragma once
#pragma once #include <vector>
#include "reader.h"
//
// Class for the iotrace driver. //
// // Class for the iotrace driver.
//
class ATL_NO_VTABLE CMyDevice : class CMyDevice;
public CComObjectRootEx<CComMultiThreadModel>,
public IPnpCallbackHardware,
public IPnpCallback, class ATL_NO_VTABLE CMyDevice :
public IRequestCallbackCancel public CComObjectRootEx<CComMultiThreadModel>,
{ public IPnpCallbackHardware,
public: public IPnpCallback,
~CMyDevice() {} public IRequestCallbackCancel
{
DECLARE_NOT_AGGREGATABLE(CMyDevice) public:
~CMyDevice() {
BEGIN_COM_MAP(CMyDevice) DeleteCriticalSection(&m_RequestLock);
COM_INTERFACE_ENTRY(IPnpCallbackHardware) }
COM_INTERFACE_ENTRY(IPnpCallback)
COM_INTERFACE_ENTRY(IRequestCallbackCancel) DECLARE_NOT_AGGREGATABLE(CMyDevice)
END_COM_MAP()
BEGIN_COM_MAP(CMyDevice)
CMyDevice(VOID) COM_INTERFACE_ENTRY(IPnpCallbackHardware)
{ COM_INTERFACE_ENTRY(IPnpCallback)
m_pWdfDevice = NULL; COM_INTERFACE_ENTRY(IRequestCallbackCancel)
waitRemoveIpr=NULL; END_COM_MAP()
waitInsertIpr=NULL;
ctx = NULL; CMyDevice(VOID)
pipe=NULL; {
eventpipe=NULL; InitializeCriticalSection(&m_RequestLock);
outdata = NULL; m_pWdfDevice = NULL;
outlength = 0; }
indata = NULL;
inlength = 0; //
} // Private data members.
//
// private:
// Private data members.
// CComPtr<IWDFDevice> m_pWdfDevice;
private: std::vector<Reader*> readers;
int numInstances;
CComPtr<IWDFDevice> m_pWdfDevice;
CComPtr<IWDFIoRequest> waitRemoveIpr,waitInsertIpr; //
struct vicc_ctx *ctx; // Private methods.
BYTE *outdata; //
SIZE_T outlength;
BYTE *indata; private:
SIZE_T inlength;
HANDLE pipe;
HANDLE eventpipe; HRESULT ConfigureQueue();
// //
// Private methods. // Public methods
// //
public:
private:
CRITICAL_SECTION m_RequestLock;
HRESULT ConfigureQueue(); //
// The factory method used to create an instance of this driver.
// //
// Public methods
// static
public: HRESULT CreateInstance(
__in IWDFDriver *FxDriver,
// __in IWDFDeviceInitialize *FxDeviceInit
// The factory method used to create an instance of this driver. );
//
//
static // COM methods
HRESULT CreateInstance( //
__in IWDFDriver *FxDriver, public:
__in IWDFDeviceInitialize *FxDeviceInit
); //
// IUnknown methods.
// //
// COM methods
// void ProcessIoControl(__in IWDFIoQueue* pQueue,
public: __in IWDFIoRequest* pRequest,
__in ULONG ControlCode,
// SIZE_T InputBufferSizeInBytes,
// IUnknown methods. SIZE_T OutputBufferSizeInBytes);
//
STDMETHOD_ (HRESULT, OnPrepareHardware)(__in IWDFDevice* pWdfDevice);
void ProcessIoControl(__in IWDFIoQueue* pQueue, STDMETHOD_ (HRESULT, OnReleaseHardware)(__in IWDFDevice* pWdfDevice);
__in IWDFIoRequest* pRequest, STDMETHOD_ (HRESULT, OnD0Entry)(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE previousState);
__in ULONG ControlCode, STDMETHOD_ (HRESULT, OnD0Exit )(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE newState);
SIZE_T InputBufferSizeInBytes, STDMETHOD_ (HRESULT, OnQueryRemove )(IN IWDFDevice* pWdfDevice);
SIZE_T OutputBufferSizeInBytes); STDMETHOD_ (HRESULT, OnQueryStop)(IN IWDFDevice* pWdfDevice);
STDMETHOD_ (void, OnSurpriseRemoval)(IN IWDFDevice* pWdfDevice);
STDMETHOD_ (HRESULT, OnPrepareHardware)(__in IWDFDevice* pWdfDevice); STDMETHOD_ (void, OnCancel)(IN IWDFIoRequest* pWdfRequest);
STDMETHOD_ (HRESULT, OnReleaseHardware)(__in IWDFDevice* pWdfDevice);
STDMETHOD_ (HRESULT, OnD0Entry)(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE previousState); void shutDown();
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 IoSmartCardGetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardIsPresent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardGetState(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardIsAbsent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardPower(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardSetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize);
void shutDown();
};

View File

@@ -1,69 +1,75 @@
#include "internal.h"
#include "internal.h" #include "VirtualSCReader.h"
#include "VirtualSCReader.h" #include "driver.h"
#include "driver.h" #include "device.h"
#include "device.h" #include <stdio.h>
#include <stdio.h> #include "SectionLocker.h"
CMyDriver::CMyDriver() CMyDriver::CMyDriver()
{ {
} inFunc
}
/////////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////////
// CMyDriver::OnDeviceAdd //
// // CMyDriver::OnDeviceAdd
// The framework call this function when device is detected. This driver //
// creates a device callback object // The framework call this function when device is detected. This driver
// // creates a device callback object
// Parameters: //
// pDriver - pointer to an IWDFDriver object // Parameters:
// pDeviceInit - pointer to a device initialization object // pDriver - pointer to an IWDFDriver object
// // pDeviceInit - pointer to a device initialization object
// Return Values: //
// S_OK: device initialized successfully // Return Values:
// // S_OK: device initialized successfully
///////////////////////////////////////////////////////////////////////// //
HRESULT CMyDriver::OnDeviceAdd( /////////////////////////////////////////////////////////////////////////
__in IWDFDriver* pDriver, HRESULT CMyDriver::OnDeviceAdd(
__in IWDFDeviceInitialize* pDeviceInit __in IWDFDriver* pDriver,
) __in IWDFDeviceInitialize* pDeviceInit
{ )
inFunc; {
HRESULT hr = CMyDevice::CreateInstance(pDriver, pDeviceInit); inFunc
SectionLogger a(__FUNCTION__);
return hr; HRESULT hr = CMyDevice::CreateInstance(pDriver, pDeviceInit);
}
///////////////////////////////////////////////////////////////////////// return hr;
// }
// CMyDriver::OnInitialize /////////////////////////////////////////////////////////////////////////
// //
// The framework calls this function just after loading the driver. The driver // CMyDriver::OnInitialize
// can perform any global, device independent intialization in this routine. //
// // The framework calls this function just after loading the driver. The driver
///////////////////////////////////////////////////////////////////////// // can perform any global, device independent intialization in this routine.
HRESULT CMyDriver::OnInitialize( //
__in IWDFDriver* pDriver /////////////////////////////////////////////////////////////////////////
) HRESULT CMyDriver::OnInitialize(
{ __in IWDFDriver* pDriver
UNREFERENCED_PARAMETER(pDriver); )
return S_OK; {
} inFunc
SectionLogger a(__FUNCTION__);
///////////////////////////////////////////////////////////////////////// UNREFERENCED_PARAMETER(pDriver);
// return S_OK;
// CMyDriver::OnDeinitialize }
//
// The framework calls this function just before de-initializing itself. All /////////////////////////////////////////////////////////////////////////
// WDF framework resources should be released by driver before returning //
// from this call. // CMyDriver::OnDeinitialize
// //
///////////////////////////////////////////////////////////////////////// // The framework calls this function just before de-initializing itself. All
void CMyDriver::OnDeinitialize( // WDF framework resources should be released by driver before returning
__in IWDFDriver* pDriver // from this call.
) //
{ /////////////////////////////////////////////////////////////////////////
UNREFERENCED_PARAMETER(pDriver); void CMyDriver::OnDeinitialize(
return; __in IWDFDriver* pDriver
} )
{
inFunc
SectionLogger a(__FUNCTION__);
UNREFERENCED_PARAMETER(pDriver);
return;
}

View File

@@ -1,37 +1,37 @@
#pragma once #pragma once
// //
// This class handles driver events for the skeleton sample. In particular // This class handles driver events for the skeleton sample. In particular
// it supports the OnDeviceAdd event, which occurs when the driver is called // it supports the OnDeviceAdd event, which occurs when the driver is called
// to setup per-device handlers for a new device stack. // to setup per-device handlers for a new device stack.
// //
class ATL_NO_VTABLE CMyDriver : class ATL_NO_VTABLE CMyDriver :
public CComObjectRootEx<CComMultiThreadModel>, public CComObjectRootEx<CComMultiThreadModel>,
public CComCoClass<CMyDriver, &CLSID_VirtualSCReaderDriver>, public CComCoClass<CMyDriver, &CLSID_VirtualSCReaderDriver>,
public IDriverEntry public IDriverEntry
{ {
public: public:
CMyDriver(); CMyDriver();
DECLARE_NO_REGISTRY() DECLARE_NO_REGISTRY()
DECLARE_CLASSFACTORY() DECLARE_CLASSFACTORY()
DECLARE_NOT_AGGREGATABLE(CMyDriver) DECLARE_NOT_AGGREGATABLE(CMyDriver)
BEGIN_COM_MAP(CMyDriver) BEGIN_COM_MAP(CMyDriver)
COM_INTERFACE_ENTRY(IDriverEntry) COM_INTERFACE_ENTRY(IDriverEntry)
END_COM_MAP() END_COM_MAP()
public: public:
// //
// IDriverEntry // IDriverEntry
// //
STDMETHOD (OnInitialize)(__in IWDFDriver* pDriver); STDMETHOD (OnInitialize)(__in IWDFDriver* pDriver);
STDMETHOD (OnDeviceAdd)(__in IWDFDriver* pDriver, __in IWDFDeviceInitialize* pDeviceInit); STDMETHOD (OnDeviceAdd)(__in IWDFDriver* pDriver, __in IWDFDeviceInitialize* pDeviceInit);
STDMETHOD_ (void, OnDeinitialize)(__in IWDFDriver* pDriver); STDMETHOD_ (void, OnDeinitialize)(__in IWDFDriver* pDriver);
}; };
OBJECT_ENTRY_AUTO(__uuidof(VirtualSCReaderDriver), CMyDriver) OBJECT_ENTRY_AUTO(__uuidof(VirtualSCReaderDriver), CMyDriver)

View File

@@ -1,15 +1,15 @@
; Skeleton.def : Declares the module parameters. ; Skeleton.def : Declares the module parameters.
; ;
; TODO: Change the library name here to match your binary name. ; TODO: Change the library name here to match your binary name.
; ;
LIBRARY "UMDFSkeleton.DLL" LIBRARY "UMDFSkeleton.DLL"
EXPORTS EXPORTS
DllCanUnloadNow PRIVATE DllCanUnloadNow PRIVATE
DllGetClassObject PRIVATE DllGetClassObject PRIVATE
DllRegisterServer PRIVATE DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE DllUnregisterServer PRIVATE

View File

@@ -1,74 +1,75 @@
#pragma once #pragma once
#include <windows.h> #include <windows.h>
#include <atlbase.h> #include <atlbase.h>
#include <atlcom.h> #include <atlcom.h>
#include <atlstr.h> #include <atlstr.h>
__user_driver; // Macro letting the compiler know this is not a kernel driver (this will help surpress needless warnings) //__user_driver; // Macro letting the compiler know this is not a kernel driver (this will help surpress needless warnings)
// Common WPD and WUDF headers // Common WPD and WUDF headers
#ifndef ARRAY_SIZE #ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) #define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))
#endif #endif
#ifndef SAFE_RELEASE #ifndef SAFE_RELEASE
#define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }} #define SAFE_RELEASE(p) {if ((p)) { (p)->Release(); (p) = NULL; }}
#endif #endif
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth #define STATUS_SUCCESS ((NTSTATUS)0x00000000L) // ntsubauth
#define STATUS_NO_MEDIA ((NTSTATUS)0xC0000178L) #define STATUS_NO_MEDIA ((NTSTATUS)0xC0000178L)
#define STATUS_INVALID_DEVICE_STATE ((NTSTATUS)0xC0000184L) #define STATUS_INVALID_DEVICE_STATE ((NTSTATUS)0xC0000184L)
// //
// Include the WUDF DDI // Include the WUDF DDI
// //
#include <devioctl.h> #include <devioctl.h>
#include <initguid.h> #include <initguid.h>
#include <propkeydef.h> #include <propkeydef.h>
#include <propvarutil.h> #include <propvarutil.h>
#include "PortableDeviceTypes.h" #include "PortableDeviceTypes.h"
#include "PortableDeviceClassExtension.h" #include "PortableDeviceClassExtension.h"
#include "PortableDevice.h" #include "PortableDevice.h"
#include "wudfddi.h" #include "wudfddi.h"
// //
// Use specstrings for in/out annotation of function parameters. // Use specstrings for in/out annotation of function parameters.
// //
#include "specstrings.h" #include "specstrings.h"
// //
// Forward definitions of classes in the other header files. // Forward definitions of classes in the other header files.
// //
typedef class CMyDriver *PCMyDriver; typedef class CMyDriver *PCMyDriver;
typedef class CMyDevice *PCMyDevice; typedef class CMyDevice *PCMyDevice;
// //
DEFINE_GUID(SmartCardReaderGuid, 0x50DD5230, 0xBA8A, 0x11D1, 0xBF,0x5D,0x00,0x00,0xF8,0x05,0xF5,0x30); DEFINE_GUID(SmartCardReaderGuid, 0x50DD5230, 0xBA8A, 0x11D1, 0xBF,0x5D,0x00,0x00,0xF8,0x05,0xF5,0x30);
// //
// Include the type specific headers. // Include the type specific headers.
// //
class funcTrace { class funcTrace {
public: public:
wchar_t funcN[500]; wchar_t funcN[500];
funcTrace (char *func) { funcTrace (char *func) {
wchar_t funcName[500]; wchar_t funcName[500];
wsprintf(funcN,L"%S",func); wsprintf(funcN,L"%S",func);
wsprintf(funcName,L"IN -> %s\n",funcN); wsprintf(funcName,L"[BixVReader]IN -> %s",funcN);
OutputDebugString(funcName); OutputDebugString(funcName);
} }
~funcTrace () { ~funcTrace () {
wchar_t funcName[500]; wchar_t funcName[500];
wsprintf(funcName,L"OUT -> %s\n",funcN); wsprintf(funcName,L"[BixVReader]OUT -> %s",funcN);
OutputDebugString(funcName); OutputDebugString(funcName);
} }
}; };
#define inFunc funcTrace _ftrace(__FUNCTION__); //#define inFunc funcTrace _ftrace(__FUNCTION__);
#define inFunc

View File

@@ -1,103 +1,83 @@
#include "memory.h" #include "memory.h"
#include "SectionLocker.h"
bool getBuffer(IWDFIoRequest *pRequest, BYTE **buffer, SIZE_T *bufferLen)
{ bool getBuffer(IWDFIoRequest* pRequest,BYTE *buffer,int *bufferLen) {
IWDFMemory *inmem=NULL;
IWDFMemory *inmem=NULL;
if (!pRequest || !buffer || !bufferLen) { pRequest->GetInputMemory(&inmem);
OutputDebugString(L"wrong arguments"); if (inmem==NULL) {
return false; OutputDebugString(L"GetInputMemory failed");
} return false;
}
pRequest->GetInputMemory(&inmem); else {
if (inmem==NULL) { SIZE_T size;
OutputDebugString(L"GetInputMemory failed"); void *data=inmem->GetDataBuffer(&size);
return false; memcpy(buffer,data,size);
} else { (*bufferLen)=(int)size;
SIZE_T size; inmem->Release();
void *data=inmem->GetDataBuffer(&size); return true;
if (*bufferLen < size) { }
BYTE *p = (BYTE *) realloc(*buffer, size); }
if (!p) { void setBuffer(CMyDevice *device,IWDFIoRequest* pRequest,BYTE *result,int inSize) {
OutputDebugString(L"realloc failed"); IWDFMemory *outmem=NULL;
inmem->Release(); pRequest->GetOutputMemory (&outmem);
return false; if (outmem==NULL) {
} SectionLocker lock(device->m_RequestLock);
*buffer = p; OutputDebugString(L"GetOutputMemory failed");
} pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE));
}
memcpy(*buffer, data, size); else {
(*bufferLen) = size; SectionLocker lock(device->m_RequestLock);
outmem->CopyFromBuffer(0,result,inSize);
inmem->Release(); outmem->Release();
return true; pRequest->CompleteWithInformation(0,(SIZE_T)inSize);
} }
} }
void completeWithBuffer(IWDFIoRequest* pRequest,BYTE *result,int inSize) { void setString(CMyDevice *device,IWDFIoRequest* pRequest,char *result,int outSize) {
IWDFMemory *outmem=NULL; IWDFMemory *outmem=NULL;
pRequest->GetOutputMemory (&outmem); pRequest->GetOutputMemory (&outmem);
if (outmem==NULL) { if (outmem==NULL) {
OutputDebugString(L"GetOutputMemory failed"); SectionLocker lock(device->m_RequestLock);
pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE)); OutputDebugString(L"GetOutputMemory failed");
} pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE));
else { }
outmem->CopyFromBuffer(0,result,inSize); else {
outmem->Release(); SectionLocker lock(device->m_RequestLock);
pRequest->CompleteWithInformation(0,(SIZE_T)inSize); int size=min(outSize,(int)strlen(result)+1);
} outmem->CopyFromBuffer(0,result,size);
} outmem->Release();
pRequest->CompleteWithInformation(0,(SIZE_T)size);
void completeWithString(IWDFIoRequest* pRequest,char *result,int outSize) { }
IWDFMemory *outmem=NULL; }
pRequest->GetOutputMemory (&outmem); void setInt(CMyDevice *device,IWDFIoRequest* pRequest,DWORD result) {
if (outmem==NULL) { IWDFMemory *outmem=NULL;
OutputDebugString(L"GetOutputMemory failed"); pRequest->GetOutputMemory (&outmem);
pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE)); if (outmem==NULL) {
} SectionLocker lock(device->m_RequestLock);
else { OutputDebugString(L"GetOutputMemory failed");
int size=min(outSize,(int)strlen(result)+1); pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE));
outmem->CopyFromBuffer(0,result,size); }
outmem->Release(); else {
pRequest->CompleteWithInformation(0,(SIZE_T)size); SectionLocker lock(device->m_RequestLock);
} outmem->CopyFromBuffer(0,&result,sizeof(result));
} outmem->Release();
void completeWithInteger(IWDFIoRequest* pRequest,DWORD result) { pRequest->CompleteWithInformation(0,sizeof(result));
IWDFMemory *outmem=NULL; }
pRequest->GetOutputMemory (&outmem); }
if (outmem==NULL) { DWORD getInt(IWDFIoRequest* pRequest) {
OutputDebugString(L"GetOutputMemory failed");
pRequest->Complete(HRESULT_FROM_WIN32(ERROR_GEN_FAILURE)); IWDFMemory *inmem=NULL;
} pRequest->GetInputMemory(&inmem);
else { if (inmem==NULL) {
outmem->CopyFromBuffer(0,&result,sizeof(result)); OutputDebugString(L"GetInputMemory failed");
outmem->Release(); return 0xffffffff;
pRequest->CompleteWithInformation(0,sizeof(result)); }
} else {
} SIZE_T size;
void *data=inmem->GetDataBuffer(&size);
bool getInteger(IWDFIoRequest *pRequest, DWORD *integer) DWORD d=*(DWORD *)data;
{ inmem->Release();
IWDFMemory *inmem=NULL; return d;
}
if (!pRequest || !integer) { }
OutputDebugString(L"wrong arguments");
return false;
}
pRequest->GetInputMemory(&inmem);
if (inmem==NULL) {
OutputDebugString(L"GetInputMemory failed");
return false;
} else {
SIZE_T size;
void *data=inmem->GetDataBuffer(&size);
if (size != sizeof(*integer)) {
OutputDebugString(L"not enough memory failed");
return false;
}
*integer=*(DWORD *)data;
inmem->Release();
return true;
}
}

View File

@@ -0,0 +1,10 @@
#pragma once
#include "internal.h"
#include "device.h"
bool getBuffer(IWDFIoRequest* pRequest,BYTE *buffer,int *bufferLen);
void setString(CMyDevice *device,IWDFIoRequest* pRequest,char *result,int outSize);
void setBuffer(CMyDevice *device,IWDFIoRequest* pRequest,BYTE *result,int inSize);
void setInt(CMyDevice *device,IWDFIoRequest* pRequest,DWORD result);
DWORD getInt(IWDFIoRequest* pRequest);

View File

@@ -0,0 +1,47 @@
#include "sectionLocker.h"
void *ShowMe=NULL;
SectionLocker::SectionLocker(CRITICAL_SECTION &critsection,char *function,int line,void* object) {
critsection;
this->section=&critsection;
Function=function;
Line=line;
Object=object;
DWORD start=GetTickCount();
if (TryEnterCriticalSection(section)==0) {
OutputDebugStringA("[BixVReader]RACE!");
char logBuffer[500];
sprintf(logBuffer,"[BixVReader]Richiesto da:Function:%s,Line:%i,Object:%x,Lock:%x",Function,Line,Object,section);
OutputDebugStringA(logBuffer);
ShowMe=section;
EnterCriticalSection(section);
DWORD end=GetTickCount();
sprintf(logBuffer,"[BixVReader]Elapsed:%i ms",end-start);
OutputDebugStringA(logBuffer);
}
}
SectionLocker::~SectionLocker() {
if (section==ShowMe) {
char logBuffer[500];
sprintf(logBuffer,"[BixVReader]Posseduto da:Function:%s,Line:%i,Object:%x,Lock:%x",Function,Line,Object,section);
OutputDebugStringA(logBuffer);
ShowMe=NULL;
}
LeaveCriticalSection(section);
}
SectionLogger::SectionLogger(char *section) {
section;
start=GetTickCount();
char logBuffer[500];
SectionName=section;
sprintf(logBuffer,"[BixVReader]Start section:%s",SectionName);
OutputDebugStringA(logBuffer);
}
SectionLogger::~SectionLogger() {
DWORD end=GetTickCount();
char logBuffer[500];
sprintf(logBuffer,"[BixVReader]End section:%s elapsed:%i",SectionName,end-start);
OutputDebugStringA(logBuffer);
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include "internal.h"
class SectionLocker {
char *Function;
int Line;
void *Object;
public:
CRITICAL_SECTION *section;
SectionLocker(CRITICAL_SECTION &critsection,char *function,int line,void* object);
//SectionLocker(CRITICAL_SECTION &section);
~SectionLocker();
};
class SectionLogger {
DWORD start;
char *SectionName;
public:
SectionLogger(char *section);
~SectionLogger();
};
#define lock(x) lockObj(x,__FUNCTION__,__LINE__,NULL)

View File

@@ -1,432 +0,0 @@
#include "vpcd.h"
#include "internal.h"
#include "VirtualSCReader.h"
#include "queue.h"
#include "device.h"
#include "driver.h"
#include <stdio.h>
#include <winscard.h>
#include "memory.h"
#include <Sddl.h>
HRESULT
CMyDevice::CreateInstance(
__in IWDFDriver *FxDriver,
__in IWDFDeviceInitialize * FxDeviceInit
)
/*++
Routine Description:
This method creates and initializs an instance of the virtual smart card reader driver's
device callback object.
Arguments:
FxDeviceInit - the settings for the device.
Device - a location to store the referenced pointer to the device object.
Return Value:
Status
--*/
{
inFunc;
CComObject<CMyDevice>* device = NULL;
HRESULT hr;
//
// Allocate a new instance of the device class.
//
hr = CComObject<CMyDevice>::CreateInstance(&device);
if (device==NULL)
{
return E_OUTOFMEMORY;
}
//
// Initialize the instance.
//
device->AddRef();
FxDeviceInit->SetLockingConstraint(WdfDeviceLevel);
CComPtr<IUnknown> spCallback;
hr = device->QueryInterface(IID_IUnknown, (void**)&spCallback);
CComPtr<IWDFDevice> spIWDFDevice;
if (SUCCEEDED(hr))
{
hr = FxDriver->CreateDevice(FxDeviceInit, spCallback, &spIWDFDevice);
}
if (spIWDFDevice->CreateDeviceInterface(&SmartCardReaderGuid,NULL)!=0)
OutputDebugString(L"CreateDeviceInterface Failed\n");
SAFE_RELEASE(device);
return hr;
}
void CMyDevice::IoSmartCardIsPresent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
if (vicc_present(ctx) == 1)
// there's a smart card present, so complete the request
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
else {
// there's no smart card present, so leave the request pending; it will be completed later
waitInsertIpr=pRequest;
IRequestCallbackCancel *callback;
QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
pRequest->MarkCancelable(callback);
callback->Release();
}
}
void CMyDevice::IoSmartCardGetState(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
if (vicc_present(ctx) == 1) {
OutputDebugString(L"[GSTA]SCARD_SPECIFIC\n");
completeWithInteger(pRequest, SCARD_SPECIFIC);
} else {
OutputDebugString(L"SCARD_ABSENT\n");
completeWithInteger(pRequest, SCARD_ABSENT);
}
}
void CMyDevice::IoSmartCardIsAbsent(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
if (vicc_present(ctx) == 0)
// there's no smart card present, so complete the request
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
else {
// there's a smart card present, so leave the request pending; it will be completed later
waitRemoveIpr=pRequest;
IRequestCallbackCancel *callback;
QueryInterface(__uuidof(IRequestCallbackCancel),(void**)&callback);
pRequest->MarkCancelable(callback);
callback->Release();
}
}
void CMyDevice::IoSmartCardPower(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
DWORD code;
if (!getInteger(pRequest, &code)) {
OutputDebugString(L"error getting code\n");
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
switch (code) {
case SCARD_COLD_RESET:
OutputDebugString(L"[POWR]SCARD_COLD_RESET\n");
vicc_poweroff(ctx);
vicc_poweron(ctx);
break;
case SCARD_WARM_RESET:
OutputDebugString(L"[POWR]SCARD_WARM_RESET\n");
vicc_reset(ctx);
break;
case SCARD_POWER_DOWN:
OutputDebugString(L"[POWR]SCARD_POWER_DOWN\n");
vicc_poweroff(ctx);
}
if (code==SCARD_COLD_RESET || code==SCARD_WARM_RESET) {
int ATRsize = vicc_getatr(ctx, &outdata);
if (ATRsize <= 0) {
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
outlength = ATRsize;
completeWithBuffer(pRequest,outdata,outlength);
} else {
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
}
}
void CMyDevice::IoSmartCardSetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
IWDFMemory *inmem=NULL;
pRequest->GetInputMemory(&inmem);
SIZE_T size;
BYTE *data=(BYTE *)inmem->GetDataBuffer(&size);
DWORD minCode=*(DWORD*)(data);
bool handled=false;
if (minCode==SCARD_ATTR_DEVICE_IN_USE) {
OutputDebugString(L"[SATT]SCARD_ATTR_DEVICE_IN_USE\n");
pRequest->CompleteWithInformation(STATUS_SUCCESS, 0);
handled=true;
}
inmem->Release();
if (!handled) {
OutputDebugString(L"[SATT]ERROR_NOT_SUPPORTED\n");
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
}
void CMyDevice::IoSmartCardTransmit(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
UNREFERENCED_PARAMETER(outBufSize);
inFunc;
if (!getBuffer(pRequest,&indata,&inlength)) {
pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0);
return;
}
if (((SCARD_IO_REQUEST*)indata)->dwProtocol!=SCARD_PROTOCOL_T1) {
pRequest->CompleteWithInformation(STATUS_INVALID_DEVICE_STATE, 0);
return;
}
int RespSize = vicc_transmit(ctx, inlength - sizeof(SCARD_IO_REQUEST), indata + sizeof(SCARD_IO_REQUEST), &outdata);
if (RespSize < 0)
{
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
outlength = RespSize;
BYTE *Resp = (BYTE *) malloc(outlength+sizeof(SCARD_IO_REQUEST));
if (!Resp) {
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
((SCARD_IO_REQUEST*)Resp)->cbPciLength=sizeof(SCARD_IO_REQUEST);
((SCARD_IO_REQUEST*)Resp)->dwProtocol=SCARD_PROTOCOL_T1;
memcpy(Resp + sizeof(SCARD_IO_REQUEST), outdata, outlength);
completeWithBuffer(pRequest,Resp,RespSize+sizeof(SCARD_IO_REQUEST));
}
void CMyDevice::IoSmartCardGetAttribute(IWDFIoRequest* pRequest,SIZE_T inBufSize,SIZE_T outBufSize) {
UNREFERENCED_PARAMETER(inBufSize);
DWORD code;
int ATRsize;
if (!getInteger(pRequest, &code)) {
OutputDebugString(L"error getting code\n");
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
switch(code) {
case SCARD_ATTR_CHARACTERISTICS:
// 0x00000000 No special characteristics
OutputDebugString(L"[GATT]SCARD_ATTR_CHARACTERISTICS\n");
completeWithInteger(pRequest,0);
return;
case SCARD_ATTR_VENDOR_NAME:
OutputDebugString(L"[GATT]SCARD_ATTR_VENDOR_NAME\n");
completeWithString(pRequest,"Virtual Smart Card Architecture",(int)outBufSize);
return;
case SCARD_ATTR_VENDOR_IFD_TYPE:
OutputDebugString(L"[GATT]SCARD_ATTR_VENDOR_IFD_TYPE\n");
completeWithString(pRequest,"Virtual PCD",(int)outBufSize);
return;
case SCARD_ATTR_DEVICE_UNIT:
OutputDebugString(L"[GATT]SCARD_ATTR_DEVICE_UNIT\n");
completeWithInteger(pRequest,0);
return;
case SCARD_ATTR_ATR_STRING:
OutputDebugString(L"[GATT]SCARD_ATTR_ATR_STRING\n");
ATRsize = vicc_getatr(ctx, &outdata);
if (ATRsize <= 0)
{
pRequest->CompleteWithInformation(STATUS_NO_MEDIA, 0);
return;
}
outlength = ATRsize;
completeWithBuffer(pRequest,outdata,outlength);
return;
case SCARD_ATTR_CURRENT_PROTOCOL_TYPE:
OutputDebugString(L"[GATT]SCARD_ATTR_CURRENT_PROTOCOL_TYPE\n");
completeWithInteger(pRequest,SCARD_PROTOCOL_T1); // T=1
return;
default:
OutputDebugString(L"[GATT]ERROR_NOT_SUPPORTED\n");
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
}
}
void CMyDevice::ProcessIoControl(__in IWDFIoQueue* pQueue,
__in IWDFIoRequest* pRequest,
__in ULONG ControlCode,
SIZE_T inBufSize,
SIZE_T outBufSize)
{
inFunc;
UNREFERENCED_PARAMETER(pQueue);
if (ControlCode==IOCTL_SMARTCARD_GET_ATTRIBUTE) {
IoSmartCardGetAttribute(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_IS_PRESENT) {
IoSmartCardIsPresent(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_GET_STATE) {
IoSmartCardGetState(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_IS_ABSENT) {
IoSmartCardIsAbsent(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_POWER) {
IoSmartCardPower(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_SET_ATTRIBUTE) {
IoSmartCardSetAttribute(pRequest,inBufSize,outBufSize);
return;
}
else if (ControlCode==IOCTL_SMARTCARD_TRANSMIT) {
IoSmartCardTransmit(pRequest,inBufSize,outBufSize);
return;
}
OutputDebugString(L"[IOCT]ERROR_NOT_SUPPORTED\n");
pRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED), 0);
return;
}
/////////////////////////////////////////////////////////////////////////
//
// CMyDevice::OnPrepareHardware
//
// Called by UMDF to prepare the hardware for use.
//
// Parameters:
// pWdfDevice - pointer to an IWDFDevice object representing the
// device
//
// Return Values:
// S_OK: success
//
/////////////////////////////////////////////////////////////////////////
HRESULT CMyDevice::OnPrepareHardware(
__in IWDFDevice* pWdfDevice
)
{
inFunc;
// Store the IWDFDevice pointer
m_pWdfDevice = pWdfDevice;
// Configure the default IO Queue
HRESULT hr = CMyQueue::CreateInstance(m_pWdfDevice, this);
ctx = vicc_init(NULL, VPCDPORT);
return hr;
}
/////////////////////////////////////////////////////////////////////////
//
// CMyDevice::OnReleaseHardware
//
// Called by WUDF to uninitialize the hardware.
//
// Parameters:
// pWdfDevice - pointer to an IWDFDevice object for the device
//
// Return Values:
// S_OK:
//
/////////////////////////////////////////////////////////////////////////
HRESULT CMyDevice::OnReleaseHardware(
__in IWDFDevice* pWdfDevice
)
{
inFunc;
UNREFERENCED_PARAMETER(pWdfDevice);
// Release the IWDFDevice handle, if it matches
if (pWdfDevice == m_pWdfDevice.p)
{
vicc_eject(ctx);
vicc_exit(ctx);
ctx = NULL;
m_pWdfDevice.Release();
}
return S_OK;
}
HRESULT CMyDevice::OnD0Entry(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE previousState) {
UNREFERENCED_PARAMETER(pWdfDevice);
UNREFERENCED_PARAMETER(previousState);
inFunc;
vicc_poweroff(ctx);
return S_OK;
}
HRESULT CMyDevice::OnD0Exit(IN IWDFDevice* pWdfDevice,IN WDF_POWER_DEVICE_STATE newState) {
UNREFERENCED_PARAMETER(pWdfDevice);
UNREFERENCED_PARAMETER(newState);
inFunc;
vicc_poweron(ctx);
return S_OK;
}
void CMyDevice::shutDown(){
if (waitRemoveIpr!=NULL) {
if (waitRemoveIpr->UnmarkCancelable()==S_OK)
waitRemoveIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitRemoveIpr=NULL;
}
if (waitInsertIpr!=NULL) {
if (waitInsertIpr->UnmarkCancelable()==S_OK)
waitInsertIpr->Complete(HRESULT_FROM_WIN32(ERROR_CANCELLED));
waitInsertIpr=NULL;
}
free(outdata);
outdata = NULL;
outlength = 0;
free(indata);
indata = NULL;
inlength = 0;
}
HRESULT CMyDevice::OnQueryRemove(IN IWDFDevice* pWdfDevice) {
UNREFERENCED_PARAMETER(pWdfDevice);
inFunc;
shutDown();
return S_OK;
}
HRESULT CMyDevice::OnQueryStop(IN IWDFDevice* pWdfDevice) {
UNREFERENCED_PARAMETER(pWdfDevice);
inFunc;
shutDown();
return S_OK;
}
void CMyDevice::OnSurpriseRemoval(IN IWDFDevice* pWdfDevice) {
UNREFERENCED_PARAMETER(pWdfDevice);
inFunc;
shutDown();
}
STDMETHODIMP_ (void) CMyDevice::OnCancel(IN IWDFIoRequest* pWdfRequest) {
inFunc;
if (pWdfRequest==waitRemoveIpr) {
OutputDebugString(L"Cancel Remove\n");
waitRemoveIpr=NULL;
} else if (pWdfRequest==waitInsertIpr) {
OutputDebugString(L"Cancel Insert\n");
waitInsertIpr=NULL;
}
pWdfRequest->CompleteWithInformation(HRESULT_FROM_WIN32(ERROR_CANCELLED), 0);
}

View File

@@ -1,37 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<STAMP Condition="'$(OVERRIDE_STAMP)'!='true'">stampinf</STAMP>
</PropertyGroup>
<ItemGroup>
<NmakeTarget Include="vpcd.inx">
<TargetKillSwitch>ConvertedTarget0_Disabled</TargetKillSwitch>
<TargetName>Converted Target 0</TargetName>
<Outputs>$(OBJ_PATH)\$(O)\vpcd.inf</Outputs>
<Condition>
</Condition>
<Cmd0>copy %24%28%40B%29.inx %24%40</Cmd0>
<Cmd1>$(STAMP) -f %24%40 -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -u $(UMDF_VERSION_MAJOR).$(UMDF_VERSION_MINOR).0</Cmd1>
</NmakeTarget>
</ItemGroup>
<Target Name="Converted Target 0" BeforeTargets="$(BuildLinkTargets)" AfterTargets="$(AfterBuildCompileTargets)" Condition="'$(ConvertedTarget0_Disabled)'!='true'">
<ItemGroup>
<AllEvaluatedTargetInputs Remove="@(AllEvaluatedTargetInputs)" />
<t_TargetInput_0 Remove="@(t_TargetInput_0)" />
<t_TargetInput_0 Include="vpcd.inx" Condition="Exists('vpcd.inx') And ('@(t_TargetInput_0)'=='')" />
<t_TargetInput_0 Include="vpcd.inx" Condition="'@(t_TargetInput_0)'==''" />
<AllEvaluatedTargetInputs Include="@(t_TargetInput_0);" />
</ItemGroup>
<ReplaceNmakeCommandTokens Command="copy %24%28%40B%29.inx %24%40" TaskInputFiles="@(AllEvaluatedTargetInputs)" TaskOutputFile="$(OBJ_PATH)\$(O)\vpcd.inf">
<Output TaskParameter="ShouldExecute" PropertyName="TargetOutDated" />
<Output TaskParameter="ProcessedCommand" PropertyName="ResolvedCommand_1" />
</ReplaceNmakeCommandTokens>
<Exec Condition="'$(TargetOutDated)'=='true'" Command="$(ResolvedCommand_1)" WorkingDirectory="$(MSBuildProjectDirectory)" />
<ReplaceNmakeCommandTokens Command="$(STAMP) -f %24%40 -a $(_BUILDARCH) -k $(KMDF_VERSION_MAJOR).$(KMDF_VERSION_MINOR) -u $(UMDF_VERSION_MAJOR).$(UMDF_VERSION_MINOR).0" TaskInputFiles="@(AllEvaluatedTargetInputs)" TaskOutputFile="$(OBJ_PATH)\$(O)\vpcd.inf">
<Output TaskParameter="ShouldExecute" PropertyName="Junk_Property" />
<Output TaskParameter="ProcessedCommand" PropertyName="ResolvedCommand_2" />
</ReplaceNmakeCommandTokens>
<Exec Condition="'$(TargetOutDated)'=='true'" Command="$(ResolvedCommand_2)" WorkingDirectory="$(MSBuildProjectDirectory)" />
<Message Condition="'$(TargetOutDated)'!='true'" Text="File $(OBJ_PATH)\$(O)\vpcd.inf is up-to-date" />
</Target>
</Project>

View File

@@ -1,9 +0,0 @@
#pragma once
#include "internal.h"
bool getBuffer(IWDFIoRequest *pRequest, BYTE **buffer, SIZE_T *bufferLen);
void completeWithString(IWDFIoRequest* pRequest,char *result,int outSize);
void completeWithBuffer(IWDFIoRequest* pRequest,BYTE *result,int inSize);
void completeWithInteger(IWDFIoRequest* pRequest,DWORD result);
bool getInteger(IWDFIoRequest *pRequest, DWORD *integer);

View File

@@ -1,33 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<UMDF_VERSION_MAJOR Condition="'$(OVERRIDE_UMDF_VERSION_MAJOR)'!='true'">1</UMDF_VERSION_MAJOR>
<UMDF_VERSION_MINOR Condition="'$(OVERRIDE_UMDF_VERSION_MINOR)'!='true'">9</UMDF_VERSION_MINOR>
<KMDF_VERSION_MAJOR Condition="'$(OVERRIDE_KMDF_VERSION_MAJOR)'!='true'">1</KMDF_VERSION_MAJOR>
<KMDF_VERSION_MINOR Condition="'$(OVERRIDE_KMDF_VERSION_MINOR)'!='true'">9</KMDF_VERSION_MINOR>
<TARGETNAME Condition="'$(OVERRIDE_TARGETNAME)'!='true'">vpcd</TARGETNAME>
<TARGETTYPE Condition="'$(OVERRIDE_TARGETTYPE)'!='true'">DYNLINK</TARGETTYPE>
<USE_ATL Condition="'$(OVERRIDE_USE_ATL)'!='true'">1</USE_ATL>
<ATL_VER Condition="'$(OVERRIDE_ATL_VER)'!='true'">71</ATL_VER>
<USE_MSVCRT Condition="'$(OVERRIDE_USE_MSVCRT)'!='true'">1</USE_MSVCRT>
<C_DEFINES Condition="'$(OVERRIDE_C_DEFINES)'!='true'">$(C_DEFINES) /D_UNICODE /DUNICODE</C_DEFINES>
<WIN32_WINNT_VERSION Condition="'$(OVERRIDE_WIN32_WINNT_VERSION)'!='true'">$(LATEST_WIN32_WINNT_VERSION)</WIN32_WINNT_VERSION>
<_NT_TARGET_VERSION Condition="'$(OVERRIDE__NT_TARGET_VERSION)'!='true'">$(_NT_TARGET_VERSION_WIN7)</_NT_TARGET_VERSION>
<NTDDI_VERSION Condition="'$(OVERRIDE_NTDDI_VERSION)'!='true'">$(LATEST_NTDDI_VERSION)</NTDDI_VERSION>
<DLLENTRY Condition="'$(OVERRIDE_DLLENTRY)'!='true'">_DllMainCRTStartup</DLLENTRY>
<DLLDEF Condition="'$(OVERRIDE_DLLDEF)'!='true'">exports.def</DLLDEF>
<SOURCES Condition="'$(OVERRIDE_SOURCES)'!='true'">vpcd.rc driver.cpp device.cpp queue.cpp memory.cpp DllMain.cpp VirtualSCReader.idl</SOURCES>
<INCLUDES Condition="'$(OVERRIDE_INCLUDES)'!='true'">$(INCLUDES); $(SDK_INC_PATH); $(DDK_INC_PATH); $(UMDF_INC_PATH)\10;</INCLUDES>
<MSC_WARNING_LEVEL Condition="'$(OVERRIDE_MSC_WARNING_LEVEL)'!='true'">/W4 /WX</MSC_WARNING_LEVEL>
<TARGETLIBS Condition="'$(OVERRIDE_TARGETLIBS)'!='true'">$(SDK_LIB_PATH)\strsafe.lib $(SDK_LIB_PATH)\kernel32.lib $(SDK_LIB_PATH)\ole32.lib $(SDK_LIB_PATH)\oleaut32.lib $(SDK_LIB_PATH)\uuid.lib $(SDK_LIB_PATH)\user32.lib $(SDK_LIB_PATH)\advapi32.lib $(SDK_LIB_PATH)\shlwapi.lib $(SDK_LIB_PATH)\ws2_32.lib</TARGETLIBS>
<NTTARGETFILE1 Condition="'$(OVERRIDE_NTTARGETFILE1)'!='true'">$(OBJ_PATH)\$(O)\vpcd.inf</NTTARGETFILE1>
<TARGET_DESTINATION Condition="'$(OVERRIDE_TARGET_DESTINATION)'!='true'">wudf</TARGET_DESTINATION>
</PropertyGroup>
<ItemGroup>
<InvokedTargetsList Include="$(OBJ_PATH)\$(O)\vpcd.inf">
<Pass>1</Pass>
<Condition>
</Condition>
</InvokedTargetsList>
</ItemGroup>
</Project>

View File

@@ -1,152 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Win8.1 Debug|Win32">
<Configuration>Win8.1 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Release|Win32">
<Configuration>Win8.1 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|Win32">
<Configuration>Win8 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|Win32">
<Configuration>Win8 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Debug|Win32">
<Configuration>Win7 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Release|Win32">
<Configuration>Win7 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Debug|x64">
<Configuration>Win8.1 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Release|x64">
<Configuration>Win8.1 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|x64">
<Configuration>Win8 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|x64">
<Configuration>Win8 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Debug|x64">
<Configuration>Win7 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Release|x64">
<Configuration>Win7 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="PropertySheets">
<PlatformToolset>WindowsKernelModeDriver8.1</PlatformToolset>
<ConfigurationType>Utility</ConfigurationType>
<DriverType>Package</DriverType>
<DisableFastUpToDateCheck>true</DisableFastUpToDateCheck>
<Configuration>Win8.1 Debug</Configuration>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Globals">
<ProjectGuid>{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|Win32'" Label="Configuration">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|Win32'" Label="Configuration">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|x64'" Label="Configuration">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|x64'" Label="Configuration">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'" Label="Configuration">
<TargetVersion>Windows8</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'" Label="Configuration">
<TargetVersion>Windows7</TargetVersion>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<PropertyGroup>
<DebuggerFlavor>DbgengRemoteDebugger</DebuggerFlavor>
<EnableDeployment>False</EnableDeployment>
<ImportToStore>False</ImportToStore>
<InstallMode>None</InstallMode>
<HardwareIdString />
<CommandLine />
<ScriptPath />
<DeployFiles />
<ScriptName />
<ScriptDeviceQuery>%PathToInf%</ScriptDeviceQuery>
<EnableVerifier>False</EnableVerifier>
<AllDrivers>False</AllDrivers>
<VerifyProjectOutput>True</VerifyProjectOutput>
<VerifyDrivers />
<VerifyFlags>133563</VerifyFlags>
</PropertyGroup>
<ItemDefinitionGroup>
</ItemDefinitionGroup>
<ItemGroup>
<!--Inf Include="DriverInf.inv" /-->
<FilesToPackage Include="@(Inf->'%(CopyOutput)')" Condition="'@(Inf)'!=''" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\vpcd.vcxproj">
<Project>{B019D202-420C-484D-9303-45B552A05B95}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -1,83 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0
MinimumVisualStudioVersion = 12.0
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Vpcd-Package", "Vpcd-Package", "{B4A2C5E7-24D0-4EBB-A564-5F52DD858932}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vpcd-Package", "vpcd-Package\vpcd-Package.vcxproj", "{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vpcd", "vpcd.vcxproj", "{B019D202-420C-484D-9303-45B552A05B95}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Win8.1 Debug|Win32 = Win8.1 Debug|Win32
Win8.1 Debug|x64 = Win8.1 Debug|x64
Win8.1 Release|Win32 = Win8.1 Release|Win32
Win8.1 Release|x64 = Win8.1 Release|x64
Win8 Debug|Win32 = Win8 Debug|Win32
Win8 Debug|x64 = Win8 Debug|x64
Win8 Release|Win32 = Win8 Release|Win32
Win8 Release|x64 = Win8 Release|x64
Win7 Debug|Win32 = Win7 Debug|Win32
Win7 Debug|x64 = Win7 Debug|x64
Win7 Release|Win32 = Win7 Release|Win32
Win7 Release|x64 = Win7 Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Debug|x64.Build.0 = Win8 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Release|Win32.Build.0 = Win8 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Release|x64.ActiveCfg = Win8 Release|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win8 Release|x64.Build.0 = Win8 Release|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Debug|x64.Build.0 = Win7 Debug|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5}.Win7 Release|x64.Build.0 = Win7 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Debug|Win32.ActiveCfg = Win8.1 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Debug|Win32.Build.0 = Win8.1 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Debug|x64.ActiveCfg = Win8.1 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Debug|x64.Build.0 = Win8.1 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Release|Win32.ActiveCfg = Win8.1 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Release|Win32.Build.0 = Win8.1 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Release|x64.ActiveCfg = Win8.1 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8.1 Release|x64.Build.0 = Win8.1 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Debug|Win32.ActiveCfg = Win8 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Debug|Win32.Build.0 = Win8 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Debug|x64.ActiveCfg = Win8 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Debug|x64.Build.0 = Win8 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Release|Win32.ActiveCfg = Win8 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Release|Win32.Build.0 = Win8 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Release|x64.ActiveCfg = Win8 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win8 Release|x64.Build.0 = Win8 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Debug|Win32.ActiveCfg = Win7 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Debug|Win32.Build.0 = Win7 Debug|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Debug|x64.ActiveCfg = Win7 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Debug|x64.Build.0 = Win7 Debug|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Release|Win32.ActiveCfg = Win7 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Release|Win32.Build.0 = Win7 Release|Win32
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Release|x64.ActiveCfg = Win7 Release|x64
{B019D202-420C-484D-9303-45B552A05B95}.Win7 Release|x64.Build.0 = Win7 Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{7D06C4DD-96FC-4421-96F1-C90A6093A6F5} = {B4A2C5E7-24D0-4EBB-A564-5F52DD858932}
EndGlobalSection
EndGlobal

View File

@@ -1,217 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Win8.1 Debug|Win32">
<Configuration>Win8.1 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|Win32">
<Configuration>Win8 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Debug|Win32">
<Configuration>Win7 Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Release|Win32">
<Configuration>Win8.1 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|Win32">
<Configuration>Win8 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Release|Win32">
<Configuration>Win7 Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Debug|x64">
<Configuration>Win8.1 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Debug|x64">
<Configuration>Win8 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Debug|x64">
<Configuration>Win7 Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8.1 Release|x64">
<Configuration>Win8.1 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win8 Release|x64">
<Configuration>Win8 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Win7 Release|x64">
<Configuration>Win7 Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="PropertySheets">
<PlatformToolset>WindowsUserModeDriver8.1</PlatformToolset>
<ConfigurationType>DynamicLibrary</ConfigurationType>
<DriverType>UMDF</DriverType>
<TARGETNAME>vpcd</TARGETNAME>
<Configuration Condition="'$(Configuration)' == ''">Win8.1 Debug</Configuration>
<Platform Condition="'$(Platform)' == ''">Win32</Platform>
<ConvertedTarget0_Disabled>True</ConvertedTarget0_Disabled>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="PropertySheets">
<ConversionToolVersion>1.0</ConversionToolVersion>
<BUILD_ALT_DIR>$(Configuration.Replace(' ',''))</BUILD_ALT_DIR>
<IntDir Condition="'$(Platform)'!='Win32'">$(BUILD_ALT_DIR)\$(Platform)\</IntDir>
<IntDir Condition="'$(Platform)'=='Win32'">$(BUILD_ALT_DIR)\x86\</IntDir>
<OutDir>$(IntDir)</OutDir>
</PropertyGroup>
<ImportGroup Label="PreConfiguration">
<Import Project="$(VCTargetsPath)\WDKConversion\PreConfiguration.props" />
</ImportGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{B019D202-420C-484D-9303-45B552A05B95}</ProjectGuid>
<RootNamespace>$(MSBuildProjectName)</RootNamespace>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|Win32'">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">
<TargetVersion>Win8</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">
<TargetVersion>Win7</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|Win32'">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">
<TargetVersion>Win8</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">
<TargetVersion>Win7</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|x64'">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">
<TargetVersion>Win8</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'">
<TargetVersion>Win7</TargetVersion>
<UseDebugLibraries>True</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|x64'">
<TargetVersion>WindowsV6.3</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">
<TargetVersion>Win8</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'">
<TargetVersion>Win7</TargetVersion>
<UseDebugLibraries>False</UseDebugLibraries>
</PropertyGroup>
<!-- Needed by any VcxProj -->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win7 Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8 Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win7 Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8 Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8 Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Win8.1 Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<!-- The WrappedTaskItems label is used by the conversion tool to identify the location where items
associated with wrapped tasks will reside.-->
<ItemGroup Label="WrappedTaskItems">
<Inf Include="vpcd.inx">
<Architecture>$(_BUILDARCH)</Architecture>
<SpecifyArchitecture>true</SpecifyArchitecture>
<KmdfVersionNumber>1.9</KmdfVersionNumber>
<UmdfVersionNumber>1.9.0</UmdfVersionNumber>
<CopyOutput>$(OBJ_PATH)\$(O)\vpcd.inf</CopyOutput>
</Inf>
</ItemGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Win7 Debug|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>$(ProjectDir)\..\..\src\vpcd;%(AdditionalIncludeDirectories);$(Includes);$(User_Includes)</AdditionalIncludeDirectories>
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<!-- We only add items (e.g. form ClSourceFiles) that do not already exist (e.g in the ClCompile list), this avoids duplication -->
<ClCompile Include="..\..\src\vpcd\vpcd.c" />
<ClCompile Include="@(ClSourceFiles)" Exclude="@(ClCompile)" />
<ResourceCompile Include="@(RcSourceFiles)" Exclude="@(ResourceCompile)" />
<Midl Include="@(IdlSourceFiles)" Exclude="@(Midl)" />
<MessageCompile Include="@(McSourceFiles)" Exclude="@(MessageCompile)" />
<MASM Include="@(AsmSourceFiles)" Exclude="@(MASM)" />
<GenerateBmf Include="@(MofSourceFiles)" Exclude="@(GenerateBmf)" />
</ItemGroup>
<!-- Set default environment variables, e.g. for stampinf -->
<ItemGroup>
<BuildMacro Include="SDK_INC_PATH">
<Value>$(KIT_SHARED_INC_PATH)</Value>
<EnvironmentVariable>true</EnvironmentVariable>
</BuildMacro>
</ItemGroup>
<ItemGroup>
<Inf Exclude="@(Inf)" Include="$(DDK_INF_FILES)" />
<Inf Exclude="@(Inf)" Include="*.inf" />
<FilesToPackage Include="$(TargetPath)" Condition="'$(ConfigurationType)'=='Driver' or '$(ConfigurationType)'=='DynamicLibrary'" />
<FilesToPackage Include="$(DDK_PACKAGE_FILES)" />
</ItemGroup>
<!-- Necessary to pick up propper files from local directory when in the IDE-->
<ItemGroup>
<None Exclude="@(None)" Include="*.txt;*.htm;*.html" />
<None Exclude="@(None)" Include="*.ico;*.cur;*.bmp;*.dlg;*.rct;*.gif;*.jpg;*.jpeg;*.wav;*.jpe;*.tiff;*.tif;*.png;*.rc2" />
<None Exclude="@(None)" Include="*.def;*.bat;*.hpj;*.asmx" />
</ItemGroup>
<ItemGroup>
<ClInclude Exclude="@(ClInclude)" Include="*.h;*.hpp;*.hxx;*.hm;*.inl;*.xsd" />
<ClInclude Include="..\..\src\vpcd\vpcd.h" />
</ItemGroup>
<!-- /Necessary to pick up propper files from local directory when in the IDE-->
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
</Project>