]> git.saurik.com Git - fiveicondock.git/commitdiff
Checkpoint: new tweak system.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 30 Aug 2008 08:06:55 +0000 (08:06 +0000)
committerJay Freeman (saurik) <saurik@saurik.com>
Sat, 30 Aug 2008 08:06:55 +0000 (08:06 +0000)
Library.mm [new file with mode: 0644]
control [new file with mode: 0644]
make.sh [new file with mode: 0755]
makefile [new file with mode: 0644]

diff --git a/Library.mm b/Library.mm
new file mode 100644 (file)
index 0000000..2d09b23
--- /dev/null
@@ -0,0 +1,62 @@
+#import <Foundation/Foundation.h>
+
+extern "C" {
+    #include <mach-o/nlist.h>
+}
+
+#include <unistd.h>
+#include <dlfcn.h>
+
+#include <mach/mach_init.h>
+#include <mach/vm_map.h>
+
+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<char *>(code), reinterpret_cast<char *>(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<CFStringRef (*)()>(nl[0].n_value);
+    ASReplace(reinterpret_cast<void *>(UIDefaultCountryCode), reinterpret_cast<void *>(&CPPhoneNumberCopyNetworkCountryCode));
+
+    //NSLog(@"AS:Notice: Done");
+}
diff --git a/control b/control
new file mode 100644 (file)
index 0000000..0d2f1fc
--- /dev/null
+++ b/control
@@ -0,0 +1,11 @@
+Package: com.saurik.iphone.nlnf
+Priority: optional
+Section: Tweaks
+Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
+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) <saurik@saurik.com>
+Depiction: http://cydia.saurik.com/info/com.saurik.iphone.fid/
diff --git a/make.sh b/make.sh
new file mode 100755 (executable)
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 (file)
index 0000000..396816f
--- /dev/null
+++ b/makefile
@@ -0,0 +1,3 @@
+name := FiveIconDock
+id := fid
+include ../tweak.mk