/* Locate a certain GUID protocol interface in a Handle's protocols. */
PROTOCOL_INTERFACE* SmmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
/* Locate a certain GUID protocol interface in a Handle's protocols. */
PROTOCOL_INTERFACE* SmmGetProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol)
{
  EFI_STATUS          Status;
  PROTOCOL_ENTRY      *ProtEntry;
  PROTOCOL_INTERFACE  *Prot;
  IHANDLE             *Handle;
  LIST_ENTRY          *Link;
  Status = SmmValidateHandle (UserHandle);
  if (EFI_ERROR (Status)) {
    return NULL;
  }
  Handle = (IHANDLE *)UserHandle;
  for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
    Prot      = CR (Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
    ProtEntry = Prot->Protocol;
    if (CompareGuid (&ProtEntry->ProtocolID, Protocol)) {
      return Prot;
    }
  }
  return NULL;
}