From 35f5315b73e3627313f1b55710db630eff4d2a0a Mon Sep 17 00:00:00 2001 From: kozlek Date: Mon, 23 Sep 2013 20:10:58 +0300 Subject: [PATCH] Implemented another method to prevent FakeSMC loading on original Apple's hardware instead of checking firmware name. Added "CPU Package" temperature entry to use by plugins in configuration --- .gitignore | 2 +- FakeSMC/FakeSMC.cpp | 28 +++++++---- FakeSMC/FakeSMCPlugin.h | 3 +- Scripts/BuildInstaller.sh | 4 +- Scripts/GenerateAppcast.sh | 72 ++++++++++++++++++++-------- Scripts/SignApp.sh | 2 +- Versioning.xcodeproj/project.pbxproj | 3 +- rnotes.html | 8 ---- 8 files changed, 79 insertions(+), 43 deletions(-) delete mode 100644 rnotes.html diff --git a/.gitignore b/.gitignore index 71ea37f2..df7a6174 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,5 @@ smcutil version.h revision.txt *.xccheckout - dsa_priv.pem +Appcast/*.* diff --git a/FakeSMC/FakeSMC.cpp b/FakeSMC/FakeSMC.cpp index 015c0630..2aae40d8 100755 --- a/FakeSMC/FakeSMC.cpp +++ b/FakeSMC/FakeSMC.cpp @@ -99,16 +99,28 @@ bool FakeSMC::start(IOService *provider) if (!super::start(provider)) return false; - OSString *vendor = OSDynamicCast(OSString, getProperty(kFakeSMCFirmwareVendor)); - int arg_value = 1; - if (PE_parse_boot_argn("-fakesmc-force-start", &arg_value, sizeof(arg_value))) { - HWSensorsInfoLog("firmware vendor check disabled"); - } - else if (vendor && vendor->isEqualTo("Apple")) { - HWSensorsFatalLog("forbidding start on Apple hardware"); - return false; + // Check if we have SMC already + if (OSDictionary *matching = serviceMatching("IOACPIPlatformDevice")) { + if (OSIterator *iterator = getMatchingServices(matching)) { + + OSString *smcNameProperty = OSString::withCString("APP0001"); + + while (IOService *service = (IOService*)iterator->getNextObject()) { + + OSObject *serviceNameProperty = service->getProperty("name"); + + if (serviceNameProperty && serviceNameProperty->isEqualTo(smcNameProperty)) { + HWSensorsFatalLog("SMC device detected, will not create another one"); + return false; + } + } + + OSSafeRelease(iterator); + } + + OSSafeRelease(matching); } if (!smcDevice->initAndStart(provider, this)) { diff --git a/FakeSMC/FakeSMCPlugin.h b/FakeSMC/FakeSMCPlugin.h index e0512676..1524587a 100644 --- a/FakeSMC/FakeSMCPlugin.h +++ b/FakeSMC/FakeSMCPlugin.h @@ -60,7 +60,8 @@ struct FakeSMCSensorDefinitionEntry { const struct FakeSMCSensorDefinitionEntry FakeSMCSensorDefinitions[] = { {"Ambient", "TA0P", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 0}, - {"CPU Die", "TC%XD", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 0xF}, + {"CPU Die", "TC%XD", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 0x9}, + {"CPU Package", "TC%XD", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0xA, 0x6}, {"CPU Core", "TC%XC", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 0xF}, {"CPU GFX", "TC%XG", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 0xF}, {"CPU Heatsink", "TC%XH", TYPE_SP78, TYPE_SPXX_SIZE, kFakeSMCCategoryTemperature, 0, 4}, diff --git a/Scripts/BuildInstaller.sh b/Scripts/BuildInstaller.sh index 962c4455..8938aead 100644 --- a/Scripts/BuildInstaller.sh +++ b/Scripts/BuildInstaller.sh @@ -6,12 +6,10 @@ # Created by Kozlek on 13/07/13. # -# Clean packages every time -find ./Binaries/ -maxdepth 1 -type f -name "*.pkg" -delete - # Exit on clean action if [ "$1" == "clean" ] then + find ./Binaries/ -maxdepth 1 -type f -name "*.pkg" -delete exit 0 fi diff --git a/Scripts/GenerateAppcast.sh b/Scripts/GenerateAppcast.sh index bccf0ea7..3c728524 100644 --- a/Scripts/GenerateAppcast.sh +++ b/Scripts/GenerateAppcast.sh @@ -8,8 +8,8 @@ if [ "$1" == "clean" ] then -find ./Binaries/ -maxdepth 1 -type f -name "*.zip" -delete -exit 0 + find ./Binaries/ -maxdepth 1 -type f -name "*.zip" -delete + exit 0 fi project_name=$(/usr/libexec/PlistBuddy -c "Print 'Project Name'" "./version.plist") @@ -24,25 +24,59 @@ zip -r -X ./Binaries/${zip_filename} ./Binaries/${pkg_filename} dsa_signature=$(openssl dgst -sha1 -binary < ./Binaries/${zip_filename} | openssl dgst -dss1 -sign ./dsa_priv.pem | openssl enc -base64) # appcast.xml -echo '' > ./appcast.xml -echo '' >> ./appcast.xml -echo '' >> ./appcast.xml -echo ' '${project_name}' Changelog' >> ./appcast.xml -echo ' https://raw.github.com/kozlek/HWSensors/master/appcast.xml' >> ./appcast.xml -echo ' Most recent changes with links to updates.' >> ./appcast.xml -echo ' en' >> ./appcast.xml -echo ' ' >> ./appcast.xml -echo ' https://raw.github.com/kozlek/HWSensors/master/rnotes.html' >> ./appcast.xml -echo ' Version '${full_version}'' >> ./appcast.xml -echo ' '$(date +"%a, %d %b %G %T %z")'' >> ./appcast.xml -echo ' ' >> ./appcast.xml -echo ' ' >> ./appcast.xml -echo '' >> ./appcast.xml -echo '' >> ./appcast.xml +echo '' > ./Appcast/appcast.xml +echo '' >> ./Appcast/appcast.xml +echo '' >> ./Appcast/appcast.xml +echo ' '${project_name}' Changelog' >> ./Appcast/appcast.xml +echo ' http://hwsensors.com/appcast/appcast.xml' >> ./Appcast/appcast.xml +echo ' Most recent changes with links to updates.' >> ./Appcast/appcast.xml +echo ' en' >> ./Appcast/appcast.xml +echo ' ' >> ./Appcast/appcast.xml +echo ' http://hwsensors.com/appcast/rnotes.html' >> ./Appcast/appcast.xml +echo ' Version '${full_version}'' >> ./Appcast/appcast.xml +echo ' '$(date +"%a, %d %b %G %T %z")'' >> ./Appcast/appcast.xml +echo ' ' >> ./Appcast/appcast.xml +echo ' ' >> ./Appcast/appcast.xml +echo '' >> ./Appcast/appcast.xml +echo '' >> ./Appcast/appcast.xml #git_log=$(git log `git describe --tags --abbrev=0`..HEAD --oneline --pretty=format:"• (%ad by %an) %s" --date=short | tr "\n" "|") -git_log=$(git log `git describe --tags --abbrev=0`..HEAD --oneline --pretty=format:"• %s" --date=short | tr "\n" "|") +git_log=$(git log `git describe --tags --abbrev=0`..HEAD --oneline --pretty=format:"
  • %s
  • \n" --date=short) #rnotes.html -echo ${git_log//|/\
    } > ./rnotes.html \ No newline at end of file +echo '' > ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' '${project_name}' v'${full_version}'' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo '
    ' >> ./Appcast/rnotes.html +echo '

    New in '${project_name}' v'${full_version}'

    ' >> ./Appcast/rnotes.html +echo '
    ' >> ./Appcast/rnotes.html +echo '

    Bug Fixed/Changes/Features

    ' >> ./Appcast/rnotes.html +echo '
      ' >> ./Appcast/rnotes.html +echo ${git_log} >> ./Appcast/rnotes.html +echo '
    ' >> ./Appcast/rnotes.html +echo '
    ' >> ./Appcast/rnotes.html +echo '
    ' >> ./Appcast/rnotes.html +echo ' ' >> ./Appcast/rnotes.html +echo '' >> ./Appcast/rnotes.html diff --git a/Scripts/SignApp.sh b/Scripts/SignApp.sh index 057bcd5c..8e4fa36e 100644 --- a/Scripts/SignApp.sh +++ b/Scripts/SignApp.sh @@ -12,7 +12,7 @@ then exit 0 fi -/usr/libexec/PlistBuddy -c "Add :SUFeedURL string https://raw.github.com/kozlek/HWSensors/master/appcast.xml" "./Binaries/HWMonitor.app/Contents/info.plist" +/usr/libexec/PlistBuddy -c "Add :SUFeedURL string http://hwsensors.com/appcast/appcast.xml" "./Binaries/HWMonitor.app/Contents/info.plist" /usr/libexec/PlistBuddy -c "Add :SUPublicDSAKeyFile string dsa_pub.pem" "./Binaries/HWMonitor.app/Contents/info.plist" # This for testing updates diff --git a/Versioning.xcodeproj/project.pbxproj b/Versioning.xcodeproj/project.pbxproj index 0ccfcbf8..ab672ab9 100644 --- a/Versioning.xcodeproj/project.pbxproj +++ b/Versioning.xcodeproj/project.pbxproj @@ -22,7 +22,6 @@ 7EBA20C817ED59C6008E54C5 /* TagCurrentVersion.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = TagCurrentVersion.sh; sourceTree = ""; }; 7EBA20D517ED7B41008E54C5 /* GenerateAppcast.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = GenerateAppcast.sh; sourceTree = ""; }; 7EBA20DF17EDBD3A008E54C5 /* appcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = ""; }; - 7EBA20E017EDBD3F008E54C5 /* rnotes.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = rnotes.html; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXGroup section */ @@ -32,7 +31,6 @@ 7E2F25191783EAE800C86586 /* version.h */, 7E3ABDBA1796580B00201804 /* revision.txt */, 7EBA20DF17EDBD3A008E54C5 /* appcast.xml */, - 7EBA20E017EDBD3F008E54C5 /* rnotes.html */, ); name = "Autogenerated Files"; sourceTree = ""; @@ -808,6 +806,7 @@ 7EBA20D917ED7D1C008E54C5 /* Release */, ); defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; }; /* End XCConfigurationList section */ }; diff --git a/rnotes.html b/rnotes.html deleted file mode 100644 index 68a403a4..00000000 --- a/rnotes.html +++ /dev/null @@ -1,8 +0,0 @@ -• Integrated Sparkle framework for automatic updates -• Minor UI tweaks -• Adding "CPU Core X" temperature keys for cpu sensors at core level instead of "CPU Die X" -• Accelerating graphs sensors list scrolling and resizing
    • Fix for drive popup item cannot be dragged to rearrange -• Warning fix. smartctl output optimizations -• Popup window constraints cleanup -• Graphs sensors list constraints cleanup -• Some new constraints work