title: LoadEnclaveImage "A device attached to the system is not functioning"
body: <p>I'm trying to load a signed DLL into a VBS enclave and <code>LoadEnclaveImage</code> is returning <code>A device attached to the system is not functioning</code>.</p>
  
  <p>Hyper-V, Secure Boot, &amp; TPM 2.0 are all functioning, so I'm not quite sure as to what the error is referring to.</p>
  
  <p>Sample Code: </p>
  
  <pre><code>if (IsEnclaveTypeSupported(ENCLAVE_TYPE_VBS))
  {
      DWORD lpError = 0;
      ENCLAVE_CREATE_INFO_VBS vci = { 0 };
      vci.Flags = 1;
  
      PVOID enclave = CreateEnclave(GetCurrentProcess(),
          NULL,
          1024 * 1024 * 2,
          NULL,
          ENCLAVE_TYPE_VBS,
          &amp;vci,
          sizeof(ENCLAVE_CREATE_INFO_VBS),
          &amp;lpError);
  
      if (enclave != NULL)
      {
          auto lib = LoadLibrary(L"kernelbase.dll");
          auto addr = (__LoadEnclaveImage)GetProcAddress(lib, "LoadEnclaveImageW");
  
          if (addr(enclave, L"...\testme.dll"))
          {
              printf("Worked!\n");
          }
          else {
              printf("Failed to load image\n");
              printf(GetLastErrorAsString().c_str());
          }
  
      }
      else
      {
          printf(GetLastErrorAsString().c_str());
      }
  }
  else {
      printf("VBS not supported\n");
  }
  </code></pre>