/* This function exports device path package to a buffer. This is a internal function. */
EFI_STATUS ExportDevicePathPackage(IN HII_DATABASE_PRIVATE_DATA *Private, IN EFI_HII_HANDLE Handle, IN HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList, IN UINTN UsedSize, IN UINTN BufferSize, IN OUT VOID *Buffer, IN OUT UINTN *ResultSize)
/* This function exports device path package to a buffer. This is a internal function. */
EFI_STATUS ExportDevicePathPackage(IN HII_DATABASE_PRIVATE_DATA *Private, IN EFI_HII_HANDLE Handle, IN HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList, IN UINTN UsedSize, IN UINTN BufferSize, IN OUT VOID *Buffer, IN OUT UINTN *ResultSize)
{
  EFI_STATUS              Status;
  UINT8                   *Package;
  EFI_HII_PACKAGE_HEADER  Header;
  if ((Private == NULL) || (PackageList == NULL) || (ResultSize == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  if ((BufferSize > 0) && (Buffer == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Package = PackageList->DevicePathPkg;
  if (Package == NULL) {
    return EFI_SUCCESS;
  }
  CopyMem (&Header, Package, sizeof (EFI_HII_PACKAGE_HEADER));
  if (Header.Length + *ResultSize + UsedSize <= BufferSize) {
    Status = InvokeRegisteredFunction (
               Private,
               EFI_HII_DATABASE_NOTIFY_EXPORT_PACK,
               (VOID *)Package,
               EFI_HII_PACKAGE_DEVICE_PATH,
               Handle
               );
    ASSERT_EFI_ERROR (Status);
    CopyMem (Buffer, Package, Header.Length);
  }
  *ResultSize += Header.Length;
  return EFI_SUCCESS;
}