Skip to content

Commit

Permalink
V2.1: Fix the night shift panel issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
0xFireWolf committed Jun 29, 2017
1 parent f9a4616 commit bed3099
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 21 deletions.
8 changes: 8 additions & 0 deletions NightShiftUnlocker.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
D51ED5931ECDF8280084868D /* libkmod.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D51ED5901ECDF8280084868D /* libkmod.a */; };
D51ED5941ECDF8280084868D /* plugin_start.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D51ED5911ECDF8280084868D /* plugin_start.cpp */; };
D51ED59C1ECE0CC20084868D /* kern_start.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D51ED59B1ECE0CC20084868D /* kern_start.cpp */; };
D56FFB641F03D59100C07AE5 /* OSVersion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D56FFB621F03D59100C07AE5 /* OSVersion.cpp */; };
D56FFB651F03D59100C07AE5 /* OSVersion.hpp in Headers */ = {isa = PBXBuildFile; fileRef = D56FFB631F03D59100C07AE5 /* OSVersion.hpp */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand All @@ -44,6 +46,8 @@
D51ED5901ECDF8280084868D /* libkmod.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libkmod.a; sourceTree = "<group>"; };
D51ED5911ECDF8280084868D /* plugin_start.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = plugin_start.cpp; sourceTree = "<group>"; };
D51ED59B1ECE0CC20084868D /* kern_start.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = kern_start.cpp; sourceTree = "<group>"; };
D56FFB621F03D59100C07AE5 /* OSVersion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = OSVersion.cpp; sourceTree = "<group>"; };
D56FFB631F03D59100C07AE5 /* OSVersion.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = OSVersion.hpp; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -80,6 +84,8 @@
D51ED58E1ECDF8280084868D /* Library */,
D51ED5751ECDF8120084868D /* Headers */,
D51ED59B1ECE0CC20084868D /* kern_start.cpp */,
D56FFB621F03D59100C07AE5 /* OSVersion.cpp */,
D56FFB631F03D59100C07AE5 /* OSVersion.hpp */,
D51ED56F1ECDF7F10084868D /* Info.plist */,
);
path = NightShiftUnlocker;
Expand Down Expand Up @@ -126,6 +132,7 @@
D51ED58A1ECDF8120084868D /* kern_policy.hpp in Headers */,
D51ED5891ECDF8120084868D /* kern_patcher.hpp in Headers */,
D51ED58C1ECDF8120084868D /* kern_util.hpp in Headers */,
D56FFB651F03D59100C07AE5 /* OSVersion.hpp in Headers */,
D51ED5861ECDF8120084868D /* kern_file.hpp in Headers */,
D51ED5921ECDF8280084868D /* LegacyIOService.h in Headers */,
D51ED5881ECDF8120084868D /* kern_mach.hpp in Headers */,
Expand Down Expand Up @@ -205,6 +212,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D56FFB641F03D59100C07AE5 /* OSVersion.cpp in Sources */,
D51ED59C1ECE0CC20084868D /* kern_start.cpp in Sources */,
D51ED5941ECDF8280084868D /* plugin_start.cpp in Sources */,
);
Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions NightShiftUnlocker/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
<key>CFBundlePackageType</key>
<string>KEXT</string>
<key>CFBundleShortVersionString</key>
<string>2.0</string>
<string>2.1</string>
<key>CFBundleVersion</key>
<string>2.0</string>
<string>2.1</string>
<key>IOKitPersonalities</key>
<dict>
<key>science.firewolf.NightShiftUnlocker</key>
Expand Down
23 changes: 4 additions & 19 deletions NightShiftUnlocker/kern_start.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ static const char* CoreBrightnessBinaryAA = "/System/Library/PrivateFrameworks/C

static const char* symbolAA = "_CBU_IsNightShiftSupported";

static const size_t numProcessesAA = 2;
static const size_t numProcessesAA = 3;

static UserPatcher::ProcInfo processesAA[] =
{
{"/usr/libexec/corebrightnessd", 28, SectionActive},

{"/System/Library/CoreServices/NotificationCenter.app/Contents/MacOS/NotificationCenter", 85, SectionActive}
{"/System/Library/CoreServices/NotificationCenter.app/Contents/MacOS/NotificationCenter", 85, SectionActive},

{"/Applications/System Preferences.app/Contents/MacOS/System Preferences", 70, SectionActive}
};

static const size_t numBytesBufferAA = 32;
Expand Down Expand Up @@ -201,23 +203,6 @@ static void generatePatches(void* unused, KernelPatcher &patcher)

IOLog("NightShiftUnlocker::generatePatches() Binary patches have been generated.\n");

// DEBUG
IOLog("\nNightShiftUnlocker::generatePatches() NEW Find: ");

for (int index = 0; index < length; index++)
{
IOLog("%02X", findBytesAA[index]);
}

IOLog("\nNightShiftUnlocker::generatePatches() NEW Repl: ");

for (int index = 0; index < length; index++)
{
IOLog("%02X", replBytesAA[index]);
}

IOLog("\n");

delete [] buffer;
}
else
Expand Down
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ It uses a global function `CBU_IsNightShiftSupported()` and an array of supporte
Instead of modifying the minimum version of supported Mac models, I make this function always return `true`.

### Update Logs
#### 2.1 @ 2017.06.29
- Fix an issue that Night Shift panel may not show up in the System Preference >> Display.

#### 2.0 @ 2017.06.28
- Dynamically generate binary patches. (Thanks to vit9696's new APIs)
- Supports the latest macOS High Sierra.
Expand Down Expand Up @@ -76,6 +79,9 @@ Night Shift 作为 10.12.4 的新功能由系统私有框架 CoreBrightness.fram
如此用户不需要再手动去修改最低机型的定义以及重新签名二进制了,也不会受到系统升级导致原有二进制文件被覆盖的限制。

### 更新日志
#### 2.1 @ 2017.06.29
- 修复 Night Shift 面板在系统偏好设置里不显示的问题

#### 2.0 @ 2017.06.28
- 动态生成二进制补丁 (感谢 vit9696 开发的新API)
- 支持最新的 macOS High Sierra
Expand Down

0 comments on commit bed3099

Please sign in to comment.