diff --git a/Library/OcBootManagementLib/BootEntryInfo.c b/Library/OcBootManagementLib/BootEntryInfo.c index 39943614..3e5aaec2 100644 --- a/Library/OcBootManagementLib/BootEntryInfo.c +++ b/Library/OcBootManagementLib/BootEntryInfo.c @@ -189,7 +189,7 @@ InternalGetAppleRecoveryName ( } UnicodeSPrint (SystemVersionPath, SystemVersionPathSize, L"%sSystemVersion.plist", BootDirectoryName); - DEBUG ((DEBUG_INFO, "Trying to get recovery from %s\n", SystemVersionPath)); + DEBUG ((DEBUG_INFO, "OCB: Trying to get recovery from %s\n", SystemVersionPath)); SystemVersionData = (CHAR8 *) ReadFile (FileSystem, SystemVersionPath, &SystemVersionDataSize, BASE_1MB); FreePool (SystemVersionPath); diff --git a/Library/OcBootManagementLib/BootEntryManagement.c b/Library/OcBootManagementLib/BootEntryManagement.c index bbf48a07..76c5015a 100644 --- a/Library/OcBootManagementLib/BootEntryManagement.c +++ b/Library/OcBootManagementLib/BootEntryManagement.c @@ -341,12 +341,33 @@ AddBootEntryOnFileSystem ( OC_BOOT_ENTRY_TYPE EntryType; LIST_ENTRY *Link; OC_BOOT_ENTRY *ExistingEntry; + CHAR16 *TextDevicePath; BOOLEAN IsFolder; - DebugPrintDevicePath (DEBUG_INFO, "OCB: Adding entry", DevicePath); - EntryType = OcGetBootDevicePathType (DevicePath, &IsFolder); + DEBUG_CODE_BEGIN (); + + if (DevicePath != NULL) { + TextDevicePath = ConvertDevicePathToText (DevicePath, TRUE, FALSE); + } else { + TextDevicePath = NULL; + } + + DEBUG (( + DEBUG_INFO, + "OCB: Adding entry type (T:%u|F:%d) - %s\n", + EntryType, + IsFolder, + OC_HUMAN_STRING (TextDevicePath) + )); + + if (TextDevicePath != NULL) { + FreePool (TextDevicePath); + } + + DEBUG_CODE_END (); + // // Mark self recovery presence. // diff --git a/Library/OcStringLib/OcUnicodeLib.c b/Library/OcStringLib/OcUnicodeLib.c index af400858..a8a95397 100755 --- a/Library/OcStringLib/OcUnicodeLib.c +++ b/Library/OcStringLib/OcUnicodeLib.c @@ -139,31 +139,55 @@ OcStriStr ( CONST CHAR16 * OcStrStrLength ( - IN CONST CHAR16 *String, - IN UINTN StringLength, - IN CONST CHAR16 *SearchString, - IN UINTN SearchStringLength + CONST CHAR16 *String, + UINTN StringLength, + CONST CHAR16 *SearchString, + UINTN SearchStringLength ) { - UINTN RestLen; - UINTN Index; - INTN CmpResult; - BOOLEAN Overflowed; + UINTN Index; + UINTN Index2; + UINTN Index3; + INTN CmpResult; + CONST CHAR16 *Y; + CONST CHAR16 *X; - Overflowed = OcOverflowSubUN (StringLength, SearchStringLength, &RestLen); - if (Overflowed) { + // + // REF: http://www-igm.univ-mlv.fr/~lecroq/string/node13.html#SECTION00130 + // + + if (SearchStringLength > StringLength + || SearchStringLength == 0 + || StringLength == 0) { return NULL; } - for (Index = 0; Index < RestLen; ++Index) { - CmpResult = CompareMem ( - &String[Index], - SearchString, - (SearchStringLength + 1) * sizeof (*SearchString) - ); - if (CmpResult == 0) { - return &String[Index]; + Y = (CONST CHAR16 *) String; + X = (CONST CHAR16 *) SearchString; + + if (X[0] == X[1]) { + Index2 = 2; + Index3 = 1; + } else { + Index2 = 1; + Index3 = 2; + } + + if (SearchStringLength > 1) { + while (Index <= StringLength - SearchStringLength) { + if (X[1] != Y[Index+1]) { + Index += Index2; + } else { + CmpResult = CompareMem (X+2, Y+Index+2, (SearchStringLength - 2) * sizeof (*SearchString)); + if (CmpResult == 0 && X[0] == Y[Index]) { + return &Y[Index]; + } + + Index += Index3; + } } + } else { + return ScanMem16 (String, StringLength * sizeof (*SearchString), *SearchString); } return NULL;