├── .github ├── FUNDING.yml ├── dependabot.yml └── workflows │ └── main.yml ├── .gitmodules ├── README.md ├── ForgedInvariant ├── Plugin.cpp ├── TSCSyncer.hpp ├── Info.plist └── TSCSyncer.cpp ├── .gitignore ├── CHANGELOG.md ├── .clang-format ├── LICENSE └── ForgedInvariant.xcodeproj └── project.pbxproj /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | ko_fi: chefkiss 2 | custom: "https://www.blockchain.com/explorer/addresses/btc/bc1qgu56kptepex2csuzl5nhzc4vxuj8c6ggjzhcem" 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: "github-actions" 4 | directory: "/" 5 | schedule: 6 | interval: "daily" 7 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "MacKernelSDK"] 2 | path = MacKernelSDK 3 | url = https://github.com/Acidanthera/MacKernelSDK.git 4 | [submodule "Lilu"] 5 | path = Lilu 6 | url = https://github.com/acidanthera/Lilu 7 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ForgedInvariant ![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/ChefKissInc/ForgedInvariant/main.yml?branch=master&logo=github&style=for-the-badge) 2 | 3 | The plug & play kext for syncing the TSC on AMD & Intel. 4 | 5 | The ForgedInvariant project is Copyright © 2024-2025 ChefKiss. The ForgedInvariant project is licensed under the `Thou Shalt Not Profit License version 1.5`. See `LICENSE` 6 | 7 | Click [here](https://chefkiss.dev/applehax/forgedinvariant/) for more information. 8 | -------------------------------------------------------------------------------- /ForgedInvariant/Plugin.cpp: -------------------------------------------------------------------------------- 1 | // Copyright © 2024-2025 ChefKiss, licensed under the Thou Shalt Not Profit License version 1.5. 2 | // See LICENSE for details. 3 | 4 | #include "TSCSyncer.hpp" 5 | #include 6 | #include 7 | #include 8 | 9 | static const char *bootargOff = "-FIOff"; 10 | static const char *bootargDebug = "-FIDebug"; 11 | static const char *bootargBeta = "-FIBeta"; 12 | 13 | PluginConfiguration ADDPR(config) { 14 | xStringify(PRODUCT_NAME), 15 | parseModuleVersion(xStringify(MODULE_VERSION)), 16 | LiluAPI::AllowNormal | LiluAPI::AllowInstallerRecovery | LiluAPI::AllowSafeMode, 17 | &bootargOff, 18 | 1, 19 | &bootargDebug, 20 | 1, 21 | &bootargBeta, 22 | 1, 23 | KernelVersion::SnowLeopard, 24 | KernelVersion::Tahoe, 25 | []() { TSCForger::singleton().init(); }, 26 | }; 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .AppleDouble 3 | .LSOverride 4 | Icon 5 | 6 | 7 | ._* 8 | .DocumentRevisions-V100 9 | .fseventsd 10 | .Spotlight-V100 11 | .TemporaryItems 12 | .Trashes 13 | .VolumeIcon.icns 14 | .com.apple.timemachine.donotpresent 15 | .AppleDB 16 | .AppleDesktop 17 | Network Trash Folder 18 | Temporary Items 19 | .apdisk 20 | xcuserdata/ 21 | *.xcscmblueprint 22 | *.xccheckout 23 | build/ 24 | DerivedData/ 25 | *.moved-aside 26 | *.pbxuser 27 | !default.pbxuser 28 | *.mode1v3 29 | !default.mode1v3 30 | *.mode2v3 31 | !default.mode2v3 32 | *.perspectivev3 33 | !default.perspectivev3 34 | /*.gcno 35 | *.xcodeproj/* 36 | !*.xcodeproj/project.pbxproj 37 | !*.xcodeproj/xcshareddata/ 38 | !*.xcworkspace/contents.xcworkspacedata 39 | **/xcshareddata/WorkspaceSettings.xcsettings 40 | /Lilu.kext 41 | /PenguinAudio/Firmware.cpp 42 | .vscode/ 43 | .cache/ 44 | CompilationDatabase/ 45 | compile_commands.json 46 | clang_analyze 47 | -------------------------------------------------------------------------------- /ForgedInvariant/TSCSyncer.hpp: -------------------------------------------------------------------------------- 1 | // Copyright © 2024-2025 ChefKiss, licensed under the Thou Shalt Not Profit License version 1.5. 2 | // See LICENSE for details. 3 | 4 | #pragma once 5 | #include 6 | #include 7 | 8 | class TSCForger { 9 | atomic_bool systemAwake = ATOMIC_VAR_INIT(true); 10 | atomic_bool synchronising = ATOMIC_VAR_INIT(false); 11 | atomic_bool synchronised = ATOMIC_VAR_INIT(false); 12 | atomic_int threadsEngaged = ATOMIC_VAR_INIT(0); 13 | atomic_ullong targetTSC = ATOMIC_VAR_INIT(0); 14 | 15 | union { 16 | struct { 17 | bool tscAdjust : 1; 18 | bool amd17h : 1; 19 | UInt8 _rsvd : 6; 20 | }; 21 | UInt8 raw {0}; 22 | } caps {}; 23 | 24 | int threadCount {0}; 25 | mach_vm_address_t orgXcpmUrgency {0}; 26 | mach_vm_address_t orgTracePoint {0}; 27 | mach_vm_address_t orgClockGetCalendarMicrotime {0}; 28 | IOTimerEventSource *timer {nullptr}; 29 | 30 | static void resetAdjust(void *); 31 | void lockFreq(); 32 | static void sync(void *); 33 | 34 | static void wrapXcpmUrgency(int urgency, UInt64 rtPeriod, UInt64 rtDeadline); 35 | static void wrapTracePoint(void *that, UInt8 point); 36 | static void wrapClockGetCalendarMicrotime(clock_sec_t *secs, clock_usec_t *microsecs); 37 | 38 | void processPatcher(KernelPatcher &patcher); 39 | 40 | void startTimer(); 41 | void stopTimer(); 42 | 43 | static void timerAction(OSObject *owner, IOTimerEventSource *timer); 44 | 45 | void syncAll(bool timer = false); 46 | 47 | public: 48 | static TSCForger &singleton(); 49 | 50 | void init(); 51 | }; 52 | -------------------------------------------------------------------------------- /.github/workflows/main.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | release: 8 | types: [published] 9 | 10 | jobs: 11 | build: 12 | name: Build 13 | runs-on: macos-latest 14 | permissions: 15 | contents: write 16 | env: 17 | JOB_TYPE: BUILD 18 | steps: 19 | - uses: actions/checkout@v6 20 | with: 21 | submodules: "recursive" 22 | - run: xcodebuild -configuration Debug -arch x86_64 build 23 | - run: xcodebuild -configuration Release -arch x86_64 build 24 | - name: Upload to Artifacts 25 | uses: actions/upload-artifact@v6 26 | with: 27 | name: Artifacts 28 | path: build/*/*.zip 29 | - name: Upload build 30 | uses: svenstaro/upload-release-action@2.11.3 31 | if: github.event_name == 'release' 32 | with: 33 | repo_token: ${{ secrets.GITHUB_TOKEN }} 34 | file: build/*/*.zip 35 | tag: ${{ github.ref }} 36 | file_glob: true 37 | overwrite: true 38 | 39 | analyse-clang: 40 | name: Analyse Clang 41 | runs-on: macos-latest 42 | env: 43 | JOB_TYPE: ANALYZE 44 | steps: 45 | - uses: actions/checkout@v6 46 | with: 47 | submodules: "recursive" 48 | - run: xcodebuild analyze -quiet -scheme ForgedInvariant -configuration Debug -arch x86_64 CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang-analyze" && [ "$(find clang-analyze -name "*.html")" = "" ] 49 | - run: xcodebuild analyze -quiet -scheme ForgedInvariant -configuration Release -arch x86_64 CLANG_ANALYZER_OUTPUT=plist-html CLANG_ANALYZER_OUTPUT_DIR="$(pwd)/clang-analyze" && [ "$(find clang-analyze -name "*.html")" = "" ] 50 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## v1.5.0 (21/11/2025) 4 | 5 | ### Bug Fixes 6 | 7 | - Sync TSC to the max value found through all threads. 8 | - Sync TSC early on processPatcher instead of IOService::start. 9 | 10 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.4.0...v1.5.0 11 | 12 | ## v1.4.0 (20/11/2025) 13 | 14 | ### Enhancements 15 | 16 | - Sync TSC early (on ForgedInvariant IOService start). 17 | 18 | ### Bug Fixes 19 | 20 | - On Intel, reset TSC_ADJUST of all CPUs at the same time. 21 | 22 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.3.0...v1.4.0 23 | 24 | ## v1.3.0 (14/11/2025) 25 | 26 | ### Enhancements 27 | 28 | - Sync to last thread on all macOS versions. 29 | - On Intel, always reset TSC_ADJUST if available. 30 | - Code cleanup. 31 | - Store capabilities using bitfield. 32 | - New boot args: `-FITSCPeriodic` to force periodic sync, `-FIOff`, `-FIBeta`. 33 | 34 | ### Bug Fixes 35 | 36 | - Check for TSC_ADJUST only on Intel. 37 | 38 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.2.0...v1.3.0 39 | 40 | ## v1.2.0 (15/06/2025) 41 | 42 | ### Enhancements 43 | 44 | - Tahoe support. 45 | 46 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.1.0...v1.2.0 47 | 48 | ## v1.1.0 (15/03/2025) 49 | 50 | ### Enhancements 51 | 52 | - Lowered minimum macOS version to `10.6`. 53 | 54 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.0.1...v1.1.0 55 | 56 | ## v1.0.1 (31/12/2024) 57 | 58 | ### Bug Fixes 59 | 60 | - Fixed a code bug causing syncTimer to be null, causing ForgedInvariant's periodic fallback to be dysfunctional. 61 | 62 | **Full Changelog**: https://github.com/ChefKissInc/ForgedInvariant/compare/v1.0.0...v1.0.1 63 | 64 | ## v1.0.0 (27/11/2024) 65 | 66 | ## 🎉 Initial release! 67 | 68 | Supports all 64-bit Intel and AMD CPUs, from El Capitan up to Sequoia. 69 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | AccessModifierOffset: 0 2 | AlignAfterOpenBracket: DontAlign 3 | AlignConsecutiveMacros: true 4 | AlignConsecutiveAssignments: false 5 | AlignConsecutiveDeclarations: false 6 | AlignEscapedNewlines: Left 7 | AlignOperands: true 8 | AlignTrailingComments: true 9 | AllowAllArgumentsOnNextLine: false 10 | AllowAllConstructorInitializersOnNextLine: true 11 | AllowAllParametersOfDeclarationOnNextLine: false 12 | AllowShortBlocksOnASingleLine: true 13 | AllowShortCaseLabelsOnASingleLine: false 14 | AllowShortFunctionsOnASingleLine: All 15 | AllowShortIfStatementsOnASingleLine: Always 16 | AllowShortLambdasOnASingleLine: All 17 | AllowShortLoopsOnASingleLine: true 18 | AlwaysBreakAfterReturnType: None 19 | AlwaysBreakBeforeMultilineStrings: false 20 | AlwaysBreakTemplateDeclarations: Yes 21 | BinPackArguments: true 22 | BinPackParameters: true 23 | BreakBeforeBinaryOperators: None 24 | BreakBeforeBraces: Attach 25 | BreakBeforeTernaryOperators: false 26 | BreakConstructorInitializers: BeforeColon 27 | BreakInheritanceList: BeforeColon 28 | BreakStringLiterals: true 29 | ColumnLimit: 120 30 | CompactNamespaces: false 31 | ConstructorInitializerAllOnOneLineOrOnePerLine: false 32 | ConstructorInitializerIndentWidth: 4 33 | ContinuationIndentWidth: 4 34 | Cpp11BracedListStyle: true 35 | DerivePointerAlignment: false 36 | DisableFormat: false 37 | FixNamespaceComments: true 38 | IncludeBlocks: Merge 39 | IndentCaseLabels: true 40 | IndentPPDirectives: BeforeHash 41 | IndentWidth: 4 42 | IndentWrappedFunctionNames: true 43 | KeepEmptyLinesAtTheStartOfBlocks: false 44 | Language: Cpp 45 | NamespaceIndentation: All 46 | PointerAlignment: Right 47 | ReflowComments: true 48 | SortIncludes: true 49 | SortUsingDeclarations: true 50 | SpaceAfterCStyleCast: false 51 | SpaceAfterLogicalNot: false 52 | SpaceAfterTemplateKeyword: false 53 | SpaceBeforeAssignmentOperators: true 54 | SpaceBeforeCpp11BracedList: true 55 | SpaceBeforeCtorInitializerColon: true 56 | SpaceBeforeInheritanceColon: true 57 | SpaceBeforeParens: ControlStatements 58 | SpaceBeforeRangeBasedForLoopColon: true 59 | SpaceInEmptyParentheses: false 60 | SpacesBeforeTrailingComments: 4 61 | SpacesInAngles: false 62 | SpacesInCStyleCastParentheses: false 63 | SpacesInContainerLiterals: false 64 | SpacesInParentheses: false 65 | SpacesInSquareBrackets: false 66 | Standard: c++17 67 | UseTab: Never -------------------------------------------------------------------------------- /ForgedInvariant/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | KEXT 17 | CFBundleShortVersionString 18 | $(MODULE_VERSION) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(MODULE_VERSION) 23 | IOKitPersonalities 24 | 25 | ForgedInvariant 26 | 27 | CFBundleIdentifier 28 | $(PRODUCT_BUNDLE_IDENTIFIER) 29 | IOClass 30 | $(PRODUCT_NAME:rfc1034identifier) 31 | IOMatchCategory 32 | $(PRODUCT_NAME:rfc1034identifier) 33 | IOProviderClass 34 | IOResources 35 | IOResourceMatch 36 | IOKit 37 | 38 | 39 | NSHumanReadableCopyright 40 | Copyright © 2024-2025 ChefKiss. Licensed under the Thou Shalt Not Profit License version 1.5. See https://github.com/ChefKissInc/ForgedInvariant/LICENSE for details. 41 | OSBundleCompatibleVersion 42 | $(MODULE_VERSION) 43 | OSBundleLibraries 44 | 45 | as.vit9696.Lilu 46 | 1.2.0 47 | com.apple.iokit.IOACPIFamily 48 | 1.0.0d1 49 | com.apple.kpi.bsd 50 | 10.0.0 51 | com.apple.kpi.dsep 52 | 10.0.0 53 | com.apple.kpi.iokit 54 | 10.0.0 55 | com.apple.kpi.libkern 56 | 10.0.0 57 | com.apple.kpi.mach 58 | 10.0.0 59 | com.apple.kpi.unsupported 60 | 10.0.0 61 | 62 | OSBundleRequired 63 | Root 64 | 65 | 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Licensed under the Thou Shalt Not Profit License version 1.5 2 | 3 | 1) Grant of Copyright License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, for the duration of the copyright, to do the following: 4 | 5 | a) to reproduce the Original Work in copies, either alone or as part of a collective work; 6 | 7 | b) to translate, adapt, alter, transform, modify, or arrange the Original Work, thereby creating derivative works ("Derivative Works") based upon the Original Work; 8 | 9 | c) to distribute or communicate copies of the Original Work and Derivative Works to the public, with the proviso that copies of Original Work or Derivative Works that You distribute or communicate shall be licensed under this Thou Shalt Not Profit License; 10 | 11 | d) to perform the Original Work publicly; and 12 | 13 | e) to display the Original Work publicly. 14 | 15 | 2) Grant of Patent License. Licensor grants You a worldwide, royalty-free, non-exclusive, sublicensable license, under patent claims owned or controlled by the Licensor that are embodied in the Original Work as furnished by the Licensor, for the duration of the patents, to make, use, sell, offer for sale, have made, and import the Original Work and Derivative Works. 16 | 17 | 3) Grant of Source Code License. The term "Source Code" means the preferred form of the Original Work for making modifications to it and all available documentation describing how to modify the Original Work. Licensor agrees to provide a machine-readable copy of the Source Code of the Original Work along with each copy of the Original Work that Licensor distributes. Licensor reserves the right to satisfy this obligation by placing a machine-readable copy of the Source Code in an information repository reasonably calculated to permit inexpensive and convenient access by You for as long as Licensor continues to distribute the Original Work. 18 | 19 | 4) Exclusions From License Grant. Neither the names of Licensor, nor the names of any contributors to the Original Work, nor any of their trademarks or service marks, may be used to endorse or promote products derived from this Original Work without express prior permission of the Licensor. Except as expressly stated herein, nothing in this License grants any license to Licensor's trademarks, copyrights, patents, trade secrets or any other intellectual property. No patent license is granted to make, use, sell, offer for sale, have made, or import embodiments of any patent claims other than the licensed claims defined in Section 2. No license is granted to the trademarks of Licensor even if such marks are included in the Original Work. Nothing in this License shall be interpreted to prohibit Licensor from licensing under terms different from this License any Original Work that Licensor otherwise would have a right to license. 20 | 21 | 5) External Deployment. The term "External Deployment" means the use, distribution, or communication of the Original Work or Derivative Works in any way such that the Original Work or Derivative Works may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Work or a Derivative Work as a distribution under section 1(c). 22 | 23 | 6) Attribution Rights. You must retain, in the Source Code of any Derivative Works that You create, all copyright, patent, or trademark notices from the Source Code of the Original Work, as well as any notices of licensing and any descriptive text identified therein as an "Attribution Notice." You must cause the Source Code for any Derivative Works that You create to carry a prominent Attribution Notice reasonably calculated to inform recipients that You have modified the Original Work. 24 | 25 | 7) Warranty of Provenance and Disclaimer of Warranty. The Original Work is provided under this License on an "AS IS" BASIS and WITHOUT WARRANTY, either express or implied, including, without limitation, the warranties of non-infringement, merchantability or fitness for a particular purpose. THE ENTIRE RISK AS TO THE QUALITY OF THE ORIGINAL WORK IS WITH YOU. This DISCLAIMER OF WARRANTY constitutes an essential part of this License. No license to the Original Work is granted by this License except under this disclaimer. 26 | 27 | 8) Limitation of Liability. Under no circumstances and under no legal theory, whether in tort (including negligence), contract, or otherwise, shall the Licensor be liable to anyone for any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or the use of the Original Work including, without limitation, damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses. This limitation of liability shall not apply to the extent applicable law prohibits such limitation. 28 | 29 | 9) Acceptance and Termination. If, at any time, You expressly assented to this License, that assent indicates your clear and irrevocable acceptance of this License and all of its terms and conditions. If You distribute or communicate copies of the Original Work or a Derivative Work, You must make a reasonable effort under the circumstances to obtain the express assent of recipients to the terms of this License. This License conditions your rights to undertake the activities listed in Section 1, including your right to create Derivative Works based upon the Original Work, and doing so without honouring these terms and conditions is prohibited by copyright law and international treaty. Nothing in this License is intended to affect copyright exceptions and limitations (including "fair use" or "fair dealing"). This License shall terminate immediately and You may no longer exercise any of the rights granted to You by this License upon your failure to honour the conditions in Section 1(c). 30 | 31 | 10) Termination for Patent Action. This License shall terminate automatically and You may no longer exercise any of the rights granted to You by this License as of the date You commence an action, including a cross-claim or counterclaim, against Licensor or any licensee alleging that the Original Work infringes a patent. This termination provision shall not apply for an action alleging patent infringement by combinations of the Original Work with other software or hardware. 32 | 33 | 11) Jurisdiction, Venue and Governing Law. Any action or suit relating to this License may be brought only in the courts of a jurisdiction wherein the Licensor resides or in which Licensor conducts its primary business, and under the laws of that jurisdiction excluding its conflict-of-law provisions. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any use of the Original Work outside the scope of this License or after its termination shall be subject to the requirements and penalties of copyright or patent law in the appropriate jurisdiction. This section shall survive the termination of this License. 34 | 35 | 12) Attorneys' Fees. In any action to enforce the terms of this License or seeking damages relating thereto, the prevailing party shall be entitled to recover its costs and expenses, including, without limitation, reasonable attorneys' fees and costs incurred in connection with such action, including any appeal of such action. This section shall survive the termination of this License. 36 | 37 | 13) Miscellaneous. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. 38 | 39 | 14) Definition of "You" in This License. "You" throughout this License, whether in upper or lower case, means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, "You" includes any entity that controls, is controlled by, or is under common control with you. For purposes of this definition, "control" means 40 | (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or 41 | (ii) ownership of fifty percent (50%) or more of the outstanding shares, or 42 | (iii) beneficial ownership of such entity. 43 | 44 | 15) Right to Use. You may use the Original Work in all ways not otherwise restricted or conditioned by this License or by law, and Licensor promises not to interfere with or be responsible for such uses by You. 45 | 46 | 16) Modification of This License. This License is Copyright © 2023 ChefKiss Inc. Permission is granted to copy, distribute, or communicate this License without modification. Nothing in this License permits You to modify this License as applied to the Original Work or to Derivative Works. However, You may modify the text of this License and copy, distribute or communicate your modified version (the "Modified License") and apply it to other original works of authorship subject to the following conditions: 47 | (i) You may not indicate in any way that your Modified License is the "Thou Shalt Not Profit License" or "TSNPL" and you may not use those names in the name of your Modified License; and 48 | (ii) You must replace the notice specified in the first paragraph above with the notice "Licensed under " or with a notice of your own that is not confusingly similar to the notice in this License. 49 | 50 | 17) Non-Commercial Use. Non-Commercial means not primarily intended for or directed towards commercial advantage or monetary compensation. For purposes of this Thou Shalt Not Profit 1.5 license, the exchange of the Original Work or Derivative Works for other material subject to Copyright and Similar Rights by digital file-sharing or similar means is Non-Commercial provided there is no payment of monetary compensation in connection with the exchange. Licensor grants You the right to distribute or communicate the Original Work or Derivative Works thereof under this Thou Shalt Not Profit 1.5 license only under Non-Commercial purposes. Otherwise, You shall not distribute or communicate the Original Work or Derivative Works. 51 | -------------------------------------------------------------------------------- /ForgedInvariant/TSCSyncer.cpp: -------------------------------------------------------------------------------- 1 | // Copyright © 2024-2025 ChefKiss, licensed under the Thou Shalt Not Profit License version 1.5. 2 | // See LICENSE for details. 3 | 4 | #include "TSCSyncer.hpp" 5 | #include 6 | #include 7 | #include 8 | 9 | static constexpr UInt32 PERIODIC_SYNC_INTERVAL = 5000; 10 | 11 | static constexpr UInt32 CPUID_LEAF7_TSC_ADJUST = getBit(1); 12 | static constexpr UInt64 CPUID_FEATURE_HTT = getBit(28); 13 | 14 | static constexpr UInt32 MSR_TSC = 0x10; 15 | static constexpr UInt32 MSR_TSC_ADJUST = 0x3B; 16 | static constexpr UInt32 MSR_HWCR = 0xC0010015; 17 | static constexpr UInt64 MSR_HWCR_LOCK_TSC_TO_CURR_P0 = getBit(21); 18 | 19 | enum { 20 | kIOPMTracePointSleepCPUs = 0x18, 21 | kIOPMTracePointWakePlatformActions = 0x22, 22 | }; 23 | 24 | static TSCForger instance {}; 25 | 26 | TSCForger &TSCForger::singleton() { return instance; } 27 | 28 | void TSCForger::resetAdjust(void *) { 29 | atomic_fetch_add_explicit(&singleton().threadsEngaged, 1, memory_order_relaxed); 30 | while (atomic_load_explicit(&singleton().threadsEngaged, memory_order_relaxed) != singleton().threadCount) {} 31 | 32 | wrmsr64(MSR_TSC_ADJUST, 0); 33 | } 34 | 35 | void TSCForger::lockFreq() { 36 | // On AMD Family 17h and newer, we can take advantage of the LockTscToCurrentP0 bit 37 | // which allows us to lock the frequency of the TSC to the current P0 frequency 38 | // and prevent it from changing regardless of future changes to it. 39 | if (this->caps.amd17h) { wrmsr64(MSR_HWCR, rdmsr64(MSR_HWCR) | MSR_HWCR_LOCK_TSC_TO_CURR_P0); } 40 | } 41 | 42 | void TSCForger::sync(void *) { 43 | singleton().lockFreq(); 44 | 45 | __c11_atomic_fetch_max(&singleton().targetTSC, rdtsc64(), __ATOMIC_SEQ_CST); 46 | 47 | atomic_fetch_add(&singleton().threadsEngaged, 1); 48 | while (atomic_load(&singleton().threadsEngaged) != singleton().threadCount) {} 49 | 50 | wrmsr64(MSR_TSC, atomic_load_explicit(&singleton().targetTSC, memory_order_relaxed)); 51 | } 52 | 53 | void TSCForger::syncAll(bool timer) { 54 | // Ensure we don't try to synchronise multiple times at once or when the system is sleeping. 55 | if (!atomic_load(&this->systemAwake) || (!timer && atomic_load(&this->synchronised)) || 56 | atomic_exchange(&this->synchronising, true)) { 57 | return; 58 | } 59 | 60 | atomic_store(&this->synchronised, false); 61 | 62 | // If TSC_ADJUST is supported, just reset it. 63 | // Otherwise, synchronise the TSC value itself. 64 | atomic_store(&this->threadsEngaged, 0); 65 | if (this->caps.tscAdjust) { 66 | mp_rendezvous_no_intrs(resetAdjust, nullptr); 67 | } else { 68 | atomic_store(&this->targetTSC, 0); 69 | mp_rendezvous_no_intrs(sync, nullptr); 70 | } 71 | 72 | atomic_store(&this->synchronising, false); 73 | atomic_store(&this->synchronised, true); 74 | } 75 | 76 | void TSCForger::wrapXcpmUrgency(int urgency, UInt64 rtPeriod, UInt64 rtDeadline) { 77 | // Maybe you should've used a reliable clock source. 78 | if (!atomic_load_explicit(&singleton().synchronised, memory_order_relaxed)) { return; } 79 | FunctionCast(wrapXcpmUrgency, singleton().orgXcpmUrgency)(urgency, rtPeriod, rtDeadline); 80 | } 81 | 82 | void TSCForger::wrapTracePoint(void *that, UInt8 point) { 83 | switch (point) { 84 | case kIOPMTracePointSleepCPUs: { // Those CPUs sure like to sleep. 85 | atomic_store_explicit(&singleton().systemAwake, false, memory_order_relaxed); 86 | atomic_store_explicit(&singleton().synchronised, false, memory_order_relaxed); 87 | singleton().stopTimer(); 88 | } break; 89 | case kIOPMTracePointWakePlatformActions: { // So now you want to wake up, huh? 90 | atomic_store_explicit(&singleton().systemAwake, true, memory_order_relaxed); 91 | singleton().syncAll(); 92 | singleton().startTimer(); 93 | } break; 94 | } 95 | FunctionCast(wrapTracePoint, singleton().orgTracePoint)(that, point); 96 | } 97 | 98 | void TSCForger::wrapClockGetCalendarMicrotime(clock_sec_t *secs, clock_usec_t *microsecs) { 99 | singleton().syncAll(); 100 | FunctionCast(wrapClockGetCalendarMicrotime, singleton().orgClockGetCalendarMicrotime)(secs, microsecs); 101 | } 102 | 103 | void TSCForger::processPatcher(KernelPatcher &patcher) { 104 | this->syncAll(); 105 | 106 | KernelPatcher::RouteRequest requests[] = { 107 | {"_xcpm_urgency", wrapXcpmUrgency, this->orgXcpmUrgency}, 108 | {"__ZN14IOPMrootDomain10tracePointEh", wrapTracePoint, this->orgTracePoint}, 109 | {"_clock_get_calendar_microtime", wrapClockGetCalendarMicrotime, this->orgClockGetCalendarMicrotime}, 110 | }; 111 | PANIC_COND(!patcher.routeMultiple(KernelPatcher::KernelID, requests), "TSCSyncer", "Failed to route symbols"); 112 | } 113 | 114 | void TSCForger::init() { 115 | UInt32 ebx; 116 | UInt32 ecx; 117 | UInt32 edx; 118 | 119 | SYSLOG("TSCSyncer", "|-----------------------------------------------------------------|"); 120 | SYSLOG("TSCSyncer", "| Copyright 2024-2025 ChefKiss. |"); 121 | SYSLOG("TSCSyncer", "| If you've paid for this, you've been scammed. Ask for a refund! |"); 122 | SYSLOG("TSCSyncer", "| Do not support tonymacx86. Support us, we truly care. |"); 123 | SYSLOG("TSCSyncer", "| Change the world for the better. |"); 124 | SYSLOG("TSCSyncer", "|-----------------------------------------------------------------|"); 125 | 126 | const BaseDeviceInfo &info = BaseDeviceInfo::get(); 127 | switch (info.cpuVendor) { 128 | case CPUInfo::CpuVendor::Unknown: { 129 | SYSLOG("TSCSyncer", "Who made your CPU? Black Mesa?"); 130 | return; 131 | } 132 | case CPUInfo::CpuVendor::AMD: { 133 | // Try to determine the thread count using an AMD-specific CPUID extension. 134 | if (CPUInfo::getCpuid(0x80000008, 0, nullptr, nullptr, &ecx)) { 135 | // Last thread index is stored in bits 0..8 136 | this->threadCount = (ecx & 0xFF) + 1; 137 | } else { 138 | DBGLOG("TSCSyncer", "AMD-specific extension not supported..."); 139 | } 140 | 141 | // We must get the family manually on AMD because Acidanthera doesn't care 142 | // about the quality of their software. And yes, the logic is the same as Intel. 143 | union { 144 | CPUInfo::CpuVersion bits; 145 | uint32_t raw; 146 | } version; 147 | if (CPUInfo::getCpuid(1, 0, &version.raw)) { 148 | const UInt32 family = version.bits.family == 0xF ? (version.bits.family + version.bits.extendedFamily) : 149 | version.bits.family; 150 | // The specific bit in the HWCR MSR is only available since 17h. 151 | this->caps.amd17h = family >= 0x17; 152 | } else { 153 | SYSLOG("TSCSyncer", "No CPUID leaf 1? [insert related megamind picture here]"); 154 | if (this->threadCount == 0) { 155 | SYSLOG("TSCSyncer", "Setting thread count to 1 as both CPUID leaf 1 and the AMD-specific extension " 156 | "are not present!"); 157 | this->threadCount = 1; 158 | } 159 | } 160 | } break; 161 | case CPUInfo::CpuVendor::Intel: { 162 | // CPUID Leaf 7 Count 0 Bit 1 defines whether a CPU supports TSC_ADJUST, according to the Intel SDM. 163 | this->caps.tscAdjust = CPUInfo::getCpuid(7, 0, nullptr, &ebx) && (ebx & CPUID_LEAF7_TSC_ADJUST) != 0; 164 | 165 | // Try to determine the thread count using MSR_CORE_THREAD_COUNT. 166 | // bits 0..16 of this MSR contain the thread count, according to the Intel SDM. 167 | // The MSR is only available after Penryn, according to the XNU source code. 168 | // The Intel SDM seems to disagree (?) and says it's available since Haswell-E. 169 | // Thanks, very cool! 170 | if (info.cpuFamily > 6 || (info.cpuFamily == 6 && info.cpuModel > CPUInfo::CPU_MODEL_PENRYN)) { 171 | this->threadCount = rdmsr64(MSR_CORE_THREAD_COUNT) & 0xFFFF; 172 | } else { 173 | SYSLOG("TSCSyncer", "MSR_CORE_THREAD_COUNT not supported!"); 174 | } 175 | } break; 176 | } 177 | 178 | if (this->threadCount == 0) { 179 | DBGLOG("TSCSyncer", "Failed to get thread count via modern methods, using CPUID!"); 180 | 181 | if (CPUInfo::getCpuid(1, 0, nullptr, &ebx, &ecx, &edx)) { 182 | const UInt64 features = (static_cast(ecx) << 32) | edx; 183 | // If the HTT feature is supported then ebc will contain the 184 | // maximum APIC ID that's usable at 16..23 185 | if (features & CPUID_FEATURE_HTT) { 186 | this->threadCount = (ebx >> 16) & 0xFF; 187 | } else { 188 | this->threadCount = 1; // shit 189 | } 190 | } else { 191 | SYSLOG("TSCSyncer", "No CPUID leaf 1? [insert related megamind picture here]"); 192 | this->threadCount = 1; 193 | } 194 | } 195 | 196 | DBGLOG("TSCSyncer", "TSC_ADJUST: %s.", this->caps.tscAdjust ? "Available" : "Unavailable"); 197 | DBGLOG("TSCSyncer", "LockTscToCurrentP0: %s.", this->caps.amd17h ? "Available" : "Unavailable"); 198 | DBGLOG("TSCSyncer", "Thread count: %d.", this->threadCount); 199 | 200 | lilu.onPatcherLoadForce( 201 | [](void *user, KernelPatcher &patcher) { static_cast(user)->processPatcher(patcher); }, this); 202 | 203 | // If we have no way to lock the rate of the TSC, then we must sync it periodically. 204 | if (checkKernelArgument("-FIPeriodic") || (!this->caps.tscAdjust && !this->caps.amd17h)) { 205 | DBGLOG("TSCSyncer", "Will have to sync periodically."); 206 | 207 | // timerEventSource fails if inOwner is nullptr so just give it some random OSObject. 208 | this->timer = IOTimerEventSource::timerEventSource(kOSBooleanTrue, timerAction); 209 | this->startTimer(); 210 | } 211 | } 212 | 213 | void TSCForger::startTimer() { 214 | if (this->timer == nullptr) { return; } 215 | 216 | this->timer->enable(); 217 | this->timer->setTimeoutMS(PERIODIC_SYNC_INTERVAL); 218 | } 219 | 220 | void TSCForger::stopTimer() { 221 | if (this->timer == nullptr) { return; } 222 | 223 | this->timer->cancelTimeout(); 224 | this->timer->disable(); 225 | } 226 | 227 | void TSCForger::timerAction(OSObject *, IOTimerEventSource *sender) { 228 | singleton().syncAll(true); 229 | sender->setTimeoutMS(PERIODIC_SYNC_INTERVAL); 230 | } 231 | -------------------------------------------------------------------------------- /ForgedInvariant.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 54; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1C748C2D1C21952C0024EED2 /* Plugin.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1C748C2C1C21952C0024EED2 /* Plugin.cpp */; }; 11 | 40FEDF472BE01162008521DD /* plugin_start.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 40FEDF462BE01162008521DD /* plugin_start.cpp */; }; 12 | CE8DA0832517C41A008C44E8 /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = CE8DA0822517C41A008C44E8 /* libkmod.a */; }; 13 | D579D09E2A629F5300A4BCCE /* TSCSyncer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D579D09C2A629F5300A4BCCE /* TSCSyncer.cpp */; }; 14 | D579D09F2A629F5300A4BCCE /* TSCSyncer.hpp in Headers */ = {isa = PBXBuildFile; fileRef = D579D09D2A629F5300A4BCCE /* TSCSyncer.hpp */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXCopyFilesBuildPhase section */ 18 | 1C642F521C8F157A006B4C51 /* Copy Files */ = { 19 | isa = PBXCopyFilesBuildPhase; 20 | buildActionMask = 2147483647; 21 | dstPath = ""; 22 | dstSubfolderSpec = 13; 23 | files = ( 24 | ); 25 | name = "Copy Files"; 26 | runOnlyForDeploymentPostprocessing = 0; 27 | }; 28 | /* End PBXCopyFilesBuildPhase section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 1C748C271C21952C0024EED2 /* ForgedInvariant.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ForgedInvariant.kext; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 1C748C2C1C21952C0024EED2 /* Plugin.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = Plugin.cpp; sourceTree = ""; }; 33 | 1C748C2E1C21952C0024EED2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | 40FEDF462BE01162008521DD /* plugin_start.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = plugin_start.cpp; path = Lilu/Lilu/Library/plugin_start.cpp; sourceTree = ""; }; 35 | CE8DA0822517C41A008C44E8 /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = SOURCE_ROOT; }; 36 | D579D09C2A629F5300A4BCCE /* TSCSyncer.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = TSCSyncer.cpp; sourceTree = ""; }; 37 | D579D09D2A629F5300A4BCCE /* TSCSyncer.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = TSCSyncer.hpp; sourceTree = ""; }; 38 | /* End PBXFileReference section */ 39 | 40 | /* Begin PBXFrameworksBuildPhase section */ 41 | 1C748C231C21952C0024EED2 /* Frameworks */ = { 42 | isa = PBXFrameworksBuildPhase; 43 | buildActionMask = 2147483647; 44 | files = ( 45 | CE8DA0832517C41A008C44E8 /* libkmod.a in Frameworks */, 46 | ); 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXFrameworksBuildPhase section */ 50 | 51 | /* Begin PBXGroup section */ 52 | 1C748C1D1C21952C0024EED2 = { 53 | isa = PBXGroup; 54 | children = ( 55 | 1C748C291C21952C0024EED2 /* ForgedInvariant */, 56 | 40FEDF482BE01171008521DD /* SDK */, 57 | 1C748C281C21952C0024EED2 /* Products */, 58 | CE8DA0812517C41A008C44E8 /* Frameworks */, 59 | ); 60 | sourceTree = ""; 61 | usesTabs = 1; 62 | }; 63 | 1C748C281C21952C0024EED2 /* Products */ = { 64 | isa = PBXGroup; 65 | children = ( 66 | 1C748C271C21952C0024EED2 /* ForgedInvariant.kext */, 67 | ); 68 | name = Products; 69 | sourceTree = ""; 70 | }; 71 | 1C748C291C21952C0024EED2 /* ForgedInvariant */ = { 72 | isa = PBXGroup; 73 | children = ( 74 | D579D09C2A629F5300A4BCCE /* TSCSyncer.cpp */, 75 | D579D09D2A629F5300A4BCCE /* TSCSyncer.hpp */, 76 | 1C748C2E1C21952C0024EED2 /* Info.plist */, 77 | 1C748C2C1C21952C0024EED2 /* Plugin.cpp */, 78 | ); 79 | path = ForgedInvariant; 80 | sourceTree = ""; 81 | }; 82 | 40FEDF482BE01171008521DD /* SDK */ = { 83 | isa = PBXGroup; 84 | children = ( 85 | 40FEDF462BE01162008521DD /* plugin_start.cpp */, 86 | ); 87 | name = SDK; 88 | sourceTree = ""; 89 | }; 90 | CE8DA0812517C41A008C44E8 /* Frameworks */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | CE8DA0822517C41A008C44E8 /* libkmod.a */, 94 | ); 95 | name = Frameworks; 96 | sourceTree = ""; 97 | }; 98 | /* End PBXGroup section */ 99 | 100 | /* Begin PBXHeadersBuildPhase section */ 101 | 1C748C241C21952C0024EED2 /* Headers */ = { 102 | isa = PBXHeadersBuildPhase; 103 | buildActionMask = 2147483647; 104 | files = ( 105 | D579D09F2A629F5300A4BCCE /* TSCSyncer.hpp in Headers */, 106 | ); 107 | runOnlyForDeploymentPostprocessing = 0; 108 | }; 109 | /* End PBXHeadersBuildPhase section */ 110 | 111 | /* Begin PBXNativeTarget section */ 112 | 1C748C261C21952C0024EED2 /* ForgedInvariant */ = { 113 | isa = PBXNativeTarget; 114 | buildConfigurationList = 1C748C311C21952C0024EED2 /* Build configuration list for PBXNativeTarget "ForgedInvariant" */; 115 | buildPhases = ( 116 | 1C748C221C21952C0024EED2 /* Sources */, 117 | 1C748C231C21952C0024EED2 /* Frameworks */, 118 | 1C748C241C21952C0024EED2 /* Headers */, 119 | 1C642F521C8F157A006B4C51 /* Copy Files */, 120 | CE131D6A1FB728990036C3A0 /* Archive */, 121 | ); 122 | buildRules = ( 123 | ); 124 | dependencies = ( 125 | ); 126 | name = ForgedInvariant; 127 | productName = ForgedInvariant; 128 | productReference = 1C748C271C21952C0024EED2 /* ForgedInvariant.kext */; 129 | productType = "com.apple.product-type.kernel-extension"; 130 | }; 131 | /* End PBXNativeTarget section */ 132 | 133 | /* Begin PBXProject section */ 134 | 1C748C1E1C21952C0024EED2 /* Project object */ = { 135 | isa = PBXProject; 136 | attributes = { 137 | BuildIndependentTargetsInParallel = YES; 138 | LastUpgradeCheck = 1430; 139 | ORGANIZATIONNAME = ChefKiss; 140 | TargetAttributes = { 141 | 1C748C261C21952C0024EED2 = { 142 | CreatedOnToolsVersion = 7.2; 143 | }; 144 | }; 145 | }; 146 | buildConfigurationList = 1C748C211C21952C0024EED2 /* Build configuration list for PBXProject "ForgedInvariant" */; 147 | compatibilityVersion = "Xcode 12.0"; 148 | developmentRegion = en; 149 | hasScannedForEncodings = 0; 150 | knownRegions = ( 151 | en, 152 | Base, 153 | ); 154 | mainGroup = 1C748C1D1C21952C0024EED2; 155 | productRefGroup = 1C748C281C21952C0024EED2 /* Products */; 156 | projectDirPath = ""; 157 | projectRoot = ""; 158 | targets = ( 159 | 1C748C261C21952C0024EED2 /* ForgedInvariant */, 160 | ); 161 | }; 162 | /* End PBXProject section */ 163 | 164 | /* Begin PBXShellScriptBuildPhase section */ 165 | CE131D6A1FB728990036C3A0 /* Archive */ = { 166 | isa = PBXShellScriptBuildPhase; 167 | buildActionMask = 2147483647; 168 | files = ( 169 | ); 170 | inputPaths = ( 171 | ); 172 | name = Archive; 173 | outputPaths = ( 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | shellPath = /bin/bash; 177 | shellScript = "cd \"${TARGET_BUILD_DIR}\"\n\ndist=(\"$FULL_PRODUCT_NAME\")\nif [ -d \"$DWARF_DSYM_FILE_NAME\" ]; then dist+=(\"$DWARF_DSYM_FILE_NAME\"); fi\n\narchive=\"${PRODUCT_NAME}-${MODULE_VERSION}-$(echo $CONFIGURATION | tr /a-z/ /A-Z/).zip\"\nrm -rf *.zip\nif [ \"$CONFIGURATION\" == \"Release\" ]; then\n strip -x -T \"${EXECUTABLE_PATH}\" &>/dev/null || strip -x \"${EXECUTABLE_PATH}\"\nfi\nzip -qry -FS \"${archive}\" \"${dist[@]}\"\n"; 178 | }; 179 | /* End PBXShellScriptBuildPhase section */ 180 | 181 | /* Begin PBXSourcesBuildPhase section */ 182 | 1C748C221C21952C0024EED2 /* Sources */ = { 183 | isa = PBXSourcesBuildPhase; 184 | buildActionMask = 2147483647; 185 | files = ( 186 | 40FEDF472BE01162008521DD /* plugin_start.cpp in Sources */, 187 | D579D09E2A629F5300A4BCCE /* TSCSyncer.cpp in Sources */, 188 | 1C748C2D1C21952C0024EED2 /* Plugin.cpp in Sources */, 189 | ); 190 | runOnlyForDeploymentPostprocessing = 0; 191 | }; 192 | /* End PBXSourcesBuildPhase section */ 193 | 194 | /* Begin XCBuildConfiguration section */ 195 | 1C748C2F1C21952C0024EED2 /* Debug */ = { 196 | isa = XCBuildConfiguration; 197 | buildSettings = { 198 | ALWAYS_SEARCH_USER_PATHS = NO; 199 | ARCHS = x86_64; 200 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 201 | CLANG_CXX_LANGUAGE_STANDARD = "c++1y"; 202 | CLANG_CXX_LIBRARY = "libc++"; 203 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 204 | CLANG_WARN_BOOL_CONVERSION = YES; 205 | CLANG_WARN_COMMA = YES; 206 | CLANG_WARN_CONSTANT_CONVERSION = YES; 207 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 208 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 209 | CLANG_WARN_EMPTY_BODY = YES; 210 | CLANG_WARN_ENUM_CONVERSION = YES; 211 | CLANG_WARN_INFINITE_RECURSION = YES; 212 | CLANG_WARN_INT_CONVERSION = YES; 213 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 214 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 215 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 216 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 217 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 218 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 219 | CLANG_WARN_STRICT_PROTOTYPES = YES; 220 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 221 | CLANG_WARN_UNREACHABLE_CODE = YES; 222 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 223 | DEAD_CODE_STRIPPING = YES; 224 | DEBUG_INFORMATION_FORMAT = dwarf; 225 | ENABLE_STRICT_OBJC_MSGSEND = YES; 226 | ENABLE_TESTABILITY = YES; 227 | GCC_C_LANGUAGE_STANDARD = c11; 228 | GCC_INLINES_ARE_PRIVATE_EXTERN = YES; 229 | GCC_OPTIMIZATION_LEVEL = 0; 230 | GCC_PREPROCESSOR_DEFINITIONS = ( 231 | "DEBUG=1", 232 | "$(inherited)", 233 | ); 234 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 235 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 236 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 237 | GCC_WARN_UNDECLARED_SELECTOR = YES; 238 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 239 | GCC_WARN_UNUSED_FUNCTION = YES; 240 | GCC_WARN_UNUSED_VARIABLE = YES; 241 | HEADER_SEARCH_PATHS = ( 242 | "$(PROJECT_DIR)/Lilu/Lilu", 243 | "$(PROJECT_DIR)/MacKernelSDK/Headers", 244 | ); 245 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 246 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 247 | LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64"; 248 | MACOSX_DEPLOYMENT_TARGET = 10.6; 249 | ONLY_ACTIVE_ARCH = YES; 250 | OTHER_CFLAGS = ( 251 | "-Wextra", 252 | "-Wall", 253 | ); 254 | SDKROOT = macosx; 255 | }; 256 | name = Debug; 257 | }; 258 | 1C748C301C21952C0024EED2 /* Release */ = { 259 | isa = XCBuildConfiguration; 260 | buildSettings = { 261 | ALWAYS_SEARCH_USER_PATHS = NO; 262 | ARCHS = x86_64; 263 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 264 | CLANG_CXX_LANGUAGE_STANDARD = "c++1y"; 265 | CLANG_CXX_LIBRARY = "libc++"; 266 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 267 | CLANG_WARN_BOOL_CONVERSION = YES; 268 | CLANG_WARN_COMMA = YES; 269 | CLANG_WARN_CONSTANT_CONVERSION = YES; 270 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 271 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 272 | CLANG_WARN_EMPTY_BODY = YES; 273 | CLANG_WARN_ENUM_CONVERSION = YES; 274 | CLANG_WARN_INFINITE_RECURSION = YES; 275 | CLANG_WARN_INT_CONVERSION = YES; 276 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 277 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 278 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 279 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 280 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 281 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 282 | CLANG_WARN_STRICT_PROTOTYPES = YES; 283 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 284 | CLANG_WARN_UNREACHABLE_CODE = YES; 285 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 286 | DEAD_CODE_STRIPPING = YES; 287 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 288 | ENABLE_STRICT_OBJC_MSGSEND = YES; 289 | GCC_C_LANGUAGE_STANDARD = c11; 290 | GCC_INLINES_ARE_PRIVATE_EXTERN = YES; 291 | GCC_OPTIMIZATION_LEVEL = 3; 292 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 293 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 294 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 295 | GCC_WARN_UNDECLARED_SELECTOR = YES; 296 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 297 | GCC_WARN_UNUSED_FUNCTION = YES; 298 | GCC_WARN_UNUSED_VARIABLE = YES; 299 | HEADER_SEARCH_PATHS = ( 300 | "$(PROJECT_DIR)/Lilu/Lilu", 301 | "$(PROJECT_DIR)/MacKernelSDK/Headers", 302 | ); 303 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 304 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 305 | LIBRARY_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64"; 306 | LLVM_LTO = YES; 307 | MACOSX_DEPLOYMENT_TARGET = 10.6; 308 | OTHER_CFLAGS = ( 309 | "-Wextra", 310 | "-Wall", 311 | ); 312 | SDKROOT = macosx; 313 | }; 314 | name = Release; 315 | }; 316 | 1C748C321C21952C0024EED2 /* Debug */ = { 317 | isa = XCBuildConfiguration; 318 | buildSettings = { 319 | CLANG_ANALYZER_DEADCODE_DEADSTORES = NO; 320 | CLANG_ANALYZER_DIVIDE_BY_ZERO = NO; 321 | CLANG_ANALYZER_NULL_DEREFERENCE = NO; 322 | CLANG_CXX_LANGUAGE_STANDARD = "c++17"; 323 | CLANG_CXX_LIBRARY = "compiler-default"; 324 | CLANG_ENABLE_OBJC_WEAK = YES; 325 | CODE_SIGN_IDENTITY = "-"; 326 | COPY_PHASE_STRIP = NO; 327 | CURRENT_PROJECT_VERSION = "$(MODULE_VERSION)"; 328 | DEPLOYMENT_POSTPROCESSING = YES; 329 | GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO; 330 | GCC_ENABLE_KERNEL_DEVELOPMENT = NO; 331 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 332 | GCC_PREPROCESSOR_DEFINITIONS = ( 333 | "MODULE_VERSION=$(MODULE_VERSION)", 334 | "PRODUCT_NAME=$(PRODUCT_NAME)", 335 | "APPLE_KEXT_ASSERTIONS=1", 336 | "$(inherited)", 337 | ); 338 | HEADER_SEARCH_PATHS = "$(inherited)"; 339 | INFOPLIST_FILE = ForgedInvariant/Info.plist; 340 | LIBRARY_SEARCH_PATHS = ( 341 | "$(inherited)", 342 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", 343 | ); 344 | MACOSX_DEPLOYMENT_TARGET = 10.6; 345 | MODULE_NAME = org.ChefKiss.ForgedInvariant; 346 | MODULE_START = "$(PRODUCT_NAME)_kern_start"; 347 | MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; 348 | MODULE_VERSION = 1.5.0; 349 | OTHER_CFLAGS = ( 350 | "-mmmx", 351 | "-msse", 352 | "-msse2", 353 | "-msse3", 354 | "-mfpmath=sse", 355 | "-mssse3", 356 | "-ftree-vectorize", 357 | "-fno-non-call-exceptions", 358 | "-fno-builtin", 359 | "-fno-asynchronous-unwind-tables", 360 | "-Wno-unknown-warning-option", 361 | "-Wno-ossharedptr-misuse", 362 | "-Wno-vla", 363 | "-Wextra", 364 | "-Wall", 365 | "$(inherited)", 366 | ); 367 | OTHER_LDFLAGS = "-static"; 368 | PRODUCT_BUNDLE_IDENTIFIER = org.ChefKiss.ForgedInvariant; 369 | PRODUCT_NAME = "$(TARGET_NAME)"; 370 | RUN_CLANG_STATIC_ANALYZER = YES; 371 | WRAPPER_EXTENSION = kext; 372 | }; 373 | name = Debug; 374 | }; 375 | 1C748C331C21952C0024EED2 /* Release */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | CLANG_CXX_LANGUAGE_STANDARD = "c++17"; 379 | CLANG_CXX_LIBRARY = "compiler-default"; 380 | CLANG_ENABLE_OBJC_WEAK = YES; 381 | CODE_SIGN_IDENTITY = "-"; 382 | CURRENT_PROJECT_VERSION = "$(MODULE_VERSION)"; 383 | DEAD_CODE_STRIPPING = YES; 384 | DEPLOYMENT_POSTPROCESSING = YES; 385 | GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO; 386 | GCC_ENABLE_KERNEL_DEVELOPMENT = NO; 387 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 388 | GCC_PREPROCESSOR_DEFINITIONS = ( 389 | "MODULE_VERSION=$(MODULE_VERSION)", 390 | "PRODUCT_NAME=$(PRODUCT_NAME)", 391 | "$(inherited)", 392 | ); 393 | HEADER_SEARCH_PATHS = "$(inherited)"; 394 | INFOPLIST_FILE = ForgedInvariant/Info.plist; 395 | LIBRARY_SEARCH_PATHS = ( 396 | "$(inherited)", 397 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", 398 | ); 399 | MACOSX_DEPLOYMENT_TARGET = 10.6; 400 | MODULE_NAME = org.ChefKiss.ForgedInvariant; 401 | MODULE_START = "$(PRODUCT_NAME)_kern_start"; 402 | MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; 403 | MODULE_VERSION = 1.5.0; 404 | OTHER_CFLAGS = ( 405 | "-mmmx", 406 | "-msse", 407 | "-msse2", 408 | "-msse3", 409 | "-mfpmath=sse", 410 | "-mssse3", 411 | "-ftree-vectorize", 412 | "-fno-non-call-exceptions", 413 | "-fno-builtin", 414 | "-fno-asynchronous-unwind-tables", 415 | "-Wno-unknown-warning-option", 416 | "-Wno-ossharedptr-misuse", 417 | "-Wno-vla", 418 | "-Wextra", 419 | "-Wall", 420 | "$(inherited)", 421 | ); 422 | OTHER_LDFLAGS = "-static"; 423 | PRODUCT_BUNDLE_IDENTIFIER = org.ChefKiss.ForgedInvariant; 424 | PRODUCT_NAME = "$(TARGET_NAME)"; 425 | WRAPPER_EXTENSION = kext; 426 | }; 427 | name = Release; 428 | }; 429 | CE9901CA21456F6C006E5CF5 /* Sanitize */ = { 430 | isa = XCBuildConfiguration; 431 | buildSettings = { 432 | ALWAYS_SEARCH_USER_PATHS = NO; 433 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 434 | CLANG_CXX_LANGUAGE_STANDARD = "c++1y"; 435 | CLANG_CXX_LIBRARY = "libc++"; 436 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 437 | CLANG_WARN_BOOL_CONVERSION = YES; 438 | CLANG_WARN_COMMA = YES; 439 | CLANG_WARN_CONSTANT_CONVERSION = YES; 440 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 441 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 442 | CLANG_WARN_EMPTY_BODY = YES; 443 | CLANG_WARN_ENUM_CONVERSION = YES; 444 | CLANG_WARN_INFINITE_RECURSION = YES; 445 | CLANG_WARN_INT_CONVERSION = YES; 446 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 447 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 448 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 449 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 450 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; 451 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 452 | CLANG_WARN_STRICT_PROTOTYPES = YES; 453 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 454 | CLANG_WARN_UNREACHABLE_CODE = YES; 455 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 456 | DEAD_CODE_STRIPPING = YES; 457 | DEBUG_INFORMATION_FORMAT = dwarf; 458 | ENABLE_STRICT_OBJC_MSGSEND = YES; 459 | ENABLE_TESTABILITY = YES; 460 | GCC_C_LANGUAGE_STANDARD = c11; 461 | GCC_INLINES_ARE_PRIVATE_EXTERN = YES; 462 | GCC_OPTIMIZATION_LEVEL = 0; 463 | GCC_PREPROCESSOR_DEFINITIONS = ( 464 | "DEBUG=1", 465 | "$(inherited)", 466 | ); 467 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 468 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 469 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 470 | GCC_WARN_UNDECLARED_SELECTOR = YES; 471 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 472 | GCC_WARN_UNUSED_FUNCTION = YES; 473 | GCC_WARN_UNUSED_VARIABLE = YES; 474 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 475 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers"; 476 | MACOSX_DEPLOYMENT_TARGET = 10.6; 477 | ONLY_ACTIVE_ARCH = YES; 478 | OTHER_CFLAGS = ( 479 | "-Wextra", 480 | "-Wall", 481 | ); 482 | SDKROOT = macosx; 483 | }; 484 | name = Sanitize; 485 | }; 486 | CE9901CB21456F6C006E5CF5 /* Sanitize */ = { 487 | isa = XCBuildConfiguration; 488 | buildSettings = { 489 | CLANG_CXX_LANGUAGE_STANDARD = "c++17"; 490 | CLANG_CXX_LIBRARY = "compiler-default"; 491 | CLANG_ENABLE_OBJC_WEAK = YES; 492 | CODE_SIGN_IDENTITY = "-"; 493 | COPY_PHASE_STRIP = NO; 494 | CURRENT_PROJECT_VERSION = "$(MODULE_VERSION)"; 495 | DEPLOYMENT_POSTPROCESSING = YES; 496 | GCC_ENABLE_FLOATING_POINT_LIBRARY_CALLS = NO; 497 | GCC_ENABLE_KERNEL_DEVELOPMENT = NO; 498 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 499 | GCC_PREPROCESSOR_DEFINITIONS = ( 500 | "MODULE_VERSION=$(MODULE_VERSION)", 501 | "PRODUCT_NAME=$(PRODUCT_NAME)", 502 | "APPLE_KEXT_ASSERTIONS=1", 503 | "$(inherited)", 504 | ); 505 | HEADER_SEARCH_PATHS = "$(inherited)"; 506 | INFOPLIST_FILE = ForgedInvariant/Info.plist; 507 | LIBRARY_SEARCH_PATHS = ( 508 | "$(inherited)", 509 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64", 510 | ); 511 | MACOSX_DEPLOYMENT_TARGET = 10.6; 512 | MODULE_NAME = org.ChefKiss.ForgedInvariant; 513 | MODULE_START = "$(PRODUCT_NAME)_kern_start"; 514 | MODULE_STOP = "$(PRODUCT_NAME)_kern_stop"; 515 | MODULE_VERSION = 1.5.0; 516 | OTHER_CFLAGS = ( 517 | "-mmmx", 518 | "-msse", 519 | "-msse2", 520 | "-msse3", 521 | "-mfpmath=sse", 522 | "-mssse3", 523 | "-ftree-vectorize", 524 | "-fno-non-call-exceptions", 525 | "-fno-builtin", 526 | "-fno-asynchronous-unwind-tables", 527 | "-fsanitize=undefined,nullability", 528 | "-fno-sanitize=function", 529 | "-Wno-unknown-warning-option", 530 | "-Wno-ossharedptr-misuse", 531 | "-Wno-vla", 532 | "-Wextra", 533 | "-Wall", 534 | "$(inherited)", 535 | ); 536 | OTHER_LDFLAGS = "-static"; 537 | PRODUCT_BUNDLE_IDENTIFIER = org.ChefKiss.ForgedInvariant; 538 | PRODUCT_NAME = "$(TARGET_NAME)"; 539 | WRAPPER_EXTENSION = kext; 540 | }; 541 | name = Sanitize; 542 | }; 543 | /* End XCBuildConfiguration section */ 544 | 545 | /* Begin XCConfigurationList section */ 546 | 1C748C211C21952C0024EED2 /* Build configuration list for PBXProject "ForgedInvariant" */ = { 547 | isa = XCConfigurationList; 548 | buildConfigurations = ( 549 | 1C748C2F1C21952C0024EED2 /* Debug */, 550 | CE9901CA21456F6C006E5CF5 /* Sanitize */, 551 | 1C748C301C21952C0024EED2 /* Release */, 552 | ); 553 | defaultConfigurationIsVisible = 0; 554 | defaultConfigurationName = Release; 555 | }; 556 | 1C748C311C21952C0024EED2 /* Build configuration list for PBXNativeTarget "ForgedInvariant" */ = { 557 | isa = XCConfigurationList; 558 | buildConfigurations = ( 559 | 1C748C321C21952C0024EED2 /* Debug */, 560 | CE9901CB21456F6C006E5CF5 /* Sanitize */, 561 | 1C748C331C21952C0024EED2 /* Release */, 562 | ); 563 | defaultConfigurationIsVisible = 0; 564 | defaultConfigurationName = Release; 565 | }; 566 | /* End XCConfigurationList section */ 567 | }; 568 | rootObject = 1C748C1E1C21952C0024EED2 /* Project object */; 569 | } 570 | --------------------------------------------------------------------------------