#include "config.h"
#include <time.h>
#include <stdio.h>
#include <string.h>
#include "pcscd.h"
#include "winscard.h"
#include "debuglog.h"
#include "winscard_msg.h"
#include "winscard_svc.h"
#include "sys_generic.h"
#include "thread_generic.h"
#include "readerfactory.h"
Go to the source code of this file.
Data Structures | |
struct | _psContext |
Represents an Application Context on the Server side. More... | |
Functions | |
LONG | MSGCheckHandleAssociation (SCARDHANDLE, DWORD) |
LONG | MSGFunctionDemarshall (psharedSegmentMsg msgStruct, DWORD dwContextIndex) |
Find out which message was sent by the Client and execute the right task. | |
LONG | MSGAddContext (SCARDCONTEXT, DWORD) |
LONG | MSGRemoveContext (SCARDCONTEXT, DWORD) |
LONG | MSGAddHandle (SCARDCONTEXT, SCARDHANDLE, DWORD) |
LONG | MSGRemoveHandle (SCARDHANDLE, DWORD) |
LONG | MSGCleanupClient (DWORD) |
static void | ContextThread (LPVOID dwIndex) |
Handles messages received from Clients. | |
LONG | ContextsInitialize (void) |
LONG | CreateContextThread (uint32_t *pdwClientID) |
Creates threads to handle messages received from Clients. | |
Variables | |
static struct _psContext | psContext [PCSCLITE_MAX_APPLICATIONS_CONTEXTS] |
Represents an Application Context on the Server side. |
Each Client message is deald by creating a thread (CreateContextThread
). The thread establishes reands and demarshalls the message and calls the appropriate function to threat it.
Definition in file winscard_svc.c.
static void ContextThread | ( | LPVOID | dwIndex | ) | [static] |
Handles messages received from Clients.
For each Client message a new instance of this thread is created.
[in] | dwIndex | Index of an avaiable Application Context slot in psContext . |
Definition at line 125 of file winscard_svc.c.
References CMD_VERSION, rxSharedSegment::command, rxSharedSegment::data, version_struct::major, version_struct::minor, MSGFunctionDemarshall(), rxSharedSegment::mtype, PCSCLITE_SERVER_ATTEMPTS, _psContext::protocol_major, _psContext::protocol_minor, PROTOCOL_VERSION_MAJOR, PROTOCOL_VERSION_MINOR, psContext, version_struct::rv, SCARD_CONTROL_EXTENDED, SCARD_E_NO_SERVICE, SCARD_S_SUCCESS, SCARD_TRANSMIT_EXTENDED, SHMClientCloseSession(), SHMMessageSend(), and SHMProcessEventsContext().
Referenced by CreateContextThread().
LONG CreateContextThread | ( | uint32_t * | pdwClientID | ) |
Creates threads to handle messages received from Clients.
[in] | pdwClientID | Connection ID used to reference the Client. |
SCARD_S_SUCCESS | Success. | |
SCARD_F_INTERNAL_ERROR | Exceded the maximum number of simultaneous Application Contexts. | |
SCARD_E_NO_MEMORY | Error creating the Context Thread. |
Definition at line 77 of file winscard_svc.c.
References ContextThread(), _psContext::dwClientID, PCSCLITE_MAX_APPLICATIONS_CONTEXTS, psContext, SCARD_E_NO_MEMORY, SCARD_F_INTERNAL_ERROR, SCARD_S_SUCCESS, and SYS_CloseFile().
Referenced by SVCServiceRunLoop().
LONG MSGFunctionDemarshall | ( | psharedSegmentMsg | msgStruct, | |
DWORD | dwContextIndex | |||
) |
Find out which message was sent by the Client and execute the right task.
According to the command type sent by the client (pcsc_msg_commands
), cast the message data to the correct struct so that is can be demarshalled. Then call the appropriate function to handle the request.
Possible structs are: establish_struct
release_struct
connect_struct
reconnect_struct
disconnect_struct
begin_struct
cancel_struct
end_struct
status_struct
transmit_struct
control_struct
getset_struct
.
[in] | msgStruct | Message to be demarshalled and executed. |
[in] | dwContextIndex |
Definition at line 255 of file winscard_svc.c.
References getset_struct::cbAttrLen, control_struct_extended::cbRecvLength, control_struct::cbRecvLength, control_struct_extended::cbSendLength, transmit_struct_extended::cbSendLength, control_struct::cbSendLength, transmit_struct::cbSendLength, rxSharedSegment::command, control_struct_extended::data, transmit_struct_extended::data, rxSharedSegment::data, getset_struct::dwAttrId, control_struct::dwBytesReturned, _psContext::dwClientID, control_struct_extended::dwControlCode, control_struct::dwControlCode, end_struct::dwDisposition, disconnect_struct::dwDisposition, reconnect_struct::dwInitialization, reconnect_struct::dwPreferredProtocols, connect_struct::dwPreferredProtocols, establish_struct::dwScope, reconnect_struct::dwShareMode, connect_struct::dwShareMode, control_struct_extended::hCard, transmit_struct_extended::hCard, getset_struct::hCard, control_struct::hCard, transmit_struct::hCard, status_struct::hCard, cancel_struct::hCard, end_struct::hCard, begin_struct::hCard, disconnect_struct::hCard, reconnect_struct::hCard, connect_struct::hContext, release_struct::hContext, MAX_BUFFER_SIZE_EXTENDED, status_struct::mszReaderNames, status_struct::pbAtr, getset_struct::pbAttr, control_struct::pbRecvBuffer, transmit_struct::pbRecvBuffer, control_struct::pbSendBuffer, transmit_struct::pbSendBuffer, status_struct::pcbAtrLen, transmit_struct_extended::pcbRecvLength, transmit_struct::pcbRecvLength, status_struct::pcchReaderLen, PCSCLITE_MAX_MESSAGE_SIZE, PCSCLITE_SERVER_ATTEMPTS, reconnect_struct::pdwActiveProtocol, connect_struct::pdwActiveProtocol, control_struct_extended::pdwBytesReturned, status_struct::pdwProtocol, status_struct::pdwState, connect_struct::phCard, establish_struct::phContext, transmit_struct_extended::pioRecvPciLength, transmit_struct::pioRecvPciLength, transmit_struct_extended::pioRecvPciProtocol, transmit_struct::pioRecvPciProtocol, transmit_struct_extended::pioSendPciLength, transmit_struct::pioSendPciLength, transmit_struct_extended::pioSendPciProtocol, transmit_struct::pioSendPciProtocol, psContext, control_struct_extended::rv, transmit_struct_extended::rv, getset_struct::rv, control_struct::rv, transmit_struct::rv, status_struct::rv, cancel_struct::rv, end_struct::rv, begin_struct::rv, disconnect_struct::rv, reconnect_struct::rv, connect_struct::rv, release_struct::rv, establish_struct::rv, SCARD_BEGIN_TRANSACTION, SCARD_CONNECT, SCARD_CONTROL, SCARD_CONTROL_EXTENDED, SCARD_DISCONNECT, SCARD_END_TRANSACTION, SCARD_ESTABLISH_CONTEXT, SCARD_GET_ATTRIB, SCARD_RECONNECT, SCARD_RELEASE_CONTEXT, SCARD_S_SUCCESS, SCARD_SET_ATTRIB, SCARD_STATUS, SCARD_TRANSMIT, SCARD_TRANSMIT_EXTENDED, SCardBeginTransaction(), SCardCancelTransaction(), SCardConnect(), SCardControl(), SCardDisconnect(), SCardEndTransaction(), SCardEstablishContext(), SCardGetAttrib(), SCardReconnect(), SCardReleaseContext(), SCardSetAttrib(), SCardStatus(), SCardTransmit(), SHMMessageReceive(), SHMMessageSend(), control_struct_extended::size, transmit_struct_extended::size, and connect_struct::szReader.
Referenced by ContextThread().
struct _psContext psContext[PCSCLITE_MAX_APPLICATIONS_CONTEXTS] [static] |
Represents an Application Context on the Server side.
An Application Context contains Channels (hCard
).
Referenced by ContextThread(), CreateContextThread(), and MSGFunctionDemarshall().