From bd716e15c5a3b950827f808e410a949dc63bc823 Mon Sep 17 00:00:00 2001 From: "Jay Freeman (saurik)" Date: Sat, 30 Aug 2008 08:06:55 +0000 Subject: [PATCH 1/1] Checkpoint: new tweak system. --- Library.mm | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ control | 11 ++++++++++ make.sh | 6 ++++++ makefile | 3 +++ 4 files changed, 82 insertions(+) create mode 100644 Library.mm create mode 100644 control create mode 100755 make.sh create mode 100644 makefile diff --git a/Library.mm b/Library.mm new file mode 100644 index 0000000..2d09b23 --- /dev/null +++ b/Library.mm @@ -0,0 +1,62 @@ +#import + +extern "C" { + #include +} + +#include +#include + +#include +#include + +extern "C" void __clear_cache (char *beg, char *end); + +extern "C" CFStringRef CPPhoneNumberCopyNetworkCountryCode(); + +static void ASReplace(void *symbol, void *replace) { + //NSLog(@"AS:Notice: Remapping %p to %p", symbol, replace); + if (symbol == NULL) + return; + + int page = getpagesize(); + uintptr_t base = (uintptr_t) symbol / page * page; + + mach_port_t self = mach_task_self(); + + if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_WRITE | VM_PROT_COPY)) { + NSLog(@"AS:Error:vm_protect():%d", error); + return; + } + + uint32_t *code = (uint32_t *) symbol; + + code[0] = 0xe51ff004; // ldr pc, [pc, #-4] + code[1] = (uint32_t) replace; + + __clear_cache(reinterpret_cast(code), reinterpret_cast(code + 2)); + + if (kern_return_t error = vm_protect(self, base, page, FALSE, VM_PROT_READ | VM_PROT_EXECUTE)) + NSLog(@"AS:Error:vm_protect():%d", error); +} + +/*static CFStringRef UIDefaultCountryCode_() { + return CPPhoneNumberCopyNetworkCountryCode(); +}*/ + +#define UIKit "/System/Library/Frameworks/UIKit.framework/UIKit" + +extern "C" void ASInitialize() { + if (dlopen(UIKit, RTLD_LAZY | RTLD_NOLOAD) == NULL) + return; + //NSLog(@"AS:Notice: Installing AppSupport..."); + + struct nlist nl[2]; + memset(nl, 0, sizeof(nl)); + nl[0].n_un.n_name = (char *) "_UIDefaultCountryCode"; + nlist(UIKit, nl); + CFStringRef (*UIDefaultCountryCode)() = reinterpret_cast(nl[0].n_value); + ASReplace(reinterpret_cast(UIDefaultCountryCode), reinterpret_cast(&CPPhoneNumberCopyNetworkCountryCode)); + + //NSLog(@"AS:Notice: Done"); +} diff --git a/control b/control new file mode 100644 index 0000000..0d2f1fc --- /dev/null +++ b/control @@ -0,0 +1,11 @@ +Package: com.saurik.iphone.nlnf +Priority: optional +Section: Tweaks +Maintainer: Jay Freeman (saurik) +Architecture: iphoneos-arm +Version: 0.9.2526-1 +Description: fix phone numbers for roaming and locales +Name: Net.-Local Number Format +Depends: mobilesubstrate (>= 0.9.2550-1) +Author: Jay Freeman (saurik) +Depiction: http://cydia.saurik.com/info/com.saurik.iphone.fid/ diff --git a/make.sh b/make.sh new file mode 100755 index 0000000..4ff90cb --- /dev/null +++ b/make.sh @@ -0,0 +1,6 @@ +#!/bin/bash +set -e +export PKG_ARCH=${PKG_ARCH-iphoneos-arm} +PATH=/apl/n42/pre/bin:$PATH /apl/tel/exec.sh com.saurik.winterboard make "$@" +export CODESIGN_ALLOCATE=$(which arm-apple-darwin9-codesign_allocate) +/apl/tel/util/ldid -S PhoneNumberFormatting.dylib diff --git a/makefile b/makefile new file mode 100644 index 0000000..396816f --- /dev/null +++ b/makefile @@ -0,0 +1,3 @@ +name := FiveIconDock +id := fid +include ../tweak.mk -- 2.47.2