Skip to content

Commit

Permalink
fix several mistakes
Browse files Browse the repository at this point in the history
Signed-off-by: SergeySlice <sergey.slice@gmail.com>
  • Loading branch information
SergeySlice committed Jul 7, 2022
1 parent 508397d commit e288a05
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
25 changes: 24 additions & 1 deletion Library/OcAppleKernelLib/CachelessContext.c
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,8 @@ CachelessContextAddKext (
IN CONST CHAR8 *InfoPlist,
IN UINT32 InfoPlistSize,
IN CONST UINT8 *Executable OPTIONAL,
IN UINT32 ExecutableSize OPTIONAL
IN UINT32 ExecutableSize OPTIONAL,
OUT CONST CHAR8 **BundleVersion OPTIONAL
)
{
EFI_STATUS Status;
Expand All @@ -834,6 +835,13 @@ CachelessContextAddKext (
ASSERT (InfoPlist != NULL);
ASSERT (InfoPlistSize > 0);

//
// Assume no bundle version from the beginning.
//
if (BundleVersion != NULL) {
*BundleVersion = NULL;
}

IsLoadable = FALSE;
PlistHasChanges = FALSE;

Expand Down Expand Up @@ -945,6 +953,21 @@ CachelessContextAddKext (
if (!Context->Is32Bit) {
InfoPlistLibraries = InfoPlistLibraries64;
}
} else {
DEBUG_CODE_BEGIN ();
if ((BundleVersion != NULL) && (AsciiStrCmp (TmpKeyValue, INFO_BUNDLE_VERSION_KEY) == 0)) {
if (PlistNodeCast (InfoPlistValue, PLIST_NODE_TYPE_STRING) == NULL) {
XmlDocumentFree (InfoPlistDocument);
FreePool (TmpInfoPlist);
FreePool (NewKext->PlistData);
FreePool (NewKext);
return EFI_INVALID_PARAMETER;
}

*BundleVersion = XmlNodeContent (InfoPlistValue);
}

DEBUG_CODE_END ();
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions Library/OcMainLib/OpenCoreKernel.c
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ OcKernelInjectKext (
CHAR8 FullPath[OC_STORAGE_SAFE_PATH_MAX];
UINT32 MaxKernel;
UINT32 MinKernel;
CONST CHAR8 *BundleVersion;

if (!Kext->Enabled || (Kext->PlistData == NULL)) {
return;
Expand Down Expand Up @@ -633,7 +634,8 @@ OcKernelInjectKext (
Kext->PlistData,
Kext->PlistDataSize,
Kext->ImageData,
Kext->ImageDataSize
Kext->ImageDataSize,
&BundleVersion
);
}
} else if (CacheType == CacheTypeMkext) {
Expand All @@ -644,7 +646,8 @@ OcKernelInjectKext (
Kext->PlistData,
Kext->PlistDataSize,
Kext->ImageData,
Kext->ImageDataSize
Kext->ImageDataSize,
&BundleVersion
);
} else if (CacheType == CacheTypePrelinked) {
Status = PrelinkedInjectKext (
Expand All @@ -655,7 +658,8 @@ OcKernelInjectKext (
Kext->PlistDataSize,
ExecutablePath,
Kext->ImageData,
Kext->ImageDataSize
Kext->ImageDataSize,
&BundleVersion
);
} else {
Status = EFI_UNSUPPORTED;
Expand Down

0 comments on commit e288a05

Please sign in to comment.