Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkcs11: Fix C_WaitForSlotEvent() not working in Windows #2919

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/libopensc/reader-pcsc.c
Expand Up @@ -1640,6 +1640,11 @@ static int pcsc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_re
#else
rgReaderStates[num_watch].szReader = "\\\\?PnP?\\Notification";
rgReaderStates[num_watch].dwCurrentState = SCARD_STATE_UNAWARE;
#ifdef _WIN32
/* Windows expects number of readers in HiWord of dwCurrentState.
* See https://stackoverflow.com/questions/16370909. */
rgReaderStates[num_watch].dwCurrentState |= (num_watch << 16);
#endif
rgReaderStates[num_watch].dwEventState = SCARD_STATE_UNAWARE;
num_watch++;
sc_log(ctx, "Trying to detect new readers");
Expand Down Expand Up @@ -1706,6 +1711,13 @@ static int pcsc_wait_for_event(sc_context_t *ctx, unsigned int event_mask, sc_re
prev_state = rsp->dwCurrentState;
state = rsp->dwEventState;
rsp->dwCurrentState = rsp->dwEventState;
#ifdef _WIN32
if (!strcmp(rsp->szReader, "\\\\?PnP?\\Notification")) {
/* Windows expects number of readers in HiWord of dwCurrentState.
* See https://stackoverflow.com/questions/16370909. */
rsp->dwCurrentState |= ((num_watch - 1) << 16);
}
#endif
if (state & SCARD_STATE_CHANGED) {
/* check for hotplug events */
if (!strcmp(rsp->szReader, "\\\\?PnP?\\Notification")) {
Expand Down