channels/smartcard: refactoring
This commit is contained in:
parent
89ad7638e4
commit
308e32ccb9
@ -1,13 +1,8 @@
|
|||||||
|
|
||||||
set(OPTION_DEFAULT OFF)
|
set(OPTION_DEFAULT OFF)
|
||||||
set(OPTION_CLIENT_DEFAULT OFF)
|
set(OPTION_CLIENT_DEFAULT ON)
|
||||||
set(OPTION_SERVER_DEFAULT OFF)
|
set(OPTION_SERVER_DEFAULT OFF)
|
||||||
|
|
||||||
if(WITH_PCSC)
|
|
||||||
set(OPTION_CLIENT_DEFAULT ON)
|
|
||||||
set(OPTION_SERVER_DEFAULT OFF)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
define_channel_options(NAME "smartcard" TYPE "device"
|
define_channel_options(NAME "smartcard" TYPE "device"
|
||||||
DESCRIPTION "Smart Card Virtual Channel Extension"
|
DESCRIPTION "Smart Card Virtual Channel Extension"
|
||||||
SPECIFICATIONS "[MS-RDPESC]"
|
SPECIFICATIONS "[MS-RDPESC]"
|
||||||
|
@ -22,8 +22,6 @@ set(${MODULE_PREFIX}_SRCS
|
|||||||
smartcard_main.h
|
smartcard_main.h
|
||||||
smartcard_operations.c)
|
smartcard_operations.c)
|
||||||
|
|
||||||
include_directories(${PCSC_INCLUDE_DIR})
|
|
||||||
|
|
||||||
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE "DeviceServiceEntry")
|
add_channel_client_library(${MODULE_PREFIX} ${MODULE_NAME} ${CHANNEL_NAME} TRUE "DeviceServiceEntry")
|
||||||
|
|
||||||
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
set_target_properties(${MODULE_NAME} PROPERTIES PREFIX "")
|
||||||
@ -36,13 +34,7 @@ set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
|||||||
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
set_complex_link_libraries(VARIABLE ${MODULE_PREFIX}_LIBS
|
||||||
MONOLITHIC ${MONOLITHIC_BUILD}
|
MONOLITHIC ${MONOLITHIC_BUILD}
|
||||||
MODULE winpr
|
MODULE winpr
|
||||||
MODULES winpr-crt winpr-synch winpr-thread winpr-interlocked)
|
MODULES winpr-crt winpr-synch winpr-thread winpr-interlocked winpr-utils)
|
||||||
|
|
||||||
set(${MODULE_PREFIX}_LIBS ${${MODULE_PREFIX}_LIBS} ${PCSC_LIBRARIES})
|
|
||||||
|
|
||||||
if(WIN32)
|
|
||||||
list(APPEND ${MODULE_PREFIX}_LIBS winscard)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
target_link_libraries(${MODULE_NAME} ${${MODULE_PREFIX}_LIBS})
|
||||||
|
|
||||||
|
@ -30,9 +30,6 @@
|
|||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
#include <winpr/smartcard.h>
|
#include <winpr/smartcard.h>
|
||||||
|
|
||||||
#include <freerdp/utils/list.h>
|
|
||||||
#include <freerdp/utils/debug.h>
|
|
||||||
|
|
||||||
#include <freerdp/channels/rdpdr.h>
|
#include <freerdp/channels/rdpdr.h>
|
||||||
|
|
||||||
#include "smartcard_main.h"
|
#include "smartcard_main.h"
|
||||||
@ -61,7 +58,6 @@ static void smartcard_process_irp(SMARTCARD_DEVICE* smartcard, IRP* irp)
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "MajorFunction 0x%X unexpected for smartcards.", irp->MajorFunction);
|
fprintf(stderr, "MajorFunction 0x%X unexpected for smartcards.", irp->MajorFunction);
|
||||||
DEBUG_WARN("Smartcard MajorFunction 0x%X not supported.", irp->MajorFunction);
|
|
||||||
irp->IoStatus = STATUS_NOT_SUPPORTED;
|
irp->IoStatus = STATUS_NOT_SUPPORTED;
|
||||||
irp->Complete(irp);
|
irp->Complete(irp);
|
||||||
break;
|
break;
|
||||||
@ -114,10 +110,10 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||||||
SMARTCARD_DEVICE* smartcard;
|
SMARTCARD_DEVICE* smartcard;
|
||||||
|
|
||||||
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
|
device = (RDPDR_SMARTCARD*) pEntryPoints->device;
|
||||||
|
|
||||||
name = device->Name;
|
name = device->Name;
|
||||||
path = device->Path;
|
path = device->Path;
|
||||||
|
|
||||||
/* TODO: check if server supports sc redirect (version 5.1) */
|
|
||||||
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
|
smartcard = (SMARTCARD_DEVICE*) calloc(1, sizeof(SMARTCARD_DEVICE));
|
||||||
|
|
||||||
if (!smartcard)
|
if (!smartcard)
|
||||||
@ -149,6 +145,8 @@ int DeviceServiceEntry(PDEVICE_SERVICE_ENTRY_POINTS pEntryPoints)
|
|||||||
smartcard->name = name;
|
smartcard->name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
smartcard->log = WLog_Get("com.freerdp.channel.smartcard.client");
|
||||||
|
|
||||||
smartcard->IrpQueue = MessageQueue_New(NULL);
|
smartcard->IrpQueue = MessageQueue_New(NULL);
|
||||||
smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
|
smartcard->thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) smartcard_thread_func,
|
||||||
smartcard, CREATE_SUSPENDED, NULL);
|
smartcard, CREATE_SUSPENDED, NULL);
|
||||||
|
@ -21,26 +21,49 @@
|
|||||||
#ifndef FREERDP_CHANNEL_SMARTCARD_CLIENT_MAIN_H
|
#ifndef FREERDP_CHANNEL_SMARTCARD_CLIENT_MAIN_H
|
||||||
#define FREERDP_CHANNEL_SMARTCARD_CLIENT_MAIN_H
|
#define FREERDP_CHANNEL_SMARTCARD_CLIENT_MAIN_H
|
||||||
|
|
||||||
#include <freerdp/utils/list.h>
|
|
||||||
#include <freerdp/utils/debug.h>
|
#include <freerdp/utils/debug.h>
|
||||||
#include <freerdp/channels/rdpdr.h>
|
#include <freerdp/channels/rdpdr.h>
|
||||||
|
|
||||||
#include <winpr/crt.h>
|
#include <winpr/crt.h>
|
||||||
|
#include <winpr/wlog.h>
|
||||||
#include <winpr/synch.h>
|
#include <winpr/synch.h>
|
||||||
#include <winpr/smartcard.h>
|
#include <winpr/smartcard.h>
|
||||||
#include <winpr/collections.h>
|
#include <winpr/collections.h>
|
||||||
|
|
||||||
struct _COMPLETIONIDINFO
|
/* [MS-RDPESC] 3.1.4 */
|
||||||
{
|
#define SCARD_IOCTL_ESTABLISH_CONTEXT 0x00090014 /* EstablishContext */
|
||||||
UINT32 ID;
|
#define SCARD_IOCTL_RELEASE_CONTEXT 0x00090018 /* ReleaseContext */
|
||||||
BOOL duplicate;
|
#define SCARD_IOCTL_IS_VALID_CONTEXT 0x0009001C /* IsValidContext */
|
||||||
};
|
#define SCARD_IOCTL_LIST_READER_GROUPS 0x00090020 /* ListReaderGroups */
|
||||||
typedef struct _COMPLETIONIDINFO COMPLETIONIDINFO;
|
#define SCARD_IOCTL_LIST_READERS 0x00090028 /* ListReadersA */
|
||||||
|
#define SCARD_IOCTL_INTRODUCE_READER_GROUP 0x00090050 /* IntroduceReaderGroup */
|
||||||
|
#define SCARD_IOCTL_FORGET_READER_GROUP 0x00090058 /* ForgetReader */
|
||||||
|
#define SCARD_IOCTL_INTRODUCE_READER 0x00090060 /* IntroduceReader */
|
||||||
|
#define SCARD_IOCTL_FORGET_READER 0x00090068 /* IntroduceReader */
|
||||||
|
#define SCARD_IOCTL_ADD_READER_TO_GROUP 0x00090070 /* AddReaderToGroup */
|
||||||
|
#define SCARD_IOCTL_REMOVE_READER_FROM_GROUP 0x00090078 /* RemoveReaderFromGroup */
|
||||||
|
#define SCARD_IOCTL_GET_STATUS_CHANGE 0x000900A0 /* GetStatusChangeA */
|
||||||
|
#define SCARD_IOCTL_CANCEL 0x000900A8 /* Cancel */
|
||||||
|
#define SCARD_IOCTL_CONNECT 0x000900AC /* ConnectA */
|
||||||
|
#define SCARD_IOCTL_RECONNECT 0x000900B4 /* Reconnect */
|
||||||
|
#define SCARD_IOCTL_DISCONNECT 0x000900B8 /* Disconnect */
|
||||||
|
#define SCARD_IOCTL_BEGIN_TRANSACTION 0x000900BC /* BeginTransaction */
|
||||||
|
#define SCARD_IOCTL_END_TRANSACTION 0x000900C0 /* EndTransaction */
|
||||||
|
#define SCARD_IOCTL_STATE 0x000900C4 /* State */
|
||||||
|
#define SCARD_IOCTL_STATUS 0x000900C8 /* StatusA */
|
||||||
|
#define SCARD_IOCTL_TRANSMIT 0x000900D0 /* Transmit */
|
||||||
|
#define SCARD_IOCTL_CONTROL 0x000900D4 /* Control */
|
||||||
|
#define SCARD_IOCTL_GETATTRIB 0x000900D8 /* GetAttrib */
|
||||||
|
#define SCARD_IOCTL_SETATTRIB 0x000900DC /* SetAttrib */
|
||||||
|
#define SCARD_IOCTL_ACCESS_STARTED_EVENT 0x000900E0 /* SCardAccessStartedEvent */
|
||||||
|
#define SCARD_IOCTL_LOCATE_CARDS_BY_ATR 0x000900E8 /* LocateCardsByATR */
|
||||||
|
|
||||||
struct _SMARTCARD_DEVICE
|
struct _SMARTCARD_DEVICE
|
||||||
{
|
{
|
||||||
DEVICE device;
|
DEVICE device;
|
||||||
|
|
||||||
|
wLog* log;
|
||||||
|
|
||||||
char* name;
|
char* name;
|
||||||
char* path;
|
char* path;
|
||||||
|
|
||||||
@ -52,12 +75,6 @@ struct _SMARTCARD_DEVICE
|
|||||||
};
|
};
|
||||||
typedef struct _SMARTCARD_DEVICE SMARTCARD_DEVICE;
|
typedef struct _SMARTCARD_DEVICE SMARTCARD_DEVICE;
|
||||||
|
|
||||||
#ifdef WITH_DEBUG_SCARD
|
|
||||||
#define DEBUG_SCARD(fmt, ...) DEBUG_CLASS(SCARD, fmt, ## __VA_ARGS__)
|
|
||||||
#else
|
|
||||||
#define DEBUG_SCARD(fmt, ...) DEBUG_NULL(fmt, ## __VA_ARGS__)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BOOL smartcard_async_op(IRP* irp);
|
BOOL smartcard_async_op(IRP* irp);
|
||||||
void smartcard_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp);
|
void smartcard_device_control(SMARTCARD_DEVICE* smartcard, IRP* irp);
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -183,5 +183,12 @@ WINPR_API VOID _IoDeleteDeviceEx(PDEVICE_OBJECT_EX DeviceObject);
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extended API
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define ACCESS_FROM_CTL_CODE(ctrlCode) ((DWORD)((ctrlCode >> 14) & 0x3))
|
||||||
|
#define FUNCTION_FROM_CTL_CODE(ctrlCode) ((DWORD)((ctrlCode >> 2) & 0xFFF))
|
||||||
|
|
||||||
#endif /* WINPR_IO_H */
|
#endif /* WINPR_IO_H */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user