use BlueToolH4 instead of BlueToolNoH5

This commit is contained in:
matthias.ringwald 2010-06-09 11:32:58 +00:00
parent 7d1e1f4dbd
commit cd434e7b6f
4 changed files with 67 additions and 11 deletions

View File

@ -0,0 +1,56 @@
#include <fcntl.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
int main(int argc, char *argv[]) {
if (argc < 2) {
printf("Usage: %s fileToPath\n", argv[0]);
printf("This tool disables the 'csr -T' configuration from BlueTool.\n");
return 10;
}
printf("Patching %s...\n", argv[1]);
struct stat sb;
int fd = open (argv[1], O_RDWR);
if (fd < 0) return;
if (fstat (fd, &sb) == -1) {
close(fd);
return 10;
}
uint32_t len = sb.st_size;
uint8_t * p = mmap (0, len, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (p == MAP_FAILED) {
close(fd);
return 10;
}
int count = 0;
// fix Apple's horrible capitalization :)
// const char *pattern = "BlueTool";
// const char *patternNew = "Bluetool";
// comment ("csr -T")
const char *pattern = "csr -T";
const char *patternNew = "######";
const int patternLen = strlen(pattern);
int i;
for (i=0; i<len-patternLen; i++){
if (strncmp((char*)p+i, pattern, patternLen) == 0){
// comment
strncpy((char*)p+i, patternNew, patternLen);
count++;
}
}
// done
munmap(p,len);
close(fd);
printf("Done, replaced %s %u times\n", pattern, count);
}

View File

@ -18,7 +18,7 @@ echo "Version: $VERSION-$REVISION" >> $PACKAGE/DEBIAN/control
mkdir -p $PACKAGE/usr/local/bin
cp src/BTdaemon $PACKAGE/usr/local/bin
cp PatchBlueTool/PatchBlueTool $PACKAGE/usr/local/bin
cp resources/InstallBlueToolNoH5.sh $PACKAGE/usr/local/bin
cp resources/InstallBlueToolH4.sh $PACKAGE/usr/local/bin
cp example/inquiry $PACKAGE/usr/local/bin
mkdir -p $PACKAGE/usr/local/lib
@ -36,14 +36,14 @@ echo "/bin/launchctl load /Library/LaunchDaemons/ch.ringwald.BTstack.plist" >>
chmod +x $PACKAGE/DEBIAN/postinst
echo "#!/bin/sh" > $PACKAGE/DEBIAN/prerm
echo "/bin/launchctl unload /Library/LaunchDaemons/ch.ringwald.BTstack.plist" >> $PACKAGE/DEBIAN/prerm
echo "rm -f /usr/sbin/BlueToolNoH5" >> $PACKAGE/DEBIAN/prerm
echo "rm -f /usr/sbin/BlueToolH4" >> $PACKAGE/DEBIAN/prerm
chmod +x $PACKAGE/DEBIAN/prerm
# set ownership to root:root
sudo chown -R 0:0 $PACKAGE
# set suid for InstallBlueToolNoH5
sudo chmod 4755 $PACKAGE/usr/local/bin/InstallBlueToolNoH5.sh
# set suid for InstallBlueToolH4
sudo chmod 4755 $PACKAGE/usr/local/bin/InstallBlueToolH4.sh
echo Packaging $PACKAGE
export COPYFILE_DISABLE

View File

@ -0,0 +1,7 @@
#!/bin/sh
rm -f /tmp/BlueToolH4 /usr/local/bin/BlueToolH4
cp /usr/sbin/BlueTool /tmp/BlueToolH4
/usr/local/bin/PatchBlueTool /tmp/BlueToolH4
ldid -s /tmp/BlueToolH4
cp -f /tmp/BlueToolH4 /usr/local/bin
rm -f /tmp/BlueToolH4

View File

@ -1,7 +0,0 @@
#!/bin/sh
rm -f /tmp/BlueToolNoH5
cp /usr/sbin/BlueTool /tmp/BlueToolNoH5
/usr/local/bin/PatchBlueTool /tmp/BlueToolNoH5
ldid -S /tmp/BlueToolNoH5
cp -f /tmp/BlueToolNoH5 /usr/local/bin
rm -f /tmp/BlueToolNoH5