Skip to content

Commit

Permalink
Fixed KDK support disrespecting file suffixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vit9696 committed Apr 14, 2020
1 parent 5a7b368 commit 40e8202
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Lilu Changelog
==============
#### v1.4.4
- Added new CFL connector-less framebuffers: 0x9BC80003, 0x9BC50003, 0x9BC40003
- Fixed KDK support disrespecting file suffixes

#### v1.4.3
- Improved modern CPUID detection
Expand Down
7 changes: 4 additions & 3 deletions Lilu/Sources/kern_mach.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ kern_return_t MachInfo::initFromFileSystem(const char * const paths[], size_t nu
bool found = false;
// Starting with 10.10 macOS supports kcsuffix that may be appended to processes, kernels, and kexts
char suffix[32] {};
size_t suffixnum = getKernelVersion() >= KernelVersion::Yosemite && PE_parse_boot_argn("kcsuffix", suffix, sizeof(suffix));
size_t suffixnum = getKernelVersion() >= KernelVersion::Yosemite && PE_parse_boot_argn("kcsuffix", suffix, sizeof(suffix)) ? 2 : 0;

for (size_t i = 0; i < num && !found; i++) {
auto pathlen = static_cast<uint32_t>(strlen(paths[i]));
Expand All @@ -139,9 +139,10 @@ kern_return_t MachInfo::initFromFileSystem(const char * const paths[], size_t nu
for (size_t j = 0; j <= suffixnum; j++) {
auto path = paths[i];
char tmppath[PATH_MAX];
// Prefer the suffixed version
// Prefer the suffixed version if available and fallback to unsuffixed otherwise.
if (j != suffixnum) {
snprintf(tmppath, sizeof(tmppath), "%s.%s", path, suffix);
// Kexts(?) may use _ for suffixes e.g. IOPCIFamily_development.
snprintf(tmppath, sizeof(tmppath), "%s%c%s", path, j == 0 ? '.' : '_', suffix);
path = tmppath;
}

Expand Down

0 comments on commit 40e8202

Please sign in to comment.