Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
btwise
OpenCorePKG_MOD
提交
d8ace476
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,发现更多精彩内容 >>
提交
d8ace476
编写于
7月 05, 2020
作者:
V
vit9696
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
OcAppleKernelLib: Fix patching KC vtables with imports from kexts
上级
9e166de9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
46 addition
and
9 deletion
+46
-9
Include/Apple/IndustryStandard/AppleMachoImage.h
Include/Apple/IndustryStandard/AppleMachoImage.h
+1
-1
Library/OcAppleKernelLib/KernelCollection.c
Library/OcAppleKernelLib/KernelCollection.c
+3
-3
Library/OcAppleKernelLib/Link.c
Library/OcAppleKernelLib/Link.c
+2
-1
Library/OcAppleKernelLib/PrelinkedInternal.h
Library/OcAppleKernelLib/PrelinkedInternal.h
+4
-0
Library/OcAppleKernelLib/Vtables.c
Library/OcAppleKernelLib/Vtables.c
+32
-4
Utilities/TestKextInject/KextInject.c
Utilities/TestKextInject/KextInject.c
+4
-0
未找到文件。
Include/Apple/IndustryStandard/AppleMachoImage.h
浏览文件 @
d8ace476
...
...
@@ -1805,7 +1805,7 @@ typedef struct {
Key
:
2
,
Next
:
12
,
///< 1 or 4-byte stide
IsAuth
:
1
;
///< 0 -> not authenticated. 1 -> authenticated
}
MACH_DY
K
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
;
}
MACH_DY
L
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
;
// header of the LC_DYLD_CHAINED_FIXUPS payload
typedef
struct
{
...
...
Library/OcAppleKernelLib/KernelCollection.c
浏览文件 @
d8ace476
...
...
@@ -444,11 +444,11 @@ InternalKcConvertRelocToFixup (
UINT16
NewFixupPage
;
UINT16
NewFixupPageOffset
;
MACH_DY
K
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
NewFixup
;
MACH_DY
L
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
NewFixup
;
UINT16
IterFixupPageOffset
;
VOID
*
IterFixupData
;
MACH_DY
K
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
IterFixup
;
MACH_DY
L
D_CHAINED_PTR_64_KERNEL_CACHE_REBASE
IterFixup
;
UINT16
NextIterFixupPageOffset
;
UINT16
FixupDelta
;
...
...
@@ -488,7 +488,7 @@ InternalKcConvertRelocToFixup (
// This 1MB here is a bit of a hack. I think it is just the same thing
// as KERNEL_BASE_PADDR in OcAfterBootCompatLib.
//
NewFixup
.
Target
=
ReadUnaligned64
(
RelocDest
)
-
BASE_1MB
;
NewFixup
.
Target
=
ReadUnaligned64
(
RelocDest
)
-
KERNEL_FIXUP_OFFSET
;
NewFixupPage
=
(
UINT16
)
(
RelocOffsetInSeg
/
MACHO_PAGE_SIZE
);
NewFixupPageOffset
=
(
UINT16
)
(
RelocOffsetInSeg
%
MACHO_PAGE_SIZE
);
...
...
Library/OcAppleKernelLib/Link.c
浏览文件 @
d8ace476
...
...
@@ -1405,10 +1405,11 @@ InternalPrelinkKext64 (
//
// Undefined symbols are solved via their name.
//
SymbolName
=
MachoGetSymbolName64
(
MachoContext
,
Symbol
);
Result
=
InternalSolveSymbol64
(
Context
,
Kext
,
MachoGetSymbolName64
(
MachoContext
,
Symbol
)
,
SymbolName
,
Symbol
,
&
WeakTestValue
,
UndefinedSymtab
,
...
...
Library/OcAppleKernelLib/PrelinkedInternal.h
浏览文件 @
d8ace476
...
...
@@ -257,6 +257,10 @@ InternalConnectExternalSymtab (
#define VTABLE_HEADER_LEN_64 2U
#define VTABLE_HEADER_SIZE_64 (VTABLE_HEADER_LEN_64 * VTABLE_ENTRY_SIZE_64)
#define KERNEL_ADDRESS_MASK 0xFFFFFFFF00000000ULL
#define KERNEL_ADDRESS_BASE 0xFFFFFF8000000000ULL
#define KERNEL_FIXUP_OFFSET BASE_1MB
typedef
union
{
struct
{
UINT32
Major
:
14
;
...
...
Library/OcAppleKernelLib/Vtables.c
浏览文件 @
d8ace476
...
...
@@ -96,10 +96,11 @@ InternalConstructVtablePrelinked64 (
OUT
PRELINKED_VTABLE
*
Vtable
)
{
CONST
UINT64
*
VtableData
;
UINT64
Value
;
UINT32
Index
;
CONST
PRELINKED_KEXT_SYMBOL
*
Symbol
;
CONST
UINT64
*
VtableData
;
UINT64
Value
;
UINT32
Index
;
CONST
PRELINKED_KEXT_SYMBOL
*
Symbol
;
MACH_DYLD_CHAINED_PTR_64_KERNEL_CACHE_REBASE
*
Rebase
;
ASSERT
(
Kext
!=
NULL
);
ASSERT
(
VtableLookup
!=
NULL
);
...
...
@@ -123,6 +124,32 @@ InternalConstructVtablePrelinked64 (
(
Value
=
VtableData
[
Index
+
VTABLE_HEADER_LEN_64
])
!=
0
;
++
Index
)
{
//
// For all non-kernel (which uses own relocation) virtual tables
// all virtual tables will contain fixups exclusively.
// For now we will just detect them by the kernel address
// as it is faster than compare Kext->Identifier and Context->IsKernelCollection.
//
if
((
Value
&
KERNEL_ADDRESS_MASK
)
!=
KERNEL_ADDRESS_BASE
)
{
//
// FIXME: This needs a bit more love with aliasing and alignment.
// Some day, when Intel rewrites EDK II.
//
Rebase
=
(
MACH_DYLD_CHAINED_PTR_64_KERNEL_CACHE_REBASE
*
)(
UINTN
)
&
Value
;
DEBUG_CODE_BEGIN
();
if
(
Rebase
->
CacheLevel
!=
0
||
Rebase
->
Diversity
!=
0
||
Rebase
->
AddrDiv
!=
0
||
Rebase
->
Key
!=
0
||
Rebase
->
IsAuth
!=
0
)
{
DEBUG
((
DEBUG_INFO
,
"OCAK: Invalid fixup %Lx in %a for %a
\n
"
,
Value
,
Vtable
->
Name
,
Kext
->
Identifier
));
}
DEBUG_CODE_END
();
Value
=
Rebase
->
Target
+
KERNEL_FIXUP_OFFSET
+
KERNEL_ADDRESS_BASE
;
}
//
// If we can't find the symbol, it means that the virtual function was
// defined inline. There's not much I can do about this; it just means
...
...
@@ -205,6 +232,7 @@ InternalPrepareCreateVtablesPrelinked64 (
// __ZTV20IOACPIPlatformDevice
//
if
(
Symbol
->
Value
==
0
)
{
DEBUG
((
DEBUG_VERBOSE
,
"OCAK: Skipping %a with NULL value
\n
"
,
Symbol
->
Name
));
continue
;
}
...
...
Utilities/TestKextInject/KextInject.c
浏览文件 @
d8ace476
...
...
@@ -446,6 +446,10 @@ GetFileSize (
}
int
wrap_main
(
int
argc
,
char
**
argv
)
{
PcdGet32
(
PcdFixedDebugPrintErrorLevel
)
|=
DEBUG_INFO
;
PcdGet32
(
PcdDebugPrintErrorLevel
)
|=
DEBUG_INFO
;
UINT32
AllocSize
;
PRELINKED_CONTEXT
Context
;
const
char
*
name
=
argc
>
1
?
argv
[
1
]
:
"/System/Library/PrelinkedKernels/prelinkedkernel"
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录