ITpmVirtualSmartCardManager::CreateVirtualSmartCard PIN 设置不正确

ITpmVirtualSmartCardManager::CreateVirtualSmartCard the PIN is not set correctly

我按照此 thread 创建 TPM Vistual Smnart 卡,在 运行 虚拟智能卡创建的应用程序之后可以在设备管理器中看到,但是当我尝试插入 PIN 时 123456789 验证显示 PIN 不正确

#include "Tpmvscmgr.h"    
#include  "StrSafe.h"
#pragma comment (lib, "Vscmgr.lib")
#include <Windows.h>

HRESULT CoCreateInstanceAsAdmin(HWND hwnd, REFCLSID rclsid, REFIID riid, __out void ** ppv)
{
 BIND_OPTS3 bo;
 WCHAR  wszCLSID[50];
 WCHAR  wszMonikerName[300];

 StringFromGUID2(rclsid, wszCLSID, sizeof(wszCLSID) / sizeof(wszCLSID[0]));
 HRESULT hr = StringCchPrintfW(wszMonikerName, sizeof(wszMonikerName) / sizeof(wszMonikerName[0]), L"Elevation:Administrator!new:%s", wszCLSID);
 if (FAILED(hr))
  return hr;
 memset(&bo, 0, sizeof(bo));
 bo.cbStruct = sizeof(bo);
 bo.hwnd = hwnd;
 bo.dwClassContext = CLSCTX_LOCAL_SERVER;
 return CoGetObject(wszMonikerName, &bo, riid, ppv);
}

int main()
{
 HRESULT hr = S_OK;
 HWND hwnd = NULL;
 ITpmVirtualSmartCardManager *pObj = NULL;
 CoInitialize(NULL);
 hr = CoCreateInstanceAsAdmin(
  hwnd,
  CLSID_TpmVirtualSmartCardManager,
  IID_ITpmVirtualSmartCardManager,
  (void**)&pObj);


 //ITpmVirtualSmartCardManager *pObj = NULL;
 LPWSTR friendly = L"Friendly";
 LPWSTR out = L"";
 BYTE pin[] = "123456789";
 DWORD size = sizeof(pin);
 BOOL boot;

 hr = pObj->CreateVirtualSmartCard(friendly, TPMVSC_DEFAULT_ADMIN_ALGORITHM_ID, pin, size, NULL, 0, pin, size, pin, size, false, NULL, &out, &boot);

 return 0;
}

有人知道问题出在哪里吗?

  • 第四个参数为CreateVirtualSmartCard()must be 24。无论如何,它不应该与 PIN 相同。
  • 在这种情况下,
  • sizeof(pin) 将 return 10,因为空终止符包含在计算大小中。 TpmVscMgr 也是这样做的吗?