1 Star 0 Fork 27

Ccing/OpenCore_NO_ACPI

forked from btwise/OpenCore_NO_ACPI 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
0005-ShellPkg-Devices-shell-command-support-misaligned-de.patch 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
vit9696 提交于 2022-03-05 19:58 . Patches: Fix previous patch update
From 835e353002ab6e5606c3a9f73d6e2f00f3c2a259 Mon Sep 17 00:00:00 2001
From: ocbuild <[email protected]>
Date: Wed, 31 Mar 2021 07:11:46 +0100
Subject: [PATCH] ShellPkg: Devices shell command support misaligned device
names found in some Apple firmware
---
ShellPkg/Application/Shell/ShellProtocol.c | 27 ++++++++++++++++++++++
1 file changed, 27 insertions(+)
diff --git a/ShellPkg/Application/Shell/ShellProtocol.c b/ShellPkg/Application/Shell/ShellProtocol.c
index 509eb60e40..25f33166e6 100644
--- a/ShellPkg/Application/Shell/ShellProtocol.c
+++ b/ShellPkg/Application/Shell/ShellProtocol.c
@@ -598,6 +598,25 @@ EfiShellGetDevicePathFromFilePath (
return (DevicePathForReturn);
}
+STATIC
+CHAR16 *
+RealignString16 (
+ IN CONST VOID *Source
+ )
+{
+ CHAR16 NextChar;
+ CONST UINT8 *Walker;
+
+ Walker = Source;
+
+ do {
+ NextChar = ReadUnaligned16 ((VOID *) Walker);
+ Walker += sizeof (CHAR16);
+ } while (NextChar != CHAR_NULL);
+
+ return AllocateCopyPool ((UINTN) (Walker - (CONST UINT8 *) Source), Source);
+}
+
/**
Gets the name of the device specified by the device handle.
@@ -655,6 +674,7 @@ EfiShellGetDeviceName (
EFI_HANDLE *ParentControllerBuffer;
UINTN ParentDriverCount;
EFI_HANDLE *ParentDriverBuffer;
+ BOOLEAN NeedsRealign;
if ((BestDeviceName == NULL) ||
(DeviceHandle == NULL)
@@ -783,7 +803,14 @@ EfiShellGetDeviceName (
//
if (DeviceNameToReturn != NULL) {
ASSERT (BestDeviceName != NULL);
+ NeedsRealign = ((UINTN) DeviceNameToReturn & BIT0) != 0;
+ if (NeedsRealign) {
+ DeviceNameToReturn = RealignString16 (DeviceNameToReturn);
+ }
StrnCatGrow (BestDeviceName, NULL, DeviceNameToReturn, 0);
+ if (NeedsRealign) {
+ FreePool (DeviceNameToReturn);
+ }
return (EFI_SUCCESS);
}
}
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Ccing/OpenCore_NO_ACPI.git
[email protected]:Ccing/OpenCore_NO_ACPI.git
Ccing
OpenCore_NO_ACPI
OpenCore_NO_ACPI
master

搜索帮助