Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
43d40493
O
OpenCorePKG_MOD
项目概览
btwise
/
OpenCorePKG_MOD
通知
26
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
OpenCorePKG_MOD
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
43d40493
编写于
12月 01, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcAfterBootCompatLib: Provide cleaner patches for sur safe mode
上级
260cd294
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
45 addition
and
54 deletion
+45
-54
Library/OcAfterBootCompatLib/CustomSlide.c
Library/OcAfterBootCompatLib/CustomSlide.c
+45
-54
未找到文件。
Library/OcAfterBootCompatLib/CustomSlide.c
浏览文件 @
43d40493
...
...
@@ -660,82 +660,70 @@ AppleSlideUnlockForSafeMode (
UINTN
SearchSeqNewSize
;
BOOLEAN
NewWay
;
BOOLEAN
IsSur
;
UINT8
SurWay
;
StartOff
=
ImageBase
;
EndOff
=
StartOff
+
ImageSize
-
sizeof
(
SearchSeq
)
-
MaxDist
;
FirstOff
=
0
;
SecondOff
=
0
;
//
// Rebranding started with macOS 11. All the ones before had Mac OS X or none.
//
IsSur
=
FindPattern
(
(
CONST
UINT8
*
)
"Mac OS X 10.
"
,
(
CONST
UINT8
*
)
"macOS
"
,
NULL
,
L_STR_LEN
(
"
Mac OS X 10.
"
),
L_STR_LEN
(
"
macOS
"
),
ImageBase
,
(
UINT32
)
ImageSize
,
(
INT32
)
(
ImageSize
/
2
)
)
<
0
;
)
>=
0
;
if
(
IsSur
)
{
for
(
FirstOff
=
0
;
StartOff
+
FirstOff
<=
EndOff
;
++
FirstOff
)
{
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqSur
,
sizeof
(
SearchSeqSur
))
==
0
)
{
DEBUG
((
DEBUG_INFO
,
"OCABC: Patching safe mode sur-1 at off %X
\n
"
,
(
UINT32
)
FirstOff
));
SetMem
(
StartOff
+
FirstOff
,
sizeof
(
SearchSeqSur
)
+
1
,
0x90
);
return
;
}
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqSur2
,
sizeof
(
SearchSeqSur2
))
==
0
)
{
DEBUG
((
DEBUG_INFO
,
"OCABC: Patching safe mode sur-2 at off %X
\n
"
,
(
UINT32
)
FirstOff
));
*
(
StartOff
+
FirstOff
+
3
)
=
0xEB
;
return
;
}
}
DEBUG
((
DEBUG_INFO
,
"OCABC: Failed to find safe mode sur sequence
\n
"
));
return
;
}
FirstOff
=
0
;
SecondOff
=
0
;
do
{
NewWay
=
FALSE
;
SurWay
=
0
;
while
(
StartOff
+
FirstOff
<=
EndOff
)
{
if
(
IsSur
)
{
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqSur
,
sizeof
(
SearchSeqSur
))
==
0
)
{
SurWay
=
1
;
break
;
}
else
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqSur2
,
sizeof
(
SearchSeqSur2
))
==
0
)
{
SurWay
=
2
;
break
;
}
}
else
if
(
StartOff
+
FirstOff
<=
EndOff
-
1
if
(
StartOff
+
FirstOff
<=
EndOff
-
1
&&
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqNew2
,
sizeof
(
SearchSeqNew2
))
==
0
)
{
SearchSeqNewSize
=
sizeof
(
SearchSeqNew2
);
NewWay
=
TRUE
;
break
;
}
else
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqNew
,
sizeof
(
SearchSeqNew
))
==
0
)
{
}
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeqNew
,
sizeof
(
SearchSeqNew
))
==
0
)
{
SearchSeqNewSize
=
sizeof
(
SearchSeqNew
);
NewWay
=
TRUE
;
break
;
}
else
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeq
,
sizeof
(
SearchSeq
))
==
0
)
{
}
if
(
CompareMem
(
StartOff
+
FirstOff
,
SearchSeq
,
sizeof
(
SearchSeq
))
==
0
)
{
break
;
}
FirstOff
++
;
}
DEBUG
((
DEBUG_INFO
,
"OCABC: Found kaslr %a way at off %X
\n
"
,
SurWay
?
"sur"
:
(
NewWay
?
"new"
:
"legacy"
),
(
UINT32
)
FirstOff
));
if
(
StartOff
+
FirstOff
>
EndOff
)
{
DEBUG
((
DEBUG_INFO
,
"OCABC: Failed to find first BOOT_MODE_SAFE | BOOT_MODE_ASLR sequence
\n
"
));
break
;
}
if
(
SurWay
==
1
)
{
//
// Here we just patch the comparison code and the check by straight nopping.
//
DEBUG
((
DEBUG_VERBOSE
,
"OCABC: Patching sur safe mode aslr check...
\n
"
));
SetMem
(
StartOff
+
FirstOff
,
sizeof
(
SearchSeqSur
)
+
1
,
0x90
);
return
;
}
if
(
SurWay
==
2
)
{
//
// Here we just patch the comparison code and the check by straight nopping.
//
DEBUG
((
DEBUG_VERBOSE
,
"OCABC: Patching sur safe mode aslr check v2...
\n
"
));
*
(
StartOff
+
FirstOff
+
3
)
=
0xEB
;
DEBUG
((
DEBUG_INFO
,
"OCABC: Failed to find safe mode sequence
\n
"
));
return
;
}
...
...
@@ -743,11 +731,13 @@ AppleSlideUnlockForSafeMode (
//
// Here we just patch the comparison code and the check by straight nopping.
//
DEBUG
((
DEBUG_
VERBOSE
,
"OCABC: Patching new safe mode aslr check...
\n
"
));
DEBUG
((
DEBUG_
INFO
,
"OCABC: Patching safe mode new at off %X
\n
"
,
(
UINT32
)
FirstOff
));
SetMem
(
StartOff
+
FirstOff
,
SearchSeqNewSize
+
1
,
0x90
);
return
;
}
DEBUG
((
DEBUG_INFO
,
"OCABC: Found safe mode legacy p1 at off %X
\n
"
,
(
UINT32
)
FirstOff
));
SecondOff
=
FirstOff
+
sizeof
(
SearchSeq
);
while
(
...
...
@@ -756,13 +746,14 @@ AppleSlideUnlockForSafeMode (
SecondOff
++
;
}
DEBUG
((
DEBUG_VERBOSE
,
"OCABC: Found second at off %X
\n
"
,
(
UINT32
)
SecondOff
));
if
(
FirstOff
+
MaxDist
<
SecondOff
)
{
DEBUG
((
DEBUG_
VERBOSE
,
"OCABC: Trying next match...
\n
"
));
DEBUG
((
DEBUG_
INFO
,
"OCABC: Trying safe mode next legacy match
\n
"
));
SecondOff
=
0
;
FirstOff
+=
sizeof
(
SearchSeq
);
continue
;
}
DEBUG
((
DEBUG_INFO
,
"OCABC: Found safe mode legacy p2 at off %X
\n
"
,
(
UINT32
)
SecondOff
));
}
while
(
SecondOff
==
0
);
if
(
SecondOff
!=
0
)
{
...
...
@@ -771,7 +762,7 @@ AppleSlideUnlockForSafeMode (
// Since the state values are contradictive (e.g. safe & single at the same time)
// We are allowed to use this instead of to simulate if (false).
//
DEBUG
((
DEBUG_
VERBOSE
,
"OCABC: Patching safe mode aslr check...
\n
"
));
DEBUG
((
DEBUG_
INFO
,
"OCABC: Patching safe mode legacy
\n
"
));
SetMem
(
StartOff
+
FirstOff
,
sizeof
(
SearchSeq
),
0xFF
);
SetMem
(
StartOff
+
SecondOff
,
sizeof
(
SearchSeq
),
0xFF
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录