Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8396941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T20:39:57+00:00 2026-06-09T20:39:57+00:00

I am developing an application that will access smart cards using the standard PKCS#11.

  • 0

I am developing an application that will access smart cards using the standard PKCS#11. At this moment the application is working very well both on Ubuntu and OS X. Now I am porting it to Windows, but I am getting an “access violation” exception whenever I call functions from the pkcs#11 library, which is linked at runtime.

Below I tried to reproduce a SSCCE of my code (The place where the exception is happening is identified with a comment).

void * libraryHandle = NULL;
CK_RV   rv;
CK_C_GetFunctionList pC_GetFunctionList;
CK_FUNCTION_LIST_PTR functions;


libraryHandle = LoadLibrary(L"C:\\WINDOWS\\system32\\pteidpkcs11.dll");
if (libraryHandle == NULL)
{
    printf("Library not loaded\n");
    exit(1);
}

pC_GetFunctionList = (CK_C_GetFunctionList) GetProcAddress((HMODULE)libraryHandle, "C_GetFunctionList");

if (pC_GetFunctionList == NULL)
{
    printf("Function not loaded\n");
    FreeLibrary((HMODULE)libraryHandle);
    exit(1);
}

rv = (*pC_GetFunctionList) (&functions);
assert(rv == CKR_OK);
printf("Point A\n");

if(functions == NULL)
{ 
    printf("Functions not loaded\n");
    FreeLibrary((HMODULE)libraryHandle);
    exit(1);        
}

printf("%u - %u\n",functions->version.major, functions->version.minor); // Prints without problems
rv = (*functions->C_Initialize) (NULL_PTR); //THIS IS THE PLACE WHERE I AM GETTING THE ACCESS VIOLATION
assert(rv == CKR_OK);

//printf("Point B\n");

FreeLibrary((HMODULE)libraryHandle);

When I debug the application the structure “CK_FUNCTION_LIST_PTR functions” seems to be valid.

Does anyone know what is causing this exception?

I am using Visual Studio 2010 Ultimate and Windows XP SP3.

Thanks!

(PS: I have already tried to load the function “C_Initialize” using “GetProcAddress” from the library, and it worked)

— Edit

CK_FUNCTION_LIST definition

struct CK_FUNCTION_LIST {

  CK_VERSION    version;  /* Cryptoki version */

/* Pile all the function pointers into the CK_FUNCTION_LIST. */
/* pkcs11f.h has all the information about the Cryptoki
 * function prototypes. */
#include "pkcs11f.h"

};

Full headers in:
http://www.rsa.com/rsalabs/node.asp?id=2133

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T20:39:59+00:00Added an answer on June 9, 2026 at 8:39 pm

    From that image, it looks like you either have some sort of disagreement on the layout of your CK_FUNCTION_LIST_PTR structure between the executable and the DLL. Make sure the executable and DLL are both compiled with the same compiler settings etc.

    What is the definition (including any surrounding pragmas/macros) of CK_FUNCTION_LIST_PTR? Is sizeof(CK_FUNCTION_LIST_PTR) the same if you print out its value from both your executable and from inside the DLL (in, say, C_GetFunctionList())?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing an iPhone application that will access XML files (or something similar) from
I am developing a Rails application that will access a lot of RSS feeds
I'm developing an application that will be published via ClickOnce. I've been using the
I am developing a custom server application that will access a database. I need
I am developing an application that will use MongoDB running on Windows Azure. This
I am developing an application that will run on 64 bit computers. However, we
I'm currently developing an application that will be run on local network in B2B
I'm developing an application that will be available from a website (market probably as
I'm looking into developing an application that will require live streaming of audio. I
At our company we are developing an application that will consists of several modules.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.