--- /dev/null
+#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");
+}
--- /dev/null
+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/