title: WinBio Save Capture Sample as Image - Unable to read from memory
body: <p>I'm C++ newbie and need to save image <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/dd401603(v=vs.85).aspx" rel="nofollow">captured by Biometric fingerprint sensor</a> as bmp image file. I've found that <a href="https://github.com/djbozkosz/Windows-Biometric-Framework-FingerPrint-Example" rel="nofollow">this</a> example might be suitable for my requirements, but while I'm running the application (as administrator), I've got error while trying to get pointer <code>&amp;sample</code> says <code>'Unable to read from memory'</code></p>
  
  <pre><code>    HRESULT CaptureSample()
      {
        HRESULT hr = S_OK;
        WINBIO_SESSION_HANDLE sessionHandle = NULL;
        WINBIO_UNIT_ID unitId = 0;
        WINBIO_REJECT_DETAIL rejectDetail = 0;
        PWINBIO_BIR sample = NULL;
        SIZE_T sampleSize = 0;
        // Connect to the system pool &amp; opening session code done successfully. 
        // Capture a biometric sample.
        std::cout &lt;&lt; "Calling WinBioCaptureSample - Swipe sensor...\n";
  
        hr = WinBioCaptureSample(
          sessionHandle,
          WINBIO_NO_PURPOSE_AVAILABLE,
          WINBIO_DATA_FLAG_RAW,
          &amp;unitId,
          &amp;sample, // Here Application crashes and error is 'Unable to read from memory'
          &amp;sampleSize,
          &amp;rejectDetail
          );
  
        std::cout &lt;&lt; "Swipe processed - Unit ID: " &lt;&lt; unitId &lt;&lt; "\n";
  
  
        if(FAILED(hr))
        {
          if(hr == WINBIO_E_BAD_CAPTURE)
            std:: cout &lt;&lt; "Bad capture; reason: " &lt;&lt; rejectDetail &lt;&lt; "\n";
          else
            std::cout &lt;&lt; "WinBioCaptureSample failed.hr = 0x" &lt;&lt; std::hex &lt;&lt; hr &lt;&lt; std::dec &lt;&lt; "\n";
  
          if(sample != NULL)
          {
            WinBioFree(sample);
            sample = NULL;
          }
  
          if(sessionHandle != NULL)
          {
            WinBioCloseSession(sessionHandle);
            sessionHandle = NULL;
          }
  
          return hr;
        }
      }
  </code></pre>