当前位置: 首页>>代码示例>>C++>>正文


C++ EFI_SERVICE_BINDING_PROTOCOL::CreateChild方法代码示例

本文整理汇总了C++中EFI_SERVICE_BINDING_PROTOCOL::CreateChild方法的典型用法代码示例。如果您正苦于以下问题:C++ EFI_SERVICE_BINDING_PROTOCOL::CreateChild方法的具体用法?C++ EFI_SERVICE_BINDING_PROTOCOL::CreateChild怎么用?C++ EFI_SERVICE_BINDING_PROTOCOL::CreateChild使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EFI_SERVICE_BINDING_PROTOCOL的用法示例。


在下文中一共展示了EFI_SERVICE_BINDING_PROTOCOL::CreateChild方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

/**
  Creates a Tls child handle, open EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.

  @param[in]  ImageHandle           The firmware allocated handle for the UEFI image.
  @param[out] TlsProto              Pointer to the EFI_TLS_PROTOCOL instance.
  @param[out] TlsConfiguration      Pointer to the EFI_TLS_CONFIGURATION_PROTOCOL instance.

  @return  The child handle with opened EFI_TLS_PROTOCOL and EFI_TLS_CONFIGURATION_PROTOCOL.

**/
EFI_HANDLE
EFIAPI
TlsCreateChild (
  IN  EFI_HANDLE                     ImageHandle,
  OUT EFI_TLS_PROTOCOL               **TlsProto,
  OUT EFI_TLS_CONFIGURATION_PROTOCOL **TlsConfiguration
  )
{
  EFI_STATUS                    Status;
  EFI_SERVICE_BINDING_PROTOCOL  *TlsSb;
  EFI_HANDLE                    TlsChildHandle;

  TlsSb          = NULL;
  TlsChildHandle = 0;

  //
  // Locate TlsServiceBinding protocol.
  //
  gBS->LocateProtocol (
     &gEfiTlsServiceBindingProtocolGuid,
     NULL,
     (VOID **) &TlsSb
     );
  if (TlsSb == NULL) {
    return NULL;
  }

  Status = TlsSb->CreateChild (TlsSb, &TlsChildHandle);
  if (EFI_ERROR (Status)) {
    return NULL;
  }

  Status = gBS->OpenProtocol (
                  TlsChildHandle,
                  &gEfiTlsProtocolGuid,
                  (VOID **) TlsProto,
                  ImageHandle,
                  TlsChildHandle,
                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
                  );
  if (EFI_ERROR (Status)) {
    TlsSb->DestroyChild (TlsSb, TlsChildHandle);
    return NULL;
  }

  Status = gBS->OpenProtocol (
                  TlsChildHandle,
                  &gEfiTlsConfigurationProtocolGuid,
                  (VOID **) TlsConfiguration,
                  ImageHandle,
                  TlsChildHandle,
                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
                  );
  if (EFI_ERROR (Status)) {
    TlsSb->DestroyChild (TlsSb, TlsChildHandle);
    return NULL;
  }

  return TlsChildHandle;
}
开发者ID:baranee,项目名称:edk2,代码行数:70,代码来源:HttpsSupport.c

示例2:

BOOLEAN
EFIAPI
HSTestExistingShaImpl(BOOLEAN *ImplExists)
{
  EFI_SERVICE_BINDING_PROTOCOL  *BindingProto;
  EFI_HASH_PROTOCOL             *HashProto;
  EFI_HASH_OUTPUT               HashOut;
  EFI_SHA1_HASH                 Sha1Hash;
  EFI_STATUS                    Status;
  EFI_HANDLE                    Child;
  UINTN                         HashIter;

  //
  // Create binding.
  //
  Status = gBS->LocateProtocol(
    &gEfiHashServiceBindingProtocolGuid,
    NULL,
    (VOID **)&BindingProto
  );

  if (EFI_ERROR(Status)) {
    *ImplExists = FALSE;
    return FALSE;
  }
  
  Child = NULL;
  *ImplExists = TRUE;

  Status = BindingProto->CreateChild(BindingProto, &Child);
  if (EFI_ERROR(Status)) {
    return FALSE;
  }

  //
  // Obtain protocol.
  //
  HashProto = NULL;
  Status = gBS->LocateProtocol(
    &gEfiHashProtocolGuid, 
    NULL, 
    (VOID **)&HashProto
  );

  if (EFI_ERROR(Status)) {
    BindingProto->DestroyChild(BindingProto, Child);
    return FALSE;
  }
  
  //
  // Do two iterations of test-hashing.
  //
  HashOut.Sha1Hash = &Sha1Hash;
  for (HashIter = 0; HashIter < 2; ++HashIter) {
    Status = HashProto->Hash(
      HashProto, 
      &gEfiHashAlgorithmSha1Guid, 
      (BOOLEAN)HashIter, 
      (CONST UINT8 *)"ABCDEFGHIJKLMNOP", 
      16, 
      &HashOut
    );

    if (EFI_ERROR(Status)) {
      BindingProto->DestroyChild(BindingProto, Child);
      return FALSE;
    }
  }

  BindingProto->DestroyChild(BindingProto, Child);

  //
  // Verify result.
  //
  if (CompareMem(
    Sha1Hash,
    "\x14\x80\x6E\x23\xB4\xCE\xB6\x5D\xDF\x01"
    "\xE5\xEA\x7F\xBC\xDD\x03\xAA\xFA\xF5\xCD",
    sizeof Sha1Hash
    )) {
    return FALSE;
  }
  
  return TRUE;
}
开发者ID:jief666,项目名称:clover,代码行数:85,代码来源:HashServiceFix.c


注:本文中的EFI_SERVICE_BINDING_PROTOCOL::CreateChild方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。