title: Accessing SLE4442 memory card in C - need some help (RPC_X_BAD_STUB_DATA)
body: <p>I'm new to SmartCard Programming, so please bear with me..</p>
  
  <p>I'm trying to access an SLE4442 memory card anagrammatically using the WinSCard API.
  When accessing the card with pcscdiag.exe tool from here:
  <a href="http://scm-smartpcscdiag.software.informer.com/" rel="nofollow">http://scm-smartpcscdiag.software.informer.com/</a>
  I get the following information:</p>
  
  <p>T=65535<br>
  Clock=372<br>
  F=372<br>
  D=-<br>
  N=0<br>
  W=0<br>
  IFSD=252<br>
  EBC=Longitudinal Redundancy Check<br>
  ICC type per ATR=unknown Type</p>
  
  <p>Naturally, trying to access the card using T=0 or T=1 protocol fails, but I am able to connect to the read with RAW access:  </p>
  
  <pre><code>lReturn = SCardConnect(   
      (sc-&gt;hContext),  
      (LPCTSTR)(sc-&gt;pmszReaders),  
      SCARD_SHARE_EXCLUSIVE,  
      SCARD_PROTOCOL_RAW,  
      //SCARD_SHARE_EXCLUSIVE,  
      //SCARD_PROTOCOL_T1,  
      &amp;(sc-&gt;hCardHandle),  
      &amp;(sc-&gt;dwAP) );  
  </code></pre>
  
  <p>Now, I'm trying, as a first step, to read the contents of the card:</p>
  
  <pre><code>lReturn = SCardBeginTransaction(sc.hCardHandle); // successful ,err checking omitted
  
  DWORD dwSendLength, dwRecvLength;
  SCARD_IO_REQUEST pioRecvPci;
  BYTE pbSendBuffer[512];
  BYTE pbRecvBuffer[512];
  dwSendLength = 512;
  dwRecvLength = 512;
  
  pbSendBuffer[0] = 0x00;     // CLA
  pbSendBuffer[1] = 0xB0; // INS
  pbSendBuffer[2] = 0x00;     // P1
  pbSendBuffer[3] = 0x00;     // P2
  pbSendBuffer[4] = 0x00;     // LEN
  
  dwSendLength = 5;
  
  lReturn = SCardTransmit(
      sc.hCardHandle,
      SCARD_PCI_RAW,
      //SCARD_PCI_T1,
      pbSendBuffer,
      dwSendLength,
      &amp;pioRecvPci, 
      pbRecvBuffer, 
      &amp;dwRecvLength
      );
  </code></pre>
  
  <p>I've also tries setting the CLA to 0xFF, and other variants (nested loops, with values of 0..255 for the CLA and the INS)</p>
  
  <p>I keep getting an 1783 error: RPC_X_BAD_STUB_DATA</p>
  
  <p>What am I doing wrong? What do I need to do in order to read the card?</p>
  
  <p>Thanks in advance!</p>