1

Hi all i am working on a smart card driver that works fine for windows 7 but on windows 8.1 some times it popup with an error "the smart card requires driver are not present on this system.Pl;ease try another smart card or contact your administrator." And one more thing that i have noticed is smart card driver behavior is also differ on win 8.1. For that i have written a simple application code i am providing below with driver log on win 7 and windows 8.1.

lReturn = SCardEstablishContext(SCARD_SCOPE_USER,
                             NULL,
                             NULL,
                             &hSC);
if ( SCARD_S_SUCCESS != lReturn )
    message("Failed SCardEstablishContext\n");
else
{
    message("context established\n");
    lReturn = SCardGetCardTypeProviderName(hSC,
                                       szCardName,
                                       SCARD_PROVIDER_CSP,
                                       (LPTSTR)&szProvider,
                                       &chProvider);
    if (SCARD_S_SUCCESS == lReturn)
    {
        BOOL fSts = TRUE;
        HCRYPTPROV hProv = NULL;
        message("successfully reads the provider name\n >> %S: \n",szProvider);
        //
        __try
        {
            // Acquire a Cryptographic operation context.
            fSts = CryptAcquireContext(&hProv,
                                    NULL,
                                    szProvider,
                                    PROV_RSA_FULL,
                                    0);
            if(!fSts)
            {
                message("crypt aquire context failed\n");
            }
         }
         __finally
         {
            if (CryptReleaseContext(hProv,0))
            {
                mesage("The handle has been released.\n");
            }
            else
            {
                message("The handle could not be released.\n");
            }

        }

        // Free memory allocated by SCardGetCardTypeProviderName.
        lReturn = SCardFreeMemory(hSC, szProvider);
    }

}

lReturn = SCardReleaseContext(hSC);
if(SCARD_S_SUCCESS != lReturn)
{
    printf("failed in release context");
}

Links for log file are here win 7 Log for app for win 7 win 8.1 Log for above app on win 8.1 log for win 7 while try to run the application

# CardAcquireContext : Enter    
# CardAcquireContext : Exit, Return = 0x0   
# CardGetProperty : Enter   
# CardDataOperations.cppCardReadFile : Enter    
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  // reads cmapfile
# CardReadFile : Exit, Return : 0x0 
# CardGetContainerProperty : Enter  
# CardGetContainerProperty : Exit, Return = 0x0 
# CardGetProperty : Enter   // collects the pin info
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  
# CardReadFile : Exit, Return : 0x0 
# CardGetContainerInfo : Enter // reads public key  
# CardGetContainerInfo : Exit, Return : 0x0 
# CardDeleteContext : Enter 
# CardDeleteContext : Exit, Return = 0x0

On windows 8.1 log is....means there is no call to delete context where i am freeing all resources

# CardAcquireContext : Enter    
# CardAcquireContext : Exit, Return = 0x0   
# CardGetProperty : Enter   
# CardReadFile : Enter  
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter   // reads card config file
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  // reads cmap file
# CardReadFile : Exit, Return : 0x0 
# CardReadFile : Enter  // reads cmap file
# CardReadFile : Exit, Return : 0x0 
# CardGetContainerProperty : Enter  
# CardGetContainerProperty : Exit, Return = 0x0 
# CardGetProperty : Enter   // reads pin info
# CardGetProperty : Exit, Return = 0x0  
# CardAcquireContext : Enter    
# CardAcquireContext : Exit, Return = 0x0   
# CardGetProperty : Enter   
# CardReadFile : Enter   // reads card id
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  // reads card configuration
# CardReadFile : Exit, Return : 0x0 
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardGetProperty : Enter   
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter reads cmap file  
# CardReadFile : Exit, Return : 0x0 
# CardReadFile : Enter  
# CardReadFile : Exit, Return : 0x0 
# CardGetContainerProperty : Enter  
# CardGetContainerProperty : Exit, Return = 0x0 
# CardGetProperty : Enter   / gets pin info 
# CardGetProperty : Exit, Return = 0x0  
# CardReadFile : Enter  // reads cmap file
# CardReadFile : Exit, Return : 0x0 
# CardGetContainerInfo : Enter  
# CardGetContainerInfo : Exit, Return : 0x0

if i am missing anything than please let me know

0 Answers0