Skip to content

Commit

Permalink
Make SCardListener dormant when service not present
Browse files Browse the repository at this point in the history
  • Loading branch information
Greg Domzalski committed Jun 28, 2022
1 parent 0dba76a commit 0f2100c
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,15 @@ public DesktopSmartCardDeviceListener()
uint result = SCardEstablishContext(SCARD_SCOPE.USER, out SCardContext context);
_log.SCardApiCall(nameof(SCardEstablishContext), result);

// If we failed to establish context to the smart card subsystem, something substantially wrong
// has occured. We should not continue, and the device listener should remain dormant.
if (result != ErrorCode.SCARD_S_SUCCESS)
{
_context = new SCardContext(IntPtr.Zero);
_readerStates = Array.Empty<SCARD_READER_STATE>();
return;
}

_context = context;
_readerStates = GetReaderStateList();

Expand Down

0 comments on commit 0f2100c

Please sign in to comment.