mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-01-10 19:18:25 +01:00
Fix -W effc++ warnings.
SETTINGS_DATA is a class. XIcon is separate class. KernelAndKextPatches in LOADER_ENTRY is not a pointer anymore.
This commit is contained in:
parent
7765a988fe
commit
29718aaa0b
@ -246,7 +246,7 @@
|
||||
954BBE98238196EE0032425F /* Locale.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Locale.swift; sourceTree = "<group>"; };
|
||||
954C3DF0237DF0250059C698 /* ServiceManagement.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ServiceManagement.framework; path = System/Library/Frameworks/ServiceManagement.framework; sourceTree = SDKROOT; };
|
||||
954DECD423899F5F006A9876 /* Bootmanager.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Bootmanager.png; sourceTree = "<group>"; };
|
||||
954FCFD023917A8A00C9273C /* Clover-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Clover-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
954FCFD023917A8A00C9273C /* Clover-Bridging-Header.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.h; path = "Clover-Bridging-Header.h"; sourceTree = "<group>"; };
|
||||
954FCFD72391818300C9273C /* NSWindowFix.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSWindowFix.h; sourceTree = "<group>"; };
|
||||
954FCFD82391818300C9273C /* NSWindowFix.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSWindowFix.m; sourceTree = "<group>"; };
|
||||
955005EC242531E300AB3979 /* PE_Undo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PE_Undo.swift; sourceTree = "<group>"; };
|
||||
@ -1240,6 +1240,7 @@
|
||||
SDKROOT = macosx;
|
||||
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
|
||||
};
|
||||
name = Debug;
|
||||
};
|
||||
@ -1296,6 +1297,7 @@
|
||||
SDKROOT = macosx;
|
||||
SWIFT_COMPILATION_MODE = wholemodule;
|
||||
SWIFT_OPTIMIZATION_LEVEL = "-O";
|
||||
SWIFT_PRECOMPILE_BRIDGING_HEADER = NO;
|
||||
};
|
||||
name = Release;
|
||||
};
|
||||
|
@ -467,6 +467,12 @@
|
||||
9AD469562452B63800D6D0DB /* XToolsConf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AD469542452B63300D6D0DB /* XToolsConf.h */; };
|
||||
9AD469572452B63800D6D0DB /* XToolsConf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AD469542452B63300D6D0DB /* XToolsConf.h */; };
|
||||
9AD469582452B63900D6D0DB /* XToolsConf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AD469542452B63300D6D0DB /* XToolsConf.h */; };
|
||||
9AEFE64624E2A7D1005D56D8 /* XIcon.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AEFE64424E2A7D0005D56D8 /* XIcon.h */; };
|
||||
9AEFE64724E2A7D1005D56D8 /* XIcon.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AEFE64524E2A7D0005D56D8 /* XIcon.cpp */; };
|
||||
9AEFE64C24E2C64B005D56D8 /* XBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AEFE64824E2C64B005D56D8 /* XBuffer.cpp */; };
|
||||
9AEFE64D24E2C64B005D56D8 /* XRBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AEFE64924E2C64B005D56D8 /* XRBuffer.h */; };
|
||||
9AEFE64E24E2C64B005D56D8 /* XRBuffer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AEFE64A24E2C64B005D56D8 /* XRBuffer.cpp */; };
|
||||
9AEFE64F24E2C64B005D56D8 /* XBuffer.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AEFE64B24E2C64B005D56D8 /* XBuffer.h */; };
|
||||
9AF41562242BABC700D2644C /* printlib-test-cpp_conf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */; };
|
||||
9AF41563242BABC700D2644C /* printlib-test.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF41560242BABC700D2644C /* printlib-test.h */; };
|
||||
9AF41566242BAD5600D2644C /* printf_lite-test-cpp_conf.h in Headers */ = {isa = PBXBuildFile; fileRef = 9AF41565242BAD5600D2644C /* printf_lite-test-cpp_conf.h */; };
|
||||
@ -1034,6 +1040,12 @@
|
||||
9AD4694E2452B5A600D6D0DB /* Pci.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Pci.h; sourceTree = "<group>"; };
|
||||
9AD4694F2452B5A600D6D0DB /* OneLinerMacros.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OneLinerMacros.h; sourceTree = "<group>"; };
|
||||
9AD469542452B63300D6D0DB /* XToolsConf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XToolsConf.h; sourceTree = "<group>"; };
|
||||
9AEFE64424E2A7D0005D56D8 /* XIcon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XIcon.h; sourceTree = "<group>"; };
|
||||
9AEFE64524E2A7D0005D56D8 /* XIcon.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XIcon.cpp; sourceTree = "<group>"; };
|
||||
9AEFE64824E2C64B005D56D8 /* XBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XBuffer.cpp; sourceTree = "<group>"; };
|
||||
9AEFE64924E2C64B005D56D8 /* XRBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XRBuffer.h; sourceTree = "<group>"; };
|
||||
9AEFE64A24E2C64B005D56D8 /* XRBuffer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XRBuffer.cpp; sourceTree = "<group>"; };
|
||||
9AEFE64B24E2C64B005D56D8 /* XBuffer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XBuffer.h; sourceTree = "<group>"; };
|
||||
9AF4155F242BABC700D2644C /* printlib-test-cpp_conf.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printlib-test-cpp_conf.h"; sourceTree = "<group>"; };
|
||||
9AF41560242BABC700D2644C /* printlib-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printlib-test.h"; sourceTree = "<group>"; };
|
||||
9AF41561242BABC700D2644C /* printlib-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printlib-test.cpp"; sourceTree = "<group>"; };
|
||||
@ -1299,19 +1311,17 @@
|
||||
9AC77F5C24176C04005CDD5C /* libeg */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A105B3824483AD50006DE06 /* image.h */,
|
||||
9A105B2424464A830006DE06 /* BmLib.h */,
|
||||
9A105B2324464A830006DE06 /* ftol.asm */,
|
||||
9A105B18244644C50006DE06 /* XCinema.cpp */,
|
||||
9A105B19244644C50006DE06 /* XCinema.h */,
|
||||
9AC77F5F24176C04005CDD5C /* BmLib.cpp */,
|
||||
9A105B2424464A830006DE06 /* BmLib.h */,
|
||||
9AC77F6B24176C04005CDD5C /* EfiFileLib.h */,
|
||||
9AC77F6A24176C04005CDD5C /* egemb_font.cpp */,
|
||||
9AC77F5E24176C04005CDD5C /* egemb_icons_dark.cpp */,
|
||||
9AC77F6224176C04005CDD5C /* egemb_icons.cpp */,
|
||||
9AC77F6D24176C04005CDD5C /* FloatLib.cpp */,
|
||||
9AC77F7324176C04005CDD5C /* FloatLib.h */,
|
||||
9A105B2324464A830006DE06 /* ftol.asm */,
|
||||
9AC77F6424176C04005CDD5C /* image.cpp */,
|
||||
9A105B3824483AD50006DE06 /* image.h */,
|
||||
9AC77F6824176C04005CDD5C /* libeg.h */,
|
||||
9AC77F6124176C04005CDD5C /* libegint.h */,
|
||||
9AC77F7424176C04005CDD5C /* libscreen.cpp */,
|
||||
@ -1323,8 +1333,12 @@
|
||||
9AC77F6E24176C04005CDD5C /* nanosvgrast.cpp */,
|
||||
9AC77F6924176C04005CDD5C /* scroll_images.cpp */,
|
||||
9AC77F6624176C04005CDD5C /* text.cpp */,
|
||||
9A105B2224464A830006DE06 /* VectorGraphics.h */,
|
||||
9AC77F6524176C04005CDD5C /* VectorGraphics.cpp */,
|
||||
9A105B2224464A830006DE06 /* VectorGraphics.h */,
|
||||
9A105B18244644C50006DE06 /* XCinema.cpp */,
|
||||
9A105B19244644C50006DE06 /* XCinema.h */,
|
||||
9AEFE64524E2A7D0005D56D8 /* XIcon.cpp */,
|
||||
9AEFE64424E2A7D0005D56D8 /* XIcon.h */,
|
||||
9AC77F7524176C04005CDD5C /* XImage.cpp */,
|
||||
9AC77F7124176C04005CDD5C /* XImage.h */,
|
||||
9AC77F7024176C04005CDD5C /* XPointer.cpp */,
|
||||
@ -1420,16 +1434,20 @@
|
||||
9AC77FAB24176C04005CDD5C /* cpp_foundation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */,
|
||||
9A9AEB90243F7B5600FBD7D8 /* unicode_conversions.cpp */,
|
||||
9A9AEB93243F7B5600FBD7D8 /* unicode_conversions.h */,
|
||||
9AC77FB624176C04005CDD5C /* XArray.h */,
|
||||
9AEFE64824E2C64B005D56D8 /* XBuffer.cpp */,
|
||||
9AEFE64B24E2C64B005D56D8 /* XBuffer.h */,
|
||||
9AC77FB724176C04005CDD5C /* XObjArray.h */,
|
||||
9AEFE64A24E2C64B005D56D8 /* XRBuffer.cpp */,
|
||||
9AEFE64924E2C64B005D56D8 /* XRBuffer.h */,
|
||||
9A28CC91241AB33700F3D247 /* XString.cpp */,
|
||||
9A28CC92241AB33700F3D247 /* XString.h */,
|
||||
9A35A6172451FE1500CAFF76 /* XStringAbstract.h */,
|
||||
9AC77FAF24176C04005CDD5C /* XStringArray.cpp */,
|
||||
9AC77FAC24176C04005CDD5C /* XStringArray.h */,
|
||||
9A7AEDE6245963BF003AAD04 /* XToolsCommon.h */,
|
||||
);
|
||||
path = cpp_foundation;
|
||||
sourceTree = "<group>";
|
||||
@ -1459,6 +1477,7 @@
|
||||
9AC7808C24176C04005CDD5C /* remove_ref.h in Headers */,
|
||||
9AC7803124176C04005CDD5C /* loader.h in Headers */,
|
||||
9AC7800724176C04005CDD5C /* AmlGenerator.h in Headers */,
|
||||
9AEFE64624E2A7D1005D56D8 /* XIcon.h in Headers */,
|
||||
9A105B2D24464A830006DE06 /* BmLib.h in Headers */,
|
||||
9AF4173F242F15CC00D2644C /* BootLog.h in Headers */,
|
||||
9AC77FC024176C04005CDD5C /* XObjArray_tests.h in Headers */,
|
||||
@ -1494,6 +1513,7 @@
|
||||
9A105B6A24483AE40006DE06 /* stdlib.h in Headers */,
|
||||
9AC7803524176C04005CDD5C /* b64cdecode.h in Headers */,
|
||||
9AC7805224176C04005CDD5C /* EfiFileLib.h in Headers */,
|
||||
9AEFE64D24E2C64B005D56D8 /* XRBuffer.h in Headers */,
|
||||
9AC7807324176C04005CDD5C /* menu_globals.h in Headers */,
|
||||
9AC7809824176C04005CDD5C /* XObjArray.h in Headers */,
|
||||
9A9AEB99243F7B7A00FBD7D8 /* printf_lite-test.h in Headers */,
|
||||
@ -1520,6 +1540,7 @@
|
||||
9A105B7A24483AE40006DE06 /* cpu.h in Headers */,
|
||||
9AC7803824176C04005CDD5C /* ati_reg.h in Headers */,
|
||||
9A105B81244852D70006DE06 /* VersionString.h in Headers */,
|
||||
9AEFE64F24E2C64B005D56D8 /* XBuffer.h in Headers */,
|
||||
9AC7804824176C04005CDD5C /* libegint.h in Headers */,
|
||||
9AC7800624176C04005CDD5C /* memvendors.h in Headers */,
|
||||
9AC7800B24176C04005CDD5C /* kernel_patcher.h in Headers */,
|
||||
@ -2039,6 +2060,7 @@
|
||||
9AC7804524176C04005CDD5C /* egemb_icons_dark.cpp in Sources */,
|
||||
9AC7805024176C04005CDD5C /* scroll_images.cpp in Sources */,
|
||||
9AC7809024176C04005CDD5C /* XStringArray.cpp in Sources */,
|
||||
9AEFE64C24E2C64B005D56D8 /* XBuffer.cpp in Sources */,
|
||||
9AC7801024176C04005CDD5C /* PlatformDriverOverride.cpp in Sources */,
|
||||
9AC7800224176C04005CDD5C /* HdaCodecDump.cpp in Sources */,
|
||||
9AC7801A24176C04005CDD5C /* Nvram.cpp in Sources */,
|
||||
@ -2071,6 +2093,7 @@
|
||||
9AC7803F24176C04005CDD5C /* usbfix.cpp in Sources */,
|
||||
9AC7804624176C04005CDD5C /* BmLib.cpp in Sources */,
|
||||
9AC7804024176C04005CDD5C /* card_vlist.cpp in Sources */,
|
||||
9AEFE64724E2A7D1005D56D8 /* XIcon.cpp in Sources */,
|
||||
9AC780B32417EE4B005CDD5C /* global_test.cpp in Sources */,
|
||||
9AC7805624176C04005CDD5C /* load_icns.cpp in Sources */,
|
||||
9A105B6924483AE40006DE06 /* APFS.cpp in Sources */,
|
||||
@ -2091,6 +2114,7 @@
|
||||
9AC7806924176C04005CDD5C /* lockedgraphics.cpp in Sources */,
|
||||
9A28CC97241AB34800F3D247 /* XString_test.cpp in Sources */,
|
||||
9AC269A824E0514100254048 /* Utils.cpp in Sources */,
|
||||
9AEFE64E24E2C64B005D56D8 /* XRBuffer.cpp in Sources */,
|
||||
9A4185BA2439F29D00BEAFB8 /* LoadOptions_test.cpp in Sources */,
|
||||
9AC7803724176C04005CDD5C /* device_inject.cpp in Sources */,
|
||||
9AC7804224176C04005CDD5C /* Settings.cpp in Sources */,
|
||||
@ -2561,6 +2585,7 @@
|
||||
"-Wchar-subscripts",
|
||||
"-Wmismatched-tags",
|
||||
"-Wimplicit-function-declaration",
|
||||
"-Weffc++",
|
||||
);
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
USE_HEADERMAP = NO;
|
||||
@ -2640,6 +2665,7 @@
|
||||
"-Wchar-subscripts",
|
||||
"-Wmismatched-tags",
|
||||
"-Wimplicit-function-declaration",
|
||||
"-Weffc++",
|
||||
);
|
||||
SUPPORTED_PLATFORMS = macosx;
|
||||
USE_HEADERMAP = NO;
|
||||
|
@ -642,7 +642,7 @@ AddCustomSubEntry (
|
||||
|
||||
BOOLEAN
|
||||
CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst,
|
||||
IN KERNEL_AND_KEXT_PATCHES *Src)
|
||||
IN CONST KERNEL_AND_KEXT_PATCHES *Src)
|
||||
{
|
||||
if (Dst == NULL || Src == NULL) return FALSE;
|
||||
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
INPUT_ITEM MenuItem;
|
||||
BOOLEAN OtherOS;
|
||||
|
||||
ACPI_DROP_TABLE() : Next(0), Signature(0), Length(0), TableId(0), OtherOS(0) {}
|
||||
ACPI_DROP_TABLE() : Next(0), Signature(0), Length(0), TableId(0), MenuItem(), OtherOS(0) {}
|
||||
ACPI_DROP_TABLE(const ACPI_DROP_TABLE& other) = delete; // Can be defined if needed
|
||||
const ACPI_DROP_TABLE& operator = ( const ACPI_DROP_TABLE & ) = delete; // Can be defined if needed
|
||||
~ACPI_DROP_TABLE() {}
|
||||
@ -120,9 +120,10 @@ struct CUSTOM_LOADER_ENTRY {
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL BootBgColor;
|
||||
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
|
||||
|
||||
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), ImagePath(0), DriveImagePath(0), Volume(0), Settings(0), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
|
||||
KernelScan(0), CustomBoot(0), BootBgColor({0,0,0,0})
|
||||
{ memset(&KernelAndKextPatches, 0, sizeof(KernelAndKextPatches)); }
|
||||
CUSTOM_LOADER_ENTRY() : Next(0), SubEntries(0), Image(), DriveImage(), ImagePath(), DriveImagePath(), Volume(), Path(), LoadOptions(),
|
||||
FullTitle(), Title(), Settings(), Hotkey(0), CommonSettings(0), Flags(0), Type(0), VolumeType(0),
|
||||
KernelScan(0), CustomBoot(0), CustomLogo(), BootBgColor({0,0,0,0}), KernelAndKextPatches()
|
||||
{ }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
CUSTOM_LOADER_ENTRY(const CUSTOM_LOADER_ENTRY&) = delete;
|
||||
@ -146,7 +147,7 @@ public:
|
||||
UINT8 Type;
|
||||
UINT8 VolumeType;
|
||||
|
||||
CUSTOM_LEGACY_ENTRY() : Next(0), Hotkey(0), Flags(0), Type(0), VolumeType(0) { }
|
||||
CUSTOM_LEGACY_ENTRY() : Next(0), Image(), DriveImage(), ImagePath(), DriveImagePath(), Volume(), FullTitle(), Title(), Hotkey(0), Flags(0), Type(0), VolumeType(0) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
CUSTOM_LEGACY_ENTRY(const CUSTOM_LEGACY_ENTRY&) = delete;
|
||||
@ -168,7 +169,7 @@ public:
|
||||
UINT8 Flags;
|
||||
UINT8 VolumeType;
|
||||
|
||||
CUSTOM_TOOL_ENTRY() : Next(0), Hotkey(0), Flags(0), VolumeType(0) { }
|
||||
CUSTOM_TOOL_ENTRY() : Next(0), Image(), ImagePath(), Volume(), Path(), LoadOptions(), FullTitle(), Title(), Hotkey(0), Flags(0), VolumeType(0) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
CUSTOM_TOOL_ENTRY(const CUSTOM_TOOL_ENTRY&) = delete;
|
||||
@ -203,15 +204,15 @@ public:
|
||||
INPUT_ITEM MenuItem;
|
||||
TAG_TYPE ValueType;
|
||||
|
||||
DEV_PROPERTY() : Device(0), DevicePath(0), Key(0), Value(0), ValueLen(0), Next(0), Child(0), Label(0), ValueType(kTagTypeNone) { }
|
||||
DEV_PROPERTY() : Device(0), DevicePath(0), Key(0), Value(0), ValueLen(0), Next(0), Child(0), Label(0), MenuItem(), ValueType(kTagTypeNone) { }
|
||||
|
||||
// Not sure if default are valid. Delete them. If needed, proper ones can be created
|
||||
DEV_PROPERTY(const DEV_PROPERTY&) = delete;
|
||||
DEV_PROPERTY& operator=(const DEV_PROPERTY&) = delete;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
|
||||
class SETTINGS_DATA {
|
||||
public:
|
||||
// SMBIOS TYPE0
|
||||
CHAR8 VendorName[64];
|
||||
CHAR8 RomVersion[64];
|
||||
@ -494,10 +495,10 @@ typedef struct {
|
||||
//Patch DSDT arbitrary
|
||||
UINT32 PatchDsdtNum;
|
||||
UINT8 **PatchDsdtFind;
|
||||
UINT32 *LenToFind;
|
||||
UINT8 **PatchDsdtReplace;
|
||||
UINT32 *LenToFind;
|
||||
UINT8 **PatchDsdtReplace;
|
||||
|
||||
UINT32 *LenToReplace;
|
||||
UINT32 *LenToReplace;
|
||||
BOOLEAN DebugDSDT;
|
||||
BOOLEAN SlpWak;
|
||||
BOOLEAN UseIntelHDMI;
|
||||
@ -559,7 +560,40 @@ typedef struct {
|
||||
UINT32 QuirksMask;
|
||||
UINTN MaxSlide;
|
||||
|
||||
} SETTINGS_DATA;
|
||||
|
||||
SETTINGS_DATA() : VendorName{0}, RomVersion{0}, EfiVersion{0}, ReleaseDate{0}, ManufactureName{0}, ProductName{0}, VersionNr{0}, SerialNr{0}, SmUUID({0,0,0,{0}}),
|
||||
SmUUIDConfig(0), pad0{0}, FamilyName{0}, OEMProduct{0}, OEMVendor{0}, BoardManufactureName{0}, BoardSerialNumber{0}, BoardNumber{0}, LocationInChassis{0},
|
||||
BoardVersion{0}, OEMBoard{0}, BoardType(0), Pad1(0), Mobile(0), ChassisType(0), ChassisManufacturer{0}, ChassisAssetTag{0}, CpuFreqMHz(0),
|
||||
BusSpeed(0), Turbo(0), EnabledCores(0), UserChange(0), QEMU(0), SmbiosVersion(0), Attribute(0), Pad17{0}, MemoryManufacturer{0},
|
||||
MemorySerialNumber{0}, MemoryPartNumber{0}, MemorySpeed{0}, CpuType(0), QPI(0), SetTable132(0), TrustSMBIOS(0), InjectMemoryTables(0), XMPDetection(0),
|
||||
UseARTFreq(0), PlatformFeature(0), NoRomInfo(0), Language{0}, BootArgs{0}, CustomUuid{0}, DefaultVolume(0), DefaultLoader(0), LastBootedVolume(0),
|
||||
SkipHibernateTimeout(0), IntelMaxBacklight(0), VendorEDID(0), ProductEDID(0), BacklightLevel(0), BacklightLevelConfig(0), IntelBacklight(0), MemoryFix(0), WithKexts(0),
|
||||
WithKextsIfNoFakeSMC(0), FakeSMCFound(0), NoCaches(0), Debug(0), Pad22{0}, DefaultBackgroundColor(0), ResetAddr(0), ResetVal(0), NoASPM(0),
|
||||
DropSSDT(0), NoOemTableId(0), NoDynamicExtract(0), AutoMerge(0), GeneratePStates(0), GenerateCStates(0), GenerateAPSN(0), GenerateAPLF(0), GeneratePluginType(0),
|
||||
PLimitDict(0), UnderVoltStep(0), DoubleFirstState(0), SuspendOverride(0), EnableC2(0), EnableC4(0), EnableC6(0), EnableISS(0), SlpSmiEnable(0),
|
||||
FixHeaders(0), C3Latency(0), smartUPS(0), PatchNMI(0), EnableC7(0), SavingMode(0), DsdtName{0}, FixDsdt(0), MinMultiplier(0),
|
||||
MaxMultiplier(0), PluginType(0), FixMCFG(0), DeviceRenameCount(0), DeviceRename(0), StringInjector(0), InjectSystemID(0), NoDefaultProperties(0), ReuseFFFF(0),
|
||||
FakeATI(0), FakeNVidia(0), FakeIntel(0), FakeLAN(0), FakeWIFI(0), FakeSATA(0), FakeXHCI(0), FakeIMEI(0), GraphicsInjector(0),
|
||||
InjectIntel(0), InjectATI(0), InjectNVidia(0), DeInit(0), LoadVBios(0), PatchVBios(0), PatchVBiosBytes(0), PatchVBiosBytesCount(0), InjectEDID(0),
|
||||
LpcTune(0), DropOEM_DSM(0), CustomEDID(0), CustomEDIDsize(0), EdidFixHorizontalSyncPulseWidth(0), EdidFixVideoInputSignal(0), FBName{0}, VideoPorts(0), NvidiaGeneric(0),
|
||||
NvidiaNoEFI(0), NvidiaSingle(0), VRAM(0), Dcfg{0}, NVCAP{0}, BootDisplay(0), NvidiaWeb(0), pad41{0}, DualLink(0),
|
||||
IgPlatform(0), SecureBootWhiteListCount(0), SecureBootBlackListCount(0), SecureBootWhiteList(0), SecureBootBlackList(0), SecureBoot(0), SecureBootSetupMode(0), SecureBootPolicy(0), HDAInjection(0),
|
||||
HDALayoutId(0), USBInjection(0), USBFixOwnership(0), InjectClockID(0), HighCurrent(0), NameEH00(0), NameXH00(0), LANInjection(0), HDMIInjection(0),
|
||||
LegacyBoot{0}, LegacyBiosDefaultEntry(0), HWP(0), TDP(0), HWPValue(0), HVHideStrings(0), HVCount(0), KernelAndKextPatches(), KextPatchesAllowed(0),
|
||||
KernelPatchesAllowed(0), AirportBridgeDeviceName{0}, KbdPrevLang(0), PointerEnabled(0), PointerSpeed(0), DoubleClickTime(0), PointerMirror(0), CustomBoot(0), CustomLogo(0),
|
||||
RefCLK(0), RtMLB(0), RtROM(0), RtROMLen(0), CsrActiveConfig(0), BooterConfig(0), BooterCfgStr{0}, DisableCloverHotkeys(0), NeverDoRecovery(0),
|
||||
ConfigName{0}, MainConfigName(0), BlackListCount(0), BlackList(0), RPlt{0}, RBr{0}, EPCI{0}, REV{0}, Rtc8Allowed(0),
|
||||
ForceHPET(0), ResetHDA(0), PlayAsync(0), DisableFunctions(0), PatchDsdtNum(0), PatchDsdtFind(0), LenToFind(0), PatchDsdtReplace(0), LenToReplace(0), DebugDSDT(0), SlpWak(0), UseIntelHDMI(0),
|
||||
AFGLowPowerState(0), PNLF_UID(0), ACPIDropTables(0), DisableEntryScan(0), DisableToolScan(0), ShowHiddenEntries(0), KernelScan(0), LinuxScan(0), CustomEntries(0),
|
||||
CustomLegacy(0), CustomTool(0), NrAddProperties(0), AddProperties(0), BlockKexts{0}, SortedACPICount(0), SortedACPI(0), DisabledAMLCount(0), DisabledAML(0),
|
||||
PatchDsdtLabel(0), PatchDsdtTgt(0), PatchDsdtMenuItem(0), IntelMaxValue(0), OptionsBits(0), FlagsBits(0), UIScale(0), EFILoginHiDPI(0), flagstate{0},
|
||||
ArbProperties(0), QuirksMask(0), MaxSlide(0)
|
||||
{};
|
||||
SETTINGS_DATA(const SETTINGS_DATA& other) = delete; // Can be defined if needed
|
||||
const SETTINGS_DATA& operator = ( const SETTINGS_DATA & ) = delete; // Can be defined if needed
|
||||
~SETTINGS_DATA() {}
|
||||
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
english = 0, //en
|
||||
@ -614,7 +648,7 @@ public:
|
||||
CHAR16 *FileName;
|
||||
INPUT_ITEM MenuItem;
|
||||
|
||||
ACPI_PATCHED_AML() : Next(0), FileName(0) {};
|
||||
ACPI_PATCHED_AML() : Next(0), FileName(0), MenuItem() {};
|
||||
ACPI_PATCHED_AML(const ACPI_PATCHED_AML& other) = delete; // Can be defined if needed
|
||||
const ACPI_PATCHED_AML& operator = ( const ACPI_PATCHED_AML & ) = delete; // Can be defined if needed
|
||||
~ACPI_PATCHED_AML() { }
|
||||
@ -631,7 +665,7 @@ public:
|
||||
XStringW Version;
|
||||
INPUT_ITEM MenuItem;
|
||||
|
||||
SIDELOAD_KEXT() : Next(0), PlugInList(0) {};
|
||||
SIDELOAD_KEXT() : Next(0), PlugInList(0), FileName(), KextDirNameUnderOEMPath(), Version(), MenuItem() {};
|
||||
SIDELOAD_KEXT(const SIDELOAD_KEXT& other) = delete; // Can be defined if needed
|
||||
const SIDELOAD_KEXT& operator = ( const SIDELOAD_KEXT & ) = delete; // Can be defined if needed
|
||||
~SIDELOAD_KEXT() { delete Next; delete PlugInList; }
|
||||
@ -777,7 +811,7 @@ public:
|
||||
*
|
||||
*/
|
||||
REFIT_CONFIG() : Timeout(-1), DisableFlags(0), TextOnly(FALSE), Quiet(TRUE), LegacyFirst(FALSE), NoLegacy(FALSE), DebugLog(FALSE), FastBoot(FALSE), NeverHibernate(FALSE), StrictHibernate(FALSE),
|
||||
RtcHibernateAware(FALSE), HibernationFixup(FALSE), SignatureFixup(FALSE), ConsoleMode(0), CustomIcons(FALSE), IconFormat(ICON_FORMAT_DEF), NoEarlyProgress(FALSE), Timezone(0xFF),
|
||||
RtcHibernateAware(FALSE), HibernationFixup(FALSE), SignatureFixup(FALSE), Theme(), ScreenResolution(), ConsoleMode(0), CustomIcons(FALSE), IconFormat(ICON_FORMAT_DEF), NoEarlyProgress(FALSE), Timezone(0xFF),
|
||||
ShowOptimus(FALSE), Codepage(0xC0), CodepageSize(0xC0) {};
|
||||
REFIT_CONFIG(const SIDELOAD_KEXT& other) = delete; // Can be defined if needed
|
||||
const REFIT_CONFIG& operator = ( const REFIT_CONFIG & ) = delete; // Can be defined if needed
|
||||
@ -931,5 +965,9 @@ ParseSMBIOSSettings (
|
||||
TagPtr dictPointer
|
||||
);
|
||||
|
||||
BOOLEAN
|
||||
CopyKernelAndKextPatches (IN OUT KERNEL_AND_KEXT_PATCHES *Dst,
|
||||
IN CONST KERNEL_AND_KEXT_PATCHES *Src);
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -2090,7 +2090,7 @@ BOOLEAN setup_ati_devprop(LOADER_ENTRY *Entry, pci_dt_t *ati_dev)
|
||||
if (!init_card(ati_dev)) {
|
||||
return FALSE;
|
||||
}
|
||||
CurrentPatches = Entry->KernelAndKextPatches;
|
||||
CurrentPatches = &Entry->KernelAndKextPatches;
|
||||
|
||||
// -------------------------------------------------
|
||||
// Find a better way to do this (in device_inject.c)
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
// runtime debug
|
||||
//make it a member of LOADER_ENTRY class entry.DBG_RT(...)
|
||||
//#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
|
||||
//#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches.KPDebug) { printf(__VA_ARGS__); }
|
||||
|
||||
|
||||
//EFI_PHYSICAL_ADDRESS KernelRelocBase = 0;
|
||||
@ -824,8 +824,8 @@ BOOLEAN LOADER_ENTRY::PatchCPUID(const UINT8* Location, INT32 LenLoc,
|
||||
INT32 patchLocation=0, patchLocation1=0;
|
||||
INT32 Adr = 0, Num;
|
||||
BOOLEAN Patched = FALSE;
|
||||
UINT8 FakeModel = (KernelAndKextPatches->FakeCPUID >> 4) & 0x0f;
|
||||
UINT8 FakeExt = (KernelAndKextPatches->FakeCPUID >> 0x10) & 0x0f;
|
||||
UINT8 FakeModel = (KernelAndKextPatches.FakeCPUID >> 4) & 0x0f;
|
||||
UINT8 FakeExt = (KernelAndKextPatches.FakeCPUID >> 0x10) & 0x0f;
|
||||
for (Num = 0; Num < 2; Num++) {
|
||||
Adr = FindBin(&KernelData[Adr], 0x800000 - Adr, Location, (UINT32)LenLoc);
|
||||
if (Adr < 0) {
|
||||
@ -1025,7 +1025,7 @@ BOOLEAN LOADER_ENTRY::KernelPatchPm()
|
||||
}
|
||||
}
|
||||
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
gBS->Stall(3000000);
|
||||
}
|
||||
#endif
|
||||
@ -1196,7 +1196,7 @@ BOOLEAN LOADER_ENTRY::KernelLapicPatch_64()
|
||||
}
|
||||
}
|
||||
|
||||
// if (KernelAndKextPatches->KPDebug) {
|
||||
// if (KernelAndKextPatches.KPDebug) {
|
||||
Stall(3000000);
|
||||
// }
|
||||
|
||||
@ -1243,7 +1243,7 @@ BOOLEAN LOADER_ENTRY::KernelLapicPatch_32()
|
||||
}
|
||||
}
|
||||
|
||||
// if (KernelAndKextPatches->KPDebug) {
|
||||
// if (KernelAndKextPatches.KPDebug) {
|
||||
Stall(3000000);
|
||||
// }
|
||||
|
||||
@ -1477,7 +1477,7 @@ BOOLEAN LOADER_ENTRY::BroadwellEPM()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KernelAndKextPatches->FakeCPUID = (UINT32)(os_version < AsciiOSVersionToUint64("10.10.3") ? 0x0306C0 : 0x040674);
|
||||
KernelAndKextPatches.FakeCPUID = (UINT32)(os_version < AsciiOSVersionToUint64("10.10.3") ? 0x0306C0 : 0x040674);
|
||||
KernelCPUIDPatch();
|
||||
|
||||
DBG("Searching _xcpm_pkg_scope_msr ...\n");
|
||||
@ -1534,7 +1534,7 @@ BOOLEAN LOADER_ENTRY::HaswellLowEndXCPM()
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
KernelAndKextPatches->FakeCPUID = (UINT32)(0x0306A0); // correct FakeCPUID
|
||||
KernelAndKextPatches.FakeCPUID = (UINT32)(0x0306A0); // correct FakeCPUID
|
||||
KernelCPUIDPatch();
|
||||
|
||||
// 10.8.5 - 10.11.x no need the following kernel patches on Haswell Celeron/Pentium
|
||||
@ -2308,7 +2308,7 @@ LOADER_ENTRY::FindBootArgs()
|
||||
DBG_RT( "bootArgs2->flags = 0x%hx\n", bootArgs2->flags);
|
||||
DBG_RT( "bootArgs2->kslide = 0x%x\n", bootArgs2->kslide);
|
||||
DBG_RT( "bootArgs2->bootMemStart = 0x%llx\n", bootArgs2->bootMemStart);
|
||||
// if (KernelAndKextPatches && KernelAndKextPatches->KPDebug)
|
||||
// if (KernelAndKextPatches && KernelAndKextPatches.KPDebug)
|
||||
Stall(5000000);
|
||||
|
||||
// disable other pointer
|
||||
@ -2354,25 +2354,25 @@ LOADER_ENTRY::KernelUserPatch()
|
||||
{
|
||||
INTN Num, i = 0, y = 0;
|
||||
|
||||
// if we modify directly KernelAndKextPatches->KernelPatches[i].SearchLen, it will wrong for next driver
|
||||
UINTN SearchLen = KernelAndKextPatches->KernelPatches[i].SearchLen;
|
||||
// if we modify directly KernelAndKextPatches.KernelPatches[i].SearchLen, it will wrong for next driver
|
||||
UINTN SearchLen = KernelAndKextPatches.KernelPatches[i].SearchLen;
|
||||
|
||||
// old confuse
|
||||
// We are using KernelAndKextPatches as set by Custom Entries.
|
||||
// while config patches go to gSettings.KernelAndKextPatches
|
||||
// how to resolve it?
|
||||
|
||||
for (; i < KernelAndKextPatches->NrKernels; ++i) {
|
||||
DBG( "Patch[%lld]: %s\n", i, KernelAndKextPatches->KernelPatches[i].Label);
|
||||
if (!KernelAndKextPatches->KernelPatches[i].MenuItem.BValue) {
|
||||
//DBG_RT( "Patch[%d]: %a :: is not allowed for booted OS %a\n", i, KernelAndKextPatches->KernelPatches[i].Label, OSVersion);
|
||||
for (; i < KernelAndKextPatches.NrKernels; ++i) {
|
||||
DBG( "Patch[%lld]: %s\n", i, KernelAndKextPatches.KernelPatches[i].Label);
|
||||
if (!KernelAndKextPatches.KernelPatches[i].MenuItem.BValue) {
|
||||
//DBG_RT( "Patch[%d]: %a :: is not allowed for booted OS %a\n", i, KernelAndKextPatches.KernelPatches[i].Label, OSVersion);
|
||||
DBG( "==> disabled\n");
|
||||
continue;
|
||||
}
|
||||
bool once = false;
|
||||
UINTN procLen = 0;
|
||||
UINTN procAddr = searchProc(KernelAndKextPatches->KernelPatches[i].ProcedureName);
|
||||
DBG("procedure %s found at 0x%llx\n", KernelAndKextPatches->KernelPatches[i].ProcedureName, procAddr);
|
||||
UINTN procAddr = searchProc(KernelAndKextPatches.KernelPatches[i].ProcedureName);
|
||||
DBG("procedure %s found at 0x%llx\n", KernelAndKextPatches.KernelPatches[i].ProcedureName, procAddr);
|
||||
if (SearchLen == 0) {
|
||||
SearchLen = KERNEL_MAX_SIZE;
|
||||
procLen = KERNEL_MAX_SIZE - procAddr;
|
||||
@ -2383,21 +2383,21 @@ LOADER_ENTRY::KernelUserPatch()
|
||||
UINT8 * curs = &KernelData[procAddr];
|
||||
UINTN j = 0;
|
||||
while (j < KERNEL_MAX_SIZE) {
|
||||
if (!KernelAndKextPatches->KernelPatches[i].StartPattern || //old behavior
|
||||
if (!KernelAndKextPatches.KernelPatches[i].StartPattern || //old behavior
|
||||
CompareMemMask((const UINT8*)curs,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].StartPattern,
|
||||
KernelAndKextPatches->KernelPatches[i].StartPatternLen,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].StartMask,
|
||||
KernelAndKextPatches->KernelPatches[i].StartPatternLen)) {
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].StartPattern,
|
||||
KernelAndKextPatches.KernelPatches[i].StartPatternLen,
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].StartMask,
|
||||
KernelAndKextPatches.KernelPatches[i].StartPatternLen)) {
|
||||
DBG( " StartPattern found\n");
|
||||
Num = SearchAndReplaceMask(curs,
|
||||
procLen,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].Data,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].MaskFind,
|
||||
KernelAndKextPatches->KernelPatches[i].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].Patch,
|
||||
(const UINT8*)KernelAndKextPatches->KernelPatches[i].MaskReplace,
|
||||
KernelAndKextPatches->KernelPatches[i].Count
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].Data,
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].MaskFind,
|
||||
KernelAndKextPatches.KernelPatches[i].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].Patch,
|
||||
(const UINT8*)KernelAndKextPatches.KernelPatches[i].MaskReplace,
|
||||
KernelAndKextPatches.KernelPatches[i].Count
|
||||
);
|
||||
|
||||
if (Num) {
|
||||
@ -2407,15 +2407,15 @@ LOADER_ENTRY::KernelUserPatch()
|
||||
}
|
||||
DBG( "==> %s : %lld replaces done\n", Num ? "Success" : "Error", Num);
|
||||
if (once ||
|
||||
!KernelAndKextPatches->KernelPatches[i].StartPattern ||
|
||||
!KernelAndKextPatches->KernelPatches[i].StartPatternLen) {
|
||||
!KernelAndKextPatches.KernelPatches[i].StartPattern ||
|
||||
!KernelAndKextPatches.KernelPatches[i].StartPatternLen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++; curs++;
|
||||
}
|
||||
}
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
gBS->Stall(2000000);
|
||||
}
|
||||
|
||||
@ -2427,37 +2427,37 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize)
|
||||
{
|
||||
INTN Num, i = 0, y = 0;
|
||||
|
||||
// if we modify directly KernelAndKextPatches->BootPatches[i].SearchLen, it will wrong for next driver
|
||||
UINTN SearchLen = KernelAndKextPatches->BootPatches[i].SearchLen;
|
||||
// if we modify directly KernelAndKextPatches.BootPatches[i].SearchLen, it will wrong for next driver
|
||||
UINTN SearchLen = KernelAndKextPatches.BootPatches[i].SearchLen;
|
||||
|
||||
if (!SearchLen) {
|
||||
SearchLen = BooterSize;
|
||||
}
|
||||
for (; i < KernelAndKextPatches->NrBoots; ++i) {
|
||||
DBG( "Patch[%lld]: %s\n", i, KernelAndKextPatches->BootPatches[i].Label);
|
||||
if (!KernelAndKextPatches->BootPatches[i].MenuItem.BValue) {
|
||||
for (; i < KernelAndKextPatches.NrBoots; ++i) {
|
||||
DBG( "Patch[%lld]: %s\n", i, KernelAndKextPatches.BootPatches[i].Label);
|
||||
if (!KernelAndKextPatches.BootPatches[i].MenuItem.BValue) {
|
||||
DBG( "==> disabled\n");
|
||||
continue;
|
||||
}
|
||||
UINT8 * curs = BooterData;
|
||||
UINTN j = 0;
|
||||
while (j < BooterSize) {
|
||||
if (!KernelAndKextPatches->BootPatches[i].StartPattern || //old behavior
|
||||
if (!KernelAndKextPatches.BootPatches[i].StartPattern || //old behavior
|
||||
CompareMemMask((const UINT8*)curs,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].StartPattern,
|
||||
KernelAndKextPatches->BootPatches[i].StartPatternLen,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].StartMask,
|
||||
KernelAndKextPatches->BootPatches[i].StartPatternLen)) {
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].StartPattern,
|
||||
KernelAndKextPatches.BootPatches[i].StartPatternLen,
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].StartMask,
|
||||
KernelAndKextPatches.BootPatches[i].StartPatternLen)) {
|
||||
DBG( " StartPattern found\n");
|
||||
|
||||
Num = SearchAndReplaceMask(curs,
|
||||
SearchLen,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].Data,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].MaskFind,
|
||||
KernelAndKextPatches->BootPatches[i].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].Patch,
|
||||
(const UINT8*)KernelAndKextPatches->BootPatches[i].MaskReplace,
|
||||
KernelAndKextPatches->BootPatches[i].Count
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].Data,
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].MaskFind,
|
||||
KernelAndKextPatches.BootPatches[i].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].Patch,
|
||||
(const UINT8*)KernelAndKextPatches.BootPatches[i].MaskReplace,
|
||||
KernelAndKextPatches.BootPatches[i].Count
|
||||
);
|
||||
if (Num) {
|
||||
y++;
|
||||
@ -2466,15 +2466,15 @@ LOADER_ENTRY::BooterPatch(IN UINT8 *BooterData, IN UINT64 BooterSize)
|
||||
}
|
||||
|
||||
DBG( "==> %s : %lld replaces done\n", Num ? "Success" : "Error", Num);
|
||||
if (!KernelAndKextPatches->BootPatches[i].StartPattern ||
|
||||
!KernelAndKextPatches->BootPatches[i].StartPatternLen) {
|
||||
if (!KernelAndKextPatches.BootPatches[i].StartPattern ||
|
||||
!KernelAndKextPatches.BootPatches[i].StartPatternLen) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
j++; curs++;
|
||||
}
|
||||
}
|
||||
// if (KernelAndKextPatches->KPDebug) {
|
||||
// if (KernelAndKextPatches.KPDebug) {
|
||||
// gBS->Stall(2000000);
|
||||
// }
|
||||
Stall(2000000);
|
||||
@ -2600,24 +2600,24 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
* it was intended for custom entries but not work if no custom entries used
|
||||
* so set common until better solution invented
|
||||
*/
|
||||
KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
|
||||
//KernelAndKextPatches = (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches));
|
||||
CopyKernelAndKextPatches(&KernelAndKextPatches, &gSettings.KernelAndKextPatches);
|
||||
|
||||
PatcherInited = false;
|
||||
if (KernelAndKextPatches == NULL) return; //entry is not null as double check
|
||||
KernelAndKextPatcherInit();
|
||||
|
||||
KextPatchesNeeded = (
|
||||
KernelAndKextPatches->KPAppleIntelCPUPM ||
|
||||
KernelAndKextPatches->KPAppleRTC ||
|
||||
KernelAndKextPatches->EightApple ||
|
||||
KernelAndKextPatches->KPDELLSMBIOS ||
|
||||
(KernelAndKextPatches->KPATIConnectorsPatch != NULL) ||
|
||||
((KernelAndKextPatches->NrKexts > 0) && (KernelAndKextPatches->KextPatches != NULL))
|
||||
KernelAndKextPatches.KPAppleIntelCPUPM ||
|
||||
KernelAndKextPatches.KPAppleRTC ||
|
||||
KernelAndKextPatches.EightApple ||
|
||||
KernelAndKextPatches.KPDELLSMBIOS ||
|
||||
(KernelAndKextPatches.KPATIConnectorsPatch != NULL) ||
|
||||
((KernelAndKextPatches.NrKexts > 0) && (KernelAndKextPatches.KextPatches != NULL))
|
||||
);
|
||||
|
||||
// DBG_RT("\nKernelToPatch: ");
|
||||
// DBG_RT("Kernels patches: %d\n", KernelAndKextPatches->NrKernels);
|
||||
if (gSettings.KernelPatchesAllowed && (KernelAndKextPatches->KernelPatches != NULL) && KernelAndKextPatches->NrKernels) {
|
||||
// DBG_RT("Kernels patches: %d\n", KernelAndKextPatches.NrKernels);
|
||||
if (gSettings.KernelPatchesAllowed && (KernelAndKextPatches.KernelPatches != NULL) && KernelAndKextPatches.NrKernels) {
|
||||
// DBG_RT("Enabled: \n");
|
||||
DBG("Kernels patches: enabled \n");
|
||||
// KernelAndKextPatcherInit();
|
||||
@ -2634,7 +2634,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
}
|
||||
/*
|
||||
DBG_RT( "\nKernelCpu patch: ");
|
||||
if (KernelAndKextPatches->KPKernelCpu) {
|
||||
if (KernelAndKextPatches.KPKernelCpu) {
|
||||
//
|
||||
// Kernel patches
|
||||
//
|
||||
@ -2655,8 +2655,8 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
*/
|
||||
//other method for KernelCPU patch is FakeCPUID
|
||||
DBG_RT( "\nFakeCPUID patch: ");
|
||||
if (KernelAndKextPatches->FakeCPUID) {
|
||||
DBG_RT( "Enabled: 0x%06x\n", KernelAndKextPatches->FakeCPUID);
|
||||
if (KernelAndKextPatches.FakeCPUID) {
|
||||
DBG_RT( "Enabled: 0x%06x\n", KernelAndKextPatches.FakeCPUID);
|
||||
// KernelAndKextPatcherInit();
|
||||
// if (KernelData == NULL) goto NoKernelData;
|
||||
KernelCPUIDPatch();
|
||||
@ -2666,7 +2666,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
|
||||
// CPU power management patch for CPU with locked msr
|
||||
DBG_RT( "\nKernelPm patch: ");
|
||||
if (KernelAndKextPatches->KPKernelPm || KernelAndKextPatches->KPKernelXCPM) {
|
||||
if (KernelAndKextPatches.KPKernelPm || KernelAndKextPatches.KPKernelXCPM) {
|
||||
DBG_RT( "Enabled: \n");
|
||||
DBG( "KernelPm patch: Enabled\n");
|
||||
// KernelAndKextPatcherInit();
|
||||
@ -2682,7 +2682,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
|
||||
// Patch to not dump kext at panic (c)vit9696
|
||||
DBG_RT( "\nPanicNoKextDump patch: ");
|
||||
if (KernelAndKextPatches->KPPanicNoKextDump) {
|
||||
if (KernelAndKextPatches.KPPanicNoKextDump) {
|
||||
DBG_RT( "Enabled: \n");
|
||||
// KernelAndKextPatcherInit();
|
||||
// if (KernelData == NULL) goto NoKernelData;
|
||||
@ -2695,7 +2695,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
|
||||
// Lapic Panic Kernel Patch
|
||||
DBG_RT( "\nKernelLapic patch: ");
|
||||
if (KernelAndKextPatches->KPKernelLapic) {
|
||||
if (KernelAndKextPatches.KPKernelLapic) {
|
||||
DBG_RT( "Enabled: \n");
|
||||
// KernelAndKextPatcherInit();
|
||||
// if (KernelData == NULL) goto NoKernelData;
|
||||
@ -2711,7 +2711,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
DBG_RT( "Disabled\n");
|
||||
}
|
||||
|
||||
if (KernelAndKextPatches->KPKernelXCPM) {
|
||||
if (KernelAndKextPatches.KPKernelXCPM) {
|
||||
//
|
||||
// syscl - EnableExtCpuXCPM: Enable unsupported CPU's PowerManagement
|
||||
//
|
||||
@ -2803,7 +2803,7 @@ LOADER_ENTRY::KernelAndKextsPatcherStart()
|
||||
//
|
||||
// Kext add
|
||||
//
|
||||
// if (KernelAndKextPatches->KPDebug) {
|
||||
// if (KernelAndKextPatches.KPDebug) {
|
||||
// if (OSFLAG_ISSET(Entry->Flags, OSFLAG_CHECKFAKESMC) &&
|
||||
// OSFLAG_ISUNSET(Entry->Flags, OSFLAG_WITHKEXTS)) {
|
||||
// disabled kext injection if FakeSMC is already present
|
||||
|
@ -8,7 +8,8 @@
|
||||
|
||||
#include "boot.h"
|
||||
|
||||
#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
|
||||
//#define DBG_RT( ...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
|
||||
#define DBG_RT(...) if ( KernelAndKextPatches.KPDebug ) { printf(__VA_ARGS__); }
|
||||
|
||||
|
||||
#define CPUFAMILY_INTEL_6_13 0xaa33392b
|
||||
|
@ -373,20 +373,19 @@ EFI_STATUS LOADER_ENTRY::LoadKexts()
|
||||
}
|
||||
|
||||
// Force kexts to load
|
||||
if ((KernelAndKextPatches != NULL) &&
|
||||
(KernelAndKextPatches->NrForceKexts > 0) &&
|
||||
(KernelAndKextPatches->ForceKexts != NULL)) {
|
||||
for (INT32 i = 0; i < KernelAndKextPatches->NrForceKexts; ++i) {
|
||||
MsgLog(" Force kext: %ls\n", KernelAndKextPatches->ForceKexts[i]);
|
||||
if ((KernelAndKextPatches.NrForceKexts > 0) &&
|
||||
(KernelAndKextPatches.ForceKexts != NULL)) {
|
||||
for (INT32 i = 0; i < KernelAndKextPatches.NrForceKexts; ++i) {
|
||||
MsgLog(" Force kext: %ls\n", KernelAndKextPatches.ForceKexts[i]);
|
||||
if (Volume && Volume->RootDir) {
|
||||
// Check if the entry is a directory
|
||||
if (StrStr(KernelAndKextPatches->ForceKexts[i], L".kext") == NULL) {
|
||||
DirIterOpen(Volume->RootDir, KernelAndKextPatches->ForceKexts[i], &PlugInIter);
|
||||
if (StrStr(KernelAndKextPatches.ForceKexts[i], L".kext") == NULL) {
|
||||
DirIterOpen(Volume->RootDir, KernelAndKextPatches.ForceKexts[i], &PlugInIter);
|
||||
while (DirIterNext(&PlugInIter, 1, L"*.kext", &PlugInFile)) {
|
||||
if (PlugInFile->FileName[0] == '.' || StrStr(PlugInFile->FileName, L".kext") == NULL)
|
||||
continue; // skip this
|
||||
FileName = SWPrintf("%ls\\%ls", KernelAndKextPatches->ForceKexts[i], PlugInFile->FileName);
|
||||
// snwprintf(FileName, 512, "%s\\%s", KernelAndKextPatches->ForceKexts[i], PlugInFile->FileName);
|
||||
FileName = SWPrintf("%ls\\%ls", KernelAndKextPatches.ForceKexts[i], PlugInFile->FileName);
|
||||
// snwprintf(FileName, 512, "%s\\%s", KernelAndKextPatches.ForceKexts[i], PlugInFile->FileName);
|
||||
MsgLog(" Force kext: %ls\n", FileName.wc_str());
|
||||
AddKext( Volume->RootDir, FileName.wc_str(), archCpuType);
|
||||
PlugIns = SWPrintf("%ls\\Contents\\PlugIns", FileName.wc_str());
|
||||
@ -395,9 +394,9 @@ EFI_STATUS LOADER_ENTRY::LoadKexts()
|
||||
}
|
||||
DirIterClose(&PlugInIter);
|
||||
} else {
|
||||
AddKext( Volume->RootDir, KernelAndKextPatches->ForceKexts[i], archCpuType);
|
||||
PlugIns = SWPrintf("%ls\\Contents\\PlugIns", KernelAndKextPatches->ForceKexts[i]);
|
||||
// snwprintf(PlugIns, 512, "%s\\Contents\\PlugIns", KernelAndKextPatches->ForceKexts[i]);
|
||||
AddKext( Volume->RootDir, KernelAndKextPatches.ForceKexts[i], archCpuType);
|
||||
PlugIns = SWPrintf("%ls\\Contents\\PlugIns", KernelAndKextPatches.ForceKexts[i]);
|
||||
// snwprintf(PlugIns, 512, "%s\\Contents\\PlugIns", KernelAndKextPatches.ForceKexts[i]);
|
||||
LoadPlugInKexts(Volume->RootDir, PlugIns.wc_str(), archCpuType, TRUE);
|
||||
}
|
||||
}
|
||||
@ -739,7 +738,7 @@ EFI_STATUS LOADER_ENTRY::InjectKexts(IN UINT32 deviceTreeP, IN UINT32* deviceTre
|
||||
KextCount = GetKextCount();
|
||||
if (KextCount == 0) {
|
||||
DBG_RT("no kexts to inject.\nPausing 5 secs ...\n");
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
gBS->Stall(5000000);
|
||||
}
|
||||
return EFI_NOT_FOUND;
|
||||
@ -832,9 +831,9 @@ EFI_STATUS LOADER_ENTRY::InjectKexts(IN UINT32 deviceTreeP, IN UINT32* deviceTre
|
||||
SavedValue = InfoPlist[drvinfo->infoDictLength];
|
||||
InfoPlist[drvinfo->infoDictLength] = '\0';
|
||||
// KernelAndKextPatcherInit();
|
||||
for (i = 0; i < KernelAndKextPatches->NrKexts; i++) {
|
||||
if ((KernelAndKextPatches->KextPatches[i].DataLen > 0) &&
|
||||
(AsciiStrStr(InfoPlist, KernelAndKextPatches->KextPatches[i].Name) != NULL)) {
|
||||
for (i = 0; i < KernelAndKextPatches.NrKexts; i++) {
|
||||
if ((KernelAndKextPatches.KextPatches[i].DataLen > 0) &&
|
||||
(AsciiStrStr(InfoPlist, KernelAndKextPatches.KextPatches[i].Name) != NULL)) {
|
||||
AnyKextPatch(
|
||||
(UINT8*)(UINTN)drvinfo->executablePhysAddr,
|
||||
drvinfo->executableLength,
|
||||
|
@ -37,7 +37,7 @@ extern "C" {
|
||||
|
||||
|
||||
// runtime debug
|
||||
#define DBG_RT(...) if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { printf(__VA_ARGS__); }
|
||||
//#define DBG_RT(...) if ( KernelAndKextPatches.KPDebug ) { printf(__VA_ARGS__); }
|
||||
|
||||
//
|
||||
// Searches Source for Search pattern of size SearchSize
|
||||
@ -366,13 +366,13 @@ VOID LOADER_ENTRY::ATIConnectorsPatchInit()
|
||||
sizeof(ATIKextBundleId[0]),
|
||||
"com.apple.kext.ATI%sController", // when it was AsciiSPrint, %a was used with KPATIConnectorsController which is CHAR16 ??? Result is printing stop at first char <= 255
|
||||
//now it is CHAR8*
|
||||
KernelAndKextPatches->KPATIConnectorsController
|
||||
KernelAndKextPatches.KPATIConnectorsController
|
||||
);
|
||||
// ML
|
||||
snprintf(ATIKextBundleId[1],
|
||||
sizeof(ATIKextBundleId[1]),
|
||||
"com.apple.kext.AMD%sController", // when it was AsciiSPrint, %a was used with KPATIConnectorsController which is CHAR16 ??? Result is printing stop at first char <= 255
|
||||
KernelAndKextPatches->KPATIConnectorsController
|
||||
KernelAndKextPatches.KPATIConnectorsController
|
||||
);
|
||||
|
||||
ATIConnectorsPatchInited = TRUE;
|
||||
@ -391,11 +391,11 @@ VOID LOADER_ENTRY::ATIConnectorsPatchRegisterKexts(void *FSInject_v, void *Force
|
||||
FSI_STRING_LIST *ForceLoadKexts = (FSI_STRING_LIST *)ForceLoadKexts_v;
|
||||
// for future?
|
||||
FSInject->AddStringToList(ForceLoadKexts,
|
||||
SWPrintf("\\AMD%sController.kext\\Contents\\Info.plist", KernelAndKextPatches->KPATIConnectorsController).wc_str()
|
||||
SWPrintf("\\AMD%sController.kext\\Contents\\Info.plist", KernelAndKextPatches.KPATIConnectorsController).wc_str()
|
||||
);
|
||||
// Lion, ML, SnowLeo 10.6.7 2011 MBP
|
||||
FSInject->AddStringToList(ForceLoadKexts,
|
||||
SWPrintf("\\ATI%sController.kext\\Contents\\Info.plist", KernelAndKextPatches->KPATIConnectorsController).wc_str()
|
||||
SWPrintf("\\ATI%sController.kext\\Contents\\Info.plist", KernelAndKextPatches.KPATIConnectorsController).wc_str()
|
||||
);
|
||||
// SnowLeo
|
||||
FSInject->AddStringToList(ForceLoadKexts, L"\\ATIFramebuffer.kext\\Contents\\Info.plist");
|
||||
@ -419,12 +419,12 @@ VOID LOADER_ENTRY::ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *I
|
||||
UINTN Num = 0;
|
||||
|
||||
DBG_RT("\nATIConnectorsPatch: driverAddr = %llx, driverSize = %x\nController = %s\n",
|
||||
(UINTN)Driver, DriverSize, KernelAndKextPatches->KPATIConnectorsController);
|
||||
(UINTN)Driver, DriverSize, KernelAndKextPatches.KPATIConnectorsController);
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
DBG_RT("Kext: %s\n", gKextBundleIdentifier);
|
||||
|
||||
// number of occurences od Data should be 1
|
||||
Num = SearchAndCount(Driver, DriverSize, KernelAndKextPatches->KPATIConnectorsData, KernelAndKextPatches->KPATIConnectorsDataLen);
|
||||
Num = SearchAndCount(Driver, DriverSize, KernelAndKextPatches.KPATIConnectorsData, KernelAndKextPatches.KPATIConnectorsDataLen);
|
||||
if (Num > 1) {
|
||||
// error message - shoud always be printed
|
||||
printf("==> KPATIConnectorsData found %llu times in %s - skipping patching!\n", Num, gKextBundleIdentifier);
|
||||
@ -435,9 +435,9 @@ VOID LOADER_ENTRY::ATIConnectorsPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *I
|
||||
// patch
|
||||
Num = SearchAndReplace(Driver,
|
||||
DriverSize,
|
||||
KernelAndKextPatches->KPATIConnectorsData,
|
||||
KernelAndKextPatches->KPATIConnectorsDataLen,
|
||||
KernelAndKextPatches->KPATIConnectorsPatch,
|
||||
KernelAndKextPatches.KPATIConnectorsData,
|
||||
KernelAndKextPatches.KPATIConnectorsDataLen,
|
||||
KernelAndKextPatches.KPATIConnectorsPatch,
|
||||
1);
|
||||
if (Num > 0) {
|
||||
DBG_RT("==> patched %llu times!\n", Num);
|
||||
@ -709,7 +709,7 @@ VOID LOADER_ENTRY::DellSMBIOSPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *Info
|
||||
UINTN gPatchCount = 0;
|
||||
|
||||
DBG_RT("\nDellSMBIOSPatch: driverAddr = %llx, driverSize = %x\n", (UINTN)Driver, DriverSize);
|
||||
if (KernelAndKextPatches->KPDebug)
|
||||
if (KernelAndKextPatches.KPDebug)
|
||||
{
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
}
|
||||
@ -745,7 +745,7 @@ VOID LOADER_ENTRY::SNBE_AICPUPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *Info
|
||||
UINT64 os_ver = AsciiOSVersionToUint64(OSVersion);
|
||||
|
||||
DBG_RT("\nSNBE_AICPUPatch: driverAddr = %llx, driverSize = %x\n", (UINTN)Driver, DriverSize);
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
}
|
||||
|
||||
@ -1021,7 +1021,7 @@ VOID LOADER_ENTRY::BDWE_IOPCIPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *Info
|
||||
UINT64 os_ver = AsciiOSVersionToUint64(OSVersion);
|
||||
|
||||
DBG_RT("\nBDWE_IOPCIPatch: driverAddr = %llx, driverSize = %x\n", (UINTN)Driver, DriverSize);
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
}
|
||||
|
||||
@ -1111,14 +1111,14 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
INTN Ind;
|
||||
|
||||
// if we modify value directly at KernelAndKextPatches->KextPatches[N].SearchLen, it will be wrong for next driver
|
||||
UINTN SearchLen = KernelAndKextPatches->KextPatches[N].SearchLen;
|
||||
UINTN SearchLen = KernelAndKextPatches.KextPatches[N].SearchLen;
|
||||
|
||||
DBG_RT("\nAnyKextPatch %d: driverAddr = %llx, driverSize = %x\nAnyKext = %s\n",
|
||||
N, (UINTN)Driver, DriverSize, KernelAndKextPatches->KextPatches[N].Label);
|
||||
N, (UINTN)Driver, DriverSize, KernelAndKextPatches.KextPatches[N].Label);
|
||||
DBG("\nAnyKextPatch %d: driverAddr = %llx, driverSize = %x\nLabel = %s\n",
|
||||
N, (UINTN)Driver, DriverSize, KernelAndKextPatches->KextPatches[N].Label);
|
||||
N, (UINTN)Driver, DriverSize, KernelAndKextPatches.KextPatches[N].Label);
|
||||
|
||||
if (!KernelAndKextPatches->KextPatches[N].MenuItem.BValue) {
|
||||
if (!KernelAndKextPatches.KextPatches[N].MenuItem.BValue) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1128,18 +1128,18 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
SearchLen = DriverSize;
|
||||
}
|
||||
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
}
|
||||
|
||||
DBG_RT("Kext: %s\n", gKextBundleIdentifier);
|
||||
|
||||
if (!KernelAndKextPatches->KextPatches[N].IsPlistPatch) {
|
||||
if (!KernelAndKextPatches.KextPatches[N].IsPlistPatch) {
|
||||
// kext binary patch
|
||||
DBG_RT("Binary patch\n");
|
||||
bool once = false;
|
||||
UINTN procLen = 0;
|
||||
UINTN procAddr = searchProcInDriver(Driver, DriverSize, KernelAndKextPatches->KextPatches[N].ProcedureName);
|
||||
UINTN procAddr = searchProcInDriver(Driver, DriverSize, KernelAndKextPatches.KextPatches[N].ProcedureName);
|
||||
|
||||
if (SearchLen == DriverSize) {
|
||||
procLen = DriverSize - procAddr;
|
||||
@ -1150,21 +1150,21 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
UINT8 * curs = &Driver[procAddr];
|
||||
UINTN j = 0;
|
||||
while (j < DriverSize) {
|
||||
if (!KernelAndKextPatches->KextPatches[N].StartPattern || //old behavior
|
||||
if (!KernelAndKextPatches.KextPatches[N].StartPattern || //old behavior
|
||||
CompareMemMask((const UINT8*)curs,
|
||||
(const UINT8 *)KernelAndKextPatches->KextPatches[N].StartPattern,
|
||||
KernelAndKextPatches->KextPatches[N].StartPatternLen,
|
||||
(const UINT8 *)KernelAndKextPatches->KextPatches[N].StartMask,
|
||||
KernelAndKextPatches->KextPatches[N].StartPatternLen)) {
|
||||
(const UINT8 *)KernelAndKextPatches.KextPatches[N].StartPattern,
|
||||
KernelAndKextPatches.KextPatches[N].StartPatternLen,
|
||||
(const UINT8 *)KernelAndKextPatches.KextPatches[N].StartMask,
|
||||
KernelAndKextPatches.KextPatches[N].StartPatternLen)) {
|
||||
DBG_RT(" StartPattern found\n");
|
||||
|
||||
Num = SearchAndReplaceMask(curs,
|
||||
procLen,
|
||||
(const UINT8*)KernelAndKextPatches->KextPatches[N].Data,
|
||||
(const UINT8*)KernelAndKextPatches->KextPatches[N].MaskFind,
|
||||
KernelAndKextPatches->KextPatches[N].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches->KextPatches[N].Patch,
|
||||
(const UINT8*)KernelAndKextPatches->KextPatches[N].MaskReplace,
|
||||
(const UINT8*)KernelAndKextPatches.KextPatches[N].Data,
|
||||
(const UINT8*)KernelAndKextPatches.KextPatches[N].MaskFind,
|
||||
KernelAndKextPatches.KextPatches[N].DataLen,
|
||||
(const UINT8*)KernelAndKextPatches.KextPatches[N].Patch,
|
||||
(const UINT8*)KernelAndKextPatches.KextPatches[N].MaskReplace,
|
||||
-1);
|
||||
if (Num) {
|
||||
curs += SearchLen - 1;
|
||||
@ -1172,8 +1172,8 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
}
|
||||
}
|
||||
if (once ||
|
||||
!KernelAndKextPatches->KextPatches[N].StartPattern ||
|
||||
!KernelAndKextPatches->KextPatches[N].StartPatternLen) {
|
||||
!KernelAndKextPatches.KextPatches[N].StartPattern ||
|
||||
!KernelAndKextPatches.KextPatches[N].StartPatternLen) {
|
||||
break;
|
||||
}
|
||||
j++; curs++;
|
||||
@ -1181,25 +1181,25 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
} else {
|
||||
// Info plist patch
|
||||
DBG_RT("Info.plist data : '");
|
||||
for (Ind = 0; Ind < KernelAndKextPatches->KextPatches[N].DataLen; Ind++) {
|
||||
DBG_RT("%c", KernelAndKextPatches->KextPatches[N].Data[Ind]);
|
||||
for (Ind = 0; Ind < KernelAndKextPatches.KextPatches[N].DataLen; Ind++) {
|
||||
DBG_RT("%c", KernelAndKextPatches.KextPatches[N].Data[Ind]);
|
||||
}
|
||||
DBG_RT("' ->\n");
|
||||
DBG_RT("Info.plist patch: '");
|
||||
for (Ind = 0; Ind < KernelAndKextPatches->KextPatches[N].DataLen; Ind++) {
|
||||
DBG_RT("%c", KernelAndKextPatches->KextPatches[N].Patch[Ind]);
|
||||
for (Ind = 0; Ind < KernelAndKextPatches.KextPatches[N].DataLen; Ind++) {
|
||||
DBG_RT("%c", KernelAndKextPatches.KextPatches[N].Patch[Ind]);
|
||||
}
|
||||
DBG_RT("' \n");
|
||||
|
||||
Num = SearchAndReplaceTxt((UINT8*)InfoPlist,
|
||||
InfoPlistSize,
|
||||
KernelAndKextPatches->KextPatches[N].Data,
|
||||
KernelAndKextPatches->KextPatches[N].DataLen,
|
||||
KernelAndKextPatches->KextPatches[N].Patch,
|
||||
KernelAndKextPatches.KextPatches[N].Data,
|
||||
KernelAndKextPatches.KextPatches[N].DataLen,
|
||||
KernelAndKextPatches.KextPatches[N].Patch,
|
||||
-1);
|
||||
}
|
||||
|
||||
if (KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
if (Num > 0) {
|
||||
DBG_RT("==> patched %llu times!\n", Num);
|
||||
} else {
|
||||
@ -1216,13 +1216,13 @@ VOID LOADER_ENTRY::AnyKextPatch(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPli
|
||||
VOID LOADER_ENTRY::KextPatcherRegisterKexts(void *FSInject_v, void *ForceLoadKexts)
|
||||
{
|
||||
FSINJECTION_PROTOCOL *FSInject = (FSINJECTION_PROTOCOL *)FSInject_v;
|
||||
if (KernelAndKextPatches->KPATIConnectorsController != NULL) {
|
||||
if (KernelAndKextPatches.KPATIConnectorsController != NULL) {
|
||||
ATIConnectorsPatchRegisterKexts(FSInject_v, ForceLoadKexts);
|
||||
}
|
||||
|
||||
for (INTN i = 0; i < KernelAndKextPatches->NrKexts; i++) {
|
||||
for (INTN i = 0; i < KernelAndKextPatches.NrKexts; i++) {
|
||||
FSInject->AddStringToList((FSI_STRING_LIST*)ForceLoadKexts,
|
||||
SWPrintf("\\%s.kext\\Contents\\Info.plist", KernelAndKextPatches->KextPatches[i].Name).wc_str() );
|
||||
SWPrintf("\\%s.kext\\Contents\\Info.plist", KernelAndKextPatches.KextPatches[i].Name).wc_str() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1232,7 +1232,7 @@ VOID LOADER_ENTRY::KextPatcherRegisterKexts(void *FSInject_v, void *ForceLoadKex
|
||||
//
|
||||
VOID LOADER_ENTRY::PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist, UINT32 InfoPlistSize)
|
||||
{
|
||||
if (KernelAndKextPatches->KPATIConnectorsController != NULL) {
|
||||
if (KernelAndKextPatches.KPATIConnectorsController != NULL) {
|
||||
//
|
||||
// ATIConnectors
|
||||
//
|
||||
@ -1251,27 +1251,27 @@ VOID LOADER_ENTRY::PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist,
|
||||
|
||||
ExtractKextBundleIdentifier(InfoPlist);
|
||||
|
||||
if (KernelAndKextPatches->KPAppleIntelCPUPM &&
|
||||
if (KernelAndKextPatches.KPAppleIntelCPUPM &&
|
||||
(AsciiStrStr(InfoPlist,
|
||||
"<string>com.apple.driver.AppleIntelCPUPowerManagement</string>") != NULL)) {
|
||||
//
|
||||
// AppleIntelCPUPM
|
||||
//
|
||||
AppleIntelCPUPMPatch(Driver, DriverSize, InfoPlist, InfoPlistSize);
|
||||
} else if (KernelAndKextPatches->KPAppleRTC &&
|
||||
} else if (KernelAndKextPatches.KPAppleRTC &&
|
||||
(AsciiStrStr(InfoPlist, "com.apple.driver.AppleRTC") != NULL)) {
|
||||
//
|
||||
// AppleRTC
|
||||
//
|
||||
AppleRTCPatch(Driver, DriverSize, InfoPlist, InfoPlistSize);
|
||||
} else if (KernelAndKextPatches->KPDELLSMBIOS &&
|
||||
} else if (KernelAndKextPatches.KPDELLSMBIOS &&
|
||||
(AsciiStrStr(InfoPlist, "com.apple.driver.AppleSMBIOS") != NULL)) {
|
||||
//
|
||||
// DellSMBIOSPatch
|
||||
//
|
||||
DBG_RT("Remap SMBIOS Table require, AppleSMBIOS...\n");
|
||||
DellSMBIOSPatch(Driver, DriverSize, InfoPlist, InfoPlistSize);
|
||||
} else if (KernelAndKextPatches->KPDELLSMBIOS &&
|
||||
} else if (KernelAndKextPatches.KPDELLSMBIOS &&
|
||||
(AsciiStrStr(InfoPlist, "com.apple.driver.AppleACPIPlatform") != NULL)) {
|
||||
//
|
||||
// DellSMBIOS
|
||||
@ -1289,7 +1289,7 @@ VOID LOADER_ENTRY::PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist,
|
||||
// SandyBridge-E AppleIntelCPUPowerManagement Patch implemented by syscl
|
||||
//
|
||||
SNBE_AICPUPatch(Driver, DriverSize, InfoPlist, InfoPlistSize);
|
||||
} else if (KernelAndKextPatches->EightApple &&
|
||||
} else if (KernelAndKextPatches.EightApple &&
|
||||
/* (AsciiStrStr(InfoPlist, "com.apple.iokit.IOGraphicsFamily") != NULL) && */
|
||||
(AsciiStrStr(InfoPlist, "I/O Kit Graphics Family") != NULL)) {
|
||||
//
|
||||
@ -1301,13 +1301,13 @@ VOID LOADER_ENTRY::PatchKext(UINT8 *Driver, UINT32 DriverSize, CHAR8 *InfoPlist,
|
||||
}
|
||||
//com.apple.iokit.IOGraphicsFamily
|
||||
|
||||
for (INT32 i = 0; i < KernelAndKextPatches->NrKexts; i++) {
|
||||
CHAR8 *Name = KernelAndKextPatches->KextPatches[i].Name;
|
||||
for (INT32 i = 0; i < KernelAndKextPatches.NrKexts; i++) {
|
||||
CHAR8 *Name = KernelAndKextPatches.KextPatches[i].Name;
|
||||
BOOLEAN isBundle = (AsciiStrStr(Name, ".") != NULL);
|
||||
if ((KernelAndKextPatches->KextPatches[i].DataLen > 0) &&
|
||||
if ((KernelAndKextPatches.KextPatches[i].DataLen > 0) &&
|
||||
isBundle?(AsciiStrCmp(gKextBundleIdentifier, Name) == 0):(AsciiStrStr(gKextBundleIdentifier, Name) != NULL)) {
|
||||
// (AsciiStrStr(InfoPlist, KernelAndKextPatches->KextPatches[i].Name) != NULL)) {
|
||||
DBG_RT("\n\nPatch kext: %s\n", KernelAndKextPatches->KextPatches[i].Name);
|
||||
// (AsciiStrStr(InfoPlist, KernelAndKextPatches.KextPatches[i].Name) != NULL)) {
|
||||
DBG_RT("\n\nPatch kext: %s\n", KernelAndKextPatches.KextPatches[i].Name);
|
||||
AnyKextPatch(Driver, DriverSize, InfoPlist, InfoPlistSize, i);
|
||||
}
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ class XArray
|
||||
{
|
||||
protected:
|
||||
TYPE *m_data;
|
||||
xsize m_len;
|
||||
xsize m_allocatedSize;
|
||||
xsize _GrowBy;
|
||||
size_t m_len;
|
||||
size_t m_allocatedSize;
|
||||
// size_t _GrowBy;
|
||||
|
||||
public:
|
||||
void Init();
|
||||
XArray() { Init(); }
|
||||
// void Init();
|
||||
XArray() : m_data(0), m_len(0), m_allocatedSize(0) { }
|
||||
XArray(const XArray<TYPE> &anArray);
|
||||
const XArray<TYPE> &operator =(const XArray<TYPE> &anArray);
|
||||
virtual ~XArray();
|
||||
@ -41,10 +41,10 @@ class XArray
|
||||
TYPE *data() { return m_data; }
|
||||
|
||||
public:
|
||||
xsize allocatedSize() const { return m_allocatedSize; }
|
||||
xsize length() const { return m_len; }
|
||||
xsize size() const { return m_len; }
|
||||
void setSize(xsize l);
|
||||
size_t allocatedSize() const { return m_allocatedSize; }
|
||||
size_t length() const { return m_len; }
|
||||
size_t size() const { return m_len; }
|
||||
void setSize(size_t l);
|
||||
|
||||
//low case functions like in std::vector
|
||||
|
||||
@ -54,17 +54,17 @@ class XArray
|
||||
const TYPE& end() const { return ElementAt(m_len - 1); }
|
||||
TYPE& end() { return ElementAt(m_len - 1); }
|
||||
|
||||
xsize insert(const TYPE newElement, xsize pos, xsize count = 1) { return Insert(newElement, pos, count); }
|
||||
size_t insert(const TYPE newElement, size_t pos, size_t count = 1) { return Insert(newElement, pos, count); }
|
||||
|
||||
//--------------------------------------------------
|
||||
|
||||
const TYPE& ElementAt(xsize nIndex) const;
|
||||
TYPE& ElementAt(xsize nIndex);
|
||||
const TYPE& ElementAt(size_t nIndex) const;
|
||||
TYPE& ElementAt(size_t nIndex);
|
||||
const TYPE& ElementAt(int nIndex) const;
|
||||
TYPE& ElementAt(int nIndex);
|
||||
|
||||
// const TYPE& operator[](xsize nIndex) const { return ElementAt(nIndex); }
|
||||
// TYPE& operator[](xsize nIndex) { return ElementAt(nIndex); }
|
||||
// const TYPE& operator[](size_t nIndex) const { return ElementAt(nIndex); }
|
||||
// TYPE& operator[](size_t nIndex) { return ElementAt(nIndex); }
|
||||
// const TYPE& operator[]( int nIndex) const { return ElementAt(nIndex); }
|
||||
TYPE& operator[]( int nIndex) { return ElementAt(nIndex); }
|
||||
// const TYPE& operator[]( unsigned long long nIndex) const { return ElementAt((size_t)nIndex); }
|
||||
@ -79,34 +79,34 @@ class XArray
|
||||
|
||||
const TYPE * operator +( int i) const { return m_data+i; };
|
||||
TYPE * operator +( int i) { return m_data+i; };
|
||||
const TYPE * operator +(xsize i) const { return m_data+i; };
|
||||
TYPE * operator +(xsize i) { return m_data+i; };
|
||||
const TYPE * operator +(size_t i) const { return m_data+i; };
|
||||
TYPE * operator +(size_t i) { return m_data+i; };
|
||||
const TYPE * operator -( int i) const { return m_data-i; };
|
||||
TYPE * operator -( int i) { return m_data-i; };
|
||||
const TYPE * operator -(xsize i) const { return m_data-i; };
|
||||
TYPE * operator -(xsize i) { return m_data-i; };
|
||||
const TYPE * operator -(size_t i) const { return m_data-i; };
|
||||
TYPE * operator -(size_t i) { return m_data-i; };
|
||||
|
||||
// xsize Add(const TYPE newElement);
|
||||
// size_t Add(const TYPE newElement);
|
||||
// TYPE AddNew();
|
||||
// xsize Inserts(const TYPE &newElement, xsize pos, xsize count);
|
||||
// size_t Inserts(const TYPE &newElement, size_t pos, size_t count);
|
||||
|
||||
void CheckSize(xsize nNewSize);
|
||||
void CheckSize(xsize nNewSize, xsize nGrowBy);
|
||||
void CheckSize(size_t nNewSize);
|
||||
void CheckSize(size_t nNewSize, size_t nGrowBy);
|
||||
|
||||
xsize AddUninitialized(xsize count); // add count uninitialzed elements
|
||||
xsize Add(const TYPE newElement, xsize count = 1);
|
||||
xsize AddArray(const TYPE *newElements, xsize count = 1);
|
||||
xsize Insert(const TYPE newElement, xsize pos, xsize count = 1);
|
||||
size_t AddUninitialized(size_t count); // add count uninitialzed elements
|
||||
size_t Add(const TYPE newElement, size_t count = 1);
|
||||
size_t AddArray(const TYPE *newElements, size_t count = 1);
|
||||
size_t Insert(const TYPE newElement, size_t pos, size_t count = 1);
|
||||
|
||||
void Remove(const TYPE *Element);
|
||||
void Remove(const TYPE &Element);
|
||||
void RemoveAtIndex(xsize nIndex);
|
||||
void RemoveAtIndex(size_t nIndex);
|
||||
void RemoveAtIndex(int nIndex);
|
||||
|
||||
void setEmpty();
|
||||
bool isEmpty() const { return size() == 0; }
|
||||
|
||||
xsize indexOf(TYPE& e) const;
|
||||
size_t indexOf(TYPE& e) const;
|
||||
bool contains(TYPE& e) const { return indexOf(e) != MAX_XSIZE; } //logically it should be named as Contains(e)
|
||||
};
|
||||
|
||||
@ -117,9 +117,9 @@ class XArray
|
||||
//xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
||||
|
||||
template<class TYPE>
|
||||
xsize XArray<TYPE>::indexOf(TYPE& e) const
|
||||
size_t XArray<TYPE>::indexOf(TYPE& e) const
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<size() ; i+=1 ) {
|
||||
if ( ElementAt(i) == e ) return i;
|
||||
@ -127,21 +127,21 @@ xsize XArray<TYPE>::indexOf(TYPE& e) const
|
||||
return MAX_XSIZE;
|
||||
}
|
||||
|
||||
/* Constructeur */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::Init()
|
||||
{
|
||||
m_data = nullptr;
|
||||
m_allocatedSize = 0;
|
||||
m_len = 0;
|
||||
_GrowBy = XArrayGrowByDefault;
|
||||
}
|
||||
///* Constructeur */
|
||||
//template<class TYPE>
|
||||
//void XArray<TYPE>::Init()
|
||||
//{
|
||||
// m_data = nullptr;
|
||||
// m_allocatedSize = 0;
|
||||
// m_len = 0;
|
||||
// _GrowBy = XArrayGrowByDefault;
|
||||
//}
|
||||
|
||||
/* Constructeur */
|
||||
template<class TYPE>
|
||||
XArray<TYPE>::XArray(const XArray<TYPE> &anArray)
|
||||
XArray<TYPE>::XArray(const XArray<TYPE> &anArray) : m_data(0), m_len(0), m_allocatedSize(0)
|
||||
{
|
||||
Init();
|
||||
// Init();
|
||||
AddArray(anArray.data(), anArray.size());
|
||||
}
|
||||
|
||||
@ -161,7 +161,7 @@ const XArray<TYPE> &XArray<TYPE>::operator =(const XArray<TYPE> &anArray)
|
||||
}
|
||||
//
|
||||
//
|
||||
//xsize ui;
|
||||
//size_t ui;
|
||||
//
|
||||
// setEmpty();
|
||||
// for ( ui=0 ; ui<anArray.length() ; ui+=1 ) Add(anArray[ui] );
|
||||
@ -178,7 +178,7 @@ XArray<TYPE>::~XArray()
|
||||
|
||||
/* CheckSize() // nNewSize is number of TYPE, not in bytes */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
void XArray<TYPE>::CheckSize(size_t nNewSize, size_t nGrowBy)
|
||||
{
|
||||
//XArray_DBG("CheckSize: m_len=%d, m_size=%d, nGrowBy=%d, nNewSize=%d\n", m_len, m_size, nGrowBy, nNewSize);
|
||||
if ( nNewSize > m_allocatedSize ) {
|
||||
@ -194,20 +194,20 @@ void XArray<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
|
||||
/* CheckSize() */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::CheckSize(xsize nNewSize)
|
||||
void XArray<TYPE>::CheckSize(size_t nNewSize)
|
||||
{
|
||||
CheckSize(nNewSize, XArrayGrowByDefault);
|
||||
}
|
||||
|
||||
/* SetLength (xsize i) */
|
||||
/* SetLength (size_t i) */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::setSize(xsize l)
|
||||
void XArray<TYPE>::setSize(size_t l)
|
||||
{
|
||||
CheckSize(l, XArrayGrowByDefault); // be sure the size is allocated
|
||||
m_len = l;
|
||||
#ifdef DEBUG
|
||||
if(m_len > m_allocatedSize) {
|
||||
panic("XArray::SetLength(xsize) -> _Len > _Size");
|
||||
panic("XArray::SetLength(size_t) -> _Len > _Size");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -215,11 +215,11 @@ void XArray<TYPE>::setSize(xsize l)
|
||||
|
||||
/* ElementAt() */
|
||||
template<class TYPE>
|
||||
TYPE &XArray<TYPE>::ElementAt(xsize index)
|
||||
TYPE &XArray<TYPE>::ElementAt(size_t index)
|
||||
{
|
||||
// #ifdef _DEBUG
|
||||
if ( index >= m_len ) {
|
||||
panic("XArray::ElementAt(xsize) -> Operator [] : index > m_len");
|
||||
panic("XArray::ElementAt(size_t) -> Operator [] : index > m_len");
|
||||
}
|
||||
// #endif
|
||||
return m_data[index];
|
||||
@ -227,11 +227,11 @@ TYPE &XArray<TYPE>::ElementAt(xsize index)
|
||||
|
||||
/* ElementAt() */
|
||||
template<class TYPE>
|
||||
const TYPE& XArray<TYPE>::ElementAt(xsize index) const
|
||||
const TYPE& XArray<TYPE>::ElementAt(size_t index) const
|
||||
{
|
||||
// #ifdef _DEBUG
|
||||
if ( index >= m_len ) {
|
||||
panic("XArray::ElementAt(xsize) const -> Operator [] : index > m_len");
|
||||
panic("XArray::ElementAt(size_t) const -> Operator [] : index > m_len");
|
||||
}
|
||||
// #endif
|
||||
return m_data[index];
|
||||
@ -267,21 +267,21 @@ const TYPE& XArray<TYPE>::ElementAt(int index) const
|
||||
return m_data[index];
|
||||
}
|
||||
|
||||
/* Add(xsize) */
|
||||
/* Add(size_t) */
|
||||
template<class TYPE>
|
||||
xsize XArray<TYPE>::AddUninitialized(xsize count)
|
||||
size_t XArray<TYPE>::AddUninitialized(size_t count)
|
||||
{
|
||||
CheckSize(m_len+count);
|
||||
m_len += count;
|
||||
return m_len-count;
|
||||
}
|
||||
|
||||
/* Add(TYPE, xsize) */
|
||||
/* Add(TYPE, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XArray<TYPE>::Add(const TYPE newElement, xsize count)
|
||||
size_t XArray<TYPE>::Add(const TYPE newElement, size_t count)
|
||||
{
|
||||
// XArray_DBG("xsize XArray<TYPE>::Add(const TYPE newElement, xsize count) -> Enter. count=%d _Len=%d _Size=%d\n", count, m_len, m_size);
|
||||
xsize i;
|
||||
// XArray_DBG("size_t XArray<TYPE>::Add(const TYPE newElement, size_t count) -> Enter. count=%d _Len=%d _Size=%d\n", count, m_len, m_size);
|
||||
size_t i;
|
||||
|
||||
CheckSize(m_len+count);
|
||||
for ( i=0 ; i<count ; i++ ) {
|
||||
@ -291,11 +291,11 @@ xsize XArray<TYPE>::Add(const TYPE newElement, xsize count)
|
||||
return m_len-count;
|
||||
}
|
||||
|
||||
/* Add(TYPE *, xsize) */
|
||||
/* Add(TYPE *, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XArray<TYPE>::AddArray(const TYPE *newElements, xsize count)
|
||||
size_t XArray<TYPE>::AddArray(const TYPE *newElements, size_t count)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
CheckSize(m_len+count);
|
||||
for ( i=0 ; i<count ; i++ ) {
|
||||
@ -305,11 +305,11 @@ xsize XArray<TYPE>::AddArray(const TYPE *newElements, xsize count)
|
||||
return m_len-count;
|
||||
}
|
||||
|
||||
/* Insert(TYPE &, xsize, xsize) */
|
||||
/* Insert(TYPE &, size_t, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XArray<TYPE>::Insert(const TYPE newElement, xsize pos, xsize count)
|
||||
size_t XArray<TYPE>::Insert(const TYPE newElement, size_t pos, size_t count)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
if ( pos < m_len ) {
|
||||
CheckSize(m_len+count);
|
||||
@ -324,9 +324,9 @@ xsize XArray<TYPE>::Insert(const TYPE newElement, xsize pos, xsize count)
|
||||
}
|
||||
}
|
||||
|
||||
/* Remove(xsize) */
|
||||
/* Remove(size_t) */
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
void XArray<TYPE>::RemoveAtIndex(size_t nIndex)
|
||||
{
|
||||
if ( nIndex < m_len ) {
|
||||
if ( nIndex<m_len-1 ) memmove(&m_data[nIndex], &m_data[nIndex+1], (m_len-nIndex-1)*sizeof(TYPE));
|
||||
@ -334,7 +334,7 @@ void XArray<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
return;
|
||||
}
|
||||
#if defined(_DEBUG) && defined(TRACE)
|
||||
TRACE("XArray::Remove(xsize) -> nIndex > m_len\n");
|
||||
TRACE("XArray::Remove(size_t) -> nIndex > m_len\n");
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -348,7 +348,7 @@ void XArray<TYPE>::RemoveAtIndex(int nIndex)
|
||||
}
|
||||
#endif
|
||||
|
||||
RemoveAtIndex( (xsize)nIndex ); // Check of nIndex is made in Remove(xsize nIndex)
|
||||
RemoveAtIndex( (size_t)nIndex ); // Check of nIndex is made in Remove(size_t nIndex)
|
||||
return;
|
||||
}
|
||||
|
||||
@ -356,7 +356,7 @@ void XArray<TYPE>::RemoveAtIndex(int nIndex)
|
||||
template<class TYPE>
|
||||
void XArray<TYPE>::Remove(const TYPE &Element)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<m_len ; i+= 1) {
|
||||
if ( m_data[i] == Element ) {
|
||||
|
277
rEFIt_UEFI/cpp_foundation/XBuffer.cpp
Executable file
277
rEFIt_UEFI/cpp_foundation/XBuffer.cpp
Executable file
@ -0,0 +1,277 @@
|
||||
//*************************************************************************************************
|
||||
//
|
||||
// Buffer
|
||||
//
|
||||
//*************************************************************************************************
|
||||
|
||||
#if !defined(__XBUFFER_CPP__)
|
||||
#define __XBUFFER_CPP__
|
||||
|
||||
#include <XToolsConf.h>
|
||||
#include "XToolsCommon.h"
|
||||
|
||||
#include "XBuffer.h"
|
||||
|
||||
//#include "../JiefDevTools/XConstString.h"
|
||||
#include "XString.h"
|
||||
|
||||
const XBuffer NullXBuffer;
|
||||
|
||||
//*************************************************************************************************
|
||||
void XBuffer::Initialize(const unsigned char* p, size_t count, size_t index)
|
||||
{
|
||||
if ( p!=NULL && count>0 )
|
||||
{
|
||||
m_allocatedSize = count;
|
||||
_WData = (unsigned char*)malloc(m_allocatedSize);
|
||||
if ( !_WData ) {
|
||||
panic("XBuffer::Initialize(%zu) : malloc returned NULL. System halted\n", count);
|
||||
}
|
||||
memcpy(_WData, p, count);
|
||||
_RData = _WData;
|
||||
_Len = count;
|
||||
_Index = index;
|
||||
}
|
||||
else{
|
||||
m_allocatedSize = 0;
|
||||
_WData = NULL;
|
||||
_RData = NULL;
|
||||
_Len = 0;
|
||||
_Index = 0;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// CheckSize
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void XBuffer::CheckSize(size_t nNewSize, size_t nGrowBy)
|
||||
{
|
||||
if ( m_allocatedSize < nNewSize )
|
||||
{
|
||||
nNewSize += nGrowBy;
|
||||
_WData = (unsigned char*)Xrealloc(_WData, nNewSize, m_allocatedSize);
|
||||
if ( !_WData ) {
|
||||
panic("XBuffer::CheckSize(%zu, %zu) : Xrealloc(%" PRIuPTR " %zu, %zu) returned NULL. System halted\n", nNewSize, nGrowBy, uintptr_t(_WData), nNewSize, m_allocatedSize);
|
||||
}
|
||||
_RData = _WData;
|
||||
m_allocatedSize = nNewSize;
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// ctor
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
|
||||
XBuffer::XBuffer() : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning
|
||||
{
|
||||
Initialize(NULL, 0, 0);
|
||||
}
|
||||
|
||||
XBuffer::XBuffer(XRBuffer &aXRBuffer, size_t pos, size_t count) : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning
|
||||
{
|
||||
if ( pos < aXRBuffer.Length() ) {
|
||||
Initialize(NULL, 0, 0);
|
||||
}else{
|
||||
if ( count > aXRBuffer.Length()-pos ) count = aXRBuffer.Length()-pos;
|
||||
Initialize(aXRBuffer.UCData(pos), count, aXRBuffer.Index());
|
||||
}
|
||||
}
|
||||
|
||||
XBuffer::XBuffer(XBuffer &aXBuffer, size_t pos, size_t count) : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning
|
||||
{
|
||||
if ( pos >= aXBuffer.Length() ) {
|
||||
Initialize(NULL, 0, 0);
|
||||
}else{
|
||||
if ( count > aXBuffer.Length()-pos ) count = aXBuffer.Length()-pos;
|
||||
Initialize(aXBuffer.UCData(pos), count, aXBuffer.Index());
|
||||
}
|
||||
}
|
||||
|
||||
XBuffer::XBuffer(void *p, size_t count) : _WData(NULL), m_allocatedSize(0) // initialisation to avoid effc++ warning
|
||||
{
|
||||
Initialize((const unsigned char*)p, count, 0);
|
||||
}
|
||||
|
||||
XBuffer::~XBuffer()
|
||||
{
|
||||
free(_WData);
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// operator =, +=
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
const XBuffer &XBuffer::operator =(const XRBuffer &aBuffer)
|
||||
{
|
||||
//TRACE("Operator =const XBuffer&\n");
|
||||
Cpy(aBuffer.Data(), aBuffer.Length());
|
||||
SetIndex(aBuffer.Index());
|
||||
return *this;
|
||||
}
|
||||
|
||||
const XBuffer &XBuffer::operator =(const XBuffer &aBuffer)
|
||||
{
|
||||
//TRACE("Operator =const XBuffer&\n");
|
||||
Cpy(aBuffer.Data(), aBuffer.Length());
|
||||
SetIndex(aBuffer.Index());
|
||||
return *this;
|
||||
}
|
||||
|
||||
const XBuffer &XBuffer::operator +=(const XRBuffer &aBuffer)
|
||||
{
|
||||
//TRACE("Operator +=const XBuffer&\n");
|
||||
Cat(aBuffer.Data(), aBuffer.Length());
|
||||
return *this;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// Cpy, Cat, Delete
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
void XBuffer::Cpy(const void *buf, size_t len)
|
||||
{
|
||||
if ( buf && len > 0 ) {
|
||||
CheckSize(len, 0); // GrowBy <20> 0
|
||||
memcpy(Data(), buf, len);
|
||||
SetLength(len);
|
||||
}
|
||||
}
|
||||
|
||||
void XBuffer::Cat(const void *buf, size_t len)
|
||||
{
|
||||
if ( buf && len > 0 ) {
|
||||
CheckSize(Length()+len);
|
||||
memcpy(Data(Length()), buf, len);
|
||||
SetLength(Length()+len);
|
||||
}
|
||||
}
|
||||
|
||||
void XBuffer::Cat(const XString8 &aXString8)
|
||||
{
|
||||
Cat(aXString8.sizeInBytes());
|
||||
Cat(aXString8.data(),aXString8.sizeInBytes());
|
||||
};
|
||||
|
||||
void XBuffer::Delete(unsigned int pos, unsigned int count)
|
||||
{
|
||||
if ( pos < Length() ) {
|
||||
if ( pos + count < Length() ) {
|
||||
memmove( _WData+pos, _WData+pos+count, Length()-pos-count);
|
||||
SetLength(Length()-count);
|
||||
}else{
|
||||
SetLength(pos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
// ReadFrom
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//bool XBuffer::ReadFileName(const char* FileName, unsigned int AddZeros)
|
||||
//{
|
||||
// FILE *fp;
|
||||
// long int ulen;
|
||||
// unsigned int len;
|
||||
//
|
||||
// fp = fopen(FileName, "rb");
|
||||
// if ( fp == NULL ) {
|
||||
// SetLastErrorMsgf("Impossible d'ouvrir le fichier en lecture '%s'", FileName);
|
||||
// goto finally;
|
||||
// }
|
||||
//
|
||||
// fseek(fp, 0, 2); // Seek to end of file
|
||||
// ulen = ftell(fp);
|
||||
// if ( ulen <= 0 ) {
|
||||
// SetLastErrorMsgf("Impossible d'avoir la longueur du fichier '%s'", FileName);
|
||||
// goto finally;
|
||||
// }
|
||||
//
|
||||
// len = (unsigned int)ulen;
|
||||
// fseek(fp, 0, 0);
|
||||
//
|
||||
// if ( fread(CDataWithSizeMin(0, len+AddZeros), 1, len, fp) != len ) {
|
||||
// SetLastErrorMsgf("Impossible de lire %d octets du fichier '%s'", len, FileName);
|
||||
// goto finally;
|
||||
// }
|
||||
// SetLength(len);
|
||||
// SetIndex(0);
|
||||
// if ( fclose(fp) != 0 ) {
|
||||
// SetLastErrorMsgf("Impossible de fermer les fichier '%s'", FileName);
|
||||
// goto finally;
|
||||
// }
|
||||
// {for ( unsigned int ui=len ; ui<len+AddZeros ; ui+=1 ) *CData(ui) = 0;}
|
||||
// return YES;
|
||||
// finally:
|
||||
// if ( fp != NULL ) fclose(fp);
|
||||
// SetLength(0);
|
||||
// return false;
|
||||
//
|
||||
//}
|
||||
|
||||
//bool XBuffer::ReadFromFILE(FILE *fp)
|
||||
//{
|
||||
// unsigned int longueur;
|
||||
//
|
||||
// if ( fread(&longueur, sizeof(longueur), 1, fp) != 1 ) goto fin;
|
||||
// if ( longueur > 0 && fread(DataWithSizeMin(0, longueur, 0), longueur, 1, fp) != 1 ) goto fin;
|
||||
// SetLength(longueur);
|
||||
// SetIndex(0);
|
||||
// return OUI;
|
||||
// fin:
|
||||
// SetNull();
|
||||
// return NON;
|
||||
//}
|
||||
|
||||
bool XBuffer::ReadFromXBuffer(XRBuffer &unXBuffer)
|
||||
{
|
||||
size_t longueur;
|
||||
|
||||
if ( !unXBuffer.GetSize_t(&longueur) ) return false;
|
||||
if ( !unXBuffer.Get(DataWithSizeMin(0, longueur, 0), longueur) ) return false; // GrowBy (param 3 de DataWithSizeMin est <20> 0 pour eviter du gachis m<>moire
|
||||
SetLength(longueur);
|
||||
SetIndex(0);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool XBuffer::ReadFromBuf(const char *buf, size_t *idx, size_t count)
|
||||
{
|
||||
size_t longueur;
|
||||
|
||||
if ( count-*idx >= sizeof(longueur) ) {
|
||||
longueur = *((size_t *)(buf+*idx));
|
||||
*idx += sizeof(longueur);
|
||||
if ( longueur > 0 && count-*idx>=longueur ) memcpy(DataWithSizeMin(0, longueur, 0), buf+*idx, longueur);
|
||||
*idx += longueur;
|
||||
SetLength(longueur);
|
||||
SetIndex(0);
|
||||
return true;
|
||||
}else{
|
||||
SetNull();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __DEVTOOLS_SOCKETS__
|
||||
void XBuffer::ReadFromSOCKETT(SOCKET Sock, unsigned int LenMax, unsigned int TO, unsigned int AddZeros, const char *ErrMsg)
|
||||
{
|
||||
unsigned int longueur;
|
||||
|
||||
SockReceiveT(Sock, &longueur, sizeof(longueur), TO, ErrMsg);
|
||||
if ( longueur > LenMax ) Throw("Longueur re<72>ue (%d) sup<75>rieure <20> la longueur max (%d)", longueur, LenMax);
|
||||
if ( longueur > 0 ) SockReceiveT(Sock, DataWithSizeMin(0, longueur+AddZeros, 0), longueur, TO, ErrMsg);
|
||||
SetLength(longueur);
|
||||
{for ( unsigned int ui=longueur ; ui<longueur+AddZeros ; ui+=1 ) *CData(ui) = 0;}
|
||||
SetIndex(0);
|
||||
}
|
||||
|
||||
bool XBuffer::ReadFromSOCKET(SOCKET Sock, unsigned int LenMax, unsigned int TO, unsigned int AddZeros, const char *ErrMsg)
|
||||
{
|
||||
try
|
||||
{
|
||||
ReadFromSOCKETT(Sock, LenMax, TO, AddZeros, ErrMsg);
|
||||
SetLastErrorFlag(NON);
|
||||
}
|
||||
StdCatch();
|
||||
return !LastErrorFlag();
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
91
rEFIt_UEFI/cpp_foundation/XBuffer.h
Executable file
91
rEFIt_UEFI/cpp_foundation/XBuffer.h
Executable file
@ -0,0 +1,91 @@
|
||||
//*************************************************************************************************
|
||||
//*************************************************************************************************
|
||||
//
|
||||
// BUFFER
|
||||
//
|
||||
//*************************************************************************************************
|
||||
//*************************************************************************************************
|
||||
#if !defined(__XBUFFER_H__)
|
||||
#define __XBUFFER_H__
|
||||
|
||||
#include <XToolsConf.h>
|
||||
#include "XToolsCommon.h"
|
||||
|
||||
#include "XRBuffer.h"
|
||||
#include "XString.h"
|
||||
|
||||
|
||||
#define XBuffer_Super XRBuffer
|
||||
class XBuffer : public XBuffer_Super
|
||||
{
|
||||
protected:
|
||||
unsigned char*_WData; // same as RData (see XRBuffer)
|
||||
size_t m_allocatedSize;
|
||||
|
||||
void Initialize(const unsigned char* p, size_t count, size_t index);
|
||||
public:
|
||||
XBuffer();
|
||||
XBuffer(XRBuffer &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE);
|
||||
XBuffer(XBuffer &aBuffer, size_t pos = 0, size_t count = MAX_XSIZE);
|
||||
XBuffer(void *p, size_t count);
|
||||
const XBuffer &operator =(const XRBuffer &aBuffer);
|
||||
const XBuffer &operator =(const XBuffer &aBuffer);
|
||||
|
||||
~XBuffer();
|
||||
|
||||
public:
|
||||
void CheckSize(size_t nNewSize, size_t nGrowBy = XBufferGrowByDefault);
|
||||
|
||||
// La red<65>finition de la m<>thode suivante ne devrait pas <20>tre n<>cessaire (je crois !). Et pourtant, si on l'enleve, <20>a ne compile pas...
|
||||
const void *Data(size_t ui=0) const { return XBuffer_Super::Data(ui); }
|
||||
void *Data(size_t ui=0) { return _WData+ui; }
|
||||
void *DataWithSizeMin(size_t ui, size_t size, size_t nGrowBy=XBufferGrowByDefault) { CheckSize(size, nGrowBy); return Data(ui); }
|
||||
|
||||
char *CData(size_t ui=0) { return (char *)(_WData+ui); }
|
||||
char *CDataWithSizeMin(size_t ui, size_t size, size_t nGrowBy=XBufferGrowByDefault) { CheckSize(size, nGrowBy); return CData(ui); }
|
||||
|
||||
unsigned char *UCData(size_t ui=0) { return _WData+ui; }
|
||||
void *UCDataWithSizeMin(size_t ui, unsigned int size, size_t nGrowBy=XBufferGrowByDefault) { CheckSize(size, nGrowBy); return UCData(ui); }
|
||||
|
||||
size_t Size() const { return m_allocatedSize; }
|
||||
void SetLength(size_t len) { _Len = len; };
|
||||
|
||||
/* IsNull ? */
|
||||
void SetNull() { SetLength(0); };
|
||||
|
||||
/* [] */
|
||||
unsigned char& operator [](int i) { return UCData()[i]; } // underflow ? overflow ?
|
||||
unsigned char& operator [](size_t i) { return UCData()[i]; }
|
||||
|
||||
void Cpy(const void *buf, size_t len);
|
||||
// Cat
|
||||
void Cat(const void *buf, size_t len);
|
||||
|
||||
void Cat(bool b) { Cat(&b, sizeof(b)); };
|
||||
|
||||
void Cat(char c) { Cat(&c, sizeof(c)); };
|
||||
void Cat(unsigned char b) { Cat(&b, sizeof(b)); };
|
||||
void Cat(short s) { Cat(&s, sizeof(s)); };
|
||||
void Cat(unsigned short us) { Cat(&us, sizeof(us)); };
|
||||
void Cat(int i) { Cat(&i, sizeof(i)); };
|
||||
void Cat(unsigned int ui) { Cat(&ui, sizeof(ui)); };
|
||||
void Cat(long l) { Cat(&l, sizeof(l)); };
|
||||
void Cat(unsigned long ul) { Cat(&ul, sizeof(ul)); };
|
||||
void Cat(unsigned long long ull) { Cat(&ull, sizeof(ull)); };
|
||||
|
||||
void Cat(float f) { Cat(&f, sizeof(f)); };
|
||||
void Cat(double d) { Cat(&d, sizeof(d)); };
|
||||
|
||||
void Cat(const XString8 &aXString8);
|
||||
void Cat(const XBuffer &unXBuffer) { Cat(unXBuffer.Length()); Cat(unXBuffer.Data(), unXBuffer.Length()); }
|
||||
void Delete(unsigned int pos, unsigned int count=1);
|
||||
|
||||
const XBuffer &operator += (const XRBuffer &aBuffer);
|
||||
|
||||
size_t Sizeof() const;
|
||||
// bool ReadFileName(const char* FileName, unsigned int AddZeros=0);
|
||||
bool ReadFromBuf(const char *buf, size_t *idx, size_t count);
|
||||
bool ReadFromXBuffer(XRBuffer &unXBuffer);
|
||||
};
|
||||
|
||||
#endif
|
@ -41,7 +41,7 @@ class XObjArrayNC
|
||||
|
||||
public:
|
||||
void Init();
|
||||
XObjArrayNC() { Init(); }
|
||||
XObjArrayNC() : _Data(0), _Len(0), m_allocatedSize(0) { Init(); }
|
||||
virtual ~XObjArrayNC();
|
||||
|
||||
protected:
|
||||
@ -49,12 +49,12 @@ class XObjArrayNC
|
||||
// const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) { (void)anObjArrayNC; panic("Intentionally not defined"); }
|
||||
XObjArrayNC(const XObjArrayNC<TYPE> &anObjArrayNC) = delete;
|
||||
const XObjArrayNC<TYPE> &operator =(const XObjArrayNC<TYPE> &anObjArrayNC) = delete;
|
||||
xsize _getLen() const { return _Len; }
|
||||
size_t _getLen() const { return _Len; }
|
||||
|
||||
public:
|
||||
xsize AllocatedSize() const { return m_allocatedSize; }
|
||||
xsize size() const { return _Len; }
|
||||
xsize length() const { return _Len; }
|
||||
size_t AllocatedSize() const { return m_allocatedSize; }
|
||||
size_t size() const { return _Len; }
|
||||
size_t length() const { return _Len; }
|
||||
|
||||
bool NotNull() const { return size() > 0; }
|
||||
bool IsNull() const { return size() == 0; }
|
||||
@ -85,7 +85,7 @@ class XObjArrayNC
|
||||
|
||||
// This was useful for realtime debugging with a debugger that do not recognise references. That was years and years ago. Probably not needed anymore.
|
||||
// #ifdef _DEBUG_iufasdfsfk
|
||||
const TYPE *DbgAt(int i) const { if ( i >= 0 && (xsize)i < _Len ) return &ElementAt ((xsize) i); else return NULL; }
|
||||
const TYPE *DbgAt(int i) const { if ( i >= 0 && (size_t)i < _Len ) return &ElementAt ((size_t) i); else return NULL; }
|
||||
// #endif
|
||||
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
@ -94,27 +94,27 @@ class XObjArrayNC
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
TYPE &operator[](IntegralType nIndex) { return ElementAt(nIndex); }
|
||||
|
||||
xsize AddReference(TYPE *newElement, bool FreeIt);
|
||||
size_t AddReference(TYPE *newElement, bool FreeIt);
|
||||
|
||||
// xsize InsertRef(TYPE *newElement, xsize pos, bool FreeIt = false);
|
||||
xsize InsertRef(TYPE *newElement, xsize pos, bool FreeIt);
|
||||
// size_t InsertRef(TYPE *newElement, size_t pos, bool FreeIt = false);
|
||||
size_t InsertRef(TYPE *newElement, size_t pos, bool FreeIt);
|
||||
|
||||
void SetFreeIt(xsize nIndex, bool Flag);
|
||||
void SetFreeIt(size_t nIndex, bool Flag);
|
||||
void SetFreeIt(const TYPE *Element, bool Flag);
|
||||
|
||||
void Remove(const TYPE *Element);
|
||||
void RemoveWithoutFreeing(const TYPE *Element);
|
||||
void Remove(const TYPE &Element);
|
||||
void RemoveAtIndex(xsize nIndex);
|
||||
void RemoveAtIndex(size_t nIndex);
|
||||
void RemoveAtIndex(int nIndex);
|
||||
void RemoveWithoutFreeing(xsize nIndex); // If you use this, there might be a design problem somewhere ???
|
||||
void RemoveWithoutFreeing(size_t nIndex); // If you use this, there might be a design problem somewhere ???
|
||||
//void Remove(int nIndex);
|
||||
void RemoveAllBut(const TYPE *Element);
|
||||
|
||||
void Empty();
|
||||
|
||||
public:
|
||||
void CheckSize(xsize nNewSize, xsize nGrowBy = XArrayGrowByDefault);
|
||||
void CheckSize(size_t nNewSize, size_t nGrowBy = XArrayGrowByDefault);
|
||||
|
||||
};
|
||||
|
||||
@ -126,24 +126,24 @@ class XObjArray : public XObjArrayNC<TYPE>
|
||||
XObjArray(const XObjArray<TYPE> &anObjArray);
|
||||
const XObjArray<TYPE> &operator =(const XObjArray<TYPE> &anObjArray);
|
||||
|
||||
xsize AddCopy(const TYPE &newElement, bool FreeIt = true);
|
||||
xsize AddCopies(const TYPE &n1, bool FreeIt = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem = true);
|
||||
xsize AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem = true);
|
||||
size_t AddCopy(const TYPE &newElement, bool FreeIt = true);
|
||||
size_t AddCopies(const TYPE &n1, bool FreeIt = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem = true);
|
||||
size_t AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem = true);
|
||||
//TYPE & AddNew(bool FreeIt = true);
|
||||
|
||||
xsize InsertCopy(const TYPE &newElement, xsize pos);
|
||||
size_t InsertCopy(const TYPE &newElement, size_t pos);
|
||||
|
||||
};
|
||||
|
||||
@ -174,10 +174,10 @@ void XObjArrayNC<TYPE>::Init()
|
||||
template<class TYPE>
|
||||
XObjArray<TYPE>::XObjArray(const XObjArray<TYPE> &anObjArray) : XObjArrayNC<TYPE>()
|
||||
{
|
||||
xsize ui;
|
||||
size_t ui;
|
||||
|
||||
XObjArrayNC<TYPE>::Init();
|
||||
this->CheckSize(anObjArray.size(), (xsize)0);
|
||||
this->CheckSize(anObjArray.size(), (size_t)0);
|
||||
for ( ui=0 ; ui<anObjArray.size() ; ui+=1 ) AddCopy(anObjArray.ElementAt(ui));
|
||||
}
|
||||
|
||||
@ -185,7 +185,7 @@ XObjArray<TYPE>::XObjArray(const XObjArray<TYPE> &anObjArray) : XObjArrayNC<TYPE
|
||||
template<class TYPE>
|
||||
const XObjArray<TYPE> &XObjArray<TYPE>::operator =(const XObjArray<TYPE> &anObjArray)
|
||||
{
|
||||
xsize ui;
|
||||
size_t ui;
|
||||
|
||||
if ( this == &anObjArray ) return *this; // self assignement
|
||||
XObjArrayNC<TYPE>::Empty();
|
||||
@ -205,7 +205,7 @@ XObjArrayNC<TYPE>::~XObjArrayNC()
|
||||
|
||||
/* CheckSize() */
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
void XObjArrayNC<TYPE>::CheckSize(size_t nNewSize, size_t nGrowBy)
|
||||
{
|
||||
if ( m_allocatedSize < nNewSize ) {
|
||||
nNewSize += nGrowBy + 1;
|
||||
@ -229,9 +229,9 @@ void XObjArrayNC<TYPE>::CheckSize(xsize nNewSize, xsize nGrowBy)
|
||||
// return *((TYPE *)(XObjArray<TYPE>::_Data[XObjArray<TYPE>::_Len-1].Object));
|
||||
//}
|
||||
|
||||
/* Add(TYPE &, xsize) */
|
||||
/* Add(TYPE &, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopy(const TYPE &newElement, bool FreeIt)
|
||||
size_t XObjArray<TYPE>::AddCopy(const TYPE &newElement, bool FreeIt)
|
||||
{
|
||||
XObjArrayNC<TYPE>::CheckSize(XObjArray<TYPE>::_Len+1);
|
||||
XObjArray<TYPE>::_Data[XObjArray<TYPE>::_Len].Object = new TYPE(newElement);
|
||||
@ -241,118 +241,118 @@ xsize XObjArray<TYPE>::AddCopy(const TYPE &newElement, bool FreeIt)
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, bool FreeIt)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, bool FreeIt)
|
||||
{
|
||||
return AddCopy(n1, FreeIt);
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, FreeThem);
|
||||
size_t ui = AddCopies(n1, FreeThem);
|
||||
AddCopy(n2, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, FreeThem);
|
||||
AddCopy(n3, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, FreeThem);
|
||||
AddCopy(n4, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, FreeThem);
|
||||
AddCopy(n5, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, FreeThem);
|
||||
AddCopy(n6, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, FreeThem);
|
||||
AddCopy(n7, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, FreeThem);
|
||||
AddCopy(n8, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, FreeThem);
|
||||
AddCopy(n9, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, FreeThem);
|
||||
AddCopy(n10, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, FreeThem);
|
||||
AddCopy(n11, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, FreeThem);
|
||||
AddCopy(n12, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, FreeThem);
|
||||
AddCopy(n13, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem)
|
||||
size_t XObjArray<TYPE>::AddCopies(const TYPE &n1, const TYPE &n2, const TYPE &n3, const TYPE &n4, const TYPE &n5, const TYPE &n6, const TYPE &n7, const TYPE &n8, const TYPE &n9, const TYPE &n10, const TYPE &n11, const TYPE &n12, const TYPE &n13, const TYPE &n14, bool FreeThem)
|
||||
{
|
||||
xsize ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, FreeThem);
|
||||
size_t ui = AddCopies(n1, n2, n3, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, FreeThem);
|
||||
AddCopy(n14, FreeThem);
|
||||
return ui;
|
||||
}
|
||||
|
||||
/* Add(TYPE *, xsize) */
|
||||
/* Add(TYPE *, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XObjArrayNC<TYPE>::AddReference(TYPE *newElement, bool FreeIt)
|
||||
size_t XObjArrayNC<TYPE>::AddReference(TYPE *newElement, bool FreeIt)
|
||||
{
|
||||
XObjArrayNC<TYPE>::CheckSize(XObjArrayNC<TYPE>::_Len+1);
|
||||
XObjArrayNC<TYPE>::_Data[XObjArrayNC<TYPE>::_Len].Object = newElement;
|
||||
@ -361,9 +361,9 @@ xsize XObjArrayNC<TYPE>::AddReference(TYPE *newElement, bool FreeIt)
|
||||
return XObjArrayNC<TYPE>::_Len-1;
|
||||
}
|
||||
|
||||
/* Insert(TYPE &, xsize) */
|
||||
/* Insert(TYPE &, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XObjArray<TYPE>::InsertCopy(const TYPE &newElement, xsize pos)
|
||||
size_t XObjArray<TYPE>::InsertCopy(const TYPE &newElement, size_t pos)
|
||||
{
|
||||
if ( pos < XObjArray<TYPE>::_Len ) {
|
||||
XObjArrayNC<TYPE>::CheckSize(XObjArray<TYPE>::_Len+1);
|
||||
@ -377,9 +377,9 @@ xsize XObjArray<TYPE>::InsertCopy(const TYPE &newElement, xsize pos)
|
||||
}
|
||||
}
|
||||
|
||||
/* Insert(TYPE &, xsize) */
|
||||
/* Insert(TYPE &, size_t) */
|
||||
template<class TYPE>
|
||||
xsize XObjArrayNC<TYPE>::InsertRef(TYPE *newElement, xsize pos, bool FreeIt)
|
||||
size_t XObjArrayNC<TYPE>::InsertRef(TYPE *newElement, size_t pos, bool FreeIt)
|
||||
{
|
||||
if ( pos < XObjArrayNC<TYPE>::_Len ) {
|
||||
CheckSize(XObjArrayNC<TYPE>::_Len+1);
|
||||
@ -393,9 +393,9 @@ xsize XObjArrayNC<TYPE>::InsertRef(TYPE *newElement, xsize pos, bool FreeIt)
|
||||
}
|
||||
}
|
||||
|
||||
/* SetFreeIt(xsize, bool) */
|
||||
/* SetFreeIt(size_t, bool) */
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::SetFreeIt(xsize nIndex, bool Flag)
|
||||
void XObjArrayNC<TYPE>::SetFreeIt(size_t nIndex, bool Flag)
|
||||
{
|
||||
if ( nIndex < XObjArrayNC<TYPE>::_Len )
|
||||
{
|
||||
@ -403,7 +403,7 @@ void XObjArrayNC<TYPE>::SetFreeIt(xsize nIndex, bool Flag)
|
||||
}
|
||||
else{
|
||||
#if defined(_DEBUG)
|
||||
throw "XObjArray::SetFreeIt(xsize) -> nIndex >= _Len\n";
|
||||
throw "XObjArray::SetFreeIt(size_t) -> nIndex >= _Len\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -412,7 +412,7 @@ void XObjArrayNC<TYPE>::SetFreeIt(xsize nIndex, bool Flag)
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::SetFreeIt(const TYPE *Element, bool Flag)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i < XObjArrayNC<TYPE>::_Len ; i+= 1) {
|
||||
if ( ((TYPE *)XObjArrayNC<TYPE>::_Data[i].Object) == Element ) {
|
||||
@ -425,14 +425,14 @@ void XObjArrayNC<TYPE>::SetFreeIt(const TYPE *Element, bool Flag)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Remove(xsize) */
|
||||
/* Remove(size_t) */
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
void XObjArrayNC<TYPE>::RemoveAtIndex(size_t nIndex)
|
||||
{
|
||||
if ( nIndex < XObjArrayNC<TYPE>::_Len )
|
||||
{
|
||||
if ( nIndex >= XObjArrayNC<TYPE>::_Len ) {
|
||||
panic("void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex) : BUG nIndex (%zu) is > length(). System halted\n", nIndex);
|
||||
panic("void XObjArrayNC<TYPE>::RemoveAtIndex(size_t nIndex) : BUG nIndex (%zu) is > length(). System halted\n", nIndex);
|
||||
}
|
||||
}
|
||||
if ( _Data[nIndex].FreeIt )
|
||||
@ -450,9 +450,9 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(xsize nIndex)
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
/* RemoveWithoutFreeing(xsize) */
|
||||
/* RemoveWithoutFreeing(size_t) */
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::RemoveWithoutFreeing(xsize nIndex)
|
||||
void XObjArrayNC<TYPE>::RemoveWithoutFreeing(size_t nIndex)
|
||||
{
|
||||
if ( nIndex < _Len )
|
||||
{
|
||||
@ -461,7 +461,7 @@ void XObjArrayNC<TYPE>::RemoveWithoutFreeing(xsize nIndex)
|
||||
return;
|
||||
}
|
||||
#if defined(_DEBUG)
|
||||
throw "XObjArray::RemoveWithoutFreeing(xsize) -> nIndex > _Len\n";
|
||||
throw "XObjArray::RemoveWithoutFreeing(size_t) -> nIndex > _Len\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -477,14 +477,14 @@ void XObjArrayNC<TYPE>::RemoveAtIndex(int nIndex)
|
||||
panic("XArray<TYPE>::RemoveAtIndex(int nIndex) : BUG nIndex (%d) is < 0. System halted\n", nIndex);
|
||||
}
|
||||
#endif
|
||||
RemoveAtIndex( (xsize)nIndex ); // Remove(xsize) will check that index is < _Len
|
||||
RemoveAtIndex( (size_t)nIndex ); // Remove(size_t) will check that index is < _Len
|
||||
}
|
||||
|
||||
/* Remove(const TYPE &) */
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::Remove(const TYPE &Element)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<_Len ; i+= 1) {
|
||||
if ( *((TYPE *)(_Data[i].Object)) == Element ) {
|
||||
@ -505,7 +505,7 @@ void XObjArrayNC<TYPE>::Remove(const TYPE &Element)
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::Remove(const TYPE *Element)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<_Len ; i+= 1) {
|
||||
if ( ((TYPE *)_Data[i].Object) == Element ) {
|
||||
@ -525,7 +525,7 @@ void XObjArrayNC<TYPE>::Remove(const TYPE *Element)
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::RemoveWithoutFreeing(const TYPE *Element)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<_Len ; i+= 1) {
|
||||
if ( ((TYPE *)_Data[i].Object) == Element ) {
|
||||
@ -544,7 +544,7 @@ void XObjArrayNC<TYPE>::RemoveWithoutFreeing(const TYPE *Element)
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::RemoveAllBut(const TYPE *Element)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=_Len ; i-- ; ) {
|
||||
if ( ((TYPE *)_Data[i].Object) != Element ) {
|
||||
@ -557,7 +557,7 @@ void XObjArrayNC<TYPE>::RemoveAllBut(const TYPE *Element)
|
||||
template<class TYPE>
|
||||
void XObjArrayNC<TYPE>::Empty()
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
if ( _Len > 0 ) {
|
||||
for ( i=0 ; i<_Len ; i+= 1) {
|
||||
|
154
rEFIt_UEFI/cpp_foundation/XRBuffer.cpp
Executable file
154
rEFIt_UEFI/cpp_foundation/XRBuffer.cpp
Executable file
@ -0,0 +1,154 @@
|
||||
//*************************************************************************************************
|
||||
//
|
||||
// Buffer
|
||||
//
|
||||
//*************************************************************************************************
|
||||
|
||||
#if !defined(__XRBUFFER_CPP__)
|
||||
#define __XRBUFFER_CPP__
|
||||
|
||||
#include <XToolsConf.h>
|
||||
#include "XToolsCommon.h"
|
||||
|
||||
#include "XRBuffer.h"
|
||||
|
||||
#include "XString.h"
|
||||
#include "XStringArray.h"
|
||||
|
||||
const XRBuffer NullXRBuffer;
|
||||
|
||||
|
||||
//*************************************************************************************************
|
||||
//
|
||||
// RBuffer (ConstBuffer)
|
||||
//
|
||||
//*************************************************************************************************
|
||||
void XRBuffer::Initialize(const void *p, size_t count)
|
||||
{
|
||||
_RData = (unsigned char*)p;
|
||||
_Len = count;
|
||||
_Index = 0;
|
||||
}
|
||||
|
||||
XRBuffer::XRBuffer(const XRBuffer &aXRBuffer, size_t pos, size_t count) : _RData(0), _Len(0), _Index(0)
|
||||
{
|
||||
if ( pos < aXRBuffer.Length() ) {
|
||||
_Len = count;
|
||||
if ( _Len > aXRBuffer.Length()-pos ) _Len = aXRBuffer.Length()-pos;
|
||||
_RData = (unsigned char*)aXRBuffer.Data(pos);
|
||||
}
|
||||
}
|
||||
/*
|
||||
XRBuffer::XRBuffer(const XBuffer &aXBuffer, size_t pos, size_t count)
|
||||
{
|
||||
if ( count > aXBuffer.Length() ) count = aXBuffer.Length();
|
||||
_Data = aXBuffer.UCData();
|
||||
_Len = count;
|
||||
_Index = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
//
|
||||
//-------------------------------------------------------------------------------------------------
|
||||
bool XRBuffer::Get(void *buf, size_t count)
|
||||
{
|
||||
if ( Length() - Index() >= count ) {
|
||||
memcpy(buf, Data(Index()), count);
|
||||
SetIndex(Index()+count);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
size_t XRBuffer::IdxOf(const XString8& aXString8, size_t Pos) const
|
||||
{
|
||||
if ( aXString8.length() > Length()-Pos ) return MAX_XSIZE;
|
||||
size_t nb = Length()-aXString8.length()+1;
|
||||
for ( size_t ui=Pos ; ui<nb ; ui+=1 ) {
|
||||
if ( strncmp(CData(ui), aXString8.c_str(), aXString8.sizeInBytes()) == 0 ) return ui;
|
||||
}
|
||||
return MAX_XSIZE;
|
||||
}
|
||||
|
||||
size_t XRBuffer::IdxOf(const XString8Array& aXString8Array, size_t Pos, size_t *n) const
|
||||
{
|
||||
size_t pos;
|
||||
|
||||
for (size_t ui=0 ; ui<aXString8Array.size() ; ui+=1 ) {
|
||||
pos = IdxOf(aXString8Array[ui], Pos);
|
||||
if ( pos != MAX_XSIZE ) {
|
||||
if ( n != NULL ) *n = ui;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
return MAX_XSIZE;
|
||||
}
|
||||
|
||||
size_t XRBuffer::Sizeof() const
|
||||
{
|
||||
return sizeof(unsigned int)+Length();
|
||||
}
|
||||
/*
|
||||
bool XRBuffer::WriteToBuf(char *buf, size_t *idx, size_t count) const
|
||||
{
|
||||
unsigned int longueur;
|
||||
|
||||
if ( count-*idx < sizeof(longueur) + Length() ) return NON;
|
||||
longueur = Length();
|
||||
memcpy(buf+*idx, &longueur, sizeof(longueur));
|
||||
*idx += sizeof(longueur);
|
||||
memcpy(buf+*idx, _Data, Length());
|
||||
*idx += Length();
|
||||
return OUI;
|
||||
}
|
||||
*/
|
||||
//void XRBuffer::WriteToFileNameT(const char* FileName) const
|
||||
//{
|
||||
// XFILE f;
|
||||
//
|
||||
// f.OpenT(FileName, "wb");
|
||||
// f.WriteT(Data(), Length());
|
||||
// f.CloseT();
|
||||
//}
|
||||
//
|
||||
//bool XRBuffer::WriteToFileName(const char* FileName) const
|
||||
//{
|
||||
// try {
|
||||
// WriteToFileNameT(FileName);
|
||||
// SetLastErrorFlag(NON);
|
||||
// }
|
||||
// StdCatch();
|
||||
// return !LastErrorFlag();
|
||||
//}
|
||||
//
|
||||
//bool XRBuffer::WriteToFILE(FILE *fp) const
|
||||
//{
|
||||
// size_t longueur;
|
||||
//
|
||||
// longueur = Length();
|
||||
// if ( fwrite(&longueur, sizeof(longueur), 1, fp) != 1 ) return NON;
|
||||
// if ( longueur > 0 && fwrite(Data(), longueur, 1, fp) != 1 ) return NON;
|
||||
// return OUI;
|
||||
//}
|
||||
//
|
||||
//void XRBuffer::WriteToXFILET(XFILE *f) const
|
||||
//{
|
||||
// size_t longueur;
|
||||
//
|
||||
// longueur = Length();
|
||||
// f->WriteT(&longueur, sizeof(longueur));
|
||||
// if ( longueur > 0 ) f->WriteT(Data(), longueur);
|
||||
//}
|
||||
//
|
||||
//bool XRBuffer::WriteToXFILE(XFILE *f) const
|
||||
//{
|
||||
// try {
|
||||
// WriteToXFILET(f);
|
||||
// SetLastErrorFlag(NON);
|
||||
// }
|
||||
// StdCatch();
|
||||
// return !LastErrorFlag();
|
||||
//}
|
||||
|
||||
#endif
|
106
rEFIt_UEFI/cpp_foundation/XRBuffer.h
Executable file
106
rEFIt_UEFI/cpp_foundation/XRBuffer.h
Executable file
@ -0,0 +1,106 @@
|
||||
//*************************************************************************************************
|
||||
//*************************************************************************************************
|
||||
//
|
||||
// RBUFFER
|
||||
//
|
||||
//*************************************************************************************************
|
||||
//*************************************************************************************************
|
||||
|
||||
#if !defined(__XRBUFFER_H__)
|
||||
#define __XRBUFFER_H__
|
||||
|
||||
#include <XToolsConf.h>
|
||||
#include "XToolsCommon.h"
|
||||
|
||||
|
||||
class XStringW;
|
||||
class XString8;
|
||||
class XString8Array;
|
||||
class XBuffer;
|
||||
|
||||
class XRBuffer
|
||||
{
|
||||
protected:
|
||||
const unsigned char *_RData;
|
||||
size_t _Len;
|
||||
size_t _Index;
|
||||
|
||||
public:
|
||||
void Initialize(const void *p, size_t count);
|
||||
XRBuffer() : _RData(0), _Len(0), _Index(0) { }
|
||||
XRBuffer(const void *p, size_t count) : _RData((const unsigned char *)p), _Len(count), _Index(0) { Initialize(p, count); }
|
||||
XRBuffer(const XRBuffer& aXRBuffer, size_t pos = 0, size_t count = MAX_XSIZE);
|
||||
|
||||
|
||||
// XRBuffer(const XBuffer &aBuffer, unsigned int pos = 0, unsigned int count = MAX_XSIZE);
|
||||
|
||||
public:
|
||||
|
||||
const void *Data(size_t ui=0) const { return _RData+ui; }
|
||||
const char *CData(size_t ui=0) const { return (char *)(_RData+ui); }
|
||||
const unsigned char *UCData(size_t ui=0) const { return _RData+ui; }
|
||||
|
||||
size_t Sizeof() const;
|
||||
|
||||
size_t Length() const { return _Len; }
|
||||
size_t Index() const { return _Index; }
|
||||
void SetIndex(size_t Idx) { _Index = Idx; };
|
||||
|
||||
// IsNull ? //
|
||||
bool IsNull() const { return Length() == 0 ; }
|
||||
bool NotNull() const { return Length() > 0 ; }
|
||||
|
||||
// Cast //
|
||||
operator const char *() const { return CData(); }
|
||||
|
||||
// [] //
|
||||
template<typename IntegralType, enable_if(is_integral(IntegralType))>
|
||||
unsigned char operator [](IntegralType i) const {
|
||||
if (i < 0) {
|
||||
panic("XRBuffer::operator [] : i < 0. System halted\n");
|
||||
}
|
||||
if ( (unsigned_type(IntegralType))i >= _Len ) {
|
||||
panic("XRBuffer::operator [] : index > len. System halted\n");
|
||||
}
|
||||
return UCData()[i];
|
||||
} // underflow ? overflow ?
|
||||
|
||||
bool Get(void *buf, size_t count);
|
||||
|
||||
bool Get(bool *b) { return Get(b, sizeof(*b)); }
|
||||
|
||||
bool Get(char *c) { return Get(c, sizeof(*c)); }
|
||||
bool Get(unsigned char *b) { return Get(b, sizeof(*b)); }
|
||||
bool Get(short *s) { return Get(s, sizeof(*s)); }
|
||||
bool Get(unsigned short *us) { return Get(us, sizeof(*us)); }
|
||||
bool Get(int *i) { return Get(i, sizeof(*i)); };
|
||||
bool Get(unsigned int *ui) { return Get(ui, sizeof(*ui)); };
|
||||
bool Get(long *l) { return Get(l, sizeof(*l)); };
|
||||
bool Get(unsigned long *ul) { return Get(ul, sizeof(*ul)); };
|
||||
bool Get(long long *ll) { return Get(ll, sizeof(*ll)); };
|
||||
bool Get(unsigned long long *ull) { return Get(ull, sizeof(*ull)); };
|
||||
|
||||
bool Get(float *f) { return Get(f, sizeof(*f)); };
|
||||
bool Get(double *d) { return Get(d, sizeof(*d)); };
|
||||
|
||||
bool GetBool(bool *b) { return Get(b, sizeof(*b)); }
|
||||
bool GetChar(char *c) { return Get(c, sizeof(*c)); }
|
||||
bool GetByte(unsigned char *b) { return Get(b, sizeof(*b)); }
|
||||
bool GetUShort(unsigned short *us) { return Get(us, sizeof(*us)); }
|
||||
bool GetUInt(unsigned int *ui) { return Get(ui, sizeof(*ui)); };
|
||||
bool GetULong(unsigned long *ul) { return Get(ul, sizeof(*ul)); };
|
||||
bool GetULongLong(unsigned long long *ull) { return Get(ull, sizeof(*ull)); };
|
||||
|
||||
bool GetSize_t(size_t *size) { return Get(size, sizeof(*size)); };
|
||||
|
||||
size_t IdxOf(const XString8& aXString8, size_t Pos = 0) const;
|
||||
size_t IdxOf(const XString8Array& aXString8Array, size_t Pos = 0, size_t *n = NULL) const;
|
||||
|
||||
// bool WriteToBuf(char *buf, size_t *idx, size_t count) const;
|
||||
// void WriteToFileNameT(const char* FileName) const;
|
||||
// bool WriteToFileName(const char* FileName) const;
|
||||
|
||||
// bool WriteToXFILE(XFILE *f) const;
|
||||
};
|
||||
|
||||
#endif
|
@ -673,8 +673,10 @@ public:
|
||||
/* Copy Assign */ // Only other XString, no litteral at the moment.
|
||||
XStringAbstract& operator=(const XStringAbstract &S) { takeValueFrom(S); return *this; }
|
||||
/* Assign */
|
||||
#pragma GCC diagnostic ignored "-Weffc++"
|
||||
template<typename O, class OtherXStringClass>
|
||||
ThisXStringClass& operator =(const __String<O, OtherXStringClass>& S) { strcpy(S.s()); return *((ThisXStringClass*)this); }
|
||||
#pragma GCC diagnostic warning "-Weffc++"
|
||||
// TEMPORARILY DISABLED
|
||||
// template<class O>
|
||||
// ThisXStringClass& operator =(const O* S) { strcpy(S); return *this; }
|
||||
|
@ -67,7 +67,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
public:
|
||||
typedef XStringClass_ XStringClass;
|
||||
|
||||
XStringArray_() {};
|
||||
XStringArray_() : array() {};
|
||||
|
||||
size_t size() const { return array.size(); }
|
||||
void setEmpty() { array.Empty(); }
|
||||
@ -93,7 +93,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
>
|
||||
XStringClass ConcatAll(const Type1& Separator, const Type2& Prefix, const Type3& Suffix) const
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
XStringClass s;
|
||||
|
||||
if ( array.size() > 0 ) {
|
||||
@ -123,7 +123,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Equal(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
xsize ui;
|
||||
size_t ui;
|
||||
|
||||
if ( array.size() != aStrings.size() ) return false;
|
||||
for ( ui=0 ; ui<array.size() ; ui+=1 ) {
|
||||
@ -183,7 +183,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
template<class OtherXStringArrayClass>
|
||||
bool Same(const OtherXStringArrayClass &aStrings) const
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<this->size() ; i+=1 ) {
|
||||
if ( !aStrings.contains(array.ElementAt(i)) ) return false;
|
||||
@ -236,7 +236,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
template<class OtherXStringClass>
|
||||
void import(const XStringArray_<OtherXStringClass> &aStrings)
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
array.AddCopy(aStrings[i]);
|
||||
@ -249,7 +249,7 @@ class XStringArray_/* : public XStringArraySuper*/
|
||||
}
|
||||
void importID(const XStringArray_ &aStrings) /* ignore Duplicate */
|
||||
{
|
||||
xsize i;
|
||||
size_t i;
|
||||
|
||||
for ( i=0 ; i<aStrings.size() ; i+=1 ) {
|
||||
if ( !Contains(aStrings[i]) ) AddCopy(aStrings[i]);
|
||||
|
@ -12,6 +12,9 @@ class TestObjInt
|
||||
{
|
||||
*m_destructor_called=false;
|
||||
};
|
||||
TestObjInt(const TestObjInt&) = delete;
|
||||
TestObjInt& operator=(const TestObjInt&) = delete;
|
||||
|
||||
~TestObjInt()
|
||||
{
|
||||
*m_destructor_called = true;
|
||||
|
@ -53,18 +53,18 @@ class SimpleString
|
||||
char* data;
|
||||
size_t allocatedSize;
|
||||
public:
|
||||
SimpleString() : data(NULL) {}
|
||||
SimpleString(const SimpleString& simpleString) {
|
||||
SimpleString() : data(NULL), allocatedSize(0) {}
|
||||
SimpleString(const SimpleString& simpleString) : data(NULL), allocatedSize(0) {
|
||||
allocatedSize = strlen(simpleString.data)+1;
|
||||
data = (char*)malloc(allocatedSize);
|
||||
strcpy(data, simpleString.data);
|
||||
}
|
||||
SimpleString(const char* s) {
|
||||
SimpleString(const char* s) : data(NULL), allocatedSize(0) {
|
||||
allocatedSize = strlen(s)+1;
|
||||
data = (char*)malloc(allocatedSize);
|
||||
strcpy(data, s);
|
||||
}
|
||||
SimpleString(const char16_t* s) {
|
||||
SimpleString(const char16_t* s) : data(NULL), allocatedSize(0) {
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
data = 0; // silence warning
|
||||
#endif
|
||||
@ -72,7 +72,7 @@ public:
|
||||
data = (char*)malloc(allocatedSize);
|
||||
utf_string_from_utf_string(data, allocatedSize, s);
|
||||
}
|
||||
SimpleString(const char32_t* s) {
|
||||
SimpleString(const char32_t* s) : data(NULL), allocatedSize(0) {
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
data = 0; // silence warning
|
||||
#endif
|
||||
@ -80,7 +80,7 @@ public:
|
||||
data = (char*)malloc(allocatedSize);
|
||||
utf_string_from_utf_string(data, allocatedSize, s);
|
||||
}
|
||||
SimpleString(const wchar_t* s) {
|
||||
SimpleString(const wchar_t* s) : data(NULL), allocatedSize(0) {
|
||||
#if defined(__GNUC__) && !defined(__clang__)
|
||||
data = 0; // silence warning
|
||||
#endif
|
||||
|
@ -381,11 +381,11 @@ BOOLEAN AskUserForFilePathFromDir(IN CHAR16 *Title OPTIONAL, IN REFIT_VOLUME *Vo
|
||||
//STATIC REFIT_MENU_SCREEN InitialMenu = {0, L"Please Select File...", NULL, 0, NULL,
|
||||
// 0, NULL, NULL, FALSE, FALSE, 0, 0, 0, 0,
|
||||
// { 0, 0, 0, 0 }, NULL};
|
||||
STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File..."_XSW, XStringW());
|
||||
//STATIC REFIT_MENU_SCREEN InitialMenu(0, L"Please Select File..."_XSW, XStringW());
|
||||
// Ask user for file path from volumes menu
|
||||
BOOLEAN AskUserForFilePathFromVolumes(IN CHAR16 *Title OPTIONAL, OUT EFI_DEVICE_PATH_PROTOCOL **Result)
|
||||
{
|
||||
REFIT_MENU_SCREEN Menu = InitialMenu;
|
||||
REFIT_MENU_SCREEN Menu(0, L"Please Select File..."_XSW, XStringW());
|
||||
UINTN Index = 0, /*Count = 0,*/ MenuExit;
|
||||
BOOLEAN Responded = FALSE;
|
||||
if (Result == NULL) {
|
||||
|
@ -757,7 +757,8 @@ STATIC LOADER_ENTRY *CreateLoaderEntry(IN CONST XStringW& LoaderPath,
|
||||
}
|
||||
Entry->BootBgColor = BootBgColor;
|
||||
|
||||
Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches);
|
||||
// Entry->KernelAndKextPatches = ((Patches == NULL) ? (KERNEL_AND_KEXT_PATCHES *)(((UINTN)&gSettings) + OFFSET_OF(SETTINGS_DATA, KernelAndKextPatches)) : Patches);
|
||||
CopyKernelAndKextPatches(&Entry->KernelAndKextPatches, Patches == NULL ? &gSettings.KernelAndKextPatches : Patches);
|
||||
#ifdef DUMP_KERNEL_KEXT_PATCHES
|
||||
DumpKernelAndKextPatches(Entry->KernelAndKextPatches);
|
||||
#endif
|
||||
|
@ -113,12 +113,11 @@ public:
|
||||
|
||||
|
||||
REFIT_MENU_SCREEN()
|
||||
: ID(0), Title(), TitleImage(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
|
||||
/*AnimeRun(0), LastDraw(0), CurrentFrame(0),*/
|
||||
FilmC(),
|
||||
mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
: ID(0), Title(), TitleImage(), InfoLines(), Entries(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
|
||||
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
|
||||
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
|
||||
{
|
||||
EFI_TIME Now;
|
||||
gRT->GetTime(&Now, NULL);
|
||||
@ -131,38 +130,42 @@ public:
|
||||
Daylight = true;
|
||||
}
|
||||
};
|
||||
|
||||
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText)
|
||||
: ID(ID), Title(TTitle), TitleImage(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
|
||||
/*AnimeRun(0), LastDraw(0), CurrentFrame(0),*/
|
||||
FilmC(),
|
||||
mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
: ID(ID), Title(TTitle), TitleImage(), InfoLines(), Entries(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
|
||||
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
|
||||
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
|
||||
{};
|
||||
|
||||
//TODO exclude CHAR16
|
||||
REFIT_MENU_SCREEN(UINTN ID, CONST CHAR16* TitleC, CONST CHAR16* TimeoutTextC)
|
||||
: ID(ID), Title(), TitleImage(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
|
||||
/*AnimeRun(0), LastDraw(0), CurrentFrame(0),*/
|
||||
FilmC(),
|
||||
mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
: ID(ID), Title(), TitleImage(), InfoLines(), Entries(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
|
||||
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
|
||||
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
|
||||
{
|
||||
Title.takeValueFrom(TitleC);
|
||||
TimeoutText.takeValueFrom(TimeoutTextC);
|
||||
};
|
||||
|
||||
REFIT_MENU_SCREEN(UINTN ID, XStringW TTitle, XStringW TTimeoutText, REFIT_ABSTRACT_MENU_ENTRY* entry1, REFIT_ABSTRACT_MENU_ENTRY* entry2)
|
||||
: ID(ID), Title(TTitle), TitleImage(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false),
|
||||
/*AnimeRun(0), LastDraw(0), CurrentFrame(0),*/
|
||||
FilmC(),
|
||||
mAction(ActionNone), mItemID(0)//, mPointer(NULL) //, StyleFunc(&REFIT_MENU_SCREEN::TextMenuStyle)
|
||||
: ID(ID), Title(TTitle), TitleImage(), InfoLines(), Entries(),
|
||||
TimeoutSeconds(0), Daylight(true), TimeoutText(TTimeoutText), ThemeName(),
|
||||
OldTextBufferRect(), OldTextBufferImage(), isBootScreen(false), FilmC(),
|
||||
mAction(ActionNone), mItemID(0), ScrollState{0,0,0,0}, ScrollEnabled(0), TextStyle(0), IsDragging(0),
|
||||
BarStart(), BarEnd(), ScrollStart(), ScrollEnd(), ScrollTotal(), UpButton(), DownButton(), ScrollbarBackground(), Scrollbar(), ScrollbarOldPointerPlace(), ScrollbarNewPointerPlace()
|
||||
{
|
||||
Entries.AddReference(entry1, false);
|
||||
Entries.AddReference(entry2, false);
|
||||
};
|
||||
|
||||
REFIT_MENU_SCREEN(const REFIT_MENU_SCREEN&) = delete;
|
||||
REFIT_MENU_SCREEN& operator=(const REFIT_MENU_SCREEN&) = delete;
|
||||
|
||||
|
||||
//Scroll functions
|
||||
VOID InitScroll(IN INTN ItemCount, IN UINTN MaxCount,
|
||||
IN UINTN VisibleSpace, IN INTN Selected);
|
||||
@ -213,7 +216,7 @@ public:
|
||||
virtual VOID GraphicsMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
|
||||
virtual VOID TextMenuStyle(IN UINTN Function, IN CONST CHAR16 *ParamText);
|
||||
|
||||
~REFIT_MENU_SCREEN() {};
|
||||
virtual ~REFIT_MENU_SCREEN() {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -75,7 +75,7 @@ LOADER_ENTRY* LOADER_ENTRY::getPartiallyDuplicatedEntry() const
|
||||
DuplicateEntry->LoaderType = LoaderType;
|
||||
DuplicateEntry->OSVersion = OSVersion;
|
||||
DuplicateEntry->BuildVersion = BuildVersion;
|
||||
DuplicateEntry->KernelAndKextPatches = KernelAndKextPatches;
|
||||
CopyKernelAndKextPatches(&DuplicateEntry->KernelAndKextPatches, &KernelAndKextPatches);
|
||||
return DuplicateEntry;
|
||||
}
|
||||
|
||||
|
@ -135,23 +135,30 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
virtual void StartLegacy() {};
|
||||
virtual void StartTool() {};
|
||||
|
||||
REFIT_ABSTRACT_MENU_ENTRY() : Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_) : Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY()
|
||||
: Title(), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_)
|
||||
: Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(ActionNone), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, ACTION AtClick_)
|
||||
: Title(Title_), Row(0), ShortcutDigit(0), ShortcutLetter(0), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_, CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, ACTION AtClick_)
|
||||
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_,
|
||||
CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, const XIcon& Icon_,
|
||||
EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_,
|
||||
REFIT_MENU_SCREEN *SubScreen_)
|
||||
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_),
|
||||
Image(Icon_), Place(Place_),
|
||||
AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
|
||||
SubScreen(SubScreen_) {};
|
||||
: Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_), Image(), Place(), AtClick(AtClick_), AtDoubleClick(ActionNone), AtRightClick(ActionNone), AtMouseOver(ActionNone), SubScreen(NULL)
|
||||
{};
|
||||
// REFIT_ABSTRACT_MENU_ENTRY(const XStringW& Title_, UINTN Row_,
|
||||
// CHAR16 ShortcutDigit_, CHAR16 ShortcutLetter_, const XIcon& Icon_,
|
||||
// EG_RECT Place_, ACTION AtClick_, ACTION AtDoubleClick_, ACTION AtRightClick_, ACTION AtMouseOver_,
|
||||
// REFIT_MENU_SCREEN *SubScreen_)
|
||||
// : Title(Title_), Row(Row_), ShortcutDigit(ShortcutDigit_), ShortcutLetter(ShortcutLetter_),
|
||||
// Image(Icon_), Place(Place_),
|
||||
// AtClick(AtClick_), AtDoubleClick(AtDoubleClick_), AtRightClick(AtRightClick_), AtMouseOver(AtMouseOver_),
|
||||
// SubScreen(SubScreen_)
|
||||
// {};
|
||||
|
||||
REFIT_ABSTRACT_MENU_ENTRY(const REFIT_ABSTRACT_MENU_ENTRY&) = delete;
|
||||
REFIT_ABSTRACT_MENU_ENTRY& operator=(const REFIT_ABSTRACT_MENU_ENTRY&) = delete;
|
||||
|
||||
virtual ~REFIT_ABSTRACT_MENU_ENTRY() {}; // virtual destructor : this is vital
|
||||
};
|
||||
@ -238,6 +245,8 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
public:
|
||||
INPUT_ITEM *Item;
|
||||
REFIT_MENU_ENTRY_ITEM_ABSTRACT() : Item(0) {}
|
||||
REFIT_MENU_ENTRY_ITEM_ABSTRACT(const REFIT_MENU_ENTRY_ITEM_ABSTRACT&) = delete;
|
||||
REFIT_MENU_ENTRY_ITEM_ABSTRACT& operator=(const REFIT_MENU_ENTRY_ITEM_ABSTRACT&) = delete;
|
||||
virtual REFIT_MENU_ENTRY_ITEM_ABSTRACT* getREFIT_MENU_ITEM_IEM_ABSTRACT() { return this; };
|
||||
};
|
||||
|
||||
@ -271,8 +280,11 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
XIcon BadgeImage;
|
||||
|
||||
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER()
|
||||
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), DriveImage(), BadgeImage()
|
||||
{}
|
||||
: REFIT_ABSTRACT_MENU_ENTRY(), DevicePathString(0), LoadOptions(), LoaderPath(), DriveImage(), BadgeImage()
|
||||
{}
|
||||
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(const REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER&) = delete;
|
||||
REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER& operator=(const REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER&) = delete;
|
||||
|
||||
virtual XIcon* getDriveImage() { return &DriveImage; };
|
||||
virtual XIcon* getBadgeImage() { return &BadgeImage; };
|
||||
|
||||
@ -291,6 +303,8 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
void StartTool();
|
||||
|
||||
REFIT_MENU_ENTRY_LOADER_TOOL() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), NoMemset(1), Flags(0), DevicePath(0) {};
|
||||
REFIT_MENU_ENTRY_LOADER_TOOL(const REFIT_MENU_ENTRY_LOADER_TOOL&) = delete;
|
||||
REFIT_MENU_ENTRY_LOADER_TOOL& operator=(const REFIT_MENU_ENTRY_LOADER_TOOL&) = delete;
|
||||
|
||||
virtual REFIT_MENU_ENTRY_LOADER_TOOL* getREFIT_MENU_ENTRY_LOADER_TOOL() { return this; };
|
||||
};
|
||||
@ -306,7 +320,9 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
EFI_DEVICE_PATH *DevicePath;
|
||||
UINT16 Flags;
|
||||
|
||||
REFIT_MENU_ENTRY_CLOVER() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), Volume(NULL), DevicePath(NULL), Flags(0) {};
|
||||
REFIT_MENU_ENTRY_CLOVER() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), Volume(NULL), VolName(), DevicePath(NULL), Flags(0) {};
|
||||
REFIT_MENU_ENTRY_CLOVER(const REFIT_MENU_ENTRY_CLOVER&) = delete;
|
||||
REFIT_MENU_ENTRY_CLOVER& operator=(const REFIT_MENU_ENTRY_CLOVER&) = delete;
|
||||
|
||||
REFIT_MENU_ENTRY_CLOVER* getPartiallyDuplicatedEntry() const;
|
||||
virtual REFIT_MENU_ENTRY_CLOVER* getREFIT_MENU_ENTRY_CLOVER() { return this; };
|
||||
@ -322,6 +338,8 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
UINTN BootNum;
|
||||
|
||||
REFIT_MENU_ITEM_BOOTNUM() : REFIT_MENU_ITEM_ABSTRACT_ENTRY_LOADER(), Volume(NULL), BootNum(0) {};
|
||||
REFIT_MENU_ITEM_BOOTNUM(const REFIT_MENU_ITEM_BOOTNUM&) = delete;
|
||||
REFIT_MENU_ITEM_BOOTNUM& operator=(const REFIT_MENU_ITEM_BOOTNUM&) = delete;
|
||||
virtual REFIT_MENU_ITEM_BOOTNUM* getREFIT_MENU_ITEM_BOOTNUM() { return this; };
|
||||
} ;
|
||||
|
||||
@ -341,8 +359,6 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
|
||||
//--------------------------------------- LOADER_ENTRY ---------------------------------------//
|
||||
|
||||
struct KERNEL_AND_KEXT_PATCHES;
|
||||
|
||||
class LOADER_ENTRY : public REFIT_MENU_ITEM_BOOTNUM
|
||||
{
|
||||
public:
|
||||
@ -358,7 +374,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
|
||||
UINT8 CustomBoot;
|
||||
XImage CustomLogo;
|
||||
KERNEL_AND_KEXT_PATCHES *KernelAndKextPatches;
|
||||
KERNEL_AND_KEXT_PATCHES KernelAndKextPatches;
|
||||
XStringW Settings;
|
||||
UINT8 *KernelData;
|
||||
UINT32 AddrVtable;
|
||||
@ -396,15 +412,17 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
|
||||
|
||||
LOADER_ENTRY()
|
||||
: REFIT_MENU_ITEM_BOOTNUM(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0),
|
||||
: REFIT_MENU_ITEM_BOOTNUM(), APFSTargetUUID(), VolName(0), DevicePath(0), Flags(0), LoaderType(0), OSVersion(0), BuildVersion(0),
|
||||
BootBgColor({0,0,0,0}),
|
||||
CustomBoot(0), KernelAndKextPatches(0), Settings(0), KernelData(0),
|
||||
AddrVtable(0), SizeVtable(0), NamesTable(0), shift(0),
|
||||
CustomBoot(0), CustomLogo(), KernelAndKextPatches(), Settings(0), KernelData(0),
|
||||
AddrVtable(0), SizeVtable(0), NamesTable(0), SegVAddr(0), shift(0),
|
||||
PatcherInited(false), gSNBEAICPUFixRequire(false), gBDWEIOPCIFixRequire(false), isKernelcache(false), is64BitKernel(false),
|
||||
KernelSlide(0), KernelOffset(0), PrelinkTextLoadCmdAddr(0), PrelinkTextAddr(0), PrelinkTextSize(0),
|
||||
PrelinkInfoLoadCmdAddr(0), PrelinkInfoAddr(0), PrelinkInfoSize(0),
|
||||
KernelRelocBase(0), bootArgs1(0), bootArgs2(0), dtRoot(0), dtLength(0)
|
||||
{};
|
||||
LOADER_ENTRY(const LOADER_ENTRY&) = delete;
|
||||
LOADER_ENTRY& operator=(const LOADER_ENTRY&) = delete;
|
||||
|
||||
void SetKernelRelocBase();
|
||||
void FindBootArgs();
|
||||
@ -468,7 +486,7 @@ class REFIT_ABSTRACT_MENU_ENTRY
|
||||
BOOLEAN KernelIvyE5XCPM();
|
||||
void EightApplePatch(UINT8 *Driver, UINT32 DriverSize);
|
||||
|
||||
void Stall(int Pause) { if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) { gBS->Stall(Pause); } };
|
||||
void Stall(int Pause) { if ( KernelAndKextPatches.KPDebug ) { gBS->Stall(Pause); } };
|
||||
void StartLoader();
|
||||
void AddDefaultMenu();
|
||||
LOADER_ENTRY* getPartiallyDuplicatedEntry() const;
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
#define XStringGrowByDefault 10
|
||||
#define XArrayGrowByDefault 8
|
||||
//extern xsize XBufferGrowByDefault;
|
||||
#define XBufferGrowByDefault 16
|
||||
|
||||
/* For convience, operator [] is define with int parameter.
|
||||
* Defining __XTOOLS_CHECK_OVERFLOW__ make a check that the parameter is >= 0
|
||||
|
@ -46,10 +46,12 @@ public:
|
||||
EG_RECT FilmPlace; // Screen has several Films each in own place
|
||||
|
||||
public:
|
||||
FILM() : AnimeRun(0), LastDraw(0), CurrentFrame(0)
|
||||
{}
|
||||
FILM(INTN Id) : Id(Id), RunOnce(FALSE), NumFrames(0), AnimeRun(0), LastDraw(0), CurrentFrame(0)
|
||||
{}
|
||||
FILM() : Id(0), RunOnce(0), NumFrames(0), FrameTime(0), FilmX(0), FilmY(0), ScreenEdgeHorizontal(0), ScreenEdgeVertical(0),
|
||||
NudgeX(0), NudgeY(0), Path(), AnimeRun(0), LastDraw(0), Frames(), LastIndex(0), CurrentFrame(0), FilmPlace()
|
||||
{}
|
||||
FILM(INTN Id) : Id(Id), RunOnce(0), NumFrames(0), FrameTime(0), FilmX(0), FilmY(0), ScreenEdgeHorizontal(0), ScreenEdgeVertical(0),
|
||||
NudgeX(0), NudgeY(0), Path(), AnimeRun(0), LastDraw(0), Frames(), LastIndex(0), CurrentFrame(0), FilmPlace()
|
||||
{}
|
||||
~FILM() {}
|
||||
|
||||
INTN GetIndex() { return Id; }
|
||||
@ -94,7 +96,7 @@ class XCinema
|
||||
XObjArray<FILM> Cinema;
|
||||
|
||||
public:
|
||||
XCinema() {}
|
||||
XCinema() : Cinema() {}
|
||||
~XCinema() {}
|
||||
|
||||
FILM* GetFilm(INTN Id);
|
||||
|
290
rEFIt_UEFI/libeg/XIcon.cpp
Normal file
290
rEFIt_UEFI/libeg/XIcon.cpp
Normal file
@ -0,0 +1,290 @@
|
||||
/*
|
||||
* a class to keep definitions for all theme settings
|
||||
*/
|
||||
|
||||
extern "C" {
|
||||
#include <Protocol/GraphicsOutput.h>
|
||||
}
|
||||
|
||||
#include "libegint.h"
|
||||
#include "../refit/screen.h"
|
||||
#include "../refit/lib.h"
|
||||
|
||||
#include "XTheme.h"
|
||||
#include "nanosvg.h"
|
||||
|
||||
#ifndef DEBUG_ALL
|
||||
#define DEBUG_XICON 1
|
||||
#else
|
||||
#define DEBUG_XICON DEBUG_ALL
|
||||
#endif
|
||||
|
||||
#if DEBUG_XICON == 0
|
||||
#define DBG(...)
|
||||
#else
|
||||
#define DBG(...) DebugLog(DEBUG_XICON, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
CONST CHAR8* IconsNames[] = {
|
||||
"func_about",
|
||||
"func_options",
|
||||
"func_clover",
|
||||
"func_secureboot",
|
||||
"func_secureboot_config",
|
||||
"func_reset",
|
||||
"func_shutdown",
|
||||
"func_help",
|
||||
"tool_shell", //8
|
||||
"tool_part",
|
||||
"tool_rescue",
|
||||
"pointer",//11
|
||||
"vol_internal",
|
||||
"vol_external",
|
||||
"vol_optical",
|
||||
"vol_firewire",
|
||||
"vol_clover" ,
|
||||
"vol_internal_hfs" , //17
|
||||
"vol_internal_apfs",
|
||||
"vol_internal_ntfs",
|
||||
"vol_internal_ext3" ,
|
||||
"vol_recovery",//21
|
||||
// not used? will be skipped while theme parsing
|
||||
"logo",
|
||||
"selection_small",
|
||||
"selection_big", //BUILTIN_SELECTION_BIG=24 we keep this numeration
|
||||
//os icons
|
||||
"os_mac", //0 + 25
|
||||
"os_tiger",
|
||||
"os_leo",
|
||||
"os_snow",
|
||||
"os_lion",
|
||||
"os_cougar",
|
||||
"os_mav",
|
||||
"os_yos",
|
||||
"os_cap", //33
|
||||
"os_sierra",
|
||||
"os_hsierra",
|
||||
"os_moja", //36
|
||||
"os_cata", //37 //there is no reserve for 10.16, next oses should be added to the end of the list
|
||||
"os_linux", //13 + 25 = 38
|
||||
"os_ubuntu",
|
||||
"os_suse",
|
||||
"os_freebsd", //16+25 = 41
|
||||
"os_freedos",
|
||||
"os_win",
|
||||
"os_vista",
|
||||
"radio_button", //20+25 = 45
|
||||
"radio_button_selected",
|
||||
"checkbox", //22+25 = 47
|
||||
"checkbox_checked",
|
||||
"scrollbar_background", //24 - present here for SVG theme but should be done more common way
|
||||
"scrollbar_holder",
|
||||
"os_unknown", //51 == ICON_OTHER_OS
|
||||
"os_clover", //52 == ICON_CLOVER
|
||||
//other oses will be added below
|
||||
"os_bigsur", //53 == ICON_BIGSUR
|
||||
""
|
||||
};
|
||||
const INTN IconsNamesSize = sizeof(IconsNames) / sizeof(IconsNames[0]);
|
||||
|
||||
//icons class
|
||||
//if ImageNight is not set then Image should be used
|
||||
#define DEC_BUILTIN_ICON(id, ico) { \
|
||||
Empty = EFI_ERROR(Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico))); \
|
||||
}
|
||||
|
||||
#define DEC_BUILTIN_ICON2(id, ico, dark) { \
|
||||
Empty = EFI_ERROR(Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico))); \
|
||||
ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
|
||||
}
|
||||
|
||||
XIcon::XIcon(INTN Index, bool TakeEmbedded) : Id(Index), Name(), Image(), ImageNight(), Native(false),
|
||||
ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(0)
|
||||
{
|
||||
// Id = Index;
|
||||
// Name.setEmpty();
|
||||
// Native = false;
|
||||
// ImageSVG = nullptr;
|
||||
// ImageSVGnight = nullptr;
|
||||
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index < IconsNamesSize) { //full table
|
||||
Name.takeValueFrom(IconsNames[Index]);
|
||||
}
|
||||
if (TakeEmbedded) {
|
||||
GetEmbedded();
|
||||
}
|
||||
}
|
||||
|
||||
XIcon& XIcon::operator=(const XIcon& src)
|
||||
{
|
||||
Id = src.Id;
|
||||
Name = src.Name;
|
||||
if (!src.isEmpty()) {
|
||||
Image = src.Image;
|
||||
if (!src.ImageNight.isEmpty()) {
|
||||
ImageNight = src.ImageNight;
|
||||
}
|
||||
setFilled();
|
||||
//this moment we copy pointers. Later it will be class variables
|
||||
ImageSVG = src.ImageSVG;
|
||||
ImageSVGnight = src.ImageSVGnight;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void XIcon::GetEmbedded()
|
||||
{
|
||||
switch (Id) {
|
||||
case BUILTIN_ICON_FUNC_ABOUT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_ABOUT, emb_func_about, emb_dark_func_about)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_OPTIONS:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_OPTIONS, emb_func_options, emb_dark_func_options)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_CLOVER:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_CLOVER, emb_func_clover, emb_dark_func_clover)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_SECURE_BOOT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT, emb_func_secureboot, emb_dark_func_secureboot)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG, emb_func_secureboot_config, emb_dark_func_secureboot_config)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_RESET:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_RESET, emb_func_reset, emb_dark_func_reset)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_EXIT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_EXIT, emb_func_exit, emb_dark_func_exit)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_HELP:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_HELP, emb_func_help, emb_dark_func_help)
|
||||
break;
|
||||
case BUILTIN_ICON_TOOL_SHELL:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_TOOL_SHELL, emb_func_shell, emb_dark_func_shell)
|
||||
break;
|
||||
case BUILTIN_ICON_BANNER:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_BANNER, emb_logo, emb_dark_logo)
|
||||
break;
|
||||
case BUILTIN_SELECTION_SMALL:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_SMALL, emb_selection_small, emb_dark_selection_small)
|
||||
break;
|
||||
case BUILTIN_SELECTION_BIG:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_BIG, emb_selection_big, emb_dark_selection_big)
|
||||
break;
|
||||
//next icons have no dark image
|
||||
case BUILTIN_ICON_POINTER:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_POINTER, emb_pointer)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL, emb_vol_internal)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_EXTERNAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_EXTERNAL, emb_vol_external)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_OPTICAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_OPTICAL, emb_vol_optical)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_BOOTER:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_BOOTER, emb_vol_internal_booter)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_HFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_HFS, emb_vol_internal_hfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_APFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_APFS, emb_vol_internal_apfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_NTFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_NTFS, emb_vol_internal_ntfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_EXT3:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_EXT3, emb_vol_internal_ext)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_REC:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_REC, emb_vol_internal_recovery)
|
||||
break;
|
||||
case BUILTIN_RADIO_BUTTON:
|
||||
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON, emb_radio_button)
|
||||
break;
|
||||
case BUILTIN_RADIO_BUTTON_SELECTED:
|
||||
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON_SELECTED, emb_radio_button_selected)
|
||||
break;
|
||||
case BUILTIN_CHECKBOX:
|
||||
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX, emb_checkbox)
|
||||
break;
|
||||
case BUILTIN_CHECKBOX_CHECKED:
|
||||
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX_CHECKED, emb_checkbox_checked)
|
||||
break;
|
||||
case BUILTIN_ICON_SELECTION:
|
||||
Name.takeValueFrom("selection_indicator");
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_SELECTION, emb_selection_indicator)
|
||||
break;
|
||||
default:
|
||||
// Image.setEmpty(); //done by ctor?
|
||||
break;
|
||||
}
|
||||
//something to do else?
|
||||
}
|
||||
|
||||
XIcon::~XIcon() {}
|
||||
|
||||
//copy from XImage for our purpose
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const char* IconName)
|
||||
{
|
||||
return LoadXImage(BaseDir, XStringW().takeValueFrom(IconName));
|
||||
}
|
||||
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const wchar_t* LIconName)
|
||||
{
|
||||
return LoadXImage(BaseDir, XStringW().takeValueFrom(LIconName));
|
||||
}
|
||||
//dont call this procedure for SVG theme BaseDir == NULL?
|
||||
//it can be used for other files
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName)
|
||||
{
|
||||
EFI_STATUS Status = Image.LoadXImage(BaseDir, IconName);
|
||||
ImageNight.LoadXImage(BaseDir, IconName + L"_night"_XSW);
|
||||
if (!EFI_ERROR(Status)) setFilled();
|
||||
return Status;
|
||||
}
|
||||
|
||||
XImage* XIcon::GetBest(bool night, bool *free)
|
||||
{
|
||||
#if 1
|
||||
if (ImageSVG) {
|
||||
NSVGimage* sImage = (NSVGimage*)ImageSVGnight;
|
||||
if (!night || !ImageSVGnight) sImage = (NSVGimage*)ImageSVG;
|
||||
float Scale = sImage->scale;
|
||||
NSVGrasterizer* rast = nsvgCreateRasterizer();
|
||||
float Height = sImage->height * Scale;
|
||||
float Width = sImage->width * Scale;
|
||||
int iWidth = (int)(Width + 0.5f);
|
||||
int iHeight = (int)(Height + 0.5f);
|
||||
XImage* NewImage = new XImage(iWidth, iHeight); //TODO creating new XImage we have to delete it after use
|
||||
if (sImage->shapes == NULL) {
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
float bounds[4];
|
||||
nsvg__imageBounds(sImage, bounds);
|
||||
|
||||
float tx = 0.f, ty = 0.f;
|
||||
float realWidth = (bounds[2] - bounds[0]) * Scale;
|
||||
float realHeight = (bounds[3] - bounds[1]) * Scale;
|
||||
tx = (Width - realWidth) * 0.5f;
|
||||
ty = (Height - realHeight) * 0.5f;
|
||||
|
||||
nsvgRasterize(rast, sImage, tx, ty, Scale, Scale, (UINT8*)NewImage->GetPixelPtr(0,0), iWidth, iHeight, iWidth*4);
|
||||
nsvgDeleteRasterizer(rast);
|
||||
// if (night) ImageNight = *NewImage;
|
||||
// else Image = *NewImage;
|
||||
// delete NewImage;
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
#endif
|
||||
XImage* RetImage = (night && !ImageNight.isEmpty())? &ImageNight : &Image;
|
||||
if (free) *free = false;
|
||||
return RetImage;
|
||||
}
|
||||
|
||||
|
||||
|
47
rEFIt_UEFI/libeg/XIcon.h
Normal file
47
rEFIt_UEFI/libeg/XIcon.h
Normal file
@ -0,0 +1,47 @@
|
||||
#if !defined(__XICON_H__)
|
||||
#define __XICON_H__
|
||||
|
||||
#include "../cpp_foundation/XObjArray.h"
|
||||
#include "../cpp_foundation/XString.h"
|
||||
#include "libeg.h"
|
||||
|
||||
extern CONST CHAR8* IconsNames[];
|
||||
extern const INTN IconsNamesSize;
|
||||
|
||||
class XIcon
|
||||
{
|
||||
public:
|
||||
INTN Id; //for example BUILTIN_ICON_POINTER
|
||||
XString8 Name; //for example "os_moja", "vol_internal"
|
||||
XImage Image;
|
||||
XImage ImageNight;
|
||||
bool Native;
|
||||
void *ImageSVG; //NSVGimage*
|
||||
void *ImageSVGnight;
|
||||
protected:
|
||||
bool Empty;
|
||||
public:
|
||||
XIcon(): Id(0), Name(), Image(), ImageNight(), Native(false), ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(true) {};
|
||||
XIcon(INTN Id, bool Embedded = false);
|
||||
// Initialisation of ImageSVG(other.ImageSVG), ImageSVGnight(other.ImageSVGnight) is wrong because we just copy the pointer
|
||||
XIcon(const XIcon& other) : Id(other.Id), Name(other.Name), Image(other.Image), ImageNight(other.ImageNight), Native(other.Native), ImageSVG(other.ImageSVG), ImageSVGnight(other.ImageSVGnight), Empty(other.Empty) {} ;
|
||||
~XIcon();
|
||||
|
||||
|
||||
bool isEmpty() const { return Empty; }
|
||||
void setFilled() { Empty = false; }
|
||||
void setEmpty() { Empty = true; }
|
||||
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const wchar_t* LIconName);
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName);
|
||||
|
||||
// Default are not valid, as usual. We delete them. If needed, proper ones can be created
|
||||
// Icon(const Icon&) = delete;
|
||||
XIcon& operator=(const XIcon&); // = delete;
|
||||
void GetEmbedded();
|
||||
XImage* GetBest(bool night, bool *free = nullptr);
|
||||
};
|
||||
|
||||
|
||||
#endif
|
@ -18,13 +18,8 @@
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL NullColor = {0,0,0,0};
|
||||
|
||||
XImage::XImage()
|
||||
{
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
}
|
||||
|
||||
XImage::XImage(UINTN W, UINTN H)
|
||||
XImage::XImage(UINTN W, UINTN H) : Width(0), Height(0), PixelData() // initialisation of Width and Height and , PixelData() to avoid warning with -Weffc++
|
||||
{
|
||||
// Width = W;
|
||||
// Height = H; //included below
|
||||
@ -38,7 +33,7 @@ XImage& XImage::operator= (const XImage& other)
|
||||
return *this;
|
||||
}
|
||||
|
||||
XImage::XImage(const XImage& Image, float scale)
|
||||
XImage::XImage(const XImage& Image, float scale) : Width(0), Height(0), PixelData() // initialisation of Width and Height and , PixelData() to avoid warning with -Weffc++
|
||||
{
|
||||
UINTN SrcWidth = Image.GetWidth();
|
||||
UINTN SrcHeight = Image.GetHeight();
|
||||
|
@ -50,7 +50,7 @@ protected:
|
||||
XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL> PixelData;
|
||||
|
||||
public:
|
||||
XImage();
|
||||
XImage() : Width(0), Height(0), PixelData() {};
|
||||
XImage(UINTN W, UINTN H);
|
||||
XImage(const XImage& Image, float scale = 0.f); //the constructor can accept 0 scale as 1.f
|
||||
virtual ~XImage();
|
||||
|
@ -25,18 +25,6 @@
|
||||
#define POINTER_WIDTH 64
|
||||
#define POINTER_HEIGHT 64
|
||||
|
||||
XPointer::XPointer()
|
||||
: SimplePointerProtocol(NULL), PointerImage(NULL),
|
||||
// newImage(POINTER_WIDTH, POINTER_HEIGHT),
|
||||
oldImage(0, 0), Alive(false), night(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
XPointer::~XPointer()
|
||||
{
|
||||
}
|
||||
|
||||
void XPointer::Hide()
|
||||
{
|
||||
if (Alive) {
|
||||
|
@ -9,8 +9,13 @@ class XImage;
|
||||
class XPointer
|
||||
{
|
||||
public:
|
||||
XPointer();
|
||||
~XPointer();
|
||||
XPointer() : SimplePointerProtocol(NULL), PointerImage(NULL),
|
||||
oldImage(0, 0), newPlace(), oldPlace(), LastClickTime(0), State{0}, MouseEvent(NoEvents), Alive(false), night(false)
|
||||
{}
|
||||
XPointer(const XPointer&) = delete;
|
||||
XPointer& operator=(const XPointer&) = delete;
|
||||
|
||||
~XPointer() {};
|
||||
|
||||
protected:
|
||||
EFI_SIMPLE_POINTER_PROTOCOL *SimplePointerProtocol;
|
||||
|
@ -25,269 +25,19 @@ extern "C" {
|
||||
#define DBG(...) DebugLog(DEBUG_XTHEME, __VA_ARGS__)
|
||||
#endif
|
||||
|
||||
CONST CHAR8* IconsNames[] = {
|
||||
"func_about",
|
||||
"func_options",
|
||||
"func_clover",
|
||||
"func_secureboot",
|
||||
"func_secureboot_config",
|
||||
"func_reset",
|
||||
"func_shutdown",
|
||||
"func_help",
|
||||
"tool_shell", //8
|
||||
"tool_part",
|
||||
"tool_rescue",
|
||||
"pointer",//11
|
||||
"vol_internal",
|
||||
"vol_external",
|
||||
"vol_optical",
|
||||
"vol_firewire",
|
||||
"vol_clover" ,
|
||||
"vol_internal_hfs" , //17
|
||||
"vol_internal_apfs",
|
||||
"vol_internal_ntfs",
|
||||
"vol_internal_ext3" ,
|
||||
"vol_recovery",//21
|
||||
// not used? will be skipped while theme parsing
|
||||
"logo",
|
||||
"selection_small",
|
||||
"selection_big", //BUILTIN_SELECTION_BIG=24 we keep this numeration
|
||||
//os icons
|
||||
"os_mac", //0 + 25
|
||||
"os_tiger",
|
||||
"os_leo",
|
||||
"os_snow",
|
||||
"os_lion",
|
||||
"os_cougar",
|
||||
"os_mav",
|
||||
"os_yos",
|
||||
"os_cap", //33
|
||||
"os_sierra",
|
||||
"os_hsierra",
|
||||
"os_moja", //36
|
||||
"os_cata", //37 //there is no reserve for 10.16, next oses should be added to the end of the list
|
||||
"os_linux", //13 + 25 = 38
|
||||
"os_ubuntu",
|
||||
"os_suse",
|
||||
"os_freebsd", //16+25 = 41
|
||||
"os_freedos",
|
||||
"os_win",
|
||||
"os_vista",
|
||||
"radio_button", //20+25 = 45
|
||||
"radio_button_selected",
|
||||
"checkbox", //22+25 = 47
|
||||
"checkbox_checked",
|
||||
"scrollbar_background", //24 - present here for SVG theme but should be done more common way
|
||||
"scrollbar_holder",
|
||||
"os_unknown", //51 == ICON_OTHER_OS
|
||||
"os_clover", //52 == ICON_CLOVER
|
||||
//other oses will be added below
|
||||
"os_bigsur", //53 == ICON_BIGSUR
|
||||
""
|
||||
};
|
||||
const INTN IconsNamesSize = sizeof(IconsNames) / sizeof(IconsNames[0]);
|
||||
|
||||
//icons class
|
||||
//if ImageNight is not set then Image should be used
|
||||
#define DEC_BUILTIN_ICON(id, ico) { \
|
||||
Empty = EFI_ERROR(Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico))); \
|
||||
}
|
||||
|
||||
#define DEC_BUILTIN_ICON2(id, ico, dark) { \
|
||||
Empty = EFI_ERROR(Image.FromPNG(ACCESS_EMB_DATA(ico), ACCESS_EMB_SIZE(ico))); \
|
||||
ImageNight.FromPNG(ACCESS_EMB_DATA(dark), ACCESS_EMB_SIZE(dark)); \
|
||||
}
|
||||
|
||||
XIcon::XIcon(INTN Index, bool TakeEmbedded) : Id(Index), Name(), Image(), ImageNight(), Native(false),
|
||||
ImageSVG(nullptr), ImageSVGnight(nullptr)
|
||||
{
|
||||
// Id = Index;
|
||||
// Name.setEmpty();
|
||||
// Native = false;
|
||||
// ImageSVG = nullptr;
|
||||
// ImageSVGnight = nullptr;
|
||||
if (Index >= BUILTIN_ICON_FUNC_ABOUT && Index < IconsNamesSize) { //full table
|
||||
Name.takeValueFrom(IconsNames[Index]);
|
||||
}
|
||||
if (TakeEmbedded) {
|
||||
GetEmbedded();
|
||||
}
|
||||
}
|
||||
|
||||
XIcon& XIcon::operator=(const XIcon& src)
|
||||
{
|
||||
Id = src.Id;
|
||||
Name = src.Name;
|
||||
if (!src.isEmpty()) {
|
||||
Image = src.Image;
|
||||
if (!src.ImageNight.isEmpty()) {
|
||||
ImageNight = src.ImageNight;
|
||||
}
|
||||
setFilled();
|
||||
//this moment we copy pointers. Later it will be class variables
|
||||
ImageSVG = src.ImageSVG;
|
||||
ImageSVGnight = src.ImageSVGnight;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void XIcon::GetEmbedded()
|
||||
{
|
||||
switch (Id) {
|
||||
case BUILTIN_ICON_FUNC_ABOUT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_ABOUT, emb_func_about, emb_dark_func_about)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_OPTIONS:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_OPTIONS, emb_func_options, emb_dark_func_options)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_CLOVER:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_CLOVER, emb_func_clover, emb_dark_func_clover)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_SECURE_BOOT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT, emb_func_secureboot, emb_dark_func_secureboot)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_SECURE_BOOT_CONFIG, emb_func_secureboot_config, emb_dark_func_secureboot_config)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_RESET:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_RESET, emb_func_reset, emb_dark_func_reset)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_EXIT:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_EXIT, emb_func_exit, emb_dark_func_exit)
|
||||
break;
|
||||
case BUILTIN_ICON_FUNC_HELP:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_FUNC_HELP, emb_func_help, emb_dark_func_help)
|
||||
break;
|
||||
case BUILTIN_ICON_TOOL_SHELL:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_TOOL_SHELL, emb_func_shell, emb_dark_func_shell)
|
||||
break;
|
||||
case BUILTIN_ICON_BANNER:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_ICON_BANNER, emb_logo, emb_dark_logo)
|
||||
break;
|
||||
case BUILTIN_SELECTION_SMALL:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_SMALL, emb_selection_small, emb_dark_selection_small)
|
||||
break;
|
||||
case BUILTIN_SELECTION_BIG:
|
||||
DEC_BUILTIN_ICON2(BUILTIN_SELECTION_BIG, emb_selection_big, emb_dark_selection_big)
|
||||
break;
|
||||
//next icons have no dark image
|
||||
case BUILTIN_ICON_POINTER:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_POINTER, emb_pointer)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL, emb_vol_internal)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_EXTERNAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_EXTERNAL, emb_vol_external)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_OPTICAL:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_OPTICAL, emb_vol_optical)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_BOOTER:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_BOOTER, emb_vol_internal_booter)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_HFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_HFS, emb_vol_internal_hfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_APFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_APFS, emb_vol_internal_apfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_NTFS:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_NTFS, emb_vol_internal_ntfs)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_EXT3:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_EXT3, emb_vol_internal_ext)
|
||||
break;
|
||||
case BUILTIN_ICON_VOL_INTERNAL_REC:
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_VOL_INTERNAL_REC, emb_vol_internal_recovery)
|
||||
break;
|
||||
case BUILTIN_RADIO_BUTTON:
|
||||
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON, emb_radio_button)
|
||||
break;
|
||||
case BUILTIN_RADIO_BUTTON_SELECTED:
|
||||
DEC_BUILTIN_ICON(BUILTIN_RADIO_BUTTON_SELECTED, emb_radio_button_selected)
|
||||
break;
|
||||
case BUILTIN_CHECKBOX:
|
||||
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX, emb_checkbox)
|
||||
break;
|
||||
case BUILTIN_CHECKBOX_CHECKED:
|
||||
DEC_BUILTIN_ICON(BUILTIN_CHECKBOX_CHECKED, emb_checkbox_checked)
|
||||
break;
|
||||
case BUILTIN_ICON_SELECTION:
|
||||
Name.takeValueFrom("selection_indicator");
|
||||
DEC_BUILTIN_ICON(BUILTIN_ICON_SELECTION, emb_selection_indicator)
|
||||
break;
|
||||
default:
|
||||
// Image.setEmpty(); //done by ctor?
|
||||
break;
|
||||
}
|
||||
//something to do else?
|
||||
}
|
||||
|
||||
XIcon::~XIcon() {}
|
||||
|
||||
//copy from XImage for our purpose
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const char* IconName)
|
||||
{
|
||||
return LoadXImage(BaseDir, XStringW().takeValueFrom(IconName));
|
||||
}
|
||||
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const wchar_t* LIconName)
|
||||
{
|
||||
return LoadXImage(BaseDir, XStringW().takeValueFrom(LIconName));
|
||||
}
|
||||
//dont call this procedure for SVG theme BaseDir == NULL?
|
||||
//it can be used for other files
|
||||
EFI_STATUS XIcon::LoadXImage(EFI_FILE *BaseDir, const XStringW& IconName)
|
||||
{
|
||||
EFI_STATUS Status = Image.LoadXImage(BaseDir, IconName);
|
||||
ImageNight.LoadXImage(BaseDir, IconName + L"_night"_XSW);
|
||||
if (!EFI_ERROR(Status)) setFilled();
|
||||
return Status;
|
||||
}
|
||||
|
||||
XImage* XIcon::GetBest(bool night, bool *free)
|
||||
{
|
||||
#if 1
|
||||
if (ImageSVG) {
|
||||
NSVGimage* sImage = (NSVGimage*)ImageSVGnight;
|
||||
if (!night || !ImageSVGnight) sImage = (NSVGimage*)ImageSVG;
|
||||
float Scale = sImage->scale;
|
||||
NSVGrasterizer* rast = nsvgCreateRasterizer();
|
||||
float Height = sImage->height * Scale;
|
||||
float Width = sImage->width * Scale;
|
||||
int iWidth = (int)(Width + 0.5f);
|
||||
int iHeight = (int)(Height + 0.5f);
|
||||
XImage* NewImage = new XImage(iWidth, iHeight); //TODO creating new XImage we have to delete it after use
|
||||
if (sImage->shapes == NULL) {
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
float bounds[4];
|
||||
nsvg__imageBounds(sImage, bounds);
|
||||
|
||||
float tx = 0.f, ty = 0.f;
|
||||
float realWidth = (bounds[2] - bounds[0]) * Scale;
|
||||
float realHeight = (bounds[3] - bounds[1]) * Scale;
|
||||
tx = (Width - realWidth) * 0.5f;
|
||||
ty = (Height - realHeight) * 0.5f;
|
||||
|
||||
nsvgRasterize(rast, sImage, tx, ty, Scale, Scale, (UINT8*)NewImage->GetPixelPtr(0,0), iWidth, iHeight, iWidth*4);
|
||||
nsvgDeleteRasterizer(rast);
|
||||
// if (night) ImageNight = *NewImage;
|
||||
// else Image = *NewImage;
|
||||
// delete NewImage;
|
||||
if (free) *free = true;
|
||||
return NewImage;
|
||||
}
|
||||
#endif
|
||||
XImage* RetImage = (night && !ImageNight.isEmpty())? &ImageNight : &Image;
|
||||
if (free) *free = false;
|
||||
return RetImage;
|
||||
}
|
||||
|
||||
//xtheme class
|
||||
XTheme::XTheme() {
|
||||
XTheme::XTheme() : Icons(), ThemeDir(0), HideBadges(0), HideUIFlags(0), Font(FONT_ALFA), CharWidth(0), SelectionColor(0), FontFileName(),
|
||||
BannerFileName(), SelectionSmallFileName(), SelectionBigFileName(), SelectionIndicatorName(), DefaultSelection(),
|
||||
BackgroundName(), BackgroundScale(imNone), BackgroundSharp(0), BackgroundDark(0), SelectionOnTop(0), BootCampStyle(0),
|
||||
BadgeOffsetX(0), BadgeOffsetY(0), BadgeScale(0), ThemeDesignWidth(0), ThemeDesignHeight(0), BannerPosX(0), BannerPosY(0),
|
||||
BannerEdgeHorizontal(0), BannerEdgeVertical(0), BannerNudgeX(0), BannerNudgeY(0), VerticalLayout(0), NonSelectedGrey(0),
|
||||
MainEntriesSize(0), TileXSpace(0), TileYSpace(0), Proportional(0), embedded(0), DarkEmbedded(0), TypeSVG(0), Scale(0), CentreShift(0),
|
||||
row0TileSize(0), row1TileSize(0), BanHeight(0), LayoutHeight(0), LayoutBannerOffset(0), LayoutButtonOffset(0), LayoutTextOffset(0),
|
||||
LayoutAnimMoveForMenuX(0), ScrollWidth(0), ScrollButtonsHeight(0), ScrollBarDecorationsHeight(0), ScrollScrollDecorationsHeight(0),
|
||||
FontWidth(0), FontHeight(0), TextHeight(0), Daylight(0), Background(), BigBack(), Banner(), SelectionImages(), Buttons(), ScrollbarBackgroundImage(), BarStartImage(), BarEndImage(),
|
||||
ScrollbarImage(), ScrollStartImage(), ScrollEndImage(), UpButtonImage(), DownButtonImage(), FontImage(), BannerPlace(), Cinema(), SVGParser(0)
|
||||
{
|
||||
Init();
|
||||
}
|
||||
|
||||
|
@ -6,44 +6,11 @@
|
||||
#include "libeg.h"
|
||||
//#include "nanosvg.h"
|
||||
#include "XImage.h"
|
||||
#include "XIcon.h"
|
||||
#include "XCinema.h"
|
||||
|
||||
extern const INTN IconsNamesSize;
|
||||
#define INDICATOR_SIZE (52)
|
||||
|
||||
class XIcon
|
||||
{
|
||||
public:
|
||||
INTN Id; //for example BUILTIN_ICON_POINTER
|
||||
XString8 Name; //for example "os_moja", "vol_internal"
|
||||
XImage Image;
|
||||
XImage ImageNight;
|
||||
bool Native;
|
||||
void *ImageSVG; //NSVGimage*
|
||||
void *ImageSVGnight;
|
||||
protected:
|
||||
bool Empty;
|
||||
public:
|
||||
XIcon(): Id(0), Name(), Image(), ImageNight(), Native(false), ImageSVG(nullptr), ImageSVGnight(nullptr), Empty(true)
|
||||
{};
|
||||
XIcon(INTN Id, bool Embedded = false);
|
||||
~XIcon();
|
||||
|
||||
bool isEmpty() const { return Empty; }
|
||||
void setFilled() { Empty = false; }
|
||||
void setEmpty() { Empty = true; }
|
||||
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const XStringW& FileName); //for example LoadImage(ThemeDir, L"icons\\" + Name);
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const wchar_t* LIconName);
|
||||
EFI_STATUS LoadXImage(EFI_FILE *Dir, const char* IconName);
|
||||
|
||||
// Default are not valid, as usual. We delete them. If needed, proper ones can be created
|
||||
// Icon(const Icon&) = delete;
|
||||
XIcon& operator=(const XIcon&); // = delete;
|
||||
void GetEmbedded();
|
||||
XImage* GetBest(bool night, bool *free = nullptr);
|
||||
};
|
||||
|
||||
class XTheme
|
||||
{
|
||||
public:
|
||||
@ -138,6 +105,15 @@ public:
|
||||
XCinema Cinema;
|
||||
|
||||
void *SVGParser;
|
||||
|
||||
void Init();
|
||||
XTheme(); //default constructor
|
||||
XTheme(const XTheme&) = delete;
|
||||
XTheme& operator=(const XTheme&) = delete;
|
||||
|
||||
~XTheme();
|
||||
|
||||
|
||||
//fill the theme
|
||||
// const XImage& GetIcon(const char* Name);
|
||||
// const XImage& GetIcon(const CHAR16* Name);
|
||||
@ -178,10 +154,6 @@ public:
|
||||
// void InitSelection();
|
||||
void InitBar();
|
||||
|
||||
void Init();
|
||||
XTheme(); //default constructor
|
||||
~XTheme();
|
||||
|
||||
protected:
|
||||
//internal layout variables instead of globals in menu.cpp
|
||||
|
||||
|
@ -248,7 +248,7 @@ public:
|
||||
XStringW IconName;
|
||||
XStringW Name;
|
||||
|
||||
LEGACY_OS() : Type(0) {}
|
||||
LEGACY_OS() : Type(0), IconName(), Name() {}
|
||||
LEGACY_OS(const LEGACY_OS& other) = delete; // Can be defined if needed
|
||||
const LEGACY_OS& operator = ( const LEGACY_OS & ) = delete; // Can be defined if needed
|
||||
~LEGACY_OS() {}
|
||||
@ -282,9 +282,9 @@ public:
|
||||
XString8 ApfsFileSystemUUID; // apfs file system UUID of that partition. It's not the UUID of subfolder like in Preboot.
|
||||
XString8Array ApfsTargetUUIDArray; // this is the array of folders that are named as UUID
|
||||
|
||||
REFIT_VOLUME() : DevicePath(0), DeviceHandle(0), RootDir(0), DiskKind(0), LegacyOS(0), Hidden(0), BootType(0), IsAppleLegacy(0), HasBootCode(0),
|
||||
REFIT_VOLUME() : DevicePath(0), DeviceHandle(0), RootDir(0), DevicePathString(), VolName(), VolLabel(), DiskKind(0), LegacyOS(0), Hidden(0), BootType(0), IsAppleLegacy(0), HasBootCode(0),
|
||||
IsMbrPartition(0), MbrPartitionIndex(0), BlockIO(0), BlockIOOffset(0), WholeDiskBlockIO(0), WholeDiskDevicePath(0), WholeDiskDeviceHandle(0),
|
||||
MbrPartitionTable(0), DriveCRC32(0), RootUUID({0,0,0,{0,0,0,0,0,0,0,0}}), SleepImageOffset(0)
|
||||
MbrPartitionTable(0), DriveCRC32(0), RootUUID({0,0,0,{0,0,0,0,0,0,0,0}}), SleepImageOffset(0), ApfsFileSystemUUID(), ApfsTargetUUIDArray()
|
||||
{}
|
||||
REFIT_VOLUME(const REFIT_VOLUME& other) = delete; // Can be defined if needed
|
||||
const REFIT_VOLUME& operator = ( const REFIT_VOLUME & ) = delete; // Can be defined if needed
|
||||
@ -313,9 +313,9 @@ public:
|
||||
CHAR8 *MatchBuild;
|
||||
INPUT_ITEM MenuItem;
|
||||
|
||||
KEXT_PATCH() : Name(0), Label(0), IsPlistPatch(0), DataLen(0), Data(0), Patch(0), MaskFind(0), MaskReplace(0),
|
||||
StartPattern(0), StartMask(0), StartPatternLen(0), SearchLen(0), ProcedureName(0), MatchOS(0), MatchBuild(0)
|
||||
{ memset(align, 0, sizeof(align)); }
|
||||
KEXT_PATCH() : Name(0), Label(0), IsPlistPatch(0), align{0}, DataLen(0), Data(0), Patch(0), MaskFind(0), MaskReplace(0),
|
||||
StartPattern(0), StartMask(0), StartPatternLen(0), SearchLen(0), ProcedureName(0), MatchOS(0), MatchBuild(0), MenuItem()
|
||||
{ }
|
||||
KEXT_PATCH(const KEXT_PATCH& other) = delete; // Can be defined if needed
|
||||
const KEXT_PATCH& operator = ( const KEXT_PATCH & ) = delete; // Can be defined if needed
|
||||
~KEXT_PATCH() {}
|
||||
@ -340,15 +340,16 @@ public:
|
||||
INPUT_ITEM MenuItem;
|
||||
|
||||
KERNEL_PATCH() : Label(0), DataLen(0), Data(0), Patch(0), MaskFind(0), MaskReplace(0), StartPattern(0), StartMask(0),
|
||||
StartPatternLen(0), SearchLen(0), ProcedureName(0), Count(0), MatchOS(0), MatchBuild(0)
|
||||
StartPatternLen(0), SearchLen(0), ProcedureName(0), Count(0), MatchOS(0), MatchBuild(0), MenuItem()
|
||||
{ }
|
||||
KERNEL_PATCH(const KERNEL_PATCH& other) = delete; // Can be defined if needed
|
||||
const KERNEL_PATCH& operator = ( const KERNEL_PATCH & ) = delete; // Can be defined if needed
|
||||
~KERNEL_PATCH() {}
|
||||
} ;
|
||||
|
||||
typedef struct KERNEL_AND_KEXT_PATCHES
|
||||
class KERNEL_AND_KEXT_PATCHES
|
||||
{
|
||||
public:
|
||||
BOOLEAN KPDebug;
|
||||
// BOOLEAN KPKernelCpu;
|
||||
BOOLEAN KPKernelLapic;
|
||||
@ -399,7 +400,16 @@ typedef struct KERNEL_AND_KEXT_PATCHES
|
||||
INT32 NrBoots;
|
||||
KERNEL_PATCH *BootPatches;
|
||||
|
||||
} KERNEL_AND_KEXT_PATCHES;
|
||||
KERNEL_AND_KEXT_PATCHES() : KPDebug(0), KPKernelLapic(0), KPKernelXCPM(0), KPKernelPm(0), KPAppleIntelCPUPM(0), KPAppleRTC(0), KPDELLSMBIOS(0), KPPanicNoKextDump(0),
|
||||
EightApple(0), pad{0}, FakeCPUID(0), KPATIConnectorsController(0), KPATIConnectorsData(0), KPATIConnectorsDataLen(0),
|
||||
KPATIConnectorsPatch(0), NrKexts(0), align40(0), KextPatches(0), NrForceKexts(0), align50(0), ForceKexts(),
|
||||
NrKernels(0), KernelPatches(0), NrBoots(0), BootPatches(0)
|
||||
{ }
|
||||
KERNEL_AND_KEXT_PATCHES(const KERNEL_AND_KEXT_PATCHES& other) = delete; // Can be defined if needed
|
||||
const KERNEL_AND_KEXT_PATCHES& operator = ( const KERNEL_AND_KEXT_PATCHES & ) = delete; // Can be defined if needed
|
||||
~KERNEL_AND_KEXT_PATCHES() {}
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
|
||||
@ -443,8 +453,8 @@ public:
|
||||
INTN Height;
|
||||
|
||||
EG_RECT() : XPos(0), YPos(0), Width(0), Height(0) {};
|
||||
EG_RECT(INTN x, INTN y, INTN w, INTN h) { XPos = x; YPos = y; Width = w; Height = h; }
|
||||
EG_RECT(const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; }
|
||||
EG_RECT(INTN x, INTN y, INTN w, INTN h) : XPos(x), YPos(y), Width(w), Height(h) { }
|
||||
EG_RECT(const EG_RECT& other) : XPos(other.XPos), YPos(other.YPos), Width(other.Width), Height(other.Height) { }
|
||||
const EG_RECT& operator = (const EG_RECT& other) { XPos = other.XPos; YPos = other.YPos; Width = other.Width; Height = other.Height; return *this; }
|
||||
bool operator == (const EG_RECT& other) { return XPos == other.XPos && YPos == other.YPos && Width == other.Width && Height == other.Height; }
|
||||
bool operator != (const EG_RECT& other) { return !(*this == other); }
|
||||
|
@ -105,6 +105,8 @@
|
||||
libeg/libegint.h
|
||||
libeg/XImage.cpp
|
||||
libeg/XImage.h
|
||||
libeg/XIcon.cpp
|
||||
libeg/XIcon.h
|
||||
libeg/XPointer.cpp
|
||||
libeg/XPointer.h
|
||||
libeg/XTheme.cpp
|
||||
@ -241,6 +243,10 @@
|
||||
cpp_foundation/unicode_conversions.cpp
|
||||
cpp_foundation/unicode_conversions.h
|
||||
cpp_foundation/XArray.h
|
||||
cpp_foundation/XBuffer.cpp
|
||||
cpp_foundation/XBuffer.h
|
||||
cpp_foundation/XRBuffer.cpp
|
||||
cpp_foundation/XRBuffer.h
|
||||
cpp_foundation/XObjArray.h
|
||||
cpp_foundation/XStringAbstract.h
|
||||
cpp_foundation/XString.cpp
|
||||
|
@ -415,89 +415,89 @@ VOID DumpKernelAndKextPatches(KERNEL_AND_KEXT_PATCHES *Patches)
|
||||
#endif
|
||||
VOID LOADER_ENTRY::FilterKextPatches()
|
||||
{
|
||||
if (gSettings.KextPatchesAllowed && (KernelAndKextPatches->KextPatches != NULL) && (KernelAndKextPatches->NrKexts != 0)) {
|
||||
if (gSettings.KextPatchesAllowed && (KernelAndKextPatches.KextPatches != NULL) && (KernelAndKextPatches.NrKexts != 0)) {
|
||||
DBG("Filtering KextPatches:\n");
|
||||
for (INTN i = 0; i < KernelAndKextPatches->NrKexts; i++) {
|
||||
for (INTN i = 0; i < KernelAndKextPatches.NrKexts; i++) {
|
||||
DBG(" - [%02lld]: %s :: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]",
|
||||
i,
|
||||
KernelAndKextPatches->KextPatches[i].Label,
|
||||
KernelAndKextPatches->KextPatches[i].IsPlistPatch ? "PlistPatch" : "BinPatch",
|
||||
KernelAndKextPatches.KextPatches[i].Label,
|
||||
KernelAndKextPatches.KextPatches[i].IsPlistPatch ? "PlistPatch" : "BinPatch",
|
||||
OSVersion,
|
||||
KernelAndKextPatches->KextPatches[i].MatchOS ? KernelAndKextPatches->KextPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches->KextPatches[i].MatchBuild != NULL ? KernelAndKextPatches->KextPatches[i].MatchBuild : "All"
|
||||
KernelAndKextPatches.KextPatches[i].MatchOS ? KernelAndKextPatches.KextPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches.KextPatches[i].MatchBuild != NULL ? KernelAndKextPatches.KextPatches[i].MatchBuild : "All"
|
||||
);
|
||||
if (!KernelAndKextPatches->KextPatches[i].MenuItem.BValue) {
|
||||
if (!KernelAndKextPatches.KextPatches[i].MenuItem.BValue) {
|
||||
DBG(" ==> disabled by user\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches->KextPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches->KextPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->KextPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s\n", KernelAndKextPatches->KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches.KextPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches.KextPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.KextPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
continue;
|
||||
}
|
||||
|
||||
KernelAndKextPatches->KextPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->KextPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s\n", KernelAndKextPatches->KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
KernelAndKextPatches.KextPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.KextPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s\n", KernelAndKextPatches.KextPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID LOADER_ENTRY::FilterKernelPatches()
|
||||
{
|
||||
if (gSettings.KernelPatchesAllowed && (KernelAndKextPatches->KernelPatches != NULL) && KernelAndKextPatches->NrKernels) {
|
||||
if (gSettings.KernelPatchesAllowed && (KernelAndKextPatches.KernelPatches != NULL) && KernelAndKextPatches.NrKernels) {
|
||||
INTN i = 0;
|
||||
DBG("Filtering KernelPatches:\n");
|
||||
for (; i < KernelAndKextPatches->NrKernels; ++i) {
|
||||
for (; i < KernelAndKextPatches.NrKernels; ++i) {
|
||||
DBG(" - [%02lld]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]",
|
||||
i,
|
||||
KernelAndKextPatches->KernelPatches[i].Label,
|
||||
KernelAndKextPatches.KernelPatches[i].Label,
|
||||
OSVersion,
|
||||
KernelAndKextPatches->KernelPatches[i].MatchOS ? KernelAndKextPatches->KernelPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches->KernelPatches[i].MatchBuild != NULL ? KernelAndKextPatches->KernelPatches[i].MatchBuild : "no"
|
||||
KernelAndKextPatches.KernelPatches[i].MatchOS ? KernelAndKextPatches.KernelPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches.KernelPatches[i].MatchBuild != NULL ? KernelAndKextPatches.KernelPatches[i].MatchBuild : "no"
|
||||
);
|
||||
if (!KernelAndKextPatches->KernelPatches[i].MenuItem.BValue) {
|
||||
if (!KernelAndKextPatches.KernelPatches[i].MenuItem.BValue) {
|
||||
DBG(" ==> disabled by user\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches->KernelPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches->KernelPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->KernelPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s by build\n", KernelAndKextPatches->KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches.KernelPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.KernelPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s by build\n", KernelAndKextPatches.KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
continue;
|
||||
}
|
||||
|
||||
KernelAndKextPatches->KernelPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->KernelPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s by OS\n", KernelAndKextPatches->KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
KernelAndKextPatches.KernelPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.KernelPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s by OS\n", KernelAndKextPatches.KernelPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VOID LOADER_ENTRY::FilterBootPatches()
|
||||
{
|
||||
if ((KernelAndKextPatches->BootPatches != NULL) && KernelAndKextPatches->NrBoots) {
|
||||
if ((KernelAndKextPatches.BootPatches != NULL) && KernelAndKextPatches.NrBoots) {
|
||||
DBG("Filtering BootPatches:\n");
|
||||
for (INTN i = 0; i < KernelAndKextPatches->NrBoots; ++i) {
|
||||
for (INTN i = 0; i < KernelAndKextPatches.NrBoots; ++i) {
|
||||
DBG(" - [%02lld]: %s :: [OS: %s | MatchOS: %s | MatchBuild: %s]",
|
||||
i,
|
||||
KernelAndKextPatches->BootPatches[i].Label,
|
||||
KernelAndKextPatches.BootPatches[i].Label,
|
||||
OSVersion,
|
||||
KernelAndKextPatches->BootPatches[i].MatchOS ? KernelAndKextPatches->BootPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches->BootPatches[i].MatchBuild != NULL ? KernelAndKextPatches->BootPatches[i].MatchBuild : "no"
|
||||
KernelAndKextPatches.BootPatches[i].MatchOS ? KernelAndKextPatches.BootPatches[i].MatchOS : "All",
|
||||
KernelAndKextPatches.BootPatches[i].MatchBuild != NULL ? KernelAndKextPatches.BootPatches[i].MatchBuild : "no"
|
||||
);
|
||||
if (!KernelAndKextPatches->BootPatches[i].MenuItem.BValue) {
|
||||
if (!KernelAndKextPatches.BootPatches[i].MenuItem.BValue) {
|
||||
DBG(" ==> disabled by user\n");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches->BootPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches->BootPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->BootPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s by build\n", KernelAndKextPatches->BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
if ((BuildVersion != NULL) && (KernelAndKextPatches.BootPatches[i].MatchBuild != NULL)) {
|
||||
KernelAndKextPatches.BootPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.BootPatches[i].MatchBuild, BuildVersion);
|
||||
DBG(" ==> %s by build\n", KernelAndKextPatches.BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
continue;
|
||||
}
|
||||
|
||||
KernelAndKextPatches->BootPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches->BootPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s by OS\n", KernelAndKextPatches->BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
KernelAndKextPatches.BootPatches[i].MenuItem.BValue = IsPatchEnabled(KernelAndKextPatches.BootPatches[i].MatchOS, OSVersion);
|
||||
DBG(" ==> %s by OS\n", KernelAndKextPatches.BootPatches[i].MenuItem.BValue ? "allowed" : "not allowed");
|
||||
|
||||
}
|
||||
}
|
||||
@ -778,7 +778,7 @@ VOID LOADER_ENTRY::StartLoader()
|
||||
PatchACPI(Volume, OSVersion);
|
||||
|
||||
// If KPDebug is true boot in verbose mode to see the debug messages
|
||||
if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPDebug) {
|
||||
if (KernelAndKextPatches.KPDebug) {
|
||||
LoadOptions.AddID("-v"_XS8);
|
||||
}
|
||||
|
||||
@ -815,7 +815,7 @@ VOID LOADER_ENTRY::StartLoader()
|
||||
/**
|
||||
* syscl - append "-xcpm" argument conditionally if set KernelXCPM on Intel Haswell+ low-end CPUs
|
||||
*/
|
||||
if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPKernelXCPM &&
|
||||
if (KernelAndKextPatches.KPKernelXCPM &&
|
||||
gCPUStructure.Vendor == CPU_VENDOR_INTEL && gCPUStructure.Model >= CPU_MODEL_HASWELL &&
|
||||
(AsciiStrStr(gCPUStructure.BrandString, "Celeron") || AsciiStrStr(gCPUStructure.BrandString, "Pentium")) &&
|
||||
(AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
|
||||
@ -826,7 +826,7 @@ VOID LOADER_ENTRY::StartLoader()
|
||||
}
|
||||
|
||||
// add -xcpm on Ivy Bridge if set KernelXCPM and system version is 10.8.5 - 10.11.x
|
||||
if ((KernelAndKextPatches != NULL) && KernelAndKextPatches->KPKernelXCPM &&
|
||||
if (KernelAndKextPatches.KPKernelXCPM &&
|
||||
gCPUStructure.Model == CPU_MODEL_IVY_BRIDGE &&
|
||||
(AsciiOSVersionToUint64(OSVersion) >= AsciiOSVersionToUint64("10.8.5")) &&
|
||||
(AsciiOSVersionToUint64(OSVersion) < AsciiOSVersionToUint64("10.12")) &&
|
||||
@ -1853,7 +1853,6 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
}
|
||||
construct_globals_objects(gImageHandle); // do this after SelfLoadedImage is initialized
|
||||
|
||||
|
||||
gRT->GetTime(&Now, NULL);
|
||||
|
||||
// firmware detection
|
||||
@ -1920,7 +1919,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
|
||||
// disable EFI watchdog timer
|
||||
gBS->SetWatchdogTimer(0x0000, 0x0000, 0x0000, NULL);
|
||||
ZeroMem((VOID*)&gSettings, sizeof(SETTINGS_DATA));
|
||||
// ZeroMem((VOID*)&gSettings, sizeof(SETTINGS_DATA));
|
||||
|
||||
Status = InitializeUnicodeCollationProtocol();
|
||||
if (EFI_ERROR(Status)) {
|
||||
|
Loading…
Reference in New Issue
Block a user