Skip to content
This repository has been archived by the owner on Oct 12, 2018. It is now read-only.

Commit

Permalink
Implemented another method to prevent FakeSMC loading on original App…
Browse files Browse the repository at this point in the history
…le's hardware instead of checking firmware name. Added "CPU Package" temperature entry to use by plugins in configuration
  • Loading branch information
Cozmonat committed Sep 23, 2013
1 parent 6df739a commit 35f5315
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 43 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ smcutil
version.h
revision.txt
*.xccheckout

dsa_priv.pem
Appcast/*.*
28 changes: 20 additions & 8 deletions FakeSMC/FakeSMC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
3 changes: 2 additions & 1 deletion FakeSMC/FakeSMCPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 1 addition & 3 deletions Scripts/BuildInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
72 changes: 53 additions & 19 deletions Scripts/GenerateAppcast.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 '<?xml version="1.0" encoding="utf-8"?>' > ./appcast.xml
echo '<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">' >> ./appcast.xml
echo '<channel>' >> ./appcast.xml
echo ' <title>'${project_name}' Changelog</title>' >> ./appcast.xml
echo ' <link>https://raw.github.com/kozlek/HWSensors/master/appcast.xml</link>' >> ./appcast.xml
echo ' <description>Most recent changes with links to updates.</description>' >> ./appcast.xml
echo ' <language>en</language>' >> ./appcast.xml
echo ' <item>' >> ./appcast.xml
echo ' <sparkle:releaseNotesLink>https://raw.github.com/kozlek/HWSensors/master/rnotes.html</sparkle:releaseNotesLink>' >> ./appcast.xml
echo ' <title>Version '${full_version}'</title>' >> ./appcast.xml
echo ' <pubDate>'$(date +"%a, %d %b %G %T %z")'</pubDate>' >> ./appcast.xml
echo ' <enclosure url="http://sourceforge.net/projects/hwsensors/files/'${zip_filename}'" sparkle:version="'${last_revision}'" sparkle:shortVersionString="'${full_version}'" sparkle:dsaSignature="'${dsa_signature}'" length="'$(stat -f %z ./Binaries/${zip_filename})'" type="application/x-compress"/>' >> ./appcast.xml
echo ' </item>' >> ./appcast.xml
echo '</channel>' >> ./appcast.xml
echo '</rss>' >> ./appcast.xml
echo '<?xml version="1.0" encoding="utf-8"?>' > ./Appcast/appcast.xml
echo '<rss version="2.0" xmlns:sparkle="http://www.andymatuschak.org/xml-namespaces/sparkle" xmlns:dc="http://purl.org/dc/elements/1.1/">' >> ./Appcast/appcast.xml
echo '<channel>' >> ./Appcast/appcast.xml
echo ' <title>'${project_name}' Changelog</title>' >> ./Appcast/appcast.xml
echo ' <link>http://hwsensors.com/appcast/appcast.xml</link>' >> ./Appcast/appcast.xml
echo ' <description>Most recent changes with links to updates.</description>' >> ./Appcast/appcast.xml
echo ' <language>en</language>' >> ./Appcast/appcast.xml
echo ' <item>' >> ./Appcast/appcast.xml
echo ' <sparkle:releaseNotesLink>http://hwsensors.com/appcast/rnotes.html</sparkle:releaseNotesLink>' >> ./Appcast/appcast.xml
echo ' <title>Version '${full_version}'</title>' >> ./Appcast/appcast.xml
echo ' <pubDate>'$(date +"%a, %d %b %G %T %z")'</pubDate>' >> ./Appcast/appcast.xml
echo ' <enclosure url="http://hwsensors.com/downloads/'${zip_filename}'" sparkle:version="'${last_revision}'" sparkle:shortVersionString="'${full_version}'" sparkle:dsaSignature="'${dsa_signature}'" length="'$(stat -f %z ./Binaries/${zip_filename})'" type="application/x-compress"/>' >> ./Appcast/appcast.xml
echo ' </item>' >> ./Appcast/appcast.xml
echo '</channel>' >> ./Appcast/appcast.xml
echo '</rss>' >> ./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:"<li>%s</li>\n" --date=short)

#rnotes.html
echo ${git_log//|/\<br />} > ./rnotes.html
echo '<html>' > ./Appcast/rnotes.html
echo ' <head>' >> ./Appcast/rnotes.html
echo ' <meta http-equiv="content-type" content="text/html;charset=utf-8">' >> ./Appcast/rnotes.html
echo ' <title>'${project_name}' v'${full_version}'</title>' >> ./Appcast/rnotes.html
echo ' <meta name="ROBOTS" content="NOINDEX">' >> ./Appcast/rnotes.html
echo ' <style type="text/css">' >> ./Appcast/rnotes.html
echo ' .blue {background-color: #e6edff;margin-top: -3px;margin-bottom: -3px;padding-top: -3px;padding-bottom: -3px}' >> ./Appcast/rnotes.html
echo ' .dots {border: dotted 1px #ccc}' >> ./Appcast/rnotes.html
echo ' hr {text-decoration: none;border: solid 1px #bfbfbf}' >> ./Appcast/rnotes.html
echo ' td {padding: 6px}' >> ./Appcast/rnotes.html
echo ' p {font-size: 9pt;font-family: "Lucida Grande", Arial, sans-serif;line-height: 12pt;text-decoration: none; text-indent: 1.5em}' >> ./Appcast/rnotes.html
echo ' li {font-size: 9pt;font-family: "Lucida Grande", Arial, sans-serif;line-height: 12pt;text-decoration: none}' >> ./Appcast/rnotes.html
echo ' h3 {font-size: 9pt;font-family: "Lucida Grande", Arial, sans-serif;font-weight: bold;margin-top: -4px;margin-bottom: -4px}' >> ./Appcast/rnotes.html
echo ' </style>' >> ./Appcast/rnotes.html
echo ' </head>' >> ./Appcast/rnotes.html
echo ' <body>' >> ./Appcast/rnotes.html
echo ' <table class="dots" width="100%" border="0" cellspacing="0" cellpadding="0" summary="Two column table with heading">' >> ./Appcast/rnotes.html
echo ' <tr>' >> ./Appcast/rnotes.html
echo ' <td class="blue" colspan="2">' >> ./Appcast/rnotes.html
echo ' <h3>New in '${project_name}' v'${full_version}'</h3>' >> ./Appcast/rnotes.html
echo ' </td>' >> ./Appcast/rnotes.html
echo ' </tr>' >> ./Appcast/rnotes.html
echo ' <tr><td><td/><tr/>' >> ./Appcast/rnotes.html
echo ' <tr>' >> ./Appcast/rnotes.html
echo ' <td valign="top">' >> ./Appcast/rnotes.html
echo ' <p><b>Bug Fixed/Changes/Features</b></p>' >> ./Appcast/rnotes.html
echo ' <ul>' >> ./Appcast/rnotes.html
echo ${git_log} >> ./Appcast/rnotes.html
echo ' </ul>' >> ./Appcast/rnotes.html
echo ' </td>' >> ./Appcast/rnotes.html
echo ' </tr>' >> ./Appcast/rnotes.html
echo ' </table>' >> ./Appcast/rnotes.html
echo ' <br/>' >> ./Appcast/rnotes.html
echo ' </body>' >> ./Appcast/rnotes.html
echo '</html>' >> ./Appcast/rnotes.html
2 changes: 1 addition & 1 deletion Scripts/SignApp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Versioning.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
7EBA20C817ED59C6008E54C5 /* TagCurrentVersion.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = TagCurrentVersion.sh; sourceTree = "<group>"; };
7EBA20D517ED7B41008E54C5 /* GenerateAppcast.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = GenerateAppcast.sh; sourceTree = "<group>"; };
7EBA20DF17EDBD3A008E54C5 /* appcast.xml */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = appcast.xml; sourceTree = "<group>"; };
7EBA20E017EDBD3F008E54C5 /* rnotes.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = rnotes.html; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXGroup section */
Expand All @@ -32,7 +31,6 @@
7E2F25191783EAE800C86586 /* version.h */,
7E3ABDBA1796580B00201804 /* revision.txt */,
7EBA20DF17EDBD3A008E54C5 /* appcast.xml */,
7EBA20E017EDBD3F008E54C5 /* rnotes.html */,
);
name = "Autogenerated Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -808,6 +806,7 @@
7EBA20D917ED7D1C008E54C5 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
8 changes: 0 additions & 8 deletions rnotes.html

This file was deleted.

0 comments on commit 35f5315

Please sign in to comment.