Refactor LoadOptions as XString.

This commit is contained in:
Jief L 2020-04-05 15:25:39 +03:00
parent e9bf5703f6
commit b8bb76d51e
33 changed files with 1088 additions and 744 deletions

View File

@ -38,6 +38,14 @@
9A28CD34241BC0DF00F3D247 /* strncmp_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD2E241BC0DF00F3D247 /* strncmp_test.cpp */; };
9A28CD35241BC0DF00F3D247 /* strlen_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD2F241BC0DF00F3D247 /* strlen_test.h */; };
9A28CD36241BC0DF00F3D247 /* strncmp_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A28CD30241BC0DF00F3D247 /* strncmp_test.h */; };
9A4185B62439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; };
9A4185B72439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; };
9A4185B82439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; };
9A4185B92439F29D00BEAFB8 /* LoadOptions_test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */; };
9A4185BA2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */; };
9A4185BB2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */; };
9A4185BC2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */; };
9A4185BD2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */; };
9A57C25724192D650029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C25524192D650029A39F /* XUINTN.cpp */; };
9A57C25824192D650029A39F /* XUINTN.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A57C25624192D650029A39F /* XUINTN.h */; };
9A57C25B24192D710029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C25924192D710029A39F /* XUINTN_test.cpp */; };
@ -880,6 +888,8 @@
9A28CD2E241BC0DF00F3D247 /* strncmp_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strncmp_test.cpp; sourceTree = "<group>"; };
9A28CD2F241BC0DF00F3D247 /* strlen_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strlen_test.h; sourceTree = "<group>"; };
9A28CD30241BC0DF00F3D247 /* strncmp_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = strncmp_test.h; sourceTree = "<group>"; };
9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadOptions_test.h; sourceTree = "<group>"; };
9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadOptions_test.cpp; sourceTree = "<group>"; };
9A57C25524192D650029A39F /* XUINTN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN.cpp; sourceTree = "<group>"; };
9A57C25624192D650029A39F /* XUINTN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN.h; sourceTree = "<group>"; };
9A57C25924192D710029A39F /* XUINTN_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN_test.cpp; sourceTree = "<group>"; };
@ -1183,6 +1193,8 @@
9AC77ED724176C04005CDD5C /* all_tests.h */,
9AC780B22417EE4A005CDD5C /* global_test.cpp */,
9AC780B42417EE53005CDD5C /* global_test.h */,
9A4185B52439F29D00BEAFB8 /* LoadOptions_test.cpp */,
9A4185B42439F29D00BEAFB8 /* LoadOptions_test.h */,
9AF41567242BAD7D00D2644C /* poolprint-test-cpp_conf.h */,
9AF4155C242B8FA300D2644C /* poolprint-test.cpp */,
9AF4155B242B8FA300D2644C /* poolprint-test.h */,
@ -1553,6 +1565,7 @@
9AC7808624176C04005CDD5C /* globals_ctor.h in Headers */,
9AF4155D242B8FA400D2644C /* poolprint-test.h in Headers */,
9A28CCA5241B66EA00F3D247 /* stddef.h in Headers */,
9A4185B62439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9AC7806724176C04005CDD5C /* securebootkeys.h in Headers */,
9A9D3B30242215A1006D8CD9 /* string.h in Headers */,
9A28CC94241AB33700F3D247 /* XString.h in Headers */,
@ -1663,6 +1676,7 @@
9ACFE6AD24309AF80071CC93 /* globals_ctor.h in Headers */,
9ACFE6AE24309AF80071CC93 /* poolprint-test.h in Headers */,
9ACFE6AF24309AF80071CC93 /* stddef.h in Headers */,
9A4185B92439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9ACFE6B024309AF80071CC93 /* securebootkeys.h in Headers */,
9ACFE6B124309AF80071CC93 /* string.h in Headers */,
9ACFE6B224309AF80071CC93 /* XString.h in Headers */,
@ -1705,6 +1719,7 @@
9AF415A1242CD75C00D2644C /* XStringWArray.h in Headers */,
9A09863C2438A15400826276 /* shared_with_menu.h in Headers */,
9AF415A2242CD75C00D2644C /* XUINTN.h in Headers */,
9A4185B72439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9AF415A3242CD75C00D2644C /* strcmp_test.h in Headers */,
9AF415A4242CD75C00D2644C /* boot.h in Headers */,
9AF415A5242CD75C00D2644C /* ati.h in Headers */,
@ -1813,6 +1828,7 @@
9AF4167E242CDA5800D2644C /* XStringWArray.h in Headers */,
9A09863D2438A15400826276 /* shared_with_menu.h in Headers */,
9AF4167F242CDA5800D2644C /* XUINTN.h in Headers */,
9A4185B82439F29D00BEAFB8 /* LoadOptions_test.h in Headers */,
9AF41680242CDA5800D2644C /* strcmp_test.h in Headers */,
9AF41681242CDA5800D2644C /* boot.h in Headers */,
9AF41682242CDA5800D2644C /* ati.h in Headers */,
@ -2132,6 +2148,7 @@
9AC7809124176C04005CDD5C /* XStringW.cpp in Sources */,
9AC7806924176C04005CDD5C /* lockedgraphics.cpp in Sources */,
9A28CC97241AB34800F3D247 /* XString_test.cpp in Sources */,
9A4185BA2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9AC7803724176C04005CDD5C /* device_inject.cpp in Sources */,
9AC7804224176C04005CDD5C /* Settings.cpp in Sources */,
9A0986372438A15400826276 /* shared_with_menu.cpp in Sources */,
@ -2249,6 +2266,7 @@
9ACFE6F124309AF80071CC93 /* string.cpp in Sources */,
9ACFE6F224309AF80071CC93 /* XStringW.cpp in Sources */,
9ACFE6F324309AF80071CC93 /* lockedgraphics.cpp in Sources */,
9A4185BD2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9ACFE6F424309AF80071CC93 /* XString_test.cpp in Sources */,
9ACFE6F524309AF80071CC93 /* device_inject.cpp in Sources */,
9A09863A2438A15400826276 /* shared_with_menu.cpp in Sources */,
@ -2366,6 +2384,7 @@
9AF41628242CD75C00D2644C /* XStringW.cpp in Sources */,
9AF41629242CD75C00D2644C /* lockedgraphics.cpp in Sources */,
9AF4162A242CD75C00D2644C /* XString_test.cpp in Sources */,
9A4185BB2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9AF4162B242CD75C00D2644C /* device_inject.cpp in Sources */,
9AF4162C242CD75C00D2644C /* Settings.cpp in Sources */,
9A0986382438A15400826276 /* shared_with_menu.cpp in Sources */,
@ -2483,6 +2502,7 @@
9AF41705242CDA5800D2644C /* XStringW.cpp in Sources */,
9AF41706242CDA5800D2644C /* lockedgraphics.cpp in Sources */,
9AF41707242CDA5800D2644C /* XString_test.cpp in Sources */,
9A4185BC2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
9AF41708242CDA5800D2644C /* device_inject.cpp in Sources */,
9AF41709242CDA5800D2644C /* Settings.cpp in Sources */,
9A0986392438A15400826276 /* shared_with_menu.cpp in Sources */,
@ -2588,6 +2608,7 @@
"-fno-exceptions",
"-fno-unwind-tables",
"-Wno-incompatible-ms-struct",
"-Wreorder",
);
SUPPORTED_PLATFORMS = macosx;
USE_HEADERMAP = NO;
@ -2634,6 +2655,7 @@
"-fno-exceptions",
"-fno-unwind-tables",
"-Wno-incompatible-ms-struct",
"-Wreorder",
);
SUPPORTED_PLATFORMS = macosx;
USE_HEADERMAP = NO;

View File

@ -49,6 +49,12 @@
9A28CD4B241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */; };
9A28CD4C241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */; };
9A28CD4D241F4CCE00F3D247 /* xcode_utf16.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */; };
9A4185B12439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185AF2439E4D500BEAFB8 /* LoadOptions_test.cpp */; };
9A4185B22439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185AF2439E4D500BEAFB8 /* LoadOptions_test.cpp */; };
9A4185B32439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185AF2439E4D500BEAFB8 /* LoadOptions_test.cpp */; };
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */; };
9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */; };
9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */; };
9A57C20D2418A27B0029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20B2418A27B0029A39F /* XUINTN.cpp */; };
9A57C20E2418A27B0029A39F /* XUINTN.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20B2418A27B0029A39F /* XUINTN.cpp */; };
9A57C2112418A3560029A39F /* XUINTN_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C20F2418A3550029A39F /* XUINTN_test.cpp */; };
@ -159,6 +165,10 @@
9A28CD1E241BB61B00F3D247 /* strlen.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = strlen.cpp; sourceTree = "<group>"; };
9A28CD49241F437C00F3D247 /* xcode_utf16.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = xcode_utf16.h; sourceTree = "<group>"; };
9A28CD4A241F4CCE00F3D247 /* xcode_utf16.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = xcode_utf16.cpp; sourceTree = "<group>"; };
9A4185AF2439E4D500BEAFB8 /* LoadOptions_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LoadOptions_test.cpp; sourceTree = "<group>"; };
9A4185B02439E4D600BEAFB8 /* LoadOptions_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LoadOptions_test.h; sourceTree = "<group>"; };
9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XStringArray.cpp; sourceTree = "<group>"; };
9A4185BF2439F73A00BEAFB8 /* XStringArray.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XStringArray.h; sourceTree = "<group>"; };
9A57C20A2418A1FD0029A39F /* global_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = global_test.h; sourceTree = "<group>"; };
9A57C20B2418A27B0029A39F /* XUINTN.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XUINTN.cpp; sourceTree = "<group>"; };
9A57C20C2418A27B0029A39F /* XUINTN.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XUINTN.h; sourceTree = "<group>"; };
@ -234,6 +244,8 @@
9A0B084B2402FE9300E2B470 /* XObjArray.h */,
9A57C267241A799B0029A39F /* XString.cpp */,
9A57C266241A799B0029A39F /* XString.h */,
9A4185BE2439F73A00BEAFB8 /* XStringArray.cpp */,
9A4185BF2439F73A00BEAFB8 /* XStringArray.h */,
9A0B08482402FE9300E2B470 /* XStringW.cpp */,
9A0B08462402FE9300E2B470 /* XStringW.h */,
9A0B08472402FE9300E2B470 /* XStringWArray.cpp */,
@ -252,6 +264,8 @@
9A0B084C2402FE9B00E2B470 /* cpp_unit_test */ = {
isa = PBXGroup;
children = (
9A4185AF2439E4D500BEAFB8 /* LoadOptions_test.cpp */,
9A4185B02439E4D600BEAFB8 /* LoadOptions_test.h */,
9A0B08512402FE9B00E2B470 /* all_tests.cpp */,
9A0B08542402FE9B00E2B470 /* all_tests.h */,
9A0B08642403144C00E2B470 /* global_test.cpp */,
@ -474,6 +488,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A4185B22439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A57C20E2418A27B0029A39F /* XUINTN.cpp in Sources */,
9A0B08732403B08400E2B470 /* XObjArray_tests.cpp in Sources */,
9A28CD20241BB61B00F3D247 /* abort.cpp in Sources */,
@ -496,6 +511,7 @@
9AA045902425F979000D6970 /* unicode_conversions.cpp in Sources */,
9A0B087D2403B08400E2B470 /* XStringWArray_test.cpp in Sources */,
9A28CD11241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A57C2162418A6EA0029A39F /* XStringWP.cpp in Sources */,
9A0B087E2403B08400E2B470 /* XArray_tests.cpp in Sources */,
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
@ -509,6 +525,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9A4185B32439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A57C2192418B9A00029A39F /* XUINTN.cpp in Sources */,
9A57C21A2418B9A00029A39F /* XObjArray_tests.cpp in Sources */,
9A28CD21241BB61B00F3D247 /* abort.cpp in Sources */,
@ -531,6 +548,7 @@
9AA045912425F979000D6970 /* unicode_conversions.cpp in Sources */,
9A57C2252418B9A00029A39F /* XStringWArray_test.cpp in Sources */,
9A28CD12241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A57C2262418B9A00029A39F /* XStringWP.cpp in Sources */,
9A57C2272418B9A00029A39F /* XArray_tests.cpp in Sources */,
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */,
@ -562,10 +580,12 @@
9A0B085F240308E400E2B470 /* XStringW.cpp in Sources */,
9A0B08592402FF8200E2B470 /* all_tests.cpp in Sources */,
9A0B08662403144C00E2B470 /* global_test.cpp in Sources */,
9A4185B12439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
9A0B08572402FF7A00E2B470 /* XToolsCommon.cpp in Sources */,
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */,
9AA0458F2425F979000D6970 /* unicode_conversions.cpp in Sources */,
9A0B08582402FF7F00E2B470 /* XStringWArray_test.cpp in Sources */,
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
9A28CD10241B9EF800F3D247 /* strcmp.cpp in Sources */,
9A57C2152418A6EA0029A39F /* XStringWP.cpp in Sources */,
9A0B085B2402FF8700E2B470 /* XArray_tests.cpp in Sources */,

View File

@ -130,6 +130,20 @@ void CopyMem(void *Destination, void *Source, UINTN Length)
memmove(Destination, Source, (size_t)Length);
}
CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src)
{
CHAR16* newS = (CHAR16*)malloc((wcslen(Src)+1)*sizeof(wchar_t));
memcpy(newS, Src, (wcslen(Src)+1)*sizeof(wchar_t));
return newS;
}
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString)
{
return (CHAR16*)wcsstr(String, SearchString);
}
//UINTN AsciiStrLen(const char* String)
//{
// return (UINTN)strlen(String);

View File

@ -71,6 +71,9 @@ void ZeroMem(void *Destination, UINTN Length);
void SetMem(void *Destination, UINTN Length, char c);
void CopyMem(void *Destination, void *Source, UINTN Length);
CHAR16* EfiStrDuplicate (IN CONST CHAR16 *Src);
CHAR16* StrStr (IN CONST CHAR16 *String, IN CONST CHAR16 *SearchString);
//UINTN StrLen(const char16_t* String);
UINTN StrLen(const wchar_t* String);

View File

@ -820,7 +820,7 @@ struct CUSTOM_LOADER_ENTRY {
CONST CHAR16 *DriveImagePath;
CONST CHAR16 *Volume;
CONST CHAR16 *Path;
CONST CHAR16 *Options;
XString Options;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
@ -843,6 +843,21 @@ struct CUSTOM_LOADER_ENTRY {
EG_PIXEL *BootBgColor; //why it is array? It is one value!
#endif
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
#if USE_XTHEME
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), ImagePath(0), DriveImagePath(0), Volume(0), Path(0), Settings(0), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
KernelScan(0), CustomBoot(0), CustomLogo(0), BootBgColor({0,0,0,0})
{ memset(&KernelAndKextPatches, 0, sizeof(KernelAndKextPatches)); }
#else
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), Image(0), DriveImage(0), ImagePath(0), DriveImagePath(0), Volume(0), Path(0), FullTitle(0), Title(0), Settings(0), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
KernelScan(0), CustomBoot(0), CustomLogo(0), BootBgColor(0)
{ memset(&KernelAndKextPatches, 0, sizeof(KernelAndKextPatches)); }
#endif
// Not sure if default are valid. Delete them. If needed, proper ones can be created
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY&) = delete;
CUSTOM_LOADER_ENTRY& operator=(const CUSTOM_LOADER_ENTRY&) = delete;
};
typedef struct CUSTOM_LEGACY_ENTRY CUSTOM_LEGACY_ENTRY;
@ -882,7 +897,7 @@ struct CUSTOM_TOOL_ENTRY {
CHAR16 *ImagePath;
CHAR16 *Volume;
CHAR16 *Path;
CHAR16 *Options;
XString Options;
#if USE_XTHEME
XStringW FullTitle;
XStringW Title;
@ -2323,9 +2338,6 @@ INTN
countOccurrences(CHAR8 *s, CHAR8 c);
CHAR16 *AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption);
CHAR16 *RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption);
//
// BootOptions.c
//

View File

@ -980,13 +980,12 @@ CUSTOM_LOADER_ENTRY
IN CUSTOM_LOADER_ENTRY *Entry
)
{
CUSTOM_LOADER_ENTRY *DuplicateEntry;
if (Entry == NULL) {
return NULL;
}
DuplicateEntry = (CUSTOM_LOADER_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LOADER_ENTRY));
// DuplicateEntry = (CUSTOM_LOADER_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LOADER_ENTRY));
CUSTOM_LOADER_ENTRY* DuplicateEntry = new CUSTOM_LOADER_ENTRY;
if (DuplicateEntry != NULL) {
if (Entry->Volume != NULL) {
DuplicateEntry->Volume = EfiStrDuplicate (Entry->Volume);
@ -996,9 +995,7 @@ CUSTOM_LOADER_ENTRY
DuplicateEntry->Path = EfiStrDuplicate (Entry->Path);
}
if (Entry->Options != NULL) {
DuplicateEntry->Options = EfiStrDuplicate (Entry->Options);
}
DuplicateEntry->Options = Entry->Options;
if (Entry->FullTitle != NULL) {
DuplicateEntry->FullTitle = Entry->FullTitle;
@ -1942,21 +1939,15 @@ FillinCustomEntry (
Prop = GetProperty (DictPointer, "AddArguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options != NULL) {
CONST CHAR16 *OldOptions = Entry->Options;
Entry->Options = PoolPrint (L"%s %a", OldOptions, Prop->string);
FreePool (OldOptions);
if (Entry->Options.notEmpty()) {
Entry->Options.SPrintf("%s %s", Entry->Options.c_str(), Prop->string);
} else {
Entry->Options = PoolPrint (L"%a", Prop->string);
Entry->Options.SPrintf("%s", Prop->string);
}
} else {
Prop = GetProperty (DictPointer, "Arguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options != NULL) {
FreePool (Entry->Options);
}
Entry->Options = PoolPrint (L"%a", Prop->string);
Entry->Options.SPrintf("%s", Prop->string);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_NODEFAULTARGS);
}
}
@ -2185,8 +2176,8 @@ FillinCustomEntry (
Entry->VolumeType = GetVolumeType(DictPointer);
if (Entry->Options == NULL && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->Options = L"-s -h";
if (Entry->Options.isEmpty() && OSTYPE_IS_WINDOWS(Entry->Type)) {
Entry->Options.SPrintf("-s -h");
}
#if USE_XTHEME
if (Entry->Title.isEmpty()) {
@ -2597,17 +2588,17 @@ FillingCustomTool (IN OUT CUSTOM_TOOL_ENTRY *Entry, TagPtr DictPointer)
if (Entry->Path != NULL) {
FreePool (Entry->Path);
}
Entry->Path = PoolPrint (L"%a", Prop->string);
}
Prop = GetProperty (DictPointer, "Arguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options != NULL) {
FreePool (Entry->Options);
} else {
Entry->Options = PoolPrint (L"%a", Prop->string);
}
// if (!Entry->Options.isEmpty()) {
// Entry->Options.setEmpty();
// } else {
// Entry->Options.SPrintf("%s", Prop->string);
// }
Entry->Options.SPrintf("%s", Prop->string);
}
Prop = GetProperty (DictPointer, "FullTitle");
@ -2701,11 +2692,12 @@ FillinCustomTool (
Prop = GetProperty (DictPointer, "Arguments");
if (Prop != NULL && (Prop->type == kTagTypeString)) {
if (Entry->Options != NULL) {
FreePool (Entry->Options);
} else {
Entry->Options = PoolPrint (L"%a", Prop->string);
}
// if (!Entry->Options.isEmpty()) {
// Entry->Options.setEmpty();
// } else {
// Entry->Options.SPrintf("%s", Prop->string);
// }
Entry->Options.SPrintf("%s", Prop->string);
}
Prop = GetProperty (DictPointer, "FullTitle");
@ -3519,7 +3511,7 @@ GetEarlyUserSettings (
if (Dict2 != NULL) {
Prop = GetProperty (Dict2, "Entries");
if (Prop != NULL) {
CUSTOM_LOADER_ENTRY *Entry;
// CUSTOM_LOADER_ENTRY *Entry;
INTN i, Count = GetTagCount (Prop);
TagPtr Dict3;
@ -3533,10 +3525,12 @@ GetEarlyUserSettings (
break;
}
// Allocate an entry
Entry = (CUSTOM_LOADER_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LOADER_ENTRY));
// Entry = (CUSTOM_LOADER_ENTRY *)AllocateZeroPool (sizeof(CUSTOM_LOADER_ENTRY));
CUSTOM_LOADER_ENTRY* Entry = new CUSTOM_LOADER_ENTRY;
// Fill it in
if (Entry != NULL && (!FillinCustomEntry (Entry, Dict3, FALSE) || !AddCustomEntry (Entry))) {
FreePool (Entry);
delete Entry;
}
}
}
@ -9489,7 +9483,7 @@ SetFSInjection (
}
// check if blocking of caches is needed
if (OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) || ((StrStr(Entry->LoadOptions, L"-f") != NULL))) {
if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) || Entry->LoadOptions.ExistIn("-f") ) {
MsgLog ("Blocking kext caches\n");
// BlockCaches = TRUE;
// add caches to blacklist

View File

@ -351,7 +351,7 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
CHAR16 *FileName;
CHAR16 *PlugIns;
CONST CHAR16 *Arch = NULL;
CONST CHAR16 *Ptr = NULL;
// CONST CHAR16 *Ptr = NULL;
#if defined(MDE_CPU_X64)
cpu_type_t archCpuType=CPU_TYPE_X86_64;
#else
@ -371,8 +371,8 @@ EFI_STATUS LoadKexts(IN LOADER_ENTRY *Entry)
}
// Make Arch point to the last appearance of "arch=" in LoadOptions (which is what boot.efi will use).
if (Entry->LoadOptions != NULL) {
for (Ptr = StrStr(Entry->LoadOptions, L"arch="); Ptr != NULL; Arch = Ptr + StrLen(L"arch="), Ptr = StrStr(Arch, L"arch="));
if (Entry->LoadOptions.notEmpty()) {
// for (Ptr = StrStr(Entry->LoadOptions, L"arch="); Ptr != NULL; Arch = Ptr + StrLen(L"arch="), Ptr = StrStr(Arch, L"arch="));
}
if (Arch != NULL && StrnCmp(Arch,L"x86_64",StrLen(L"x86_64")) == 0) {

View File

@ -484,12 +484,13 @@ void XObjArrayNC<TYPE>::Remove(const TYPE &Element)
for ( i=0 ; i<_Len ; i+= 1) {
if ( *((TYPE *)(_Data[i].Object)) == Element ) {
Remove(i);
RemoveAtIndex(i);
return ;
}
}
#if defined(_DEBUG)
throw "XObjArray::Remove(TYPE &) -> Not found\n";
DebugLog(2, "XObjArray::Remove(TYPE &) -> Not found\n");
panic();
#endif
}

View File

@ -24,6 +24,7 @@ const XString NullXString;
void XString::Init(xsize aSize)
{
m_data = (char*)malloc( (aSize+1)*sizeof(char) ); /* le 0 terminal n'est pas compté dans m_allocatedSize */
/* If want to change that the real allocated size is m_allocatedSize+1, _data method should be changed to limit access (ui > m_allocatedSize change to ui >= m_allocatedSize) */
if ( !m_data ) {
DebugLog(2, "XString::Init(%llu) : Xalloc returned NULL. Cpu halted\n", (aSize+1)*sizeof(char));
panic();
@ -478,34 +479,35 @@ xsize XString::IdxOf(char aChar, xsize Pos) const
return MAX_XSIZE;
}
xsize XString::IdxOf(const XString &S, xsize Pos) const
xsize XString::IdxOf(const char* s, xsize s_len, xsize pos) const
{
xsize i;
xsize Idx;
if ( length() < S.length() ) return MAX_XSIZE;
for ( Idx=Pos ; Idx<=length()-S.length() ; Idx+=1 ) {
if ( length() < s_len ) return MAX_XSIZE;
for ( Idx=pos ; Idx<=length()-s_len ; Idx+=1 ) {
i = 0;
while( i<S.length() && ( data()[Idx+i] - S[i] ) == 0 ) i += 1;
if ( i == S.length() ) return Idx;
while( i<s_len && ( data()[Idx+i] - s[i] ) == 0 ) i += 1;
if ( i == s_len ) return Idx;
}
return MAX_XSIZE;
}
xsize XString::IdxOfIC(const char* s, xsize s_len, xsize pos) const
{
xsize i;
xsize Idx;
if ( length() < s_len ) return MAX_XSIZE;
for ( Idx=pos ; Idx<=length()-s_len ; Idx+=1 ) {
i = 0;
while( i<s_len && ( to_lower(*data(Idx+i)) - to_lower(s[i]) ) == 0 ) i += 1;
if ( i == s_len ) return Idx;
}
return MAX_XSIZE;
}
#ifdef NOT_USED_ANYMORE_skqdjfhksqjhfksjqdf
unsigned int XString::IdxOfIC(const XString &S, xsize Pos) const
{
xsize i;
xsize Idx;
if ( length() < S.length() ) return MAX_XSIZE;
for ( Idx=Pos ; Idx<=length()-S.length() ; Idx+=1 ) {
i = 0;
while( i<S.length() && ( Minuscule(data()[Idx+i]) - Minuscule(S[i]) ) == 0 ) i += 1;
if ( i == S.length() ) return Idx;
}
return MAX_XSIZE;
}
unsigned int XString::IdxOfIAC(const XString &S, xsize Pos) const
{
@ -515,26 +517,26 @@ unsigned int XString::IdxOfIAC(const XString &S, xsize Pos) const
if ( length() < S.length() ) return MAX_XSIZE;
for ( Idx=Pos ; Idx<=length()-S.length() ; Idx+=1 ) {
i = 0;
while( i<S.length() && ( MinusculeSansAccent(data()[Idx+i]) - MinusculeSansAccent(S[i]) ) == 0 ) i += 1;
while( i<S.length() && ( to_lowerSansAccent(data(Idx+i)) - to_lowerSansAccent(S[i]) ) == 0 ) i += 1;
if ( i == S.length() ) return Idx;
}
return MAX_XSIZE;
}
#endif
xsize XString::RIdxOf(const XString &S, xsize Pos) const
xsize XString::RIdxOf(const char* s, xsize s_len, xsize pos) const
{
xsize i;
xsize Idx;
if ( S.length() == 0 ) return MAX_XSIZE;
if ( Pos > length() ) Pos = length();
if ( Pos < S.length() ) return MAX_XSIZE;
Pos -= S.length();
for ( Idx=Pos+1 ; Idx-- > 0 ; ) {
if ( s_len == 0 ) return MAX_XSIZE;
if ( pos > length() ) pos = length();
if ( pos < s_len ) return MAX_XSIZE;
pos -= s_len;
for ( Idx=pos+1 ; Idx-- > 0 ; ) {
i = 0;
while( i<S.length() && data()[Idx+i] == S[i] ) i += 1;
if ( i == S.length() ) return Idx;
while( i<s_len && *data(Idx+i)== s[i] ) i += 1;
if ( i == s_len ) return Idx;
}
return MAX_XSIZE;
}
@ -566,7 +568,7 @@ void XString::ToLower(bool FirstCharIsCap)
ui = 0;
}
for ( ; ui < length() ; ui+=1 ) {
data()[ui] = Minuscule(data()[ui]);
data()[ui] = to_lower(data(ui));
}
}
}
@ -579,7 +581,7 @@ bool XString::IsLetters() const
p = data();
if ( !*p ) return false;
for ( ; *p ; p+=1 ) {
aChar = MinusculeSansAccent(*p); // toutes les lettres, avec accent ou pas, seront dans l'intervalle 'a'..'z'
aChar = to_lowerSansAccent(*p); // toutes les lettres, avec accent ou pas, seront dans l'intervalle 'a'..'z'
if ( aChar < 'a' ) return false;
if ( aChar > 'z' ) return false;
}
@ -631,7 +633,7 @@ bool XString::IsLettersNoAccent() const
p = data();
if ( !*p ) return false;
for ( ; *p ; p+=1 ) {
aChar = Minuscule(*p); // Uniquement les lettres maj et min sans accent seront dans l'intervalle 'a'..'z'
aChar = to_lower(*p); // Uniquement les lettres maj et min sans accent seront dans l'intervalle 'a'..'z'
if ( aChar < 'a' ) return false;
if ( aChar > 'z' ) return false;
}
@ -1022,10 +1024,11 @@ XString SPrintf(const char *format, ...)
return str;
}
XString SubString(const char *S, xsize pos, xsize count)
XString SubString(const char *s, xsize s_len, xsize pos, xsize count)
{
if ( strlen(S)-pos < count ) count = (xsize)(strlen(S)-pos); // overflow ?
return XString().takeValueFrom( S+pos, count );
if ( pos >= s_len ) return NullXString;
if ( s_len-pos < count ) count = s_len-pos;
return XString().takeValueFrom( s+pos, count );
}
#ifdef NOT_USED_ANYMORE_skqdjfhksqjhfksjqdf
@ -1058,10 +1061,10 @@ XString ToLower(const char *S, bool FirstCharIsCap)
if ( S && *S ) {
if ( FirstCharIsCap ) ReturnValue = Majuscule(S[0]);
else ReturnValue = Minuscule(S[0]);
else ReturnValue = to_lower(S[0]);
for ( ui=1 ; S[ui] ; ui+=1 ) {
ReturnValue += Minuscule(S[ui]);
ReturnValue += to_lower(S[ui]);
}
}
return ReturnValue;

View File

@ -31,12 +31,13 @@ class XString
// Next 2 methods are protected intentionally. They are const method returning non-const pointer. That's intentional, but dangerous. Do not expose to public.
// It's better practice, if you need a non-const pointer for low-level access, to use dataSized and ahev to specify the size
char* _data(unsigned int ui) const { if ( ui >= m_allocatedSize ) panic("char* data(unsigned int ui=0) -> ui >= m_allocatedSize"); return m_data+ui; }
char* _data(int i) const { if ( i<0 ) panic("char* data(int i) -> i < 0"); if ( (unsigned int)i >= m_allocatedSize ) panic("char* data(int i) -> i >= m_allocatedSize"); return m_data+i; }
char* _data(unsigned long ui) const { if ( ui >= m_allocatedSize ) panic("char* data(unsigned long ui=0) -> ui >= m_allocatedSize"); return m_data+ui; }
char* _data(long i) const { if ( i<0 ) panic("char* data(long i) -> i < 0"); if ( (unsigned long)i >= m_allocatedSize ) panic("char* data(long i) -> i >= m_allocatedSize"); return m_data+i; }
char* _data(xsize ui) const { if ( ui >= m_allocatedSize ) panic("char* data(xsize ui=0) -> ui >= m_allocatedSize"); return m_data+ui; }
char* _data(xisize i) const { if ( i<0 ) panic("char* data(xisize i) -> i < 0"); if ( (xsize)i >= m_allocatedSize ) panic("char* data(xisize i) -> i >= m_allocatedSize"); return m_data+i; }
// It's possible to access data(m_allocatedSize) because the real allocated size is m_allocatedSize+1
char* _data(unsigned int ui) const { if ( ui > m_allocatedSize ) panic("char* data(unsigned int ui=0) -> ui > m_allocatedSize"); return m_data+ui; }
char* _data(int i) const { if ( i<0 ) panic("char* data(int i) -> i < 0"); if ( (unsigned int)i > m_allocatedSize ) panic("char* data(int i) -> i > m_allocatedSize"); return m_data+i; }
char* _data(unsigned long ui) const { if ( ui > m_allocatedSize ) panic("char* data(unsigned long ui=0) -> ui > m_allocatedSize"); return m_data+ui; }
char* _data(long i) const { if ( i<0 ) panic("char* data(long i) -> i < 0"); if ( (unsigned long)i > m_allocatedSize ) panic("char* data(long i) -> i > m_allocatedSize"); return m_data+i; }
char* _data(xsize ui) const { if ( ui > m_allocatedSize ) panic("char* data(xsize ui=0) -> ui > m_allocatedSize"); return m_data+ui; }
char* _data(xisize i) const { if ( i<0 ) panic("char* data(xisize i) -> i < 0"); if ( (xsize)i > m_allocatedSize ) panic("char* data(xisize i) -> i > m_allocatedSize"); return m_data+i; }
public:
@ -77,9 +78,10 @@ class XString
/* IsNull ? */
void setEmpty() { setLength(0); }
bool isEmpty() const { return length() == 0; }
bool notEmpty() const { return !isEmpty(); }
/* Cast */
operator const char *() const { return data(); }
// operator const char *() const { return data(); } // disabled during big refactoring
// operator char *() { return data(); }
// int ToInt() const;
@ -108,6 +110,7 @@ class XString
void StrnCpy(const char *buf, xsize len);
void StrnCat(const char *buf, xsize len);
void StrCat(const char *buf);
void StrCat(const XString& S) { StrCat(S.c_str()) ; }
void Delete(xsize pos, xsize count=1);
void Insert(xsize pos, const XString& Str);
@ -115,12 +118,7 @@ class XString
void Cat(const XString &uneXString);
XString& vSPrintf(const char *Format, va_list va);
XString& SPrintf(const char *format, ...)
#ifndef _MSC_VER
__attribute__((format (printf, 2, 3))) // 2 and 3 because of hidden parameter 'this'.
#endif
;
XString& SPrintf(const char *format, ...) __attribute__((format (printf, 2, 3))); // 2 and 3 because of hidden parameter 'this'.
const XString& takeValueFrom(const char* S) { StrCpy(S); return *this; }
const XString& takeValueFrom(const char* S, xsize count) { StrnCpy(S, count); return *this; }
@ -150,13 +148,36 @@ class XString
// const XString &operator += (unsigned long long);
XString SubString(xsize pos, xsize count) const;
xsize IdxOf(char c, xsize Pos = 0) const;
xsize IdxOf(const XString &S, xsize Pos = 0) const;
xsize IdxOf(const char* s, xsize s_len, xsize pos) const;
xsize IdxOf(const char* s, xsize pos = 0) const { return IdxOf(s, strlen(s), pos); }
xsize IdxOf(const XString &S, xsize pos = 0) const { return IdxOf(S.c_str(), S.length(), pos); }
bool ExistIn(const char* s, xsize s_len, xsize pos = 0) const { return IdxOf(s, s_len, pos) != MAX_XSIZE; }
bool ExistIn(const char* s, xsize pos = 0) const { return IdxOf(s, pos) != MAX_XSIZE; }
bool ExistIn(const XString &S, xsize pos = 0) const { return IdxOf(S, pos) != MAX_XSIZE; }
xsize IdxOfIC(const char* s, xsize s_len, xsize pos) const;
xsize IdxOfIC(const char* s, xsize pos = 0) const { return IdxOfIC(s, strlen(s), pos); }
xsize IdxOfIC(const XString &S, xsize pos = 0) const { return IdxOfIC(S.c_str(), S.length(), pos); }
bool ExistInIC(const char* s, xsize s_len, xsize pos = 0) const { return IdxOfIC(s, s_len, pos) != MAX_XSIZE; }
bool ExistInIC(const char* s, xsize pos = 0) const { return IdxOfIC(s, pos) != MAX_XSIZE; }
bool ExistInIC(const XString &S, xsize pos = 0) const { return IdxOfIC(S, pos) != MAX_XSIZE; }
#ifdef TODO_skqdjfhksqjhfksjqdf
bool ExistInIAC(const XString &S) const { return IdxOfIC(S) != MAX_XSIZE; }
#endif
#ifdef TODO_skqdjfhksqjhfksjqdf
xsize IdxOfIC(const XString &S, xsize Pos = 0) const;
xsize IdxOfIAC(const XString &S, xsize Pos = 0) const;
#endif
xsize RIdxOf(const XString &S, xsize Pos = MAX_XSIZE) const;
xsize RIdxOf(const char* s, xsize s_len, xsize pos) const;
xsize RIdxOf(const char* s, xsize pos = MAX_XSIZE) const { return IdxOf(s, strlen(s), pos); }
xsize RIdxOf(const XString &S, xsize pos = MAX_XSIZE) const { return IdxOf(S.c_str(), S.length(), pos); }
void ToLower(bool FirstCharIsCap = false);
bool IsLetters() const;
@ -164,10 +185,7 @@ class XString
bool IsDigits() const;
bool IsDigits(xsize pos, xsize count) const;
bool ExistIn(const XString &S) const { return IdxOf(S) != MAX_XSIZE; }
#ifdef TODO_skqdjfhksqjhfksjqdf
bool ExistInIC(const XString &S) const { return IdxOfIC(S) != MAX_XSIZE; }
bool ExistInIAC(const XString &S) const { return IdxOfIC(S) != MAX_XSIZE; }
bool DeleteIC(const XString &S);
#endif
void Replace(char c1, char c2);
@ -188,7 +206,8 @@ class XString
*/
#endif
bool Equal(const char* S) const { return strcmp(data(), (S ? S : "")) == 0; };
// bool Equal(const char* S) const { return strcmp(data(), (S ? S : "")) == 0; };
bool Equal(const XString& S) const { return strcmp(c_str(), S.c_str()) == 0; };
// bool BeginEqual(const char* S) const { return StringBeginEqual(data(), S); }
// bool SubStringEqual(xsize Pos, const char* S) const { return StringBeginEqual(data(Pos), S); }
#ifdef TODO_skqdjfhksqjhfksjqdf
@ -230,7 +249,7 @@ class XString
// Chaines
friend XString operator + (const XString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
// friend XString operator + (const XString& p1, const char *p2 ) { XString s; s=p1; s+=p2; return s; }
XString operator + (const char *p2 ) { XString s(*this); s+=p2; return s; }
// XString operator + (const char *p2 ) { XString s(*this); s+=p2; return s; }
friend XString operator + (const char *p1, const XString& p2) { XString s; s.takeValueFrom(p1); s+=p2; return s; }
// friend XString operator + (const XConstString& p1, const XString& p2) { XString s; s=p1; s+=p2; return s; }
@ -256,15 +275,15 @@ class XString
// OpÈrateur ==
// Chaines
friend bool operator == (const XString& s1, const XString& s2) { return s1.Equal(s2); }
friend bool operator == (const XString& s1, const char* s2 ) { return s1.Equal(s2); }
friend bool operator == (const char* s1, const XString& s2) { return s2.Equal(s1); }
// friend bool operator == (const XString& s1, const char* s2 ) { return s1.Equal(s2); } // during refactor
// friend bool operator == (const char* s1, const XString& s2) { return s2.Equal(s1); } // during refactor
// friend bool operator == (const XConstString &s1, const XString& s2) { return s1.Compare(s2) == 0; }
// friend bool operator == (const XString &s1, const XConstString& s2) { return s1.Compare(s2) == 0; }
// friend bool operator == (const XConstString &s1, const XConstString& s2) { return s1.Compare(s2) == 0; }
friend bool operator != (const XString& s1, const XString& s2) { return !s1.Equal(s2); }
friend bool operator != (const XString& s1, const char* s2 ) { return !s1.Equal(s2); }
friend bool operator != (const char* s1, const XString& s2) { return !s2.Equal(s1); }
// friend bool operator != (const XString& s1, const char* s2 ) { return !s1.Equal(s2); } // during refactor
// friend bool operator != (const char* s1, const XString& s2) { return !s2.Equal(s1); } // during refactor
// friend bool operator != (const XConstString &s1, const XString& s2) { return s1.Compare(s2) != 0; }
// friend bool operator != (const XString &s1, const XConstString& s2) { return s1.Compare(s2) != 0; }
// friend bool operator != (const XConstString &s1, const XConstString& s2) { return s1.Compare(s2) != 0; }
@ -285,18 +304,19 @@ class XString
// friend bool operator >= (const XString& s1, const char* s2 ) { return s1.Compare(s2) >= 0; }
// friend bool operator >= (const char* s1, const XString& s2) { return s2.Compare(s1) <= 0; }
static char to_lower(char ch) { return (((ch >= L'A') && (ch <= L'Z')) ? ((ch - L'A') + L'a') : ch); }
};
extern const XString NullXString;
XString operator"" _XS ( const char* s, size_t len);
XString SPrintf(const char *format, ...)
#ifndef _MSC_VER
__attribute__((format(printf, 1, 2)))
#endif
;
XString SubString(const char *S, xsize pos, xsize count);
XString SPrintf(const char *format, ...) __attribute__((format(printf, 1, 2)));
XString SubString(const char *s, xsize s_len, xsize pos, xsize count);
inline XString SubString(const char *s, xsize pos, xsize count) { return SubString(s, strlen(s), pos, count); }
inline XString SubString(const XString& S, xsize pos, xsize count) { return SubString(S.c_str(), S.length(), pos, count); }
#ifdef TODO_skqdjfhksqjhfksjqdf
XString ToAlpha(const char *S);
XString ToAlpha(const XString &S);

View File

@ -0,0 +1,139 @@
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
//
// STRINGS
//
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#include "XToolsCommon.h"
#include "XStringArray.h"
const XStringArray NullXStringArray;
XStringArray::XStringArray() : XStringArraySuper()
{
}
//-------------------------------------------------------------------------------------------------
//
//-------------------------------------------------------------------------------------------------
void XStringArray::AddStrings(const wchar_t *Val1, ...)
{
va_list va;
const wchar_t *p;
{
XString* newS = new XString;
newS->takeValueFrom(Val1);
AddReference(newS, true);
}
va_start(va, Val1);
p = VA_ARG(va, const wchar_t *);
while ( p != nullptr ) {
XString* newS = new XString;
newS->takeValueFrom(Val1);
AddReference(newS, true);
p = VA_ARG(va, const wchar_t *);
}
va_end(va);
}
XString XStringArray::ConcatAll(const XString& Separator, const XString& Prefix, const XString& Suffix) const
{
xsize i;
XString s;
if ( size() > 0 ) {
s = Prefix;
s += ElementAt(0);
for ( i=1 ; i<size() ; i+=1 ) {
s += Separator;
s += ElementAt(i);
}
s += Suffix;
}
return s;
}
bool XStringArray::Equal(const XStringArray &aStrings) const
{
xsize ui;
if ( size() != aStrings.size() ) return false;
for ( ui=0 ; ui<size() ; ui+=1 ) {
if ( ElementAt(ui) != aStrings[ui] ) return false;
}
return true;
}
bool XStringArray::Same(const XStringArray &aStrings) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( !aStrings.Contains(ElementAt(i)) ) return false;
}
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings.ElementAt(i)) ) return false;
}
return true;
}
bool XStringArray::Contains(const XString &S) const
{
xsize i;
for ( i=0 ; i<size() ; i+=1 ) {
if ( ElementAt(i) == S ) return true;
}
return false;
}
//-------------------------------------------------------------------------------------------------
// Add
//-------------------------------------------------------------------------------------------------
void XStringArray::Add(const XStringArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
AddCopy(aStrings[i]);
}
}
void XStringArray::AddID(const XString &aString)
{
if ( !Contains(aString) ) AddCopy(aString);
}
void XStringArray::AddID(const XStringArray &aStrings)
{
xsize i;
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
}
}
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// Divers
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
XStringArray Split(const XString &S, const XString &Separator)
{
XStringArray Ss;
xsize idxB, idxE;
idxB = 0;
idxE = S.IdxOf(Separator, idxB);
while ( idxE != MAX_XSIZE ) {
Ss.AddCopy(SubString(S, idxB, idxE-idxB));
idxB = idxE + Separator.length();
idxE = S.IdxOf(Separator, idxB);
}
if ( idxB < S.length() ) Ss.AddCopy(SubString(S, idxB, S.length()-idxB));
return Ss;
}

View File

@ -0,0 +1,54 @@
//*************************************************************************************************
//*************************************************************************************************
//
// STRINGS
//
//*************************************************************************************************
//*************************************************************************************************
#if !defined(__XSTRINGARRAY_H__)
#define __XSTRINGARRAY_H__
#include "XToolsCommon.h"
#include "XStringWArray.h"
#include "XString.h"
#define XStringArraySuper XObjArray<XString>
class XStringArray : public XStringArraySuper
{
public:
XStringArray();
void SetNull() { Empty(); }
bool IsNull() const { return size() == 0 ; }
bool NotNull() const { return size() > 0 ; }
XString ConcatAll(const XString& Separator = ", "_XS, const XString& Prefix = NullXString, const XString& Suffix = NullXString) const;
bool Equal(const XStringArray &aStrings) const;
bool operator ==(const XStringArray &aXStrings) const { return Equal(aXStrings); }
bool operator !=(const XStringArray& aXStrings) const { return !Equal(aXStrings); }
bool Contains(const XString &S) const;
bool Same(const XStringArray &aStrings) const;
// Add
void AddStrings(const wchar_t *Val1, ...);
void AddNoNull(const XString &aString) { if ( !aString.isEmpty() ) AddCopy(aString); }
void AddEvenNull(const XString &aString) { AddCopy(aString); }
void Add(const XString &aString) { AddCopy(aString); }
void Add(const XStringArray &aStrings);
void AddID(const XString &aString); /* ignore Duplicate */
void AddID(const XStringArray &aStrings); /* ignore Duplicate */
};
extern const XStringArray NullXStringArray;
XStringArray Split(const XString &S, const XString &Separator = ", "_XS);
#endif

View File

@ -62,6 +62,7 @@ public:
xsize length() const { return m_len; }
xsize size() const { return m_len; }
xsize sizeInBytes() const { return m_len*sizeof(wchar_t); }
xsize allocatedSize() const { return m_allocatedSize; }
void SetLength(xsize len);
const wchar_t* s() { return m_data; }
@ -116,12 +117,7 @@ public:
void vSWPrintf(const char* format, va_list va);
#ifndef _MSC_VER
void SWPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3)));
#else
void SWPrintf(const char* format, ...);
#endif // !__MSC_VER
const XStringW &operator =(const XStringW &aString);
// const XStringW &operator =(const wchar_t* S) {fdsf};
@ -212,15 +208,8 @@ extern const XStringW NullXStringW;
XStringW operator"" _XSW ( const wchar_t* s, size_t len);
#ifndef _MSC_VER
XStringW SWPrintf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)));
#else
XStringW SWPrintf(const char* format, ...);
#endif // !__MSC_VER
XStringW SubString(const wchar_t *S, xsize pos, xsize count);
XStringW CleanCtrl(const XStringW &S);
#endif

View File

@ -0,0 +1,236 @@
#include <Platform.h>
#include "../cpp_foundation/XString.h"
#include "../cpp_foundation/XStringArray.h"
#include "../cpp_foundation/XStringW.h"
#include "global_test.h"
CHAR16 *Old1_AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption)
{
// If either option strings are null nothing to do
if (LoadOptions == NULL)
{
if (LoadOption == NULL) return NULL;
// Duplicate original options as nothing to add
return EfiStrDuplicate(LoadOption);
}
// If there is no option or it is already present duplicate original
// with XStringW it will be replaced by if (LoadOptions.ExistIn(LoadOption))
else if ((LoadOption == NULL) || StrStr(LoadOptions, LoadOption))
return EfiStrDuplicate(LoadOptions);
// Otherwise add option
// return PoolPrint(L"%s %s", LoadOptions, LoadOption); //LoadOptions + LoadOption
return SWPrintf("%ls %ls", LoadOptions, LoadOption).forgetDataWithoutFreeing(); //LoadOptions + LoadOption
}
CHAR16 *Old1_RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption)
{
CONST CHAR16 *Placement;
CHAR16 *NewLoadOptions;
UINTN Length, Offset, OptionLength;
//DBG("LoadOptions: '%ls', remove LoadOption: '%ls'\n", LoadOptions, LoadOption);
// If there are no options then nothing to do
if (LoadOptions == NULL) return NULL;
// If there is no option to remove then duplicate original
if (LoadOption == NULL) return EfiStrDuplicate(LoadOptions);
// If not present duplicate original
Placement = StrStr(LoadOptions, LoadOption);
if (Placement == NULL) return EfiStrDuplicate(LoadOptions);
// Get placement of option in original options
Offset = (Placement - LoadOptions);
Length = StrLen(LoadOptions);
OptionLength = StrLen(LoadOption);
// If this is just part of some larger option (contains non-space at the beginning or end)
if ((Offset > 0 && LoadOptions[Offset - 1] != L' ') ||
((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != L' ')) {
return EfiStrDuplicate(LoadOptions);
}
// Consume preceeding spaces
while (Offset > 0 && LoadOptions[Offset - 1] == L' ') {
OptionLength++;
Offset--;
}
// Consume following spaces
while (LoadOptions[Offset + OptionLength] == L' ') {
OptionLength++;
}
// If it's the whole string return NULL
if (OptionLength == Length) return NULL;
if (Offset == 0) {
// Simple case - we just need substring after OptionLength position
NewLoadOptions = EfiStrDuplicate(LoadOptions + OptionLength);
} else {
// The rest of LoadOptions is Length - OptionLength, but we may need additional space and ending 0
NewLoadOptions = (__typeof__(NewLoadOptions))AllocateZeroPool((Length - OptionLength + 2) * sizeof(CHAR16));
// Copy preceeding substring
CopyMem(NewLoadOptions, (void*)LoadOptions, Offset * sizeof(CHAR16));
if ((Offset + OptionLength) < Length) {
// Copy following substring, but include one space also
OptionLength--;
CopyMem(NewLoadOptions + Offset, (void*)(LoadOptions + Offset + OptionLength), (Length - OptionLength - Offset) * sizeof(CHAR16));
}
}
return NewLoadOptions;
}
static XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOption)
{
// If either option strings are null nothing to do
if (LoadOptions.isEmpty())
{
// return LoadOption as nothing to add
return LoadOption;
}
// If there is no option or it is already present duplicate original
else {
if ( LoadOptions.ExistIn(LoadOption) ) return LoadOptions;
// Otherwise add option
return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
}
}
static XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption)
{
// CONST CHAR16 *Placement;
// CHAR16 *NewLoadOptions;
// UINTN Length, Offset, OptionLength;
//DBG("LoadOptions: '%ls', remove LoadOption: '%ls'\n", LoadOptions, LoadOption);
// If there are no options then nothing to do
if (LoadOptions.isEmpty()) return ""_XS;
// If there is no option to remove then duplicate original
if (LoadOption.isEmpty()) return LoadOptions;
// If not present duplicate original
xsize Offset = LoadOptions.IdxOf(LoadOption);
if ( Offset == MAX_XSIZE ) return LoadOptions;
// Get placement of option in original options
// Offset = (Placement - LoadOptions);
xsize Length = LoadOptions.length();
xsize OptionLength = LoadOption.length();
// If this is just part of some larger option (contains non-space at the beginning or end)
if ((Offset > 0 && LoadOptions[Offset - 1] != ' ') ||
((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != ' ')) {
return LoadOptions;
}
// Consume preceeding spaces
while (Offset > 0 && LoadOptions[Offset - 1] == ' ') {
OptionLength++;
Offset--;
}
// Consume following spaces
while (LoadOptions[Offset + OptionLength] == ' ') {
OptionLength++;
}
// If it's the whole string return NULL
if (OptionLength == Length) return ""_XS;
XString NewLoadOptions;
if (Offset == 0) {
// Simple case - we just need substring after OptionLength position
NewLoadOptions = LoadOptions.SubString(OptionLength, MAX_XSIZE);
} else {
// Copy preceeding substring
NewLoadOptions = LoadOptions.SubString(0, Offset);
// CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
if ((Offset + OptionLength) < Length) {
// Copy following substring, but include one space also
OptionLength--;
NewLoadOptions += LoadOptions.SubString(Offset + OptionLength, MAX_XSIZE);
// CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
}
}
return NewLoadOptions;
}
int BootOptions_tests()
{
#ifdef JIEF_DEBUG
// DebugLog(2, "XStringW_tests -> Enter\n");
#endif
{
CHAR16* LoadOptions = NULL;
LoadOptions = Old1_AddLoadOption(LoadOptions, L"opt1");
LoadOptions = Old1_AddLoadOption(LoadOptions, L"opt2");
LoadOptions = Old1_AddLoadOption(LoadOptions, L"opt3");
if ( XString().takeValueFrom(LoadOptions) != "opt1 opt2 opt3"_XS ) return 1;
CHAR16* LoadOptions1 = Old1_RemoveLoadOption(LoadOptions, L"opt1");
if ( XString().takeValueFrom(LoadOptions1) != "opt2 opt3"_XS ) return 1;
CHAR16* LoadOptions2 = Old1_RemoveLoadOption(LoadOptions, L"opt2");
if ( XString().takeValueFrom(LoadOptions2) != "opt1 opt3"_XS ) return 1;
CHAR16* LoadOptions3 = Old1_RemoveLoadOption(LoadOptions, L"opt3");
if ( XString().takeValueFrom(LoadOptions3) != "opt1 opt2"_XS ) return 1;
}
{
XString LoadOptions;
LoadOptions = AddLoadOption(LoadOptions, "opt1"_XS);
LoadOptions = AddLoadOption(LoadOptions, "opt2"_XS);
LoadOptions = AddLoadOption(LoadOptions, "opt3"_XS);
if ( LoadOptions != "opt1 opt2 opt3"_XS ) return 1;
XString LoadOptions1 = RemoveLoadOption(LoadOptions, "opt1"_XS);
if ( LoadOptions1 != "opt2 opt3"_XS ) return 1;
XString LoadOptions2 = RemoveLoadOption(LoadOptions, "opt2"_XS);
if ( LoadOptions2 != "opt1 opt3"_XS ) return 1;
XString LoadOptions3 = RemoveLoadOption(LoadOptions, "opt3"_XS);
if ( LoadOptions3 != "opt1 opt2"_XS ) return 1;
}
{
XStringArray LoadOptions;
LoadOptions.AddID("opt1"_XS);
LoadOptions.AddID("opt2"_XS);
LoadOptions.AddID("opt3"_XS);
if ( LoadOptions.ConcatAll(" "_XS) != "opt1 opt2 opt3"_XS ) return 1;
XStringArray LoadOptions1 = LoadOptions;
LoadOptions1.Remove("opt1"_XS);
if ( LoadOptions1.ConcatAll(" "_XS) != "opt2 opt3"_XS ) return 1;
XStringArray LoadOptions2 = LoadOptions;
LoadOptions2.Remove("opt2"_XS);
if ( LoadOptions2.ConcatAll(" "_XS) != "opt1 opt3"_XS ) return 1;
XStringArray LoadOptions3 = LoadOptions;
LoadOptions3.Remove("opt3"_XS);
if ( LoadOptions3.ConcatAll(" "_XS) != "opt1 opt2"_XS ) return 1;
}
return 0;
}

View File

@ -0,0 +1 @@
int BootOptions_tests();

View File

@ -13,179 +13,180 @@ class Xtest
int XString_tests()
{
XString a = "toto"_XS;
// Xtest<5> b;
// int bs = b.size();
#ifdef JIEF_DEBUG
#endif
#ifdef JIEF_DEBUG
// DebugLog(2, "XStringW_tests -> Enter\n");
#endif
if ( global_str1 != "global_str1" ) return 1;
if ( global_str2 != "global_str2" ) return 2;
// Check default ctor
{
XString str;
if (str.length() != 0) return 3;
if (str.c_str() == NULL) return 4;
}
// Check ctor with value (or check takeValueFrom while we are waiting to put back ctor(const char*)
#ifdef XSTRINGW_HAS_CTOR_LITTERAL
{
{
XString str("");
if ( str != "" ) return 100;
}
{
XString str("1");
if ( str != "1" ) return 101;
}
}
#else
{
XString str;
str.takeValueFrom("");
if (str.length() != 0) return 110;
str.takeValueFrom("1");
if ( str != "1" ) return 111;
str.StrCat("2");
if ( str != "12" ) return 112;
}
#endif
// Move assignment.
{
XString str1;
str1.takeValueFrom("str1");
XString str2(str1 + "b");
str2 += "a"; // this is more efficient than str2 = str2 + "a", of course
if ( str2 != "str1ba" ) return 120;
str2 = str2 + "a";
if ( str2 != "str1baa" ) return 121;
str2 = str1 + "a"; // this must call the move assignment operator
if ( str2 != "str1a" ) return 122;
}
// check [] operator
{
XString str;
str.takeValueFrom("01234567890123456789");
char c;
c = str[(char)1];
if ( c != '1' ) return 201;
c = str[(unsigned char)2];
if ( c != '2' ) return 202;
c = str[(short)3];
if ( c != '3' ) return 203;
c = str[(unsigned short)4];
if ( c != '4' ) return 204;
c = str[(int)5];
if ( c != '5' ) return 205;
c = str[(unsigned int)6];
if ( c != '6' ) return 206;
c = str[(long)7];
if ( c != '7' ) return 207;
c = str[(unsigned long)8];
if ( c != '8' ) return 208;
c = str[(long long)9];
if ( c != '9' ) return 209;
c = str[(unsigned long long)10];
if ( c != '0' ) return 210;
}
// Check StrCat. TODO more test, and test StrnCat
{
XString str;
str.takeValueFrom("1");
str.StrCat("2");
if ( str != "12" ) return 50;
}
// check takeValueFrom from utf8 string
XString str;
str.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
if (str != "Ň") return 80; // utf8 litteral are converted to an XStringW if ctor is available.
str.takeValueFrom("𐌾"); // this is a UTF8 string 4 bytes long
if ( str != "𐌾" ) return 81;
str.takeValueFrom("𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
if ( str != "𐌾" ) return 82;
// check takeValueFrom from UTF16 or 32 string
str.takeValueFrom(L"Ň"); // this is a UTF8 string 2 bytes long
if (str != "Ň") return 83; // utf8 litteral are converted to an XStringW if ctor is available.
str.takeValueFrom(L"𐌾"); // this is a UTF8 string 4 bytes long
if ( str != "𐌾" ) return 84;
str.takeValueFrom(L"𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
if ( str != "𐌾" ) return 85;
// Quick check of StrnCpy,StrnCat,Insert,+=
str.takeValueFrom("12");
XString str2;
if ( !str2.isEmpty() ) return 100;
str2.StrnCpy(str.data(), 2);
if ( str2 != "12" ) return 101;
str2.StrnCat("345", 2);
if ( str2 != "1234" ) return 102;
str2.Insert(1, str);
if ( str2 != "112234" ) return 103;
str2 += "6";
if ( str2 != "1122346" ) return 104;
// Check Insert at beginning and end
str2.takeValueFrom("123");
str2.Insert(0, XString().takeValueFrom("x"));
if ( str2 != "x123" ) return 105;
str2.Insert(4, XString().takeValueFrom("y"));
if ( str2 != "x123y" ) return 106;
//wchar_t c2 = L'Ň';
//printf("1=%lc\n", c2);
//const char* s1 = "𐌾";
// Check SPrintf
str2.SPrintf("%c", 'a'); // single UTF8 ascii char
if ( str2 != "a" ) return 200;
#ifndef _MSC_VER
str2.SPrintf("%lc", L'Ň'); // single UTF16(32) char. (2 bytes in total if UTF16)
if ( str2 != "Ň" ) return 202;
#endif
str2.SPrintf("%s", "Ň"); // this is a UTF8 string 2 bytes long
if (str2 != "Ň") return 203; // utf8 litteral are converted to an XStringW if ctor is available.
str2.SPrintf("%ls", L"Ň"); // this is a UTF8 string 2 bytes long
if (str2 != "Ň") return 204; // utf8 litteral are converted to an XStringW if ctor is available.
#if __WCHAR_MAX__ > 0xFFFFu
str2.SPrintf("%lc", L'𐌾'); // L'𐌾' // this char cannot convert to an UTF16 char. So it doesn't compile with -fshort-wchar
if ( str2 != "𐌾" ) return 205;
#endif
/* Stil doesn't work as VS doesn't encode correctly litteral */
#ifndef _MSC_VER
// int i1 = sizeof(wchar_t);
// int i2 = sizeof(char16_t);
// const wchar_t* ls = L"Выход";
// const char16_t* us = u"Выход";
// const char32_t* Us = U"Выход";
XString str3;
str3.takeValueFrom(L"Выход");
if ( str3 != "Выход" ) return 500;
#endif
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", L"ascii char in ucs-2 string\n");
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "ascii char in ucs-2 string\n");
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "ascii char in ucs-2 string\n");
// Commented during refactoring because of disabling operator == with litteral (to be able to catch test like : XString == NULL
//
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", L"Выход из подменю, обновление главного меню\n");
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
//MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
// XString a = "toto"_XS;
//
//DBG("Test ascii=%ls ucs-2=%ls\n", "a string", L"Выход из подменю, обновление главного меню\n");
//DBG("Test ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
//DBG("Test ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
//// Xtest<5> b;
//// int bs = b.size();
//
//#ifdef JIEF_DEBUG
//#endif
//
//#ifdef JIEF_DEBUG
//// DebugLog(2, "XStringW_tests -> Enter\n");
//#endif
//
// if ( global_str1 != "global_str1" ) return 1;
// if ( global_str2 != "global_str2" ) return 2;
//
// // Check default ctor
// {
// XString str;
// if (str.length() != 0) return 3;
// if (str.c_str() == NULL) return 4;
// }
//
// // Check ctor with value (or check takeValueFrom while we are waiting to put back ctor(const char*)
//#ifdef XSTRINGW_HAS_CTOR_LITTERAL
// {
// {
// XString str("");
// if ( str != "" ) return 100;
// }
// {
// XString str("1");
// if ( str != "1" ) return 101;
// }
// }
//#else
// {
// XString str;
// str.takeValueFrom("");
// if (str.length() != 0) return 110;
// str.takeValueFrom("1");
// if ( str != "1" ) return 111;
// str.StrCat("2");
// if ( str != "12" ) return 112;
// }
//#endif
//
// // Move assignment.
// {
// XString str1;
// str1.takeValueFrom("str1");
// XString str2(str1 + "b");
// str2 += "a"; // this is more efficient than str2 = str2 + "a", of course
// if ( str2 != "str1ba" ) return 120;
// str2 = str2 + "a";
// if ( str2 != "str1baa" ) return 121;
// str2 = str1 + "a"; // this must call the move assignment operator
// if ( str2 != "str1a" ) return 122;
// }
//
// // check [] operator
// {
// XString str;
// str.takeValueFrom("01234567890123456789");
// char c;
// c = str[(char)1];
// if ( c != '1' ) return 201;
// c = str[(unsigned char)2];
// if ( c != '2' ) return 202;
// c = str[(short)3];
// if ( c != '3' ) return 203;
// c = str[(unsigned short)4];
// if ( c != '4' ) return 204;
// c = str[(int)5];
// if ( c != '5' ) return 205;
// c = str[(unsigned int)6];
// if ( c != '6' ) return 206;
// c = str[(long)7];
// if ( c != '7' ) return 207;
// c = str[(unsigned long)8];
// if ( c != '8' ) return 208;
// c = str[(long long)9];
// if ( c != '9' ) return 209;
// c = str[(unsigned long long)10];
// if ( c != '0' ) return 210;
// }
//
// // Check StrCat. TODO more test, and test StrnCat
// {
// XString str;
// str.takeValueFrom("1");
// str.StrCat("2");
// if ( str != "12" ) return 50;
// }
//
// // check takeValueFrom from utf8 string
// XString str;
// str.takeValueFrom("Ň"); // this is a UTF8 string 2 bytes long
// if (str != "Ň") return 80; // utf8 litteral are converted to an XStringW if ctor is available.
// str.takeValueFrom("𐌾"); // this is a UTF8 string 4 bytes long
// if ( str != "𐌾" ) return 81;
// str.takeValueFrom("𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
// if ( str != "𐌾" ) return 82;
//
// // check takeValueFrom from UTF16 or 32 string
// str.takeValueFrom(L"Ň"); // this is a UTF8 string 2 bytes long
// if (str != "Ň") return 83; // utf8 litteral are converted to an XStringW if ctor is available.
// str.takeValueFrom(L"𐌾"); // this is a UTF8 string 4 bytes long
// if ( str != "𐌾" ) return 84;
// str.takeValueFrom(L"𐌾"); // this is a UTF16 or UTF32 string (depending of -fshort-wchar)
// if ( str != "𐌾" ) return 85;
//
// // Quick check of StrnCpy,StrnCat,Insert,+=
// str.takeValueFrom("12");
// XString str2;
// if ( !str2.isEmpty() ) return 100;
// str2.StrnCpy(str.data(), 2);
// if ( str2 != "12" ) return 101;
// str2.StrnCat("345", 2);
// if ( str2 != "1234" ) return 102;
// str2.Insert(1, str);
// if ( str2 != "112234" ) return 103;
// str2 += "6";
// if ( str2 != "1122346" ) return 104;
// // Check Insert at beginning and end
// str2.takeValueFrom("123");
// str2.Insert(0, XString().takeValueFrom("x"));
// if ( str2 != "x123" ) return 105;
// str2.Insert(4, XString().takeValueFrom("y"));
// if ( str2 != "x123y" ) return 106;
//
////wchar_t c2 = L'Ň';
////printf("1=%lc\n", c2);
////const char* s1 = "𐌾";
// // Check SPrintf
// str2.SPrintf("%c", 'a'); // single UTF8 ascii char
// if ( str2 != "a" ) return 200;
// #ifndef _MSC_VER
// str2.SPrintf("%lc", L'Ň'); // single UTF16(32) char. (2 bytes in total if UTF16)
// if ( str2 != "Ň" ) return 202;
// #endif
// str2.SPrintf("%s", "Ň"); // this is a UTF8 string 2 bytes long
// if (str2 != "Ň") return 203; // utf8 litteral are converted to an XStringW if ctor is available.
// str2.SPrintf("%ls", L"Ň"); // this is a UTF8 string 2 bytes long
// if (str2 != "Ň") return 204; // utf8 litteral are converted to an XStringW if ctor is available.
//#if __WCHAR_MAX__ > 0xFFFFu
// str2.SPrintf("%lc", L'𐌾'); // L'𐌾' // this char cannot convert to an UTF16 char. So it doesn't compile with -fshort-wchar
// if ( str2 != "𐌾" ) return 205;
//#endif
//
///* Stil doesn't work as VS doesn't encode correctly litteral */
//#ifndef _MSC_VER
//
//// int i1 = sizeof(wchar_t);
//// int i2 = sizeof(char16_t);
//// const wchar_t* ls = L"Выход";
//// const char16_t* us = u"Выход";
//// const char32_t* Us = U"Выход";
// XString str3;
// str3.takeValueFrom(L"Выход");
// if ( str3 != "Выход" ) return 500;
//#endif
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", L"ascii char in ucs-2 string\n");
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "ascii char in ucs-2 string\n");
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "ascii char in ucs-2 string\n");
////
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", L"Выход из подменю, обновление главного меню\n");
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
////MsgLog("Test MsgLog ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
////
////DBG("Test ascii=%ls ucs-2=%ls\n", "a string", L"Выход из подменю, обновление главного меню\n");
////DBG("Test ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
////DBG("Test ascii=%ls ucs-2=%ls\n", "a string", "Выход из подменю, обновление главного меню\n");
return 0;
}

View File

@ -16,6 +16,7 @@
#include "strlen_test.h"
#include <Platform.h> // Only use angled for Platform, else, xcode project won't compile
#include "printf_lite-test.h"
#include "LoadOptions_test.h"
//#include "poolprint-test.h"
//#include "printlib-test.h"
@ -50,17 +51,22 @@ bool all_tests()
#endif
ret = strlen_tests();
if ( ret != 0 ) {
DebugLog(2, "posix_tests() failed at test %d\n", ret);
DebugLog(2, "strlen_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = BootOptions_tests();
if ( ret != 0 ) {
DebugLog(2, "BootOptions_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = strcmp_tests();
if ( ret != 0 ) {
DebugLog(2, "posix_tests() failed at test %d\n", ret);
DebugLog(2, "strcmp_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = strncmp_tests();
if ( ret != 0 ) {
DebugLog(2, "posix_tests() failed at test %d\n", ret);
DebugLog(2, "strncmp_tests() failed at test %d\n", ret);
all_ok = false;
}
ret = XArray_tests();

View File

@ -170,75 +170,75 @@ EG_IMAGE* ScanVolumeDefaultIcon(REFIT_VOLUME *Volume, IN UINT8 OSType, IN EFI_DE
}
CHAR16 *AddLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption)
XString AddLoadOption(IN CONST XString& LoadOptions, IN CONST XString& LoadOption)
{
// If either option strings are null nothing to do
if (LoadOptions == NULL)
if (LoadOptions.isEmpty())
{
if (LoadOption == NULL) return NULL;
// Duplicate original options as nothing to add
return EfiStrDuplicate(LoadOption);
// return LoadOption as nothing to add
return LoadOption;
}
// If there is no option or it is already present duplicate original
// with XStringW it will be replaced by if (LoadOptions.ExistIn(LoadOption))
else if ((LoadOption == NULL) || StrStr(LoadOptions, LoadOption))
return EfiStrDuplicate(LoadOptions);
// Otherwise add option
return PoolPrint(L"%s %s", LoadOptions, LoadOption); //LoadOptions + LoadOption
else {
if ( LoadOptions.ExistIn(LoadOption) ) return LoadOptions;
// Otherwise add option
return SPrintf("%s %s", LoadOptions.c_str(), LoadOption.c_str()); //LoadOptions + LoadOption
}
}
CHAR16 *RemoveLoadOption(IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOption)
XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption)
{
CONST CHAR16 *Placement;
CHAR16 *NewLoadOptions;
UINTN Length, Offset, OptionLength;
// CONST CHAR16 *Placement;
// CHAR16 *NewLoadOptions;
// UINTN Length, Offset, OptionLength;
//DBG("LoadOptions: '%ls', remove LoadOption: '%ls'\n", LoadOptions, LoadOption);
// If there are no options then nothing to do
if (LoadOptions == NULL) return NULL;
if (LoadOptions.isEmpty()) return ""_XS;
// If there is no option to remove then duplicate original
if (LoadOption == NULL) return EfiStrDuplicate(LoadOptions);
if (LoadOption.isEmpty()) return LoadOptions;
// If not present duplicate original
Placement = StrStr(LoadOptions, LoadOption);
if (Placement == NULL) return EfiStrDuplicate(LoadOptions);
xsize Offset = LoadOptions.IdxOf(LoadOption);
if ( Offset == MAX_XSIZE ) return LoadOptions;
// Get placement of option in original options
Offset = (Placement - LoadOptions);
Length = StrLen(LoadOptions);
OptionLength = StrLen(LoadOption);
// Offset = (Placement - LoadOptions);
xsize Length = LoadOptions.length();
xsize OptionLength = LoadOption.length();
// If this is just part of some larger option (contains non-space at the beginning or end)
if ((Offset > 0 && LoadOptions[Offset - 1] != L' ') ||
((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != L' ')) {
return EfiStrDuplicate(LoadOptions);
if ((Offset > 0 && LoadOptions[Offset - 1] != ' ') ||
((Offset + OptionLength) < Length && LoadOptions[Offset + OptionLength] != ' ')) {
return LoadOptions;
}
// Consume preceeding spaces
while (Offset > 0 && LoadOptions[Offset - 1] == L' ') {
while (Offset > 0 && LoadOptions[Offset - 1] == ' ') {
OptionLength++;
Offset--;
}
// Consume following spaces
while (LoadOptions[Offset + OptionLength] == L' ') {
while (LoadOptions[Offset + OptionLength] == ' ') {
OptionLength++;
}
// If it's the whole string return NULL
if (OptionLength == Length) return NULL;
if (OptionLength == Length) return ""_XS;
XString NewLoadOptions;
if (Offset == 0) {
// Simple case - we just need substring after OptionLength position
NewLoadOptions = EfiStrDuplicate(LoadOptions + OptionLength);
NewLoadOptions = LoadOptions.SubString(OptionLength, MAX_XSIZE);
} else {
// The rest of LoadOptions is Length - OptionLength, but we may need additional space and ending 0
NewLoadOptions = (__typeof__(NewLoadOptions))AllocateZeroPool((Length - OptionLength + 2) * sizeof(CHAR16));
// Copy preceeding substring
CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
NewLoadOptions = LoadOptions.SubString(0, Offset);
// CopyMem(NewLoadOptions, LoadOptions, Offset * sizeof(CHAR16));
if ((Offset + OptionLength) < Length) {
// Copy following substring, but include one space also
OptionLength--;
CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
NewLoadOptions += LoadOptions.SubString(Offset + OptionLength, MAX_XSIZE);
// CopyMem(NewLoadOptions + Offset, LoadOptions + Offset + OptionLength, (Length - OptionLength - Offset) * sizeof(CHAR16));
}
}
return NewLoadOptions;

View File

@ -0,0 +1,18 @@
/*
* common.h
*
* Created on: 5 Apr 2020
* Author: jief
*/
#ifndef ENTRY_SCAN_COMMON_H_
#define ENTRY_SCAN_COMMON_H_
#include "../cpp_foundation/XString.h"
XString AddLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
XString RemoveLoadOption(IN const XString& LoadOptions, IN const XString& LoadOption);
#endif /* ENTRY_SCAN_COMMON_H_ */

View File

@ -175,7 +175,7 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
} else {
Entry->Image = ThemeX.GetIcon(XString().takeValueFrom(Volume->LegacyOS->IconName));
if (Entry->Image.isEmpty()) {
Entry->Image = ThemeX.GetIcon("vol_internal"); //we have no legacy.png
Entry->Image = ThemeX.GetIcon("vol_internal"_XS); //we have no legacy.png
}
}
#else
@ -218,7 +218,7 @@ BOOLEAN AddLegacyEntry(IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
#endif
Entry->Volume = Volume;
Entry->DevicePathString = Volume->DevicePathString;
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? L"CD" : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? L"USB" : L"HD");
Entry->LoadOptions = (Volume->DiskKind == DISK_KIND_OPTICAL) ? "CD"_XS : ((Volume->DiskKind == DISK_KIND_EXTERNAL) ? "USB"_XS : "HD"_XS);
// create the submenu
// SubScreen = (__typeof__(SubScreen))AllocateZeroPool(sizeof(REFIT_MENU_SCREEN));
SubScreen = new REFIT_MENU_SCREEN();

View File

@ -39,6 +39,7 @@
#include "../Platform/Hibernate.h"
#include "../refit/screen.h"
#include "../refit/menu.h"
#include "common.h"
#ifndef DEBUG_ALL
#define DEBUG_SCAN_LOADER 1
@ -56,13 +57,13 @@
#define MACOSX_LOADER_PATH L"\\System\\Library\\CoreServices\\boot.efi"
#define LINUX_ISSUE_PATH L"\\etc\\issue"
const XStringW LINUX_ISSUE_PATH = L"\\etc\\issue"_XSW;
#define LINUX_BOOT_PATH L"\\boot"
#define LINUX_BOOT_ALT_PATH L"\\boot"
#define LINUX_LOADER_PATH L"vmlinuz"
#define LINUX_FULL_LOADER_PATH LINUX_BOOT_PATH L"\\" LINUX_LOADER_PATH
const XString LINUX_LOADER_PATH = "vmlinuz"_XS;
const XStringW LINUX_FULL_LOADER_PATH = SWPrintf("%ls\\%s", LINUX_BOOT_PATH, LINUX_LOADER_PATH.c_str());
#define LINUX_LOADER_SEARCH_PATH L"vmlinuz*"
#define LINUX_DEFAULT_OPTIONS L"ro add_efi_memmap quiet splash vt.handoff=7"
const XString LINUX_DEFAULT_OPTIONS = "ro add_efi_memmap quiet splash vt.handoff=7"_XS;
#if defined(MDE_CPU_X64)
#define BOOT_LOADER_PATH L"\\EFI\\BOOT\\BOOTX64.efi"
@ -309,37 +310,37 @@ STATIC CONST CHAR16 *LinuxIconNameFromPath(IN CONST CHAR16 *Path,
return L"linux";
}
STATIC CONST CHAR16 *LinuxInitImagePath[] = {
L"initrd%s",
L"initrd.img%s",
L"initrd%s.img",
L"initramfs%s",
L"initramfs.img%s",
L"initramfs%s.img",
STATIC CONST XString LinuxInitImagePath[] = {
"initrd%s"_XS,
"initrd.img%s"_XS,
"initrd%s.img"_XS,
"initramfs%s"_XS,
"initramfs.img%s"_XS,
"initramfs%s.img"_XS,
};
STATIC CONST UINTN LinuxInitImagePathCount = (sizeof(LinuxInitImagePath) / sizeof(CHAR16 *));
STATIC CHAR16 *LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
STATIC XString LinuxKernelOptions(IN EFI_FILE_PROTOCOL *Dir,
IN CONST CHAR16 *Version,
IN CONST CHAR16 *PartUUID,
IN CONST CHAR16 *Options OPTIONAL)
IN CONST XString& Options OPTIONAL)
{
UINTN Index = 0;
if ((Dir == NULL) || (PartUUID == NULL)) {
return (Options == NULL) ? NULL : EfiStrDuplicate(Options);
return Options;
}
while (Index < LinuxInitImagePathCount) {
CHAR16 *InitRd = PoolPrint(LinuxInitImagePath[Index++], (Version == NULL) ? L"" : Version);
XStringW InitRd = SWPrintf(LinuxInitImagePath[Index++].c_str(), (Version == NULL) ? L"" : Version);
if (InitRd != NULL) {
if (FileExists(Dir, InitRd)) {
CHAR16 *CustomOptions = PoolPrint(L"root=/dev/disk/by-partuuid/%s initrd=%s\\%s %s %s", PartUUID, LINUX_BOOT_ALT_PATH, InitRd, LINUX_DEFAULT_OPTIONS, (Options == NULL) ? L"" : Options);
if (FileExists(Dir, InitRd.wc_str())) {
XString CustomOptions = SPrintf("root=/dev/disk/by-partuuid/%ls initrd=%ls\\%ls %s %s", PartUUID, LINUX_BOOT_ALT_PATH, InitRd.wc_str(), LINUX_DEFAULT_OPTIONS.c_str(), Options.c_str());
FreePool(InitRd);
return CustomOptions;
}
FreePool(InitRd);
}
}
return PoolPrint(L"root=/dev/disk/by-partuuid/%s %s %s", PartUUID, LINUX_DEFAULT_OPTIONS, (Options == NULL) ? L"" : Options);
return SPrintf("root=/dev/disk/by-partuuid/%ls %s %s", PartUUID, LINUX_DEFAULT_OPTIONS.c_str(), Options.c_str());
}
STATIC BOOLEAN isFirstRootUUID(REFIT_VOLUME *Volume)
@ -406,7 +407,7 @@ STATIC EFI_STATUS GetOSXVolumeName(LOADER_ENTRY *Entry)
}
#if USE_XTHEME
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST CHAR16 *LoaderOptions,
IN CONST XString& LoaderOptions,
IN CONST XStringW& FullTitle,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume,
@ -424,7 +425,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
#else
STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
IN CONST CHAR16 *LoaderOptions,
IN CONST XString& LoaderOptions,
IN CONST CHAR16 *FullTitle,
IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume,
@ -584,14 +585,14 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->DevicePath = LoaderDevicePath;
Entry->DevicePathString = LoaderDevicePathString;
Entry->Flags = OSFLAG_SET(Flags, OSFLAG_USEGRAPHICS);
if (LoaderOptions) {
if (LoaderOptions.notEmpty()) {
if (OSFLAG_ISSET(Flags, OSFLAG_NODEFAULTARGS)) {
Entry->LoadOptions = EfiStrDuplicate(LoaderOptions);
Entry->LoadOptions = LoaderOptions;
} else {
Entry->LoadOptions = PoolPrint(L"%a %s", gSettings.BootArgs, LoaderOptions);
Entry->LoadOptions = SPrintf("%s %s", gSettings.BootArgs, LoaderOptions.c_str());
}
} else if ((AsciiStrLen(gSettings.BootArgs) > 0) && OSFLAG_ISUNSET(Flags, OSFLAG_NODEFAULTARGS)) {
Entry->LoadOptions = PoolPrint(L"%a", gSettings.BootArgs);
Entry->LoadOptions = SPrintf("%s", gSettings.BootArgs);
}
// locate a custom icon for the loader
@ -616,9 +617,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
case OSTYPE_OSX_INSTALLER:
OSIconName = GetOSIconName(Entry->OSVersion);// Sothor - Get OSIcon name using OSVersion
// apianti - force custom logo even when verbose
if ((Entry->LoadOptions != NULL) &&
((StrStr(Entry->LoadOptions, L"-v") != NULL) ||
(StrStr(Entry->LoadOptions, L"-V") != NULL))) {
if ( Entry->LoadOptions.ExistInIC("-v") ) {
// OSX is not booting verbose, so we can set console to graphics mode
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS);
}
@ -763,7 +762,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
Entry->Image = *Image;
} else {
// Entry->Image = ThemeX.GetIcon("unknown"); //no such icon
Entry->Image = ThemeX.GetIcon("vol_internal");
Entry->Image = ThemeX.GetIcon("vol_internal"_XS);
}
// Load DriveImage
if (DriveImage) {
@ -827,7 +826,7 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST CHAR16 *LoaderPath,
STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
{
CONST CHAR16 *FileName;
CHAR16* TempOptions;
// CHAR16* TempOptions;
// CHAR16 DiagsFileName[256];
LOADER_ENTRY *SubEntry;
REFIT_MENU_SCREEN *SubScreen;
@ -872,7 +871,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %ls", Entry->LoadOptions);
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.c_str());
// loader-specific submenu entries
if (Entry->LoaderType == OSTYPE_OSX ||
Entry->LoaderType == OSTYPE_OSX_INSTALLER ||
@ -974,8 +973,8 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
}
} else if (Entry->LoaderType == OSTYPE_LINEFI) {
BOOLEAN Quiet = (StrStr(Entry->LoadOptions, L"quiet") != NULL);
BOOLEAN WithSplash = (StrStr(Entry->LoadOptions, L"splash") != NULL);
BOOLEAN Quiet = Entry->LoadOptions.ExistIn("quiet");
BOOLEAN WithSplash = Entry->LoadOptions.ExistIn("splash");
// default entry
SubEntry = Entry->getPartiallyDuplicatedEntry();
@ -986,57 +985,50 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
FreePool(SubEntry->LoadOptions);
if (Quiet) {
SubEntry->Title.SWPrintf("%ls verbose", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, L"quiet");
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, "quiet"_XS);
} else {
SubEntry->Title.SWPrintf("%ls quiet", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"quiet");
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "quiet"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
FreePool(SubEntry->LoadOptions);
if (WithSplash) {
SubEntry->Title.SWPrintf("%ls without splash", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, L"splash");
SubEntry->LoadOptions = RemoveLoadOption(Entry->LoadOptions, "splash"_XS);
} else {
SubEntry->Title.SWPrintf("%ls with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"splash");
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "splash"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
FreePool(SubEntry->LoadOptions);
if (WithSplash) {
if (Quiet) {
TempOptions = RemoveLoadOption(Entry->LoadOptions, L"splash");
SubEntry->Title.SWPrintf("%ls verbose without splash", Entry->Title.s());
SubEntry->LoadOptions = RemoveLoadOption(TempOptions, L"quiet");
FreePool(TempOptions);
SubEntry->LoadOptions = RemoveLoadOption(RemoveLoadOption(Entry->LoadOptions, "splash"_XS), "quiet"_XS);
} else {
TempOptions = RemoveLoadOption(Entry->LoadOptions, L"splash");
SubEntry->Title.SWPrintf("%ls quiet without splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(TempOptions, L"quiet");
FreePool(TempOptions);
SubEntry->LoadOptions = AddLoadOption(RemoveLoadOption(Entry->LoadOptions, "splash"_XS), "quiet"_XS);
}
} else if (Quiet) {
TempOptions = RemoveLoadOption(Entry->LoadOptions, L"quiet");
// TempOptions = RemoveLoadOption(Entry->LoadOptions, "quiet"_XS);
SubEntry->Title.SWPrintf("%ls verbose with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"splash");
FreePool(TempOptions);
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "splash"_XS);
// FreePool(TempOptions);
} else {
SubEntry->Title.SWPrintf("%ls quiet with splash", Entry->Title.s());
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, L"quiet splash");
SubEntry->LoadOptions = AddLoadOption(Entry->LoadOptions, "quiet splash"_XS);
}
}
SubScreen->AddMenuEntry(SubEntry, true);
} else if ((Entry->LoaderType == OSTYPE_WIN) || (Entry->LoaderType == OSTYPE_WINEFI)) {
// by default, skip the built-in selection and boot from hard disk only
Entry->LoadOptions = PoolPrint(L"-s -h");
Entry->LoadOptions.SPrintf("-s -h");
// default entry
SubEntry = Entry->getPartiallyDuplicatedEntry();
@ -1054,7 +1046,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.takeValueFrom("Boot Windows from CD-ROM");
SubEntry->LoadOptions = PoolPrint(L"-s -c");
SubEntry->LoadOptions.SPrintf("-s -c");
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -1062,7 +1054,7 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
if (SubEntry) {
SubEntry->Title.SWPrintf("Run %ls in text mode", FileName);
SubEntry->Flags = OSFLAG_UNSET(SubEntry->Flags, OSFLAG_USEGRAPHICS);
SubEntry->LoadOptions = PoolPrint(L"-v");
SubEntry->LoadOptions.SPrintf("-v");
SubEntry->LoaderType = OSTYPE_OTHER; // Sothor - Why are we using OSTYPE_OTHER here?
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -1074,13 +1066,13 @@ STATIC VOID AddDefaultMenu(IN LOADER_ENTRY *Entry)
// DBG(" Added '%ls': OSType='%d', OSVersion='%s'\n", Entry->Title, Entry->LoaderType, Entry->OSVersion);
}
#if USE_XTHEME
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions,
BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN XImage *Image,
IN UINT8 OSType, IN UINT8 Flags)
#else
STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderOptions,
IN CONST CHAR16 *LoaderTitle,
STATIC BOOLEAN AddLoaderEntry(IN CONST CHAR16 *LoaderPath, IN CONST XString& LoaderOptions,
IN CONST XStringW& LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN UINT8 OSType, IN UINT8 Flags)
#endif
@ -1160,31 +1152,16 @@ VOID AddPRSEntry(REFIT_VOLUME *Volume)
switch (WhatBoot) {
case Paper:
case (Paper | Rock):
#if USE_XTHEME
AddLoaderEntry(PaperBoot, L""_XSW, L"macOS InstallP"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(PaperBoot, NULL, L"macOS InstallP", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
AddLoaderEntry(PaperBoot, ""_XS, L"macOS InstallP"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
case Scissor:
case (Paper | Scissor):
#if USE_XTHEME
AddLoaderEntry(ScissorBoot, L""_XSW, L"macOS InstallS"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(ScissorBoot, NULL, L"macOS InstallS", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
AddLoaderEntry(ScissorBoot, ""_XS, L"macOS InstallS"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
case Rock:
case (Rock | Scissor):
case (Rock | Scissor | Paper):
#if USE_XTHEME
AddLoaderEntry(RockBoot, L""_XSW, L"macOS InstallR"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
AddLoaderEntry(RockBoot, NULL, L"macOS InstallR", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
AddLoaderEntry(RockBoot, ""_XS, L"macOS InstallR"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
break;
default:
@ -1237,69 +1214,40 @@ VOID ScanLoader(VOID)
if (FileExists(Volume->RootDir, L"\\Install OS X Mavericks.app") ||
FileExists(Volume->RootDir, L"\\Install OS X Yosemite.app") ||
FileExists(Volume->RootDir, L"\\Install OS X El Capitan.app")) {
#if USE_XTHEME
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
#else
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
#endif
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.9 - 10.11
} else {
#if USE_XTHEME
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
#else
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
#endif
AddLoaderEntry(L"\\.IABootFiles\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.13.3
}
} else if (FileExists(Volume->RootDir, L"\\.IAPhysicalMedia") && FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
#if USE_XTHEME
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
#else
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
#endif
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.13.4+
}
#if USE_XTHEME
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddPRSEntry(Volume); // 10.12+
// Netinstall
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
// 2nd stage - InstallESD/AppStore/startosinstall/Fusion Drive
AddLoaderEntry(L"\\Mac OS X Install Data\\boot.efi", NULL, L"Mac OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(L"\\OS X Install Data\\boot.efi", NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(L"\\macOS Install Data\\boot.efi", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12 - 10.12.3
AddLoaderEntry(L"\\macOS Install Data\\Locked Files\\Boot Files\\boot.efi", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12.4+
AddPRSEntry(Volume); // 10.12+
// Netinstall
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
AddLoaderEntry(L"\\NetInstall macOS High Sierra.nbi\\i386\\booter", ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
// Use standard location for boot.efi, according to the install files is present
// That file indentifies a DVD/ESD/BaseSystem/Fusion Drive Install Media, so when present, check standard path to avoid entry duplication
#if USE_XTHEME
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\OS X Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\macOS Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
} else if (FileExists(Volume->RootDir, L"\\BaseSystem.dmg") && FileExists(Volume->RootDir, L"\\mach_kernel")) {
// InstallESD
if (FileExists(Volume->RootDir, L"\\MacOSX_Media_Background.png")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
}
} else if (FileExists(Volume->RootDir, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
@ -1307,68 +1255,25 @@ VOID ScanLoader(VOID)
if (StriStr(Volume->VolName, L"Recovery") != NULL) {
// FileVault of HFS+
// TODO: need info for 10.11 and lower
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS FileVault"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS FileVault"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
} else {
// Fusion Drive
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X Install"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
}
} else if (!FileExists(Volume->RootDir, L"\\.IAPhysicalMedia")) {
// Installed
if (EFI_ERROR(GetRootUUID(Volume)) || isFirstRootUUID(Volume)) {
if (!FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"Mac OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"Mac OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"OS X"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, L""_XSW, L"macOS"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
AddLoaderEntry(MACOSX_LOADER_PATH, ""_XS, L"macOS"_XSW, Volume, NULL, OSTYPE_OSX, 0); // 10.12+
}
}
}
}
#else
if (FileExists(Volume->RootDir, MACOSX_LOADER_PATH)) {
if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\Mac OS X Installer.app")) {
// InstallDVD/BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"Mac OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.6/10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\OS X Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8 - 10.11
} else if (FileExists(Volume->RootDir, L"\\System\\Installation\\CDIS\\macOS Installer.app")) {
// BaseSystem
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"macOS Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.12+
} else if (FileExists(Volume->RootDir, L"\\BaseSystem.dmg") && FileExists(Volume->RootDir, L"\\mach_kernel")) {
// InstallESD
if (FileExists(Volume->RootDir, L"\\MacOSX_Media_Background.png")) {
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"Mac OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.7
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.8
}
} else if (FileExists(Volume->RootDir, L"\\com.apple.boot.R\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.P\\System\\Library\\PrelinkedKernels\\prelinkedkernel") ||
FileExists(Volume->RootDir, L"\\com.apple.boot.S\\System\\Library\\PrelinkedKernels\\prelinkedkernel")) {
if (StriStr(Volume->VolName, L"Recovery") != NULL) {
// FileVault of HFS+
// TODO: need info for 10.11 and lower
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"macOS FileVault", Volume, NULL, OSTYPE_OSX, 0); // 10.12+
} else {
// Fusion Drive
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"OS X Install", Volume, NULL, OSTYPE_OSX_INSTALLER, 0); // 10.11
}
} else if (!FileExists(Volume->RootDir, L"\\.IAPhysicalMedia")) {
// Installed
if (EFI_ERROR(GetRootUUID(Volume)) || isFirstRootUUID(Volume)) {
if (!FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"Mac OS X", Volume, NULL, OSTYPE_OSX, 0); // 10.6 - 10.7
} else if (FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\NotificationCenter.app") && !FileExists(Volume->RootDir, L"\\System\\Library\\CoreServices\\Siri.app")) {
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"OS X", Volume, NULL, OSTYPE_OSX, 0); // 10.8 - 10.11
} else {
AddLoaderEntry(MACOSX_LOADER_PATH, NULL, L"macOS", Volume, NULL, OSTYPE_OSX, 0); // 10.12+
}
}
}
}
#endif
/* APFS Container support.
/* APFS Container support.
* s.mtr 2017
*/
if ((StriCmp(Volume->VolName, L"Recovery") == 0 || StriCmp(Volume->VolName, L"Preboot") == 0) && APFSSupport == TRUE) {
@ -1379,65 +1284,34 @@ VOID ScanLoader(VOID)
StrnCpy(APFSFVBootPath + 1, CurrentUUID, 36);
StrnCpy(APFSRecBootPath + 1, CurrentUUID, 36);
StrnCpy(APFSInstallBootPath + 1, CurrentUUID, 36);
#if USE_XTHEME
//Try to add FileVault entry
AddLoaderEntry(APFSFVBootPath, L""_XSW, L"FileVault Prebooter"_XSW, Volume, NULL, OSTYPE_OSX, 0);
AddLoaderEntry(APFSFVBootPath, ""_XS, L"FileVault Prebooter"_XSW, Volume, NULL, OSTYPE_OSX, 0);
//Try to add Recovery APFS entry
AddLoaderEntry(APFSRecBootPath, L""_XSW, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
AddLoaderEntry(APFSRecBootPath, ""_XS, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
//Try to add macOS install entry
AddLoaderEntry(APFSInstallBootPath, L""_XSW, L"macOS Install Prebooter"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#else
//Try to add FileVault entry
AddLoaderEntry(APFSFVBootPath, NULL, L"FileVault Prebooter", Volume, NULL, OSTYPE_OSX, 0);
//Try to add Recovery APFS entry
AddLoaderEntry(APFSRecBootPath, NULL, L"Recovery", Volume, NULL, OSTYPE_RECOVERY, 0);
//Try to add macOS install entry
AddLoaderEntry(APFSInstallBootPath, NULL, L"macOS Install Prebooter", Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
#endif
AddLoaderEntry(APFSInstallBootPath, ""_XS, L"macOS Install Prebooter"_XSW, Volume, NULL, OSTYPE_OSX_INSTALLER, 0);
FreePool(CurrentUUID);
}
}
#if USE_XTHEME
// check for Mac OS X Recovery Boot
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", L""_XSW, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", ""_XS, L"Recovery"_XSW, Volume, NULL, OSTYPE_RECOVERY, 0);
// Sometimes, on some systems (HP UEFI, if Win is installed first)
// it is needed to get rid of bootmgfw.efi to allow starting of
// Clover as /efi/boot/bootx64.efi from HD. We can do that by renaming
// bootmgfw.efi to bootmgfw-orig.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", L""_XSW, L"Microsoft EFI"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", ""_XS, L"Microsoft EFI"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu
// If there is bootmgfw-orig.efi, then do not check for bootmgfw.efi
// since on some systems this will actually be CloverX64.efi
// renamed to bootmgfw.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", L""_XSW, L"Microsoft EFI Boot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", ""_XS, L"Microsoft EFI Boot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu. This entry is redundant so excluded
// AddLoaderEntry(L"\\bootmgr.efi", L"", L"Microsoft EFI mgrboot", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu on CDROM
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", L""_XSW, L"Microsoft EFI cdboot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", L""_XSW, L"Microsoft EFI CDBOOT"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", ""_XS, L"Microsoft EFI cdboot"_XSW, Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", ""_XS, L"Microsoft EFI CDBOOT"_XSW, Volume, NULL, OSTYPE_WINEFI, 0);
}
#else
// check for Mac OS X Recovery Boot
AddLoaderEntry(L"\\com.apple.recovery.boot\\boot.efi", NULL, L"Recovery", Volume, NULL, OSTYPE_RECOVERY, 0);
// Sometimes, on some systems (HP UEFI, if Win is installed first)
// it is needed to get rid of bootmgfw.efi to allow starting of
// Clover as /efi/boot/bootx64.efi from HD. We can do that by renaming
// bootmgfw.efi to bootmgfw-orig.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw-orig.efi", L"", L"Microsoft EFI", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu
// If there is bootmgfw-orig.efi, then do not check for bootmgfw.efi
// since on some systems this will actually be CloverX64.efi
// renamed to bootmgfw.efi
AddLoaderEntry(L"\\EFI\\microsoft\\Boot\\bootmgfw.efi", L"", L"Microsoft EFI Boot", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu. This entry is redundant so excluded
// AddLoaderEntry(L"\\bootmgr.efi", L"", L"Microsoft EFI mgrboot", Volume, NULL, OSTYPE_WINEFI, 0);
// check for Microsoft boot loader/menu on CDROM
if (!AddLoaderEntry(L"\\EFI\\MICROSOFT\\BOOT\\cdboot.efi", L"", L"Microsoft EFI cdboot", Volume, NULL, OSTYPE_WINEFI, 0)) {
AddLoaderEntry(L"\\EFI\\MICROSOF\\BOOT\\CDBOOT.EFI", L"", L"Microsoft EFI CDBOOT", Volume, NULL, OSTYPE_WINEFI, 0);
}
#endif
#if defined(ANDX86)
if (TRUE) { //gSettings.AndroidScan
// check for Android loaders
@ -1452,10 +1326,10 @@ VOID ScanLoader(VOID)
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeX.ThemeDir, AndroidEntryData[Index].Icon);
AddLoaderEntry(AndroidEntryData[Index].Path, L""_XSW, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(AndroidEntryData[Index].Path, L"", AndroidEntryData[Index].Title, Volume,
AddLoaderEntry(AndroidEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(AndroidEntryData[Index].Title), Volume,
LoadOSIcon(AndroidEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
}
@ -1470,10 +1344,10 @@ VOID ScanLoader(VOID)
#if USE_XTHEME
XImage ImageX;
ImageX.LoadXImage(ThemeX.ThemeDir, LinuxEntryData[Index].Icon);
AddLoaderEntry(LinuxEntryData[Index].Path, L""_XSW, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
&ImageX, OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(LinuxEntryData[Index].Path, L"", LinuxEntryData[Index].Title, Volume,
AddLoaderEntry(LinuxEntryData[Index].Path, ""_XS, XStringW().takeValueFrom(LinuxEntryData[Index].Title), Volume,
LoadOSIcon(LinuxEntryData[Index].Icon, L"unknown", 128, FALSE, TRUE), OSTYPE_LIN, OSFLAG_NODEFAULTARGS);
#endif
}
@ -1484,7 +1358,7 @@ VOID ScanLoader(VOID)
EFI_FILE_INFO *FileInfo = NULL;
EFI_TIME PreviousTime;
CHAR16 *Path = NULL;
CHAR16 *Options;
// CHAR16 *Options;
// Get the partition UUID and make sure it's lower case
CHAR16 PartUUID[40];
ZeroMem(&PreviousTime, sizeof(EFI_TIME));
@ -1506,18 +1380,15 @@ VOID ScanLoader(VOID)
// get the kernel file path
Path = PoolPrint(L"%s\\%s", LINUX_BOOT_PATH, FileInfo->FileName);
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
FreePool(Path);
}
// free the file info
@ -1545,17 +1416,9 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
}
break;
@ -1580,16 +1443,9 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
FreePool(Path);
}
break;
@ -1614,16 +1470,13 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
FreePool(Path);
}
break;
@ -1652,16 +1505,13 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, XStringW().takeValueFrom(Basename(Path) + LINUX_LOADER_PATH.length()).wc_str(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
FreePool(Path);
}
break;
@ -1690,15 +1540,12 @@ VOID ScanLoader(VOID)
}
}
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
FreePool(Path);
}
break;
@ -1711,16 +1558,13 @@ VOID ScanLoader(VOID)
// get the kernel file path
Path = PoolPrint(L"%s\\%s", LINUX_BOOT_PATH, FileInfo->FileName);
if (Path != NULL) {
Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + StrLen(LINUX_LOADER_PATH), PartUUID, NULL);
XString Options = LinuxKernelOptions(Iter.DirHandle, Basename(Path) + LINUX_LOADER_PATH.length(), PartUUID, ""_XS);
// Add the entry
#if USE_XTHEME
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : XStringW().takeValueFrom(Options), L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#else
AddLoaderEntry(Path, (Options == NULL) ? LINUX_DEFAULT_OPTIONS : Options, NULL, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
AddLoaderEntry(Path, (Options.isEmpty()) ? LINUX_DEFAULT_OPTIONS : Options, L""_XSW, Volume, NULL, OSTYPE_LINEFI, OSFLAG_NODEFAULTARGS);
#endif
if (Options != NULL) {
FreePool(Options);
}
FreePool(Path);
}
}
@ -1740,33 +1584,18 @@ VOID ScanLoader(VOID)
DirIterClose(&Iter);
}
} //if linux scan
#if USE_XTHEME
// DBG("search for optical UEFI\n");
if (Volume->DiskKind == DISK_KIND_OPTICAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI optical"_XSW, Volume, NULL, OSTYPE_OTHER, 0);
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI optical"_XSW, Volume, NULL, OSTYPE_OTHER, 0);
}
// DBG("search for internal UEFI\n");
if (Volume->DiskKind == DISK_KIND_INTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI internal"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI internal"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
// DBG("search for external UEFI\n");
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L""_XSW, L"UEFI external"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
AddLoaderEntry(BOOT_LOADER_PATH, ""_XS, L"UEFI external"_XSW, Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
#else
// DBG("search for optical UEFI\n");
if (Volume->DiskKind == DISK_KIND_OPTICAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L"", L"UEFI optical", Volume, NULL, OSTYPE_OTHER, 0);
}
// DBG("search for internal UEFI\n");
if (Volume->DiskKind == DISK_KIND_INTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L"", L"UEFI internal", Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
// DBG("search for external UEFI\n");
if (Volume->DiskKind == DISK_KIND_EXTERNAL) {
AddLoaderEntry(BOOT_LOADER_PATH, L"", L"UEFI external", Volume, NULL, OSTYPE_OTHER, OSFLAG_HIDDEN);
}
#endif
}
}
@ -2120,7 +1949,7 @@ if ((Image == NULL) && Custom->ImagePath) {
do
{
// Search for linux kernels
CONST CHAR16 *CustomOptions = Custom->Options;
XString CustomOptions = Custom->Options;
if (FindCustomPath && (Custom->KernelScan == KERNEL_SCAN_ALL)) {
EFI_FILE_INFO *FileInfo = NULL;
// Get the next kernel path or stop looking
@ -2145,7 +1974,7 @@ if ((Image == NULL) && Custom->ImagePath) {
// Check to make sure we should update custom options or not
if (FindCustomPath && OSFLAG_ISUNSET(Custom->Flags, OSFLAG_NODEFAULTARGS)) {
// Find the init ram image and select root
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath) + StrLen(LINUX_LOADER_PATH), PartUUID, Custom->Options);
CustomOptions = LinuxKernelOptions(Iter->DirHandle, Basename(CustomPath) + LINUX_LOADER_PATH.length(), PartUUID, Custom->Options);
}
// Check to make sure that this entry is not hidden or disabled by another custom entry
if (!IsSubEntry) {
@ -2308,7 +2137,7 @@ if ((Image == NULL) && Custom->ImagePath) {
if (Guid) {
SubScreen->AddMenuInfoLine_f("UUID: %s", strguid(Guid));
}
SubScreen->AddMenuInfoLine_f("Options: %ls", Entry->LoadOptions);
SubScreen->AddMenuInfoLine_f("Options: %s", Entry->LoadOptions.c_str());
DBG("Create sub entries\n");
for (CustomSubEntry = Custom->SubEntries; CustomSubEntry; CustomSubEntry = CustomSubEntry->Next) {
if (!CustomSubEntry->Settings) {
@ -2328,7 +2157,6 @@ if ((Image == NULL) && Custom->ImagePath) {
// cleanup custom
if (FindCustomPath) {
FreePool(CustomPath);
FreePool(CustomOptions);
}
} while (FindCustomPath && (Custom->KernelScan == KERNEL_SCAN_ALL));
// Close the kernel boot directory

View File

@ -75,11 +75,11 @@ extern EMU_VARIABLE_CONTROL_PROTOCOL *gEmuVariableControl;
#if USE_XTHEME
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, const XImage& Image,
IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options)
IN CHAR16 ShortcutLetter, IN CONST XString& Options)
#else
STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTitle, IN CONST CHAR16 *LoaderTitle,
IN REFIT_VOLUME *Volume, IN EG_IMAGE *Image,
IN CHAR16 ShortcutLetter, IN CONST CHAR16 *Options)
IN CHAR16 ShortcutLetter, IN CONST XString& Options)
#endif
{
@ -109,7 +109,7 @@ STATIC BOOLEAN AddToolEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *FullTi
Entry->LoaderPath = EfiStrDuplicate(LoaderPath);
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
Entry->DevicePathString = FileDevicePathToStr(Entry->DevicePath);
Entry->LoadOptions = Options ? Options : NULL;
Entry->LoadOptions = Options;
//actions
Entry->AtClick = ActionSelect;
Entry->AtDoubleClick = ActionEnter;
@ -149,7 +149,7 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
Entry->DevicePath = FileDevicePath(Volume->DeviceHandle, Entry->LoaderPath);
Entry->DevicePathString = FileDevicePathToStr(Entry->DevicePath);
Entry->Flags = 0;
Entry->LoadOptions = NULL;
Entry->LoadOptions.setEmpty();
// Entry->LoaderType = OSTYPE_OTHER;
//actions
@ -179,21 +179,21 @@ STATIC VOID AddCloverEntry(IN CONST CHAR16 *LoaderPath, IN CONST CHAR16 *LoaderT
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Add Clover boot options for all entries");
SubEntry->LoadOptions = EfiStrDuplicate(L"BO-ADD");
SubEntry->LoadOptions.SPrintf("BO-ADD");
SubScreen->AddMenuEntry(SubEntry, true);
}
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Remove all Clover boot options");
SubEntry->LoadOptions = EfiStrDuplicate(L"BO-REMOVE");
SubEntry->LoadOptions.SPrintf("BO-REMOVE");
SubScreen->AddMenuEntry(SubEntry, true);
}
SubEntry = Entry->getPartiallyDuplicatedEntry();
if (SubEntry) {
SubEntry->Title.SWPrintf("Print all UEFI boot options to log");
SubEntry->LoadOptions = EfiStrDuplicate(L"BO-PRINT");
SubEntry->LoadOptions.SPrintf("BO-PRINT");
SubScreen->AddMenuEntry(SubEntry, true);
}
@ -220,8 +220,8 @@ VOID ScanTool(VOID)
// DBG("Scanning for tools...\n");
#if USE_XTHEME
if (!(ThemeX.HideUIFlags & HIDEUI_FLAG_SHELL)) {
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL);
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, ThemeX.GetIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
}
}
#else
@ -234,12 +234,12 @@ VOID ScanTool(VOID)
// AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"EFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S');
// } else
//there seems to be the best version
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL);
if (!AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64U.efi", NULL, L"UEFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS)) {
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell64.efi", NULL, L"EFI Shell 64", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
}
// }
#else
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell32.efi", NULL, L"EFI Shell 32", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', NULL);
AddToolEntry(L"\\EFI\\CLOVER\\tools\\Shell32.efi", NULL, L"EFI Shell 32", SelfVolume, BuiltinIcon(BUILTIN_ICON_TOOL_SHELL), 'S', ""_XS);
#endif
}
#endif

View File

@ -2661,7 +2661,7 @@ VOID REFIT_MENU_SCREEN::DrawMainMenuEntry(REFIT_ABSTRACT_MENU_ENTRY *Entry, BOOL
//this should be inited by the Theme
if (MainImage.isEmpty()) {
if (!IsEmbeddedTheme()) {
MainImage = ThemeX.GetIcon("os_mac");
MainImage = ThemeX.GetIcon("os_mac"_XS);
}
if (MainImage.isEmpty()) {
MainImage.DummyImage(MainSize);
@ -3588,9 +3588,9 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
TimeoutSeconds = 0;
if (MenuExit == MENU_EXIT_DETAILS && MainChosenEntry->SubScreen != NULL) {
CHAR16 *TmpArgs = NULL;
XString TmpArgs;
if (AsciiStrLen(gSettings.BootArgs) > 0) {
TmpArgs = PoolPrint(L"%a", gSettings.BootArgs);
TmpArgs.SPrintf("%s", gSettings.BootArgs);
}
SubMenuIndex = -1;
@ -3608,10 +3608,6 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
}
// DBG(" MainChosenEntry with FlagsBits = 0x%X\n", gSettings.FlagsBits);
if (TmpArgs) {
FreePool(TmpArgs);
TmpArgs = NULL;
}
SubMenuExit = 0;
while (!SubMenuExit) {
//running details menu
@ -3625,7 +3621,7 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
break;
}
if (MainChosenEntry->getREFIT_MENU_ENTRY_CLOVER()) {
MainChosenEntry->getREFIT_MENU_ENTRY_CLOVER()->LoadOptions = EfiStrDuplicate(((REFIT_MENU_ENTRY_CLOVER*)TempChosenEntry)->LoadOptions);
MainChosenEntry->getREFIT_MENU_ENTRY_CLOVER()->LoadOptions = (((REFIT_MENU_ENTRY_CLOVER*)TempChosenEntry)->LoadOptions);
}
// DBG(" exit menu with LoadOptions: %ls\n", ((LOADER_ENTRY*)MainChosenEntry)->LoadOptions);
if (SubMenuExit == MENU_EXIT_ENTER && MainChosenEntry->getLOADER_ENTRY() && TempChosenEntry->getLOADER_ENTRY()) {
@ -3634,8 +3630,8 @@ UINTN REFIT_MENU_SCREEN::RunMainMenu(IN INTN DefaultSelection, OUT REFIT_ABSTRAC
// DBG(" get MainChosenEntry FlagsBits = 0x%X\n", ((LOADER_ENTRY*)MainChosenEntry)->Flags);
}
if (/*MenuExit == MENU_EXIT_ENTER &&*/ MainChosenEntry->getLOADER_ENTRY()) {
if (MainChosenEntry->getLOADER_ENTRY()->LoadOptions) {
snprintf(gSettings.BootArgs, 255, "%ls", MainChosenEntry->getLOADER_ENTRY()->LoadOptions);
if (MainChosenEntry->getLOADER_ENTRY()->LoadOptions.notEmpty()) {
snprintf(gSettings.BootArgs, 255, "%s", MainChosenEntry->getLOADER_ENTRY()->LoadOptions.c_str());
} else {
ZeroMem(&gSettings.BootArgs, 255);
}

View File

@ -51,7 +51,7 @@ REFIT_MENU_ENTRY_CLOVER* REFIT_MENU_ENTRY_CLOVER::getPartiallyDuplicatedEntry()
DuplicateEntry->AtClick = ActionEnter;
DuplicateEntry->Volume = Volume;
DuplicateEntry->DevicePathString= EfiStrDuplicate(DevicePathString);
DuplicateEntry->LoadOptions = EfiStrDuplicate(LoadOptions);
DuplicateEntry->LoadOptions = LoadOptions;
DuplicateEntry->LoaderPath = EfiStrDuplicate(LoaderPath);
DuplicateEntry->VolName = EfiStrDuplicate(VolName);
DuplicateEntry->DevicePath = DevicePath;
@ -66,7 +66,7 @@ LOADER_ENTRY* LOADER_ENTRY::getPartiallyDuplicatedEntry() const
DuplicateEntry->AtClick = ActionEnter;
DuplicateEntry->Volume = Volume;
DuplicateEntry->DevicePathString= EfiStrDuplicate(DevicePathString);
DuplicateEntry->LoadOptions = EfiStrDuplicate(LoadOptions);
DuplicateEntry->LoadOptions = LoadOptions;
DuplicateEntry->LoaderPath = EfiStrDuplicate(LoaderPath);
DuplicateEntry->VolName = EfiStrDuplicate(VolName);
DuplicateEntry->DevicePath = DevicePath;

View File

@ -41,6 +41,7 @@
#ifdef __cplusplus
#include "../../cpp_foundation/XObjArray.h"
#include "../../cpp_foundation/XStringWArray.h"
#include "../../cpp_foundation/XString.h"
#include "../../cpp_foundation/XStringW.h"
#include "../../libeg/XPointer.h"
#endif
@ -290,14 +291,14 @@ class REFIT_ABSTRACT_MENU_ENTRY
{
public:
CONST CHAR16 *DevicePathString;
CONST CHAR16 *LoadOptions; //moved here for compatibility with legacy
XString LoadOptions; //moved here for compatibility with legacy
CONST CHAR16 *LoaderPath;
#if USE_XTHEME
XImage DriveImage;
XImage BadgeImage;
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(0), LoaderPath(0), DriveImage(), BadgeImage()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoaderPath(0), DriveImage(), BadgeImage()
{}
virtual XImage* getDriveImage() { return &DriveImage; };
virtual XImage* getBadgeImage() { return &BadgeImage; };
@ -307,7 +308,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
EG_IMAGE *BadgeImage;
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(0), LoaderPath(0), DriveImage(0), BadgeImage(0)
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoaderPath(0), DriveImage(0), BadgeImage(0)
{}
virtual EG_IMAGE* getDriveImage() const { return DriveImage; };
virtual EG_IMAGE* getBadgeImage() const { return BadgeImage; };

View File

@ -42,43 +42,44 @@
#include "../Platform/Platform.h"
#include "../refit/lib.h"
#include "menu_items/menu_items.h"
#include "../entry_scan/common.h"
CONST CHAR16* ArgOptional[NUM_OPT] = {
L"arch=i386", //0
L"arch=x86_64", //1
L"-v ", //2
L"-f ", //3
L"-s ", //4
L"-x ", //5
L"nv_disable=1", //6
L"slide=0", //7
L"darkwake=0", //8
L"-xcpm", //9
L"-gux_no_idle", //10
L"-gux_nosleep", //11
L"-gux_nomsi", //12
L"-gux_defer_usb2", //13
L"keepsyms=1", //14
L"debug=0x100", //15
L"kextlog=0xffff", //16
L"-alcoff", //17
L"-shikioff", //18
L"nvda_drv=1" //19
CONST XString ArgOptional[NUM_OPT] = {
"arch=i386"_XS, //0
"arch=x86_64"_XS, //1
"-v "_XS, //2
"-f "_XS, //3
"-s "_XS, //4
"-x "_XS, //5
"nv_disable=1"_XS, //6
"slide=0"_XS, //7
"darkwake=0"_XS, //8
"-xcpm"_XS, //9
"-gux_no_idle"_XS, //10
"-gux_nosleep"_XS, //11
"-gux_nomsi"_XS, //12
"-gux_defer_usb2"_XS, //13
"keepsyms=1"_XS, //14
"debug=0x100"_XS, //15
"kextlog=0xffff"_XS, //16
"-alcoff"_XS, //17
"-shikioff"_XS, //18
"nvda_drv=1"_XS //19
};
CONST CHAR16 *VBIOS_BIN = L"EFI\\CLOVER\\misc\\c0000.bin";
INPUT_ITEM *InputItems = NULL;
INTN TextStyle; //why global? It will be class SCREEN member
UINT32 EncodeOptions(CONST CHAR16 *Options)
UINT32 EncodeOptions(const XString& Options)
{
UINT32 OptionsBits = 0;
INTN Index;
if (!Options) {
if (Options.isEmpty()) {
return 0;
}
for (Index = 0; Index < NUM_OPT; Index++) {
if (StrStr(Options, ArgOptional[Index])) {
if ( Options.ExistIn(ArgOptional[Index]) ) {
OptionsBits |= (1 << Index);
if (Index == 1) {
OptionsBits &= ~1;

View File

@ -20,7 +20,7 @@ extern CONST CHAR16 *VBIOS_BIN;
extern INPUT_ITEM *InputItems;
VOID DecodeOptions(REFIT_MENU_ITEM_BOOTNUM *Entry);
UINT32 EncodeOptions(CONST CHAR16 *Options);
UINT32 EncodeOptions(const XString& Options);

View File

@ -481,7 +481,7 @@ EFI_STATUS XTheme::ParseSVGXTheme(CONST CHAR8* buffer)
Icon* NewIcon = new Icon(i); //initialize with embedded but further replace by loaded
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name, Scale, &NewIcon->Image);
// DBG("parse %s status %s\n", NewIcon->Name.c_str(), strerror(Status));
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name + "_night", Scale, &NewIcon->ImageNight);
/*Status = */ParseSVGXIcon(mainParser, i, NewIcon->Name + "_night"_XS, Scale, &NewIcon->ImageNight);
// DBG("...night status %s\n", strerror(Status));
Icons.AddReference(NewIcon, true);
}

View File

@ -182,19 +182,19 @@ void XTheme::Init()
* probably it whould return Empty image
* Image.isEmpty() == true
*/
const XImage& XTheme::GetIcon(const char* Name)
{
return GetIcon(XString().takeValueFrom(Name));
}
const XImage& XTheme::GetIcon(const CHAR16* Name)
{
return GetIcon(XString().takeValueFrom(Name));
}
//const XImage& XTheme::GetIcon(const char* Name)
//{
// return GetIcon(XString().takeValueFrom(Name));
//}
//
//const XImage& XTheme::GetIcon(const CHAR16* Name)
//{
// return GetIcon(XString().takeValueFrom(Name));
//}
static XImage NullIcon;
const XImage& XTheme::GetIcon(const XString& Name)
const XImage& XTheme::GetIcon(const XString& Name) const
{
for (size_t i = 0; i < Icons.size(); i++)
{
@ -210,7 +210,7 @@ const XImage& XTheme::GetIcon(const XString& Name)
return NullIcon; //return pointer to XImage? Or XImage copy?
}
const XImage& XTheme::GetIcon(INTN Id)
const XImage& XTheme::GetIcon(INTN Id) const
{
for (size_t i = 0; i < Icons.size(); i++)
{
@ -595,10 +595,10 @@ void XTheme::InitSelection() //for PNG theme
}
} else {
//SVG theme already parsed all icons
Buttons[0] = GetIcon("radio_button");
Buttons[1] = GetIcon("radio_button_selected");
Buttons[2] = GetIcon("checkbox");
Buttons[3] = GetIcon("checkbox_checked");
Buttons[0] = GetIcon("radio_button"_XS);
Buttons[1] = GetIcon("radio_button_selected"_XS);
Buttons[2] = GetIcon("checkbox"_XS);
Buttons[3] = GetIcon("checkbox_checked"_XS);
}
// non-selected background images
@ -661,7 +661,7 @@ void XTheme::InitBar()
if (ScrollbarBackgroundImage.isEmpty()) {
if (TypeSVG) {
//return OSIconsTable[i].image;
ScrollbarBackgroundImage = GetIcon("scrollbar_background");
ScrollbarBackgroundImage = GetIcon("scrollbar_background"_XS);
}
if (ScrollbarBackgroundImage.isEmpty()) {
ScrollbarBackgroundImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_bar_fill), ACCESS_EMB_SIZE(emb_scroll_bar_fill));
@ -669,7 +669,7 @@ void XTheme::InitBar()
}
if (ScrollbarImage.isEmpty()) {
if (TypeSVG) {
ScrollbarImage = GetIcon("scrollbar_holder"); //"_night" is already accounting
ScrollbarImage = GetIcon("scrollbar_holder"_XS); //"_night" is already accounting
}
if (ScrollbarImage.isEmpty()) {
ScrollbarImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_fill), ACCESS_EMB_SIZE(emb_scroll_scroll_fill));
@ -677,7 +677,7 @@ void XTheme::InitBar()
}
if (ScrollStartImage.isEmpty()) {
if (TypeSVG) {
ScrollStartImage = GetIcon("scrollbar_start");
ScrollStartImage = GetIcon("scrollbar_start"_XS);
}
if (ScrollStartImage.isEmpty()) {
ScrollStartImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_start), ACCESS_EMB_SIZE(emb_scroll_scroll_start));
@ -685,7 +685,7 @@ void XTheme::InitBar()
}
if (ScrollEndImage.isEmpty()) {
if (TypeSVG) {
ScrollEndImage = GetIcon("scrollbar_end");
ScrollEndImage = GetIcon("scrollbar_end"_XS);
}
if (ScrollEndImage.isEmpty()) {
ScrollEndImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_scroll_end), ACCESS_EMB_SIZE(emb_scroll_scroll_end));
@ -693,13 +693,13 @@ void XTheme::InitBar()
}
if (UpButtonImage.isEmpty()) {
if (TypeSVG) {
UpButtonImage = GetIcon("scrollbar_up_button");
UpButtonImage = GetIcon("scrollbar_up_button"_XS);
}
UpButtonImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_up_button), ACCESS_EMB_SIZE(emb_scroll_up_button));
}
if (DownButtonImage.isEmpty()) {
if (TypeSVG) {
DownButtonImage = GetIcon("scrollbar_down_button");
DownButtonImage = GetIcon("scrollbar_down_button"_XS);
}
if (DownButtonImage.isEmpty()) {
DownButtonImage.FromPNG(ACCESS_EMB_DATA(emb_scroll_down_button), ACCESS_EMB_SIZE(emb_scroll_down_button));

View File

@ -113,10 +113,10 @@ public:
EG_RECT BannerPlace;
//fill the theme
const XImage& GetIcon(const XString& Name); //get by name
const XImage& GetIcon(const char* Name);
const XImage& GetIcon(const CHAR16* Name);
const XImage& GetIcon(INTN Id); //get by id
// const XImage& GetIcon(const char* Name);
// const XImage& GetIcon(const CHAR16* Name);
const XImage& GetIcon(const XString& Name) const; //get by name
const XImage& GetIcon(INTN Id) const; //get by id
// void AddIcon(Icon& NewIcon); //return EFI_STATUS?
void FillByEmbedded();

View File

@ -215,10 +215,10 @@
cpp_foundation/XObjArray.h
cpp_foundation/XString.cpp
cpp_foundation/XString.h
cpp_foundation/XStringArray.cpp
cpp_foundation/XStringArray.h
cpp_foundation/XStringW.cpp
cpp_foundation/XStringW.h
cpp_foundation/XStringWP.cpp
cpp_foundation/XStringWP.h
cpp_foundation/XStringWArray.cpp
cpp_foundation/XStringWArray.h
cpp_foundation/XToolsCommon.cpp
@ -227,8 +227,10 @@
cpp_foundation/XUINTN.h
cpp_unit_test/all_tests.h
cpp_unit_test/all_tests.cpp
cpp_unit_test/global_test.cpp
cpp_unit_test/global_test.h
cpp_unit_test/global_test.cpp
cpp_unit_test/LoadOptions_test.cpp
cpp_unit_test/LoadOptions_test.h
cpp_unit_test/unicode_conversions.cpp
cpp_unit_test/unicode_conversions.h
cpp_unit_test/printf_lite-test.cpp
@ -252,6 +254,7 @@
cpp_unit_test/XStringWArray_test.h
cpp_unit_test/XUINTN_test.cpp
cpp_unit_test/XUINTN_test.h
[Sources.IA32]
libeg/ftol.asm | MSFT

View File

@ -737,8 +737,6 @@ VOID DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches);
//VOID FilterKextPatches(IN LOADER_ENTRY *Entry);
UINT32 EncodeOptions(CONST CHAR16 *Options);
CHAR8* GetUnicodeChar(CHAR8 *s, CHAR16* UnicodeChar);
#define KERNEL_MAX_SIZE 40000000

View File

@ -50,6 +50,8 @@
#include "screen.h"
#include "../entry_scan/bootscreen.h"
#include "../Platform/Nvram.h"
#include "../entry_scan/common.h"
#include "../gui/shared_with_menu.h"
#ifndef DEBUG_ALL
#define DEBUG_MAIN 1
@ -185,14 +187,14 @@ bailout:
static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST XString& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST CHAR16 *ImageTitle,
OUT UINTN *ErrorInStep)
{
EFI_STATUS Status, ReturnStatus;
EFI_LOADED_IMAGE *ChildLoadedImage;
CHAR16 ErrorInfo[256];
CHAR16 *FullLoadOptions = NULL;
// CHAR16 *FullLoadOptions = NULL;
// DBG("Starting %ls\n", ImageTitle);
if (ErrorInStep != NULL) {
@ -205,7 +207,7 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
}
// set load options
if (LoadOptions != NULL) {
if (!LoadOptions.isEmpty()) {
ReturnStatus = Status = gBS->HandleProtocol(ChildImageHandle, &gEfiLoadedImageProtocolGuid, (VOID **) &ChildLoadedImage);
if (CheckError(Status, L"while getting a LoadedImageProtocol handle")) {
if (ErrorInStep != NULL)
@ -213,15 +215,17 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
goto bailout_unload;
}
XStringW loadOptionsW;
if (LoadOptionsPrefix != NULL) {
FullLoadOptions = PoolPrint(L"%s %s ", LoadOptionsPrefix, LoadOptions);
// NOTE: That last space is also added by the EFI shell and seems to be significant
// when passing options to Apple's boot.efi...
LoadOptions = FullLoadOptions;
loadOptionsW = SWPrintf("%ls %s ", LoadOptionsPrefix, LoadOptions.c_str());
}else{
loadOptionsW = SWPrintf("%s", LoadOptions.c_str()); // Jief : should we add a space ? Wasn't the case before big refactoring
}
// NOTE: We also include the terminating null in the length for safety.
ChildLoadedImage->LoadOptions = (VOID *)LoadOptions;
ChildLoadedImage->LoadOptionsSize = (UINT32)StrSize(LoadOptions);
ChildLoadedImage->LoadOptions = (void*)loadOptionsW.wc_str();
ChildLoadedImage->LoadOptionsSize = (UINT32)loadOptionsW.sizeInBytes() + sizeof(wchar_t);
//((UINT32)StrLen(LoadOptions) + 1) * sizeof(CHAR16);
// DBG("Using load options '%ls'\n", LoadOptions);
}
@ -262,8 +266,6 @@ static EFI_STATUS StartEFILoadedImage(IN EFI_HANDLE ChildImageHandle,
bailout_unload:
// unload the image, we don't care if it works or not...
Status = gBS->UnloadImage(ChildImageHandle);
if (FullLoadOptions != NULL)
FreePool(FullLoadOptions);
bailout:
return ReturnStatus;
}
@ -295,7 +297,7 @@ static EFI_STATUS LoadEFIImage(IN EFI_DEVICE_PATH *DevicePath,
static EFI_STATUS StartEFIImage(IN EFI_DEVICE_PATH *DevicePath,
IN CONST CHAR16 *LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST XString& LoadOptions, IN CONST CHAR16 *LoadOptionsPrefix,
IN CONST CHAR16 *ImageTitle,
OUT UINTN *ErrorInStep,
OUT EFI_HANDLE *NewImageHandle)
@ -740,21 +742,16 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
}
// Set boot argument for kernel if no caches, this should force kernel loading
if (OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) &&
(StriStr(Entry->LoadOptions, L"Kernel=") == NULL)) {
CONST CHAR16 *KernelLocation = NULL;
CHAR16 *TempOptions;
if ( OSFLAG_ISSET(Entry->Flags, OSFLAG_NOCACHES) && !Entry->LoadOptions.ExistInIC("Kernel="_XS) ) {
XString KernelLocation;
if (Entry->OSVersion && AsciiOSVersionToUint64(Entry->OSVersion) <= AsciiOSVersionToUint64("10.9")) {
KernelLocation =L"\"Kernel=/mach_kernel\"";
KernelLocation.SPrintf("\"Kernel=/mach_kernel\"");
} else {
// used for 10.10, 10.11, and new version.
KernelLocation =L"\"Kernel=/System/Library/Kernels/kernel\"";
KernelLocation.SPrintf("\"Kernel=/System/Library/Kernels/kernel\"");
}
TempOptions = AddLoadOption(Entry->LoadOptions, KernelLocation);
FreePool(Entry->LoadOptions);
Entry->LoadOptions = TempOptions;
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, KernelLocation);
}
//we are booting OSX - restore emulation if it's not installed before g boot.efi
@ -771,9 +768,7 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// If KPDebug is true boot in verbose mode to see the debug messages
if ((Entry->KernelAndKextPatches != NULL) && Entry->KernelAndKextPatches->KPDebug) {
CHAR16 *TempOptions = AddLoadOption(Entry->LoadOptions, L"-v");
FreePool(Entry->LoadOptions);
Entry->LoadOptions = TempOptions;
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-v"_XS);
}
DbgHeader("RestSetup macOS");
@ -798,13 +793,11 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
SetupDataForOSX(DoHibernateWake);
if (gDriversFlags.AptioFixLoaded &&
!DoHibernateWake &&
!StrStr(Entry->LoadOptions, L"slide=")) {
if ( gDriversFlags.AptioFixLoaded &&
!DoHibernateWake &&
!Entry->LoadOptions.ExistIn("slide=") ) {
// Add slide=0 argument for ML+ if not present
CHAR16 *TempOptions = AddLoadOption(Entry->LoadOptions, L"slide=0");
FreePool(Entry->LoadOptions);
Entry->LoadOptions = TempOptions;
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "slide=0"_XS);
}
@ -816,11 +809,9 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
(AsciiStrStr(gCPUStructure.BrandString, "Celeron") || AsciiStrStr(gCPUStructure.BrandString, "Pentium")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) &&
(!StrStr(Entry->LoadOptions, L"-xcpm"))) {
(!Entry->LoadOptions.ExistIn("-xcpm"_XS))) {
// add "-xcpm" argv if not present on Haswell+ Celeron/Pentium
CHAR16 *tmpArgv = AddLoadOption(Entry->LoadOptions, L"-xcpm");
FreePool(Entry->LoadOptions);
Entry->LoadOptions = tmpArgv;
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS);
}
// add -xcpm on Ivy Bridge if set KernelXCPM and system version is 10.8.5 - 10.11.x
@ -828,11 +819,9 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
gCPUStructure.Model == CPU_MODEL_IVY_BRIDGE &&
(AsciiOSVersionToUint64(Entry->OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
(AsciiOSVersionToUint64(Entry->OSVersion) < AsciiOSVersionToUint64("10.12")) &&
(!StrStr(Entry->LoadOptions, L"-xcpm"))) {
(!Entry->LoadOptions.ExistIn("-xcpm"))) {
// add "-xcpm" argv if not present on Ivy Bridge
CHAR16 *tmpArgv = AddLoadOption(Entry->LoadOptions, L"-xcpm");
FreePool(Entry->LoadOptions);
Entry->LoadOptions = tmpArgv;
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, "-xcpm"_XS);
}
if (AudioIo) {
@ -852,15 +841,11 @@ static VOID StartLoader(IN LOADER_ENTRY *Entry)
// which is wrong
// apianti - only block console output if using graphics
// but don't block custom boot logo
if ((Entry->LoadOptions != NULL) &&
((StrStr(Entry->LoadOptions, L"-v") != NULL) ||
(StrStr(Entry->LoadOptions, L"-V") != NULL))) {
if ( Entry->LoadOptions.ExistInIC("-v"_XS) ) {
Entry->Flags = OSFLAG_UNSET(Entry->Flags, OSFLAG_USEGRAPHICS);
} else if (!Entry->LoadOptions) {
CHAR16 *TempOptions = AddLoadOption(Entry->LoadOptions, L" ");
FreePool(Entry->LoadOptions);
Entry->LoadOptions = TempOptions;
}
} else if ( Entry->LoadOptions.isEmpty() ) {
Entry->LoadOptions = AddLoadOption(Entry->LoadOptions, " "_XS);
}
}
else if (OSTYPE_IS_WINDOWS(Entry->LoaderType)) {
@ -1172,7 +1157,7 @@ static VOID ScanDriverDir(IN CONST CHAR16 *Path, OUT EFI_HANDLE **DriversToConne
snwprintf(FileName, 512, "%ls\\%ls", Path, DirEntry->FileName);
Status = StartEFIImage(FileDevicePath(SelfLoadedImage->DeviceHandle, FileName),
L"", DirEntry->FileName, DirEntry->FileName, NULL, &DriverHandle);
""_XS, DirEntry->FileName, DirEntry->FileName, NULL, &DriverHandle);
if (EFI_ERROR(Status)) {
continue;
}
@ -2538,7 +2523,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
}
if (!GlobalConfig.FastBoot) {
CHAR16 *TmpArgs;
// CHAR16 *TmpArgs;
if (gThemeNeedInit) {
InitTheme(TRUE, &Now);
gThemeNeedInit = FALSE;
@ -2567,11 +2552,10 @@ RefitMain (IN EFI_HANDLE ImageHandle,
//now it is a time to set RtVariables
SetVariablesFromNvram();
TmpArgs = PoolPrint(L"%a ", gSettings.BootArgs);
XString TmpArgs = SPrintf("%s ", gSettings.BootArgs);
DBG("after NVRAM boot-args=%s\n", gSettings.BootArgs);
gSettings.OptionsBits = EncodeOptions(TmpArgs);
// DBG("initial OptionsBits %X\n", gSettings.OptionsBits);
FreePool(TmpArgs);
FillInputs(TRUE);
// scan for loaders and tools, add then to the menu
@ -2888,7 +2872,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
if ( ChosenEntry->getREFIT_MENU_ENTRY_CLOVER() ) { // Clover options
REFIT_MENU_ENTRY_CLOVER* LoaderEntry = ChosenEntry->getREFIT_MENU_ENTRY_CLOVER();
if (LoaderEntry->LoadOptions != NULL) {
if (LoaderEntry->LoadOptions.notEmpty()) {
// we are uninstalling in case user selected Clover Options and EmuVar is installed
// because adding bios boot option requires access to real nvram
//Slice: sure?
@ -2896,7 +2880,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
gEmuVariableControl->UninstallEmulation(gEmuVariableControl);
}
*/
if (StrStr(LoaderEntry->LoadOptions, L"BO-ADD") != NULL) {
if ( LoaderEntry->LoadOptions.ExistIn("BO-ADD") ) {
CHAR16 *Description;
CONST CHAR16 *VolName;
CONST CHAR16 *LoaderName;
@ -2965,13 +2949,13 @@ RefitMain (IN EFI_HANDLE ImageHandle,
PrintBootOptions(FALSE);
} else if (StrStr(LoaderEntry->LoadOptions, L"BO-REMOVE") != NULL) {
} else if ( LoaderEntry->LoadOptions.ExistIn("BO-REMOVE") ) {
PrintBootOptions(FALSE);
Status = DeleteBootOptionForFile (LoaderEntry->Volume->DeviceHandle,
LoaderEntry->LoaderPath
);
PrintBootOptions(FALSE);
} else if (StrStr(LoaderEntry->LoadOptions, L"BO-PRINT") != NULL) {
} else if ( LoaderEntry->LoadOptions.ExistIn("BO-PRINT") ) {
PrintBootOptions(TRUE);
}