├── .gitignore
├── OpenFirmwareManager
├── FirmwareList.h
├── Info.plist
├── Logs.h
├── zutil.h
├── zutil.cpp
├── OpenFirmwareManager.h
└── OpenFirmwareManager.cpp
├── README.md
├── .github
└── workflows
│ └── main.yml
├── bootstrap.sh
├── OpenFirmwareManager.xcodeproj
└── project.pbxproj
└── LICENSE
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | DerivedData
3 | xcshareddata
4 | xcuserdata
5 | project.xcworkspace
6 | build
7 | MacKernelSDK
8 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/FirmwareList.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | */
21 |
22 | #ifndef _OFM_FIRMWARELIST_H
23 | #define _OFM_FIRMWARELIST_H
24 |
25 | #include "OpenFirmwareManager.h"
26 |
27 | extern int fwCount;
28 | extern FirmwareDescriptor fwCandidates[];
29 |
30 | #endif
31 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
17 | CFBundleShortVersionString
18 | $(MODULE_VERSION)
19 | CFBundleVersion
20 | $(MODULE_VERSION)
21 | OSBundleCompatibleVersion
22 | $(MODULE_VERSION)
23 | IOKitPersonalities
24 |
25 | OSBundleLibraries
26 |
27 | com.apple.kpi.iokit
28 | 9.0
29 | com.apple.kpi.libkern
30 | 9.0
31 | com.apple.kpi.mach
32 | 9.0
33 | com.apple.kpi.unsupported
34 | 9.0
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/Logs.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | */
21 |
22 | #ifndef _OFM_LOGS_H
23 | #define _OFM_LOGS_H
24 |
25 | #define OpenLog kprintf
26 |
27 | #define AlwaysLog(name, format, ...) do { OpenLog("[" OS_STRINGIFY(PRODUCT_NAME) "][" name "] -- " format, ## __VA_ARGS__); OpenLog("\n"); } while (0)
28 |
29 | #ifdef DEBUG
30 | #define DebugLog AlwaysLog
31 | #else
32 | #define DebugLog(name, format, ...) do { } while (0)
33 | #endif
34 |
35 | #endif
36 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # OpenFirmwareManager
2 |
3 | ## Intro
4 |
5 | For a device to work properly, its firmware must be loaded by the driver. However, firmwares are often tremendous and take up too much space, so developers would usually compress them. Therefore, decompression needs to be done in the kext. OpenFirmwareManager is a generic macOS kernel extension that provides unified APIs for firmware decompression and management -- with this extension, developers don't have to implement those firmware opertaions anymore -- they just need an OpenFirmwareManager instance that does everything for them.
6 |
7 | ## Documentaion
8 |
9 | Please refer to the headers for specific documentations of functions or other details, which are written as comments in AppleDoc style. The headers could also be found in the Resources folder of the Debug release.
10 |
11 | ## Installation
12 |
13 | 1. Download the kext from the releases section of this GitHub repository.
14 | 2. Unzip.
15 | 3. Install the kext to your system.
16 | 4. Reboot.
17 |
18 | ## Usage
19 |
20 | To use the APIs in another project, follow these steps:
21 | 1. Download a Debug version of this kext.
22 | 2. Copy the kext to your project directory.
23 | 3. Include $(PROJECT_DIR)/OpenFirmwareManager.kext/Contents/Resources/ to your header search paths.
24 | 4. Use OpenFirmwareManager instances to manage firmwares!
25 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/zutil.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | * Zlib implementation based on /apple/xnu/libkern/c++/OSKext.cpp
21 | */
22 |
23 | #ifndef _OFM_ZUTIL_H
24 | #define _OFM_ZUTIL_H
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | typedef struct z_mem
31 | {
32 | UInt32 allocSize;
33 | UInt8 data[0];
34 | } z_mem;
35 |
36 | extern void * zalloc(void * opaque, UInt32 items, UInt32 size);
37 | extern void zfree(void * opaque, void * ptr);
38 |
39 | #endif
40 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/zutil.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | * Zlib implementation based on /apple/xnu/libkern/c++/OSKext.cpp
21 | */
22 |
23 | #include "zutil.h"
24 |
25 | void * zalloc(void * opaque, UInt32 items, UInt32 size)
26 | {
27 | void * result = NULL;
28 | z_mem * zmem = NULL;
29 | UInt32 allocSize = items * size + sizeof(zmem);
30 |
31 | zmem = (z_mem *) IOMalloc(allocSize);
32 |
33 | if (zmem)
34 | {
35 | zmem->allocSize = allocSize;
36 | result = (void *) &(zmem->data);
37 | }
38 |
39 | return result;
40 | }
41 |
42 | void zfree(void * opaque, void * ptr)
43 | {
44 | UInt32 * skipper = (UInt32 *) ptr - 1;
45 | z_mem * zmem = (z_mem *) skipper;
46 | IOFree((void *) zmem, zmem->allocSize);
47 | }
48 |
--------------------------------------------------------------------------------
/.github/workflows/main.yml:
--------------------------------------------------------------------------------
1 | name: CD
2 |
3 | on:
4 | push:
5 | branches: master
6 |
7 | env:
8 | RELEASE_BUILD_OUTPUT: 'build/Build/Products/Release'
9 | DEBUG_BUILD_OUTPUT: 'build/Build/Products/Debug'
10 |
11 | jobs:
12 |
13 | build:
14 |
15 | runs-on: macos-latest
16 |
17 | steps:
18 |
19 | - uses: actions/checkout@v2
20 |
21 | - name: Manage Version
22 | run: |
23 | git fetch --prune --unshallow --tags
24 | GIT_SHA="$(git rev-parse --short HEAD)"
25 | CUR_TAG="$(git tag -l | grep 'alpha\|beta' | tail -1)"
26 | eval $(grep -m 1 "MODULE_VERSION =" *.xcodeproj/project.pbxproj | tr -d ';' | tr -d '\t' | tr -d " ")
27 | echo "SHORT_SHA=$GIT_SHA" >> $GITHUB_ENV
28 | echo "MODULE_VER=$MODULE_VERSION" >> $GITHUB_ENV
29 | if [[ -z $CUR_TAG ]]; then
30 | echo "OLD_PRE_TAG=NULL" >> $GITHUB_ENV
31 | else
32 | echo "OLD_PRE_TAG=$CUR_TAG" >> $GITHUB_ENV
33 | fi
34 |
35 | - name: Install MacKernelSDK
36 | run: |
37 | git clone --depth=1 https://github.com/CharlieJiangXXX/MacKernelSDK.git
38 |
39 | - name: Build Release
40 | run: |
41 | xcodebuild -scheme OpenFirmwareManager -configuration Release -derivedDataPath build GIT_COMMIT=_${SHORT_SHA} | xcpretty && exit ${PIPESTATUS[0]}
42 |
43 | - name: Build Debug
44 | run: |
45 | xcodebuild -scheme OpenFirmwareManager -configuration Debug -derivedDataPath build GIT_COMMIT=_${SHORT_SHA} | xcpretty && exit ${PIPESTATUS[0]}
46 |
47 | - name: Pack Release Artifacts
48 | run: |
49 | cd $RELEASE_BUILD_OUTPUT
50 | zip -r OpenFirmwareManager-${MODULE_VER}-RELEASE-alpha-${SHORT_SHA}.zip *.kext *.dSYM
51 |
52 | - name: Pack Debug Artifacts
53 | run: |
54 | cd $DEBUG_BUILD_OUTPUT
55 | zip -r OpenFirmwareManager-${MODULE_VER}-DEBUG-alpha-${SHORT_SHA}.zip *.kext
56 |
57 | - name: Delete Old Prerelease
58 | uses: dev-drprasad/delete-tag-and-release@v0.2.0
59 | with:
60 | tag_name: ${{ env.OLD_PRE_TAG }}
61 | env:
62 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63 |
64 | - name: Publish GitHub Release
65 | uses: ncipollo/release-action@v1.8.6
66 | with:
67 | prerelease: true
68 | artifacts: "${{ env.DEBUG_BUILD_OUTPUT }}/*.zip, ${{ env.RELEASE_BUILD_OUTPUT }}/*.zip"
69 | tag: "v${{ env.MODULE_VER }}-alpha"
70 | token: ${{ secrets.GITHUB_TOKEN }}
71 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/OpenFirmwareManager.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | * Zlib implementation based on /apple/xnu/libkern/c++/OSKext.cpp
21 | */
22 |
23 | #ifndef _OFM_OPENFIRMWAREMANAGER_H
24 | #define _OFM_OPENFIRMWAREMANAGER_H
25 |
26 | #include
27 | #include
28 | #include
29 |
30 | typedef struct FirmwareDescriptor
31 | {
32 | const char * name;
33 | UInt8 * firmwareData;
34 | UInt32 firmwareSize;
35 | } FirmwareDescriptor;
36 |
37 | class OpenFirmwareManager : public IOService
38 | {
39 | OSDeclareDefaultStructors(OpenFirmwareManager)
40 |
41 | struct ResourceCallbackContext
42 | {
43 | OpenFirmwareManager * me;
44 | FirmwareDescriptor descriptor;
45 | };
46 |
47 | public:
48 | static OpenFirmwareManager * withCapacity(int capacity);
49 |
50 | /*! @function withNames
51 | * @abstract Creates an OpenFirmwareManager instance with the names of firmwares requested.
52 | * @discussion After creating the instance, the function calls initWitNames to initialize the instance.
53 | * @param names The names of the requested firmwares.
54 | * @param capacity The number of firmwares requested.
55 | * @param firmwareCandidates A list that consists of all possible firmware candidates.
56 | * @param numFirmwares The number of firmwares in firmwareList.
57 | * @result If the operation is successful, the instance created is returned. */
58 |
59 | static OpenFirmwareManager * withNames(const char ** names, int capacity, FirmwareDescriptor * firmwareCandidates, int numFirmwares);
60 | static OpenFirmwareManager * withName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares);
61 |
62 | /*! @function withDescriptors
63 | * @abstract Creates an OpenFirmwareManager instance with firmware descriptors.
64 | * @discussion After creating the instance, the function calls initWithFirmwareWithDescriptors to initialize the instance.
65 | * @param firmwares The firmware descriptors upon which the instance is generated.
66 | * @param capacity The number of firmwares requested.
67 | * @result If the operation is successful, the instance created is returned. */
68 |
69 | static OpenFirmwareManager * withDescriptors(FirmwareDescriptor * firmwares, int capacity);
70 | static OpenFirmwareManager * withDescriptor(FirmwareDescriptor firmware);
71 |
72 | static OpenFirmwareManager * withFiles(const char ** kextIdentifiers, const char ** fileNames, int capacity);
73 | static OpenFirmwareManager * withFile(const char * kextIdentifier, const char * fileName);
74 |
75 | virtual IOReturn addFirmwareWithName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares);
76 | virtual IOReturn addFirmwareWithDescriptor(FirmwareDescriptor firmware);
77 | virtual IOReturn addFirmwareWithFile(const char * kextIdentifier, const char * fileName);
78 |
79 | virtual IOReturn removeFirmware(const char * name);
80 | virtual IOReturn removeFirmwares();
81 |
82 | virtual bool init( OSDictionary * dictionary = NULL ) APPLE_KEXT_OVERRIDE;
83 | virtual void free() APPLE_KEXT_OVERRIDE;
84 |
85 | virtual OSData * getFirmwareUncompressed(const char * name);
86 |
87 | protected:
88 | static void requestResourceCallback(OSKextRequestTag requestTag, OSReturn result, const void * resourceData, uint32_t resourceDataLength, void * context);
89 |
90 | virtual bool initWithCapacity(int capacity);
91 | virtual bool initWithNames(const char ** names, int capacity, FirmwareDescriptor * firmwareCandidates, int numFirmwares);
92 | virtual bool initWithName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares);
93 | virtual bool initWithDescriptors(FirmwareDescriptor * firmwares, int capacity);
94 | virtual bool initWithDescriptor(FirmwareDescriptor firmware);
95 | virtual bool initWithFiles(const char ** kextIdentifiers, const char ** fileNames, int capacity);
96 | virtual bool initWithFile(const char * kextIdentifier, const char * fileName);
97 | virtual bool isFirmwareCompressed(OSData * firmware);
98 | virtual OSData * decompressFirmware(OSData * firmware);
99 |
100 | protected:
101 | IOLock * mFirmwareLock;
102 | OSDictionary * mFirmwares;
103 |
104 | struct ExpansionData
105 | {
106 | IOLock * mCompletionLock;
107 | };
108 | ExpansionData * mExpansionData;
109 | };
110 |
111 | #endif
112 |
--------------------------------------------------------------------------------
/bootstrap.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | #
4 | # bootstrap.sh
5 | # OpenFirmwareManager
6 | #
7 |
8 | #
9 | # Released under "The GNU General Public License (GPL-2.0)"
10 | #
11 | # Copyright (c) 2021 cjiang. All rights reserved.
12 | #
13 | # This program is free software; you can redistribute it and/or modify it
14 | # under the terms of the GNU General Public License as published by the
15 | # Free Software Foundation; either version 2 of the License, or (at your
16 | # option) any later version.
17 | #
18 | # This program is distributed in the hope that it will be useful, but
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 | # for more details.
22 | #
23 | # You should have received a copy of the GNU General Public License along
24 | # with this program; if not, write to the Free Software Foundation, Inc.,
25 | # 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 | #
27 |
28 | #
29 | # This script is supposed to quickly bootstrap OpenFirmwareManger for plugin building.
30 | # A compiled OpenFirmwareManager release will be bootstrapped in the working directory.
31 | #
32 | # Latest version available at:
33 | # https://raw.githubusercontent.com/AppleBluetooth/OpenFirmwareManager/master/bootstrap.sh
34 | #
35 | # Example usage:
36 | # src=$(/usr/bin/curl -Lfs https://raw.githubusercontent.com/AppleBluetooth/OpenFirmwareManager/master/bootstrap.sh) && eval "$src" || exit 1
37 | #
38 |
39 | REPO_PATH="AppleBluetooth/OpenFirmwareManager"
40 | SDK_PATH="OpenFirmwareManager.kext"
41 | SDK_CHECK_PATH="${SDK_PATH}/Contents/Resources/OpenFirmwareManager.h"
42 |
43 | PROJECT_PATH="$(pwd)"
44 | if [ $? -ne 0 ] || [ ! -d "${PROJECT_PATH}" ]; then
45 | echo "ERROR: Failed to determine working directory!"
46 | exit 1
47 | fi
48 |
49 | # Avoid conflicts with PATH overrides.
50 | CURL="/usr/bin/curl"
51 | GIT="/usr/bin/git"
52 | GREP="/usr/bin/grep"
53 | MKDIR="/bin/mkdir"
54 | MV="/bin/mv"
55 | RM="/bin/rm"
56 | SED="/usr/bin/sed"
57 | UNAME="/usr/bin/uname"
58 | UNZIP="/usr/bin/unzip"
59 | UUIDGEN="/usr/bin/uuidgen"
60 | XCODEBUILD="/usr/bin/xcodebuild"
61 |
62 | TOOLS=(
63 | "${CURL}"
64 | "${GIT}"
65 | "${GREP}"
66 | "${MKDIR}"
67 | "${MV}"
68 | "${RM}"
69 | "${SED}"
70 | "${UNAME}"
71 | "${UNZIP}"
72 | "${UUIDGEN}"
73 | "${XCODEBUILD}"
74 | )
75 |
76 | for tool in "${TOOLS[@]}"; do
77 | if [ ! -x "${tool}" ]; then
78 | echo "ERROR: Missing ${tool}!"
79 | exit 1
80 | fi
81 | done
82 |
83 | # Prepare temporary directory to avoid conflicts with other scripts.
84 | # Sets TMP_PATH.
85 | prepare_environment() {
86 | local ret=0
87 |
88 | local sys=$("${UNAME}") || ret=$?
89 | if [ $ret -ne 0 ] || [ "$sys" != "Darwin" ]; then
90 | echo "ERROR: This script is only meant to be used on Darwin systems!"
91 | return 1
92 | fi
93 |
94 | if [ -e "${SDK_PATH}" ]; then
95 | echo "ERROR: Found existing SDK directory ${SDK_PATH}, aborting!"
96 | return 1
97 | fi
98 |
99 | local uuid=$("${UUIDGEN}") || ret=$?
100 | if [ $ret -ne 0 ]; then
101 | echo "ERROR: Failed to generate temporary UUID with code ${ret}!"
102 | return 1
103 | fi
104 |
105 | TMP_PATH="/tmp/ofmtmp.${uuid}"
106 | if [ -e "${TMP_PATH}" ]; then
107 | echo "ERROR: Found existing temporary directory ${TMP_PATH}, aborting!"
108 | return 1
109 | fi
110 |
111 | "${MKDIR}" "${TMP_PATH}" || ret=$?
112 | if [ $ret -ne 0 ]; then
113 | echo "ERROR: Failed to create temporary directory ${TMP_PATH} with code ${ret}!"
114 | return 1
115 | fi
116 |
117 | cd "${TMP_PATH}" || ret=$?
118 | if [ $ret -ne 0 ]; then
119 | echo "ERROR: Failed to cd to temporary directory ${TMP_PATH} with code ${ret}!"
120 | "${RM}" -rf "${TMP_PATH}"
121 | return 1
122 | fi
123 |
124 | return 0
125 | }
126 |
127 | # Install manually compiled SDK for development builds.
128 | install_compiled_sdk() {
129 | local ret=0
130 |
131 | echo "Installing compiled SDK..."
132 |
133 | echo "-> Cloning the latest version from master..."
134 |
135 | local url="https://github.com/${REPO_PATH}"
136 | "${GIT}" clone "${url}" -b "master" --depth=1 "tmp" || ret=$?
137 | if [ $ret -ne 0 ]; then
138 | echo "ERROR: Failed to clone repository with code ${ret}!"
139 | return 1
140 | fi
141 |
142 | echo "-> Building the latest SDK..."
143 |
144 | cd "tmp" || ret=$?
145 | if [ $ret -ne 0 ]; then
146 | echo "ERROR: Failed to cd to temporary directory tmp with code ${ret}!"
147 | return 1
148 | fi
149 |
150 | "${GIT}" clone "https://github.com/acidanthera/MacKernelSDK" -b "master" --depth=1 || ret=$?
151 | if [ $ret -ne 0 ]; then
152 | echo "ERROR: Failed to clone MacKernelSDK with code ${ret}!"
153 | return 1
154 | fi
155 |
156 | "${XCODEBUILD}" -configuration Debug -arch x86_64 || ret=$?
157 |
158 | if [ $ret -ne 0 ]; then
159 | echo "ERROR: Failed to compile the latest version with code ${ret}!"
160 | return 1
161 | fi
162 |
163 | echo "-> Installing compiled SDK..."
164 |
165 | if [ ! -d "build/Debug/${SDK_PATH}" ] || [ ! -f "build/Debug/${SDK_CHECK_PATH}" ]; then
166 | echo "ERROR: Failed to find the built SDK!"
167 | return 1
168 | fi
169 |
170 | "${MV}" "build/Debug/${SDK_PATH}" "${PROJECT_PATH}/${SDK_PATH}" || ret=$?
171 | if [ $ret -ne 0 ]; then
172 | echo "ERROR: Failed to install SDK with code ${ret}!"
173 | return 1
174 | fi
175 |
176 | echo "Installed compiled SDK from master!"
177 | }
178 |
179 | prepare_environment || exit 1
180 |
181 | ret=0
182 | install_compiled_sdk || ret=$?
183 |
184 | cd "${PROJECT_PATH}" || ret=$?
185 |
186 | "${RM}" -rf "${TMP_PATH}"
187 |
188 | if [ $ret -ne 0 ]; then
189 | echo "ERROR: Failed to bootstrap SDK with code ${ret}!"
190 | exit 1
191 | fi
192 |
--------------------------------------------------------------------------------
/OpenFirmwareManager/OpenFirmwareManager.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * Released under "The GNU General Public License (GPL-2.0)"
3 | *
4 | * Copyright (c) 2021 cjiang. All rights reserved.
5 | *
6 | * This program is free software; you can redistribute it and/or modify it
7 | * under the terms of the GNU General Public License as published by the
8 | * Free Software Foundation; either version 2 of the License, or (at your
9 | * option) any later version.
10 | *
11 | * This program is distributed in the hope that it will be useful, but
12 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 | * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 | * for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License along
17 | * with this program; if not, write to the Free Software Foundation, Inc.,
18 | * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | * Zlib implementation based on /apple/xnu/libkern/c++/OSKext.cpp
21 | */
22 |
23 | #include "Logs.h"
24 | #include "OpenFirmwareManager.h"
25 | #include "zutil.h"
26 |
27 | #define super IOService
28 | OSDefineMetaClassAndStructors(OpenFirmwareManager, super)
29 |
30 | bool OpenFirmwareManager::init(OSDictionary * dictionary)
31 | {
32 | DebugLog("init", "Initializing variables...");
33 | if ( !super::init() )
34 | return false;
35 |
36 | mFirmwareLock = IOLockAlloc();
37 | mFirmwares = NULL;
38 | mExpansionData = IONew(ExpansionData, 1);
39 | if ( !mExpansionData )
40 | {
41 | AlwaysLog("init", "init() failed -- no memory.");
42 | return false;
43 | }
44 | mExpansionData->mCompletionLock = IOLockAlloc();
45 | DebugLog("init", "init() completed.");
46 | return true;
47 | }
48 |
49 | void OpenFirmwareManager::free()
50 | {
51 | DebugLog("free", "Releasing variables...");
52 | removeFirmwares();
53 | IOLockFree(mFirmwareLock);
54 | IOLockFree(mExpansionData->mCompletionLock);
55 | IOSafeDeleteNULL(mExpansionData, ExpansionData, 1);
56 | super::free();
57 | DebugLog("free", "free() completed.");
58 | }
59 |
60 | bool OpenFirmwareManager::isFirmwareCompressed(OSData * firmware)
61 | {
62 | UInt16 * magic = (UInt16 *) firmware->getBytesNoCopy();
63 |
64 | if ( *magic == 0x0178 // Zlib no compression
65 | || *magic == 0x9c78 // Zlib default compression
66 | || *magic == 0xda78 ) // Zlib maximum compression
67 | return true;
68 | return false;
69 | }
70 |
71 | OSData * OpenFirmwareManager::decompressFirmware(OSData * firmware)
72 | {
73 | DebugLog("decompressFirmware", "Uncompressing firmware %p...", firmware);
74 | OSData * uncompressedFirmware = NULL;
75 | z_stream zstream;
76 | int zlib_result;
77 | void * buffer = NULL;
78 | UInt32 bufferSize = 0;
79 |
80 | if ( !isFirmwareCompressed(firmware) )
81 | {
82 | DebugLog("decompressFirmware", "Firmware is not compressed!");
83 | firmware->retain();
84 | return firmware;
85 | }
86 |
87 | bufferSize = firmware->getLength() * 4;
88 | buffer = IOMalloc(bufferSize);
89 |
90 | bzero(&zstream, sizeof(zstream));
91 | zstream.next_in = (UInt8 *) firmware->getBytesNoCopy();
92 | zstream.avail_in = firmware->getLength();
93 | zstream.next_out = (UInt8 *) buffer;
94 | zstream.avail_out = bufferSize;
95 | zstream.zalloc = zalloc;
96 | zstream.zfree = zfree;
97 |
98 | zlib_result = inflateInit(&zstream);
99 | if ( zlib_result != Z_OK )
100 | {
101 | DebugLog("decompressFirmware", "inflateInit() failed: %d", zlib_result);
102 | IOFree(buffer, bufferSize);
103 | return NULL;
104 | }
105 |
106 | zlib_result = inflate(&zstream, Z_FINISH);
107 | if ( zlib_result == Z_STREAM_END || zlib_result == Z_OK )
108 | uncompressedFirmware = OSData::withBytes(buffer, (unsigned int) zstream.total_out);
109 |
110 | inflateEnd(&zstream);
111 | IOFree(buffer, bufferSize);
112 |
113 | DebugLog("decompressFirmware", "Firmware decompressed successfully.");
114 |
115 | return uncompressedFirmware;
116 | }
117 |
118 | void OpenFirmwareManager::requestResourceCallback(OSKextRequestTag requestTag, OSReturn result, const void * resourceData, uint32_t resourceDataLength, void * context1)
119 | {
120 | ResourceCallbackContext * context = (ResourceCallbackContext *) context1;
121 |
122 | IOLockLock(context->me->mExpansionData->mCompletionLock);
123 |
124 | if (kOSReturnSuccess == result)
125 | {
126 | DebugLog("requestResourceCallback", "%d bytes of data.", resourceDataLength);
127 | context->descriptor.firmwareData = (UInt8 *) resourceData;
128 | context->descriptor.firmwareSize = resourceDataLength;
129 | }
130 | else
131 | DebugLog("requestResourceCallback", "Retrieved error: %08x", result);
132 |
133 | IOLockUnlock(context->me->mExpansionData->mCompletionLock);
134 |
135 | // wake waiting task in performUpgrade (in IOLockSleep)...
136 | IOLockWakeup(context->me->mExpansionData->mCompletionLock, context->me, true);
137 | }
138 |
139 | IOReturn OpenFirmwareManager::addFirmwareWithName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares)
140 | {
141 | DebugLog("addFirmwareWithName", "name: %s -- firmwareCandidates: %p -- numFirmwares: %d", name, firmwareCandidates, numFirmwares);
142 | while ( --numFirmwares >= 0 )
143 | {
144 | DebugLog("addFirmwareWithName", "candidate name: %s, name: %s", firmwareCandidates[numFirmwares].name, name);
145 | if ( !strncmp(firmwareCandidates[numFirmwares].name, name, 64) )
146 | return addFirmwareWithDescriptor(firmwareCandidates[numFirmwares]);
147 | }
148 |
149 | AlwaysLog("addFirmwareWithName", "can't find the firmware with name!");
150 | return kIOReturnUnsupported;
151 | }
152 |
153 | IOReturn OpenFirmwareManager::addFirmwareWithDescriptor(FirmwareDescriptor firmware)
154 | {
155 | DebugLog("addFirmwareWithDescriptor", "name: %s -- firmwareData: %p -- firmwareSize: %d", firmware.name, firmware.firmwareData, firmware.firmwareSize);
156 | IOReturn err = kIOReturnSuccess;
157 |
158 | IOLockLock(mFirmwareLock);
159 | if ( !mFirmwares )
160 | {
161 | IOLockUnlock(mFirmwareLock);
162 | return kIOReturnInvalid;
163 | }
164 | IOLockUnlock(mFirmwareLock);
165 |
166 | OSData * uncompressedFirmware;
167 | OSData * fwData = OSData::withBytes(firmware.firmwareData, firmware.firmwareSize);
168 | if ( !fwData )
169 | return kIOReturnInvalid;
170 |
171 | if ( isFirmwareCompressed(fwData) )
172 | {
173 | uncompressedFirmware = decompressFirmware(fwData);
174 | OSSafeReleaseNULL(fwData);
175 | if ( !uncompressedFirmware )
176 | return kIOReturnError;
177 | goto SET_FIRMWARE;
178 | }
179 | uncompressedFirmware = fwData;
180 |
181 | SET_FIRMWARE:
182 | IOLockLock(mFirmwareLock);
183 | if ( !mFirmwares->setObject(firmware.name, uncompressedFirmware) )
184 | err = kIOReturnError;
185 |
186 | OSSafeReleaseNULL(uncompressedFirmware);
187 |
188 | OVER:
189 | IOLockUnlock(mFirmwareLock);
190 | DebugLog("addFirmwareWithDescriptor", "Firmware is added successfully!");
191 | return err;
192 | }
193 |
194 | IOReturn OpenFirmwareManager::addFirmwareWithFile(const char * kextIdentifier, const char * fileName)
195 | {
196 | DebugLog("addFirmwareWithDescriptor", "identifier: %s -- file name: %s", kextIdentifier, fileName);
197 | IOLockLock(mExpansionData->mCompletionLock);
198 |
199 | ResourceCallbackContext context = { .me = this };
200 |
201 | OSReturn ret = OSKextRequestResource(kextIdentifier, fileName, requestResourceCallback, &context, NULL);
202 | DebugLog("addFirmwareWithFile", "OSKextRequestResource: %08x", ret);
203 |
204 | // wait for completion of the async read
205 | IOLockSleep(mExpansionData->mCompletionLock, this, 0);
206 | IOLockUnlock(mExpansionData->mCompletionLock);
207 |
208 | if ( !context.descriptor.firmwareData || context.descriptor.firmwareSize <= 0 )
209 | return ret;
210 |
211 | DebugLog("addFirmwareWithFile", "Obtained firmware \"%s\" from resources.", fileName);
212 | context.descriptor.name = fileName;
213 |
214 | return addFirmwareWithDescriptor(context.descriptor);
215 | }
216 |
217 | IOReturn OpenFirmwareManager::removeFirmware(const char * name)
218 | {
219 | DebugLog("removeFirmware", "Removing firmware with the name %s", name);
220 | IOLockLock(mFirmwareLock);
221 | if ( !mFirmwares )
222 | {
223 | IOLockUnlock(mFirmwareLock);
224 | return kIOReturnInvalid;
225 | }
226 | mFirmwares->removeObject(name);
227 | IOLockUnlock(mFirmwareLock);
228 |
229 | return kIOReturnSuccess;
230 | }
231 |
232 | IOReturn OpenFirmwareManager::removeFirmwares()
233 | {
234 | DebugLog("removeFirmwares", "Removing all firmwares...");
235 | IOLockLock(mFirmwareLock);
236 | if ( !mFirmwares )
237 | {
238 | IOLockUnlock(mFirmwareLock);
239 | return kIOReturnInvalid;
240 | }
241 | mFirmwares->flushCollection();
242 | IOLockUnlock(mFirmwareLock);
243 | return kIOReturnSuccess;
244 | }
245 |
246 | OSData * OpenFirmwareManager::getFirmwareUncompressed(const char * name)
247 | {
248 | OSData * fwData;
249 |
250 | IOLockLock(mFirmwareLock);
251 | if ( !mFirmwares )
252 | {
253 | IOLockUnlock(mFirmwareLock);
254 | return NULL;
255 | }
256 | fwData = OSDynamicCast(OSData, mFirmwares->getObject(name));
257 | IOLockUnlock(mFirmwareLock);
258 | return fwData;
259 | }
260 |
261 | bool OpenFirmwareManager::initWithCapacity(int capacity)
262 | {
263 | DebugLog("initWithCapacity", "capacity: %d", capacity);
264 | if ( !init() || capacity <= 0 )
265 | return false;
266 |
267 | DebugLog("initWithCapacity", "init() succeeded!");
268 | IOLockLock(mFirmwareLock);
269 | mFirmwares = OSDictionary::withCapacity(capacity);
270 | if ( !mFirmwares )
271 | {
272 | IOLockUnlock(mFirmwareLock);
273 | return false;
274 | }
275 | IOLockUnlock(mFirmwareLock);
276 | DebugLog("initWithCapacity", "initialized successfully!");
277 | return true;
278 | }
279 |
280 | bool OpenFirmwareManager::initWithNames(const char ** names, int capacity, FirmwareDescriptor * firmwareCandidates, int numFirmwares)
281 | {
282 | if ( !initWithCapacity(capacity) )
283 | return false;
284 |
285 | while ( --capacity >= 0 )
286 | addFirmwareWithName(names[capacity], firmwareCandidates, numFirmwares);
287 |
288 | DebugLog("initWithNames", "initialized successfully!");
289 | return true;
290 | }
291 |
292 | bool OpenFirmwareManager::initWithName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares)
293 | {
294 | if ( !initWithCapacity(1) )
295 | return false;
296 |
297 | if ( !addFirmwareWithName(name, firmwareCandidates, numFirmwares) )
298 | {
299 | DebugLog("initWithName", "initialized successfully!");
300 | return true;
301 | }
302 | DebugLog("initWithName", "initialization failed!");
303 | return false;
304 | }
305 |
306 | bool OpenFirmwareManager::initWithDescriptors(FirmwareDescriptor * firmwares, int capacity)
307 | {
308 | if ( !initWithCapacity(capacity) )
309 | return false;
310 |
311 | while ( --capacity >= 0 )
312 | addFirmwareWithDescriptor(firmwares[capacity]); // no need to fail if a firmware is not added
313 |
314 | DebugLog("initWithDescriptors", "initialized successfully!");
315 | return true;
316 | }
317 |
318 | bool OpenFirmwareManager::initWithDescriptor(FirmwareDescriptor firmware)
319 | {
320 | if ( !initWithCapacity(1) )
321 | return false;
322 |
323 | if ( !addFirmwareWithDescriptor(firmware) )
324 | {
325 | DebugLog("initWithDescriptor", "initialized successfully!");
326 | return true;
327 | }
328 | DebugLog("initWithDescriptor", "initialization failed!");
329 | return false;
330 | }
331 |
332 | bool OpenFirmwareManager::initWithFiles(const char ** kextIdentifiers, const char ** fileNames, int capacity)
333 | {
334 | if ( !initWithCapacity(capacity) )
335 | return false;
336 |
337 | while ( --capacity >= 0 )
338 | addFirmwareWithFile(kextIdentifiers[capacity], fileNames[capacity]);
339 |
340 | DebugLog("initWithFiles", "initialized successfully!");
341 | return true;
342 | }
343 |
344 | bool OpenFirmwareManager::initWithFile(const char * kextIdentifier, const char * fileName)
345 | {
346 | if ( !initWithCapacity(1) )
347 | return false;
348 |
349 | if ( !addFirmwareWithFile(kextIdentifier, fileName) )
350 | {
351 | DebugLog("initWithFile", "initialized successfully!");
352 | return true;
353 | }
354 | DebugLog("initWithFile", "initialization failed!");
355 | return false;
356 | }
357 |
358 | OpenFirmwareManager * OpenFirmwareManager::withCapacity(int capacity)
359 | {
360 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
361 |
362 | if ( !me )
363 | return NULL;
364 | if ( !me->initWithCapacity(capacity) )
365 | {
366 | OSSafeReleaseNULL(me);
367 | return NULL;
368 | }
369 | return me;
370 | }
371 |
372 | OpenFirmwareManager * OpenFirmwareManager::withNames(const char ** names, int capacity, FirmwareDescriptor * firmwareCandidates, int numFirmwares)
373 | {
374 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
375 |
376 | if ( !me )
377 | return NULL;
378 | if ( !me->initWithNames(names, capacity, firmwareCandidates, numFirmwares) )
379 | {
380 | OSSafeReleaseNULL(me);
381 | return NULL;
382 | }
383 | return me;
384 | }
385 |
386 | OpenFirmwareManager * OpenFirmwareManager::withName(const char * name, FirmwareDescriptor * firmwareCandidates, int numFirmwares)
387 | {
388 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
389 |
390 | if ( !me )
391 | return NULL;
392 | if ( !me->initWithName(name, firmwareCandidates, numFirmwares) )
393 | {
394 | OSSafeReleaseNULL(me);
395 | return NULL;
396 | }
397 | return me;
398 | }
399 |
400 | OpenFirmwareManager * OpenFirmwareManager::withDescriptors(FirmwareDescriptor * firmwares, int capacity)
401 | {
402 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
403 |
404 | if ( !me )
405 | return NULL;
406 | if ( !me->initWithDescriptors(firmwares, capacity) )
407 | {
408 | OSSafeReleaseNULL(me);
409 | return NULL;
410 | }
411 | return me;
412 | }
413 |
414 | OpenFirmwareManager * OpenFirmwareManager::withDescriptor(FirmwareDescriptor firmware)
415 | {
416 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
417 |
418 | if ( !me )
419 | return NULL;
420 | if ( !me->initWithDescriptor(firmware) )
421 | {
422 | OSSafeReleaseNULL(me);
423 | return NULL;
424 | }
425 | return me;
426 | }
427 |
428 | OpenFirmwareManager * OpenFirmwareManager::withFiles(const char ** kextIdentifiers, const char ** fileNames, int capacity)
429 | {
430 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
431 |
432 | if ( !me )
433 | return NULL;
434 | if ( !me->initWithFiles(kextIdentifiers, fileNames, capacity) )
435 | {
436 | OSSafeReleaseNULL(me);
437 | return NULL;
438 | }
439 | return me;
440 | }
441 |
442 | OpenFirmwareManager * OpenFirmwareManager::withFile(const char * kextIdentifier, const char * fileName)
443 | {
444 | OpenFirmwareManager * me = OSTypeAlloc(OpenFirmwareManager);
445 |
446 | if ( !me )
447 | return NULL;
448 | if ( !me->initWithFile(kextIdentifier, fileName) )
449 | {
450 | OSSafeReleaseNULL(me);
451 | return NULL;
452 | }
453 | return me;
454 | }
455 |
--------------------------------------------------------------------------------
/OpenFirmwareManager.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 509E038F273B3A6200147EE1 /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 509E038E273B3A3500147EE1 /* libkmod.a */; };
11 | BC92575E26A3FD9D009DBAD2 /* OpenFirmwareManager.h in Headers */ = {isa = PBXBuildFile; fileRef = BC92575D26A3FD9D009DBAD2 /* OpenFirmwareManager.h */; };
12 | BC92576026A3FD9D009DBAD2 /* OpenFirmwareManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC92575F26A3FD9D009DBAD2 /* OpenFirmwareManager.cpp */; };
13 | BC92576A26A3FDF6009DBAD2 /* zutil.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BC92576826A3FDF6009DBAD2 /* zutil.cpp */; };
14 | BC92576B26A3FDF6009DBAD2 /* zutil.h in Headers */ = {isa = PBXBuildFile; fileRef = BC92576926A3FDF6009DBAD2 /* zutil.h */; };
15 | BCA7842B273AEB1000895B2F /* Logs.h in Headers */ = {isa = PBXBuildFile; fileRef = BCA7842A273AEAE900895B2F /* Logs.h */; };
16 | BCB7BA202738DE390029BC09 /* FirmwareList.h in Headers */ = {isa = PBXBuildFile; fileRef = BCB7BA1F2738DE390029BC09 /* FirmwareList.h */; };
17 | BCB7BA212738DE6F0029BC09 /* FirmwareList.h in Resources */ = {isa = PBXBuildFile; fileRef = BCB7BA1F2738DE390029BC09 /* FirmwareList.h */; };
18 | BCDF217D26E6F73F00432442 /* OpenFirmwareManager.h in Resources */ = {isa = PBXBuildFile; fileRef = BC92575D26A3FD9D009DBAD2 /* OpenFirmwareManager.h */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXFileReference section */
22 | 509E038E273B3A3500147EE1 /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libkmod.a; path = MacKernelSDK/Library/x86_64/libkmod.a; sourceTree = ""; };
23 | BC92575A26A3FD9D009DBAD2 /* OpenFirmwareManager.kext */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = OpenFirmwareManager.kext; sourceTree = BUILT_PRODUCTS_DIR; };
24 | BC92575D26A3FD9D009DBAD2 /* OpenFirmwareManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = OpenFirmwareManager.h; sourceTree = ""; usesTabs = 0; };
25 | BC92575F26A3FD9D009DBAD2 /* OpenFirmwareManager.cpp */ = {isa = PBXFileReference; indentWidth = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OpenFirmwareManager.cpp; sourceTree = ""; tabWidth = 4; usesTabs = 0; };
26 | BC92576126A3FD9D009DBAD2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
27 | BC92576826A3FDF6009DBAD2 /* zutil.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = zutil.cpp; sourceTree = ""; usesTabs = 0; };
28 | BC92576926A3FDF6009DBAD2 /* zutil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = zutil.h; sourceTree = ""; usesTabs = 0; };
29 | BCA7842A273AEAE900895B2F /* Logs.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Logs.h; sourceTree = ""; usesTabs = 0; };
30 | BCAAACE727339790005667DB /* .gitignore */ = {isa = PBXFileReference; lastKnownFileType = text; path = .gitignore; sourceTree = ""; };
31 | BCB187B6275F0688007E286A /* bootstrap.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = bootstrap.sh; sourceTree = ""; };
32 | BCB7BA1F2738DE390029BC09 /* FirmwareList.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FirmwareList.h; sourceTree = ""; usesTabs = 0; };
33 | BCDF218026E703A400432442 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = ""; };
34 | BCDF218126E703A400432442 /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; };
35 | /* End PBXFileReference section */
36 |
37 | /* Begin PBXFrameworksBuildPhase section */
38 | BC92575726A3FD9D009DBAD2 /* Frameworks */ = {
39 | isa = PBXFrameworksBuildPhase;
40 | buildActionMask = 2147483647;
41 | files = (
42 | 509E038F273B3A6200147EE1 /* libkmod.a in Frameworks */,
43 | );
44 | runOnlyForDeploymentPostprocessing = 0;
45 | };
46 | /* End PBXFrameworksBuildPhase section */
47 |
48 | /* Begin PBXGroup section */
49 | 509E038D273B3A3400147EE1 /* Frameworks */ = {
50 | isa = PBXGroup;
51 | children = (
52 | 509E038E273B3A3500147EE1 /* libkmod.a */,
53 | );
54 | name = Frameworks;
55 | sourceTree = "";
56 | };
57 | BC92575026A3FD9D009DBAD2 = {
58 | isa = PBXGroup;
59 | children = (
60 | BC92575C26A3FD9D009DBAD2 /* OpenFirmwareManager */,
61 | BCB187B6275F0688007E286A /* bootstrap.sh */,
62 | BCDF218026E703A400432442 /* LICENSE */,
63 | BCDF218126E703A400432442 /* README.md */,
64 | BCAAACE727339790005667DB /* .gitignore */,
65 | BC92575B26A3FD9D009DBAD2 /* Products */,
66 | 509E038D273B3A3400147EE1 /* Frameworks */,
67 | );
68 | sourceTree = "";
69 | };
70 | BC92575B26A3FD9D009DBAD2 /* Products */ = {
71 | isa = PBXGroup;
72 | children = (
73 | BC92575A26A3FD9D009DBAD2 /* OpenFirmwareManager.kext */,
74 | );
75 | name = Products;
76 | sourceTree = "";
77 | };
78 | BC92575C26A3FD9D009DBAD2 /* OpenFirmwareManager */ = {
79 | isa = PBXGroup;
80 | children = (
81 | BCA7842A273AEAE900895B2F /* Logs.h */,
82 | BC92576926A3FDF6009DBAD2 /* zutil.h */,
83 | BC92576826A3FDF6009DBAD2 /* zutil.cpp */,
84 | BC92575D26A3FD9D009DBAD2 /* OpenFirmwareManager.h */,
85 | BC92575F26A3FD9D009DBAD2 /* OpenFirmwareManager.cpp */,
86 | BCB7BA1F2738DE390029BC09 /* FirmwareList.h */,
87 | BC92576126A3FD9D009DBAD2 /* Info.plist */,
88 | );
89 | path = OpenFirmwareManager;
90 | sourceTree = "";
91 | };
92 | /* End PBXGroup section */
93 |
94 | /* Begin PBXHeadersBuildPhase section */
95 | BC92575526A3FD9D009DBAD2 /* Headers */ = {
96 | isa = PBXHeadersBuildPhase;
97 | buildActionMask = 2147483647;
98 | files = (
99 | BCA7842B273AEB1000895B2F /* Logs.h in Headers */,
100 | BC92576B26A3FDF6009DBAD2 /* zutil.h in Headers */,
101 | BC92575E26A3FD9D009DBAD2 /* OpenFirmwareManager.h in Headers */,
102 | BCB7BA202738DE390029BC09 /* FirmwareList.h in Headers */,
103 | );
104 | runOnlyForDeploymentPostprocessing = 0;
105 | };
106 | /* End PBXHeadersBuildPhase section */
107 |
108 | /* Begin PBXNativeTarget section */
109 | BC92575926A3FD9D009DBAD2 /* OpenFirmwareManager */ = {
110 | isa = PBXNativeTarget;
111 | buildConfigurationList = BC92576426A3FD9D009DBAD2 /* Build configuration list for PBXNativeTarget "OpenFirmwareManager" */;
112 | buildPhases = (
113 | BC92575526A3FD9D009DBAD2 /* Headers */,
114 | BC92575626A3FD9D009DBAD2 /* Sources */,
115 | BC92575726A3FD9D009DBAD2 /* Frameworks */,
116 | BC92575826A3FD9D009DBAD2 /* Resources */,
117 | );
118 | buildRules = (
119 | );
120 | dependencies = (
121 | );
122 | name = OpenFirmwareManager;
123 | productName = OpenFirmwareManager;
124 | productReference = BC92575A26A3FD9D009DBAD2 /* OpenFirmwareManager.kext */;
125 | productType = "com.apple.product-type.kernel-extension";
126 | };
127 | /* End PBXNativeTarget section */
128 |
129 | /* Begin PBXProject section */
130 | BC92575126A3FD9D009DBAD2 /* Project object */ = {
131 | isa = PBXProject;
132 | attributes = {
133 | LastUpgradeCheck = 1310;
134 | TargetAttributes = {
135 | BC92575926A3FD9D009DBAD2 = {
136 | CreatedOnToolsVersion = 12.4;
137 | };
138 | };
139 | };
140 | buildConfigurationList = BC92575426A3FD9D009DBAD2 /* Build configuration list for PBXProject "OpenFirmwareManager" */;
141 | compatibilityVersion = "Xcode 9.3";
142 | developmentRegion = en;
143 | hasScannedForEncodings = 0;
144 | knownRegions = (
145 | en,
146 | Base,
147 | );
148 | mainGroup = BC92575026A3FD9D009DBAD2;
149 | productRefGroup = BC92575B26A3FD9D009DBAD2 /* Products */;
150 | projectDirPath = "";
151 | projectRoot = "";
152 | targets = (
153 | BC92575926A3FD9D009DBAD2 /* OpenFirmwareManager */,
154 | );
155 | };
156 | /* End PBXProject section */
157 |
158 | /* Begin PBXResourcesBuildPhase section */
159 | BC92575826A3FD9D009DBAD2 /* Resources */ = {
160 | isa = PBXResourcesBuildPhase;
161 | buildActionMask = 2147483647;
162 | files = (
163 | BCDF217D26E6F73F00432442 /* OpenFirmwareManager.h in Resources */,
164 | BCB7BA212738DE6F0029BC09 /* FirmwareList.h in Resources */,
165 | );
166 | runOnlyForDeploymentPostprocessing = 0;
167 | };
168 | /* End PBXResourcesBuildPhase section */
169 |
170 | /* Begin PBXSourcesBuildPhase section */
171 | BC92575626A3FD9D009DBAD2 /* Sources */ = {
172 | isa = PBXSourcesBuildPhase;
173 | buildActionMask = 2147483647;
174 | files = (
175 | BC92576A26A3FDF6009DBAD2 /* zutil.cpp in Sources */,
176 | BC92576026A3FD9D009DBAD2 /* OpenFirmwareManager.cpp in Sources */,
177 | );
178 | runOnlyForDeploymentPostprocessing = 0;
179 | };
180 | /* End PBXSourcesBuildPhase section */
181 |
182 | /* Begin XCBuildConfiguration section */
183 | BC92576226A3FD9D009DBAD2 /* Debug */ = {
184 | isa = XCBuildConfiguration;
185 | buildSettings = {
186 | ALWAYS_SEARCH_USER_PATHS = NO;
187 | ARCHS = x86_64;
188 | CLANG_ANALYZER_NONNULL = YES;
189 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
190 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
191 | CLANG_CXX_LIBRARY = "libc++";
192 | CLANG_ENABLE_MODULES = YES;
193 | CLANG_ENABLE_OBJC_ARC = YES;
194 | CLANG_ENABLE_OBJC_WEAK = YES;
195 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
196 | CLANG_WARN_BOOL_CONVERSION = YES;
197 | CLANG_WARN_COMMA = YES;
198 | CLANG_WARN_CONSTANT_CONVERSION = YES;
199 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
200 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
201 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
202 | CLANG_WARN_EMPTY_BODY = YES;
203 | CLANG_WARN_ENUM_CONVERSION = YES;
204 | CLANG_WARN_INFINITE_RECURSION = YES;
205 | CLANG_WARN_INT_CONVERSION = YES;
206 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
207 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
208 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
209 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
210 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
211 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
212 | CLANG_WARN_STRICT_PROTOTYPES = YES;
213 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
214 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
215 | CLANG_WARN_UNREACHABLE_CODE = YES;
216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
217 | COPY_PHASE_STRIP = NO;
218 | DEBUG_INFORMATION_FORMAT = dwarf;
219 | ENABLE_STRICT_OBJC_MSGSEND = YES;
220 | ENABLE_TESTABILITY = YES;
221 | GCC_C_LANGUAGE_STANDARD = gnu11;
222 | GCC_DYNAMIC_NO_PIC = NO;
223 | GCC_NO_COMMON_BLOCKS = YES;
224 | GCC_OPTIMIZATION_LEVEL = 0;
225 | GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
226 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
227 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
228 | GCC_WARN_UNDECLARED_SELECTOR = YES;
229 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
230 | GCC_WARN_UNUSED_FUNCTION = YES;
231 | GCC_WARN_UNUSED_VARIABLE = YES;
232 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers";
233 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers";
234 | MACOSX_DEPLOYMENT_TARGET = 10.12;
235 | MODULE_VERSION = 1.0.0;
236 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
237 | MTL_FAST_MATH = YES;
238 | ONLY_ACTIVE_ARCH = YES;
239 | SDKROOT = macosx;
240 | };
241 | name = Debug;
242 | };
243 | BC92576326A3FD9D009DBAD2 /* Release */ = {
244 | isa = XCBuildConfiguration;
245 | buildSettings = {
246 | ALWAYS_SEARCH_USER_PATHS = NO;
247 | ARCHS = x86_64;
248 | CLANG_ANALYZER_NONNULL = YES;
249 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
250 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
251 | CLANG_CXX_LIBRARY = "libc++";
252 | CLANG_ENABLE_MODULES = YES;
253 | CLANG_ENABLE_OBJC_ARC = YES;
254 | CLANG_ENABLE_OBJC_WEAK = YES;
255 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
256 | CLANG_WARN_BOOL_CONVERSION = YES;
257 | CLANG_WARN_COMMA = YES;
258 | CLANG_WARN_CONSTANT_CONVERSION = YES;
259 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
260 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
261 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
262 | CLANG_WARN_EMPTY_BODY = YES;
263 | CLANG_WARN_ENUM_CONVERSION = YES;
264 | CLANG_WARN_INFINITE_RECURSION = YES;
265 | CLANG_WARN_INT_CONVERSION = YES;
266 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
267 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
268 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
269 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
270 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
271 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
272 | CLANG_WARN_STRICT_PROTOTYPES = YES;
273 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
274 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
275 | CLANG_WARN_UNREACHABLE_CODE = YES;
276 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
277 | COPY_PHASE_STRIP = NO;
278 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
279 | ENABLE_NS_ASSERTIONS = NO;
280 | ENABLE_STRICT_OBJC_MSGSEND = YES;
281 | GCC_C_LANGUAGE_STANDARD = gnu11;
282 | GCC_NO_COMMON_BLOCKS = YES;
283 | GCC_PREPROCESSOR_DEFINITIONS = "";
284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
286 | GCC_WARN_UNDECLARED_SELECTOR = YES;
287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
288 | GCC_WARN_UNUSED_FUNCTION = YES;
289 | GCC_WARN_UNUSED_VARIABLE = YES;
290 | KERNEL_EXTENSION_HEADER_SEARCH_PATHS = "$(PROJECT_DIR)/MacKernelSDK/Headers";
291 | KERNEL_FRAMEWORK_HEADERS = "$(PROJECT_DIR)/MacKernelSDK/Headers";
292 | MACOSX_DEPLOYMENT_TARGET = 10.12;
293 | MODULE_VERSION = 1.0.0;
294 | MTL_ENABLE_DEBUG_INFO = NO;
295 | MTL_FAST_MATH = YES;
296 | SDKROOT = macosx;
297 | };
298 | name = Release;
299 | };
300 | BC92576526A3FD9D009DBAD2 /* Debug */ = {
301 | isa = XCBuildConfiguration;
302 | buildSettings = {
303 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
304 | CODE_SIGN_IDENTITY = "-";
305 | CODE_SIGN_STYLE = Automatic;
306 | GCC_PREPROCESSOR_DEFINITIONS = (
307 | "PRODUCT_NAME=$(PRODUCT_NAME)",
308 | "DEBUG=1",
309 | );
310 | INFOPLIST_FILE = OpenFirmwareManager/Info.plist;
311 | LIBRARY_SEARCH_PATHS = (
312 | "$(inherited)",
313 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64",
314 | );
315 | MACOSX_DEPLOYMENT_TARGET = 10.12;
316 | MODULE_NAME = com.cjiang.OpenFirmwareManager;
317 | PRODUCT_BUNDLE_IDENTIFIER = com.cjiang.OpenFirmwareManager;
318 | PRODUCT_NAME = "$(TARGET_NAME)";
319 | RUN_CLANG_STATIC_ANALYZER = YES;
320 | WRAPPER_EXTENSION = kext;
321 | };
322 | name = Debug;
323 | };
324 | BC92576626A3FD9D009DBAD2 /* Release */ = {
325 | isa = XCBuildConfiguration;
326 | buildSettings = {
327 | CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = NO;
328 | CODE_SIGN_IDENTITY = "-";
329 | CODE_SIGN_STYLE = Automatic;
330 | EXCLUDED_SOURCE_FILE_NAMES = (
331 | "$(PROJECT_DIR)/OpenFirmwareManager/OpenFirmwareManager.h",
332 | "$(PROJECT_DIR)/OpenFirmwareManager/FirmwareList.h",
333 | );
334 | GCC_PREPROCESSOR_DEFINITIONS = "PRODUCT_NAME=$(PRODUCT_NAME)";
335 | INFOPLIST_FILE = OpenFirmwareManager/Info.plist;
336 | LIBRARY_SEARCH_PATHS = (
337 | "$(inherited)",
338 | "$(PROJECT_DIR)/MacKernelSDK/Library/x86_64",
339 | );
340 | MACOSX_DEPLOYMENT_TARGET = 10.12;
341 | MODULE_NAME = com.cjiang.OpenFirmwareManager;
342 | ONLY_ACTIVE_ARCH = NO;
343 | PRODUCT_BUNDLE_IDENTIFIER = com.cjiang.OpenFirmwareManager;
344 | PRODUCT_NAME = "$(TARGET_NAME)";
345 | RUN_CLANG_STATIC_ANALYZER = YES;
346 | WRAPPER_EXTENSION = kext;
347 | };
348 | name = Release;
349 | };
350 | /* End XCBuildConfiguration section */
351 |
352 | /* Begin XCConfigurationList section */
353 | BC92575426A3FD9D009DBAD2 /* Build configuration list for PBXProject "OpenFirmwareManager" */ = {
354 | isa = XCConfigurationList;
355 | buildConfigurations = (
356 | BC92576226A3FD9D009DBAD2 /* Debug */,
357 | BC92576326A3FD9D009DBAD2 /* Release */,
358 | );
359 | defaultConfigurationIsVisible = 0;
360 | defaultConfigurationName = Release;
361 | };
362 | BC92576426A3FD9D009DBAD2 /* Build configuration list for PBXNativeTarget "OpenFirmwareManager" */ = {
363 | isa = XCConfigurationList;
364 | buildConfigurations = (
365 | BC92576526A3FD9D009DBAD2 /* Debug */,
366 | BC92576626A3FD9D009DBAD2 /* Release */,
367 | );
368 | defaultConfigurationIsVisible = 0;
369 | defaultConfigurationName = Release;
370 | };
371 | /* End XCConfigurationList section */
372 | };
373 | rootObject = BC92575126A3FD9D009DBAD2 /* Project object */;
374 | }
375 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 2, June 1991
3 |
4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | Preamble
10 |
11 | The licenses for most software are designed to take away your
12 | freedom to share and change it. By contrast, the GNU General Public
13 | License is intended to guarantee your freedom to share and change free
14 | software--to make sure the software is free for all its users. This
15 | General Public License applies to most of the Free Software
16 | Foundation's software and to any other program whose authors commit to
17 | using it. (Some other Free Software Foundation software is covered by
18 | the GNU Lesser General Public License instead.) You can apply it to
19 | your programs, too.
20 |
21 | When we speak of free software, we are referring to freedom, not
22 | price. Our General Public Licenses are designed to make sure that you
23 | have the freedom to distribute copies of free software (and charge for
24 | this service if you wish), that you receive source code or can get it
25 | if you want it, that you can change the software or use pieces of it
26 | in new free programs; and that you know you can do these things.
27 |
28 | To protect your rights, we need to make restrictions that forbid
29 | anyone to deny you these rights or to ask you to surrender the rights.
30 | These restrictions translate to certain responsibilities for you if you
31 | distribute copies of the software, or if you modify it.
32 |
33 | For example, if you distribute copies of such a program, whether
34 | gratis or for a fee, you must give the recipients all the rights that
35 | you have. You must make sure that they, too, receive or can get the
36 | source code. And you must show them these terms so they know their
37 | rights.
38 |
39 | We protect your rights with two steps: (1) copyright the software, and
40 | (2) offer you this license which gives you legal permission to copy,
41 | distribute and/or modify the software.
42 |
43 | Also, for each author's protection and ours, we want to make certain
44 | that everyone understands that there is no warranty for this free
45 | software. If the software is modified by someone else and passed on, we
46 | want its recipients to know that what they have is not the original, so
47 | that any problems introduced by others will not reflect on the original
48 | authors' reputations.
49 |
50 | Finally, any free program is threatened constantly by software
51 | patents. We wish to avoid the danger that redistributors of a free
52 | program will individually obtain patent licenses, in effect making the
53 | program proprietary. To prevent this, we have made it clear that any
54 | patent must be licensed for everyone's free use or not licensed at all.
55 |
56 | The precise terms and conditions for copying, distribution and
57 | modification follow.
58 |
59 | GNU GENERAL PUBLIC LICENSE
60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61 |
62 | 0. This License applies to any program or other work which contains
63 | a notice placed by the copyright holder saying it may be distributed
64 | under the terms of this General Public License. The "Program", below,
65 | refers to any such program or work, and a "work based on the Program"
66 | means either the Program or any derivative work under copyright law:
67 | that is to say, a work containing the Program or a portion of it,
68 | either verbatim or with modifications and/or translated into another
69 | language. (Hereinafter, translation is included without limitation in
70 | the term "modification".) Each licensee is addressed as "you".
71 |
72 | Activities other than copying, distribution and modification are not
73 | covered by this License; they are outside its scope. The act of
74 | running the Program is not restricted, and the output from the Program
75 | is covered only if its contents constitute a work based on the
76 | Program (independent of having been made by running the Program).
77 | Whether that is true depends on what the Program does.
78 |
79 | 1. You may copy and distribute verbatim copies of the Program's
80 | source code as you receive it, in any medium, provided that you
81 | conspicuously and appropriately publish on each copy an appropriate
82 | copyright notice and disclaimer of warranty; keep intact all the
83 | notices that refer to this License and to the absence of any warranty;
84 | and give any other recipients of the Program a copy of this License
85 | along with the Program.
86 |
87 | You may charge a fee for the physical act of transferring a copy, and
88 | you may at your option offer warranty protection in exchange for a fee.
89 |
90 | 2. You may modify your copy or copies of the Program or any portion
91 | of it, thus forming a work based on the Program, and copy and
92 | distribute such modifications or work under the terms of Section 1
93 | above, provided that you also meet all of these conditions:
94 |
95 | a) You must cause the modified files to carry prominent notices
96 | stating that you changed the files and the date of any change.
97 |
98 | b) You must cause any work that you distribute or publish, that in
99 | whole or in part contains or is derived from the Program or any
100 | part thereof, to be licensed as a whole at no charge to all third
101 | parties under the terms of this License.
102 |
103 | c) If the modified program normally reads commands interactively
104 | when run, you must cause it, when started running for such
105 | interactive use in the most ordinary way, to print or display an
106 | announcement including an appropriate copyright notice and a
107 | notice that there is no warranty (or else, saying that you provide
108 | a warranty) and that users may redistribute the program under
109 | these conditions, and telling the user how to view a copy of this
110 | License. (Exception: if the Program itself is interactive but
111 | does not normally print such an announcement, your work based on
112 | the Program is not required to print an announcement.)
113 |
114 | These requirements apply to the modified work as a whole. If
115 | identifiable sections of that work are not derived from the Program,
116 | and can be reasonably considered independent and separate works in
117 | themselves, then this License, and its terms, do not apply to those
118 | sections when you distribute them as separate works. But when you
119 | distribute the same sections as part of a whole which is a work based
120 | on the Program, the distribution of the whole must be on the terms of
121 | this License, whose permissions for other licensees extend to the
122 | entire whole, and thus to each and every part regardless of who wrote it.
123 |
124 | Thus, it is not the intent of this section to claim rights or contest
125 | your rights to work written entirely by you; rather, the intent is to
126 | exercise the right to control the distribution of derivative or
127 | collective works based on the Program.
128 |
129 | In addition, mere aggregation of another work not based on the Program
130 | with the Program (or with a work based on the Program) on a volume of
131 | a storage or distribution medium does not bring the other work under
132 | the scope of this License.
133 |
134 | 3. You may copy and distribute the Program (or a work based on it,
135 | under Section 2) in object code or executable form under the terms of
136 | Sections 1 and 2 above provided that you also do one of the following:
137 |
138 | a) Accompany it with the complete corresponding machine-readable
139 | source code, which must be distributed under the terms of Sections
140 | 1 and 2 above on a medium customarily used for software interchange; or,
141 |
142 | b) Accompany it with a written offer, valid for at least three
143 | years, to give any third party, for a charge no more than your
144 | cost of physically performing source distribution, a complete
145 | machine-readable copy of the corresponding source code, to be
146 | distributed under the terms of Sections 1 and 2 above on a medium
147 | customarily used for software interchange; or,
148 |
149 | c) Accompany it with the information you received as to the offer
150 | to distribute corresponding source code. (This alternative is
151 | allowed only for noncommercial distribution and only if you
152 | received the program in object code or executable form with such
153 | an offer, in accord with Subsection b above.)
154 |
155 | The source code for a work means the preferred form of the work for
156 | making modifications to it. For an executable work, complete source
157 | code means all the source code for all modules it contains, plus any
158 | associated interface definition files, plus the scripts used to
159 | control compilation and installation of the executable. However, as a
160 | special exception, the source code distributed need not include
161 | anything that is normally distributed (in either source or binary
162 | form) with the major components (compiler, kernel, and so on) of the
163 | operating system on which the executable runs, unless that component
164 | itself accompanies the executable.
165 |
166 | If distribution of executable or object code is made by offering
167 | access to copy from a designated place, then offering equivalent
168 | access to copy the source code from the same place counts as
169 | distribution of the source code, even though third parties are not
170 | compelled to copy the source along with the object code.
171 |
172 | 4. You may not copy, modify, sublicense, or distribute the Program
173 | except as expressly provided under this License. Any attempt
174 | otherwise to copy, modify, sublicense or distribute the Program is
175 | void, and will automatically terminate your rights under this License.
176 | However, parties who have received copies, or rights, from you under
177 | this License will not have their licenses terminated so long as such
178 | parties remain in full compliance.
179 |
180 | 5. You are not required to accept this License, since you have not
181 | signed it. However, nothing else grants you permission to modify or
182 | distribute the Program or its derivative works. These actions are
183 | prohibited by law if you do not accept this License. Therefore, by
184 | modifying or distributing the Program (or any work based on the
185 | Program), you indicate your acceptance of this License to do so, and
186 | all its terms and conditions for copying, distributing or modifying
187 | the Program or works based on it.
188 |
189 | 6. Each time you redistribute the Program (or any work based on the
190 | Program), the recipient automatically receives a license from the
191 | original licensor to copy, distribute or modify the Program subject to
192 | these terms and conditions. You may not impose any further
193 | restrictions on the recipients' exercise of the rights granted herein.
194 | You are not responsible for enforcing compliance by third parties to
195 | this License.
196 |
197 | 7. If, as a consequence of a court judgment or allegation of patent
198 | infringement or for any other reason (not limited to patent issues),
199 | conditions are imposed on you (whether by court order, agreement or
200 | otherwise) that contradict the conditions of this License, they do not
201 | excuse you from the conditions of this License. If you cannot
202 | distribute so as to satisfy simultaneously your obligations under this
203 | License and any other pertinent obligations, then as a consequence you
204 | may not distribute the Program at all. For example, if a patent
205 | license would not permit royalty-free redistribution of the Program by
206 | all those who receive copies directly or indirectly through you, then
207 | the only way you could satisfy both it and this License would be to
208 | refrain entirely from distribution of the Program.
209 |
210 | If any portion of this section is held invalid or unenforceable under
211 | any particular circumstance, the balance of the section is intended to
212 | apply and the section as a whole is intended to apply in other
213 | circumstances.
214 |
215 | It is not the purpose of this section to induce you to infringe any
216 | patents or other property right claims or to contest validity of any
217 | such claims; this section has the sole purpose of protecting the
218 | integrity of the free software distribution system, which is
219 | implemented by public license practices. Many people have made
220 | generous contributions to the wide range of software distributed
221 | through that system in reliance on consistent application of that
222 | system; it is up to the author/donor to decide if he or she is willing
223 | to distribute software through any other system and a licensee cannot
224 | impose that choice.
225 |
226 | This section is intended to make thoroughly clear what is believed to
227 | be a consequence of the rest of this License.
228 |
229 | 8. If the distribution and/or use of the Program is restricted in
230 | certain countries either by patents or by copyrighted interfaces, the
231 | original copyright holder who places the Program under this License
232 | may add an explicit geographical distribution limitation excluding
233 | those countries, so that distribution is permitted only in or among
234 | countries not thus excluded. In such case, this License incorporates
235 | the limitation as if written in the body of this License.
236 |
237 | 9. The Free Software Foundation may publish revised and/or new versions
238 | of the General Public License from time to time. Such new versions will
239 | be similar in spirit to the present version, but may differ in detail to
240 | address new problems or concerns.
241 |
242 | Each version is given a distinguishing version number. If the Program
243 | specifies a version number of this License which applies to it and "any
244 | later version", you have the option of following the terms and conditions
245 | either of that version or of any later version published by the Free
246 | Software Foundation. If the Program does not specify a version number of
247 | this License, you may choose any version ever published by the Free Software
248 | Foundation.
249 |
250 | 10. If you wish to incorporate parts of the Program into other free
251 | programs whose distribution conditions are different, write to the author
252 | to ask for permission. For software which is copyrighted by the Free
253 | Software Foundation, write to the Free Software Foundation; we sometimes
254 | make exceptions for this. Our decision will be guided by the two goals
255 | of preserving the free status of all derivatives of our free software and
256 | of promoting the sharing and reuse of software generally.
257 |
258 | NO WARRANTY
259 |
260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268 | REPAIR OR CORRECTION.
269 |
270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278 | POSSIBILITY OF SUCH DAMAGES.
279 |
280 | END OF TERMS AND CONDITIONS
281 |
282 | How to Apply These Terms to Your New Programs
283 |
284 | If you develop a new program, and you want it to be of the greatest
285 | possible use to the public, the best way to achieve this is to make it
286 | free software which everyone can redistribute and change under these terms.
287 |
288 | To do so, attach the following notices to the program. It is safest
289 | to attach them to the start of each source file to most effectively
290 | convey the exclusion of warranty; and each file should have at least
291 | the "copyright" line and a pointer to where the full notice is found.
292 |
293 |
294 | Copyright (C)
295 |
296 | This program is free software; you can redistribute it and/or modify
297 | it under the terms of the GNU General Public License as published by
298 | the Free Software Foundation; either version 2 of the License, or
299 | (at your option) any later version.
300 |
301 | This program is distributed in the hope that it will be useful,
302 | but WITHOUT ANY WARRANTY; without even the implied warranty of
303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304 | GNU General Public License for more details.
305 |
306 | You should have received a copy of the GNU General Public License along
307 | with this program; if not, write to the Free Software Foundation, Inc.,
308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309 |
310 | Also add information on how to contact you by electronic and paper mail.
311 |
312 | If the program is interactive, make it output a short notice like this
313 | when it starts in an interactive mode:
314 |
315 | Gnomovision version 69, Copyright (C) year name of author
316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317 | This is free software, and you are welcome to redistribute it
318 | under certain conditions; type `show c' for details.
319 |
320 | The hypothetical commands `show w' and `show c' should show the appropriate
321 | parts of the General Public License. Of course, the commands you use may
322 | be called something other than `show w' and `show c'; they could even be
323 | mouse-clicks or menu items--whatever suits your program.
324 |
325 | You should also get your employer (if you work as a programmer) or your
326 | school, if any, to sign a "copyright disclaimer" for the program, if
327 | necessary. Here is a sample; alter the names:
328 |
329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330 | `Gnomovision' (which makes passes at compilers) written by James Hacker.
331 |
332 | , 1 April 1989
333 | Ty Coon, President of Vice
334 |
335 | This General Public License does not permit incorporating your program into
336 | proprietary programs. If your program is a subroutine library, you may
337 | consider it more useful to permit linking proprietary applications with the
338 | library. If this is what you want to do, use the GNU Lesser General
339 | Public License instead of this License.
340 |
--------------------------------------------------------------------------------