this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Constant CFString support

+54 -4
+20 -3
src/dyld/dyld.cpp
··· 108 108 return -ENOEXEC; 109 109 } 110 110 #endif 111 + // Modify the argument list so that the dyld name disappears from the process list. 112 + // The Linux kernel doesn't really support this - it remembers the byte length of the cmdline, which will now decrease. 113 + // Any app that examines this process' /proc/.../cmdline will from now on see a group of empty arguments after the real arguments. 114 + // We fix this for NSProcessInfo in libobjcdarwin. 115 + 116 + uintptr_t totalLen = argv[argc-1] + strlen(argv[argc-1]) + 1 - argv[0]; 117 + uintptr_t shortenedLen = totalLen - (strlen(argv[0]) + 1); 111 118 112 - g_argv = argv+1; 113 - g_argc = argc-1; 119 + memmove(argv[0], argv[1], shortenedLen); 120 + memset(argv[0]+shortenedLen, 0, totalLen - shortenedLen); 121 + 122 + // Reconstruct the argv array 123 + for (int pos = 0, index = 1; index < argc-1; pos++) 124 + { 125 + if (!argv[0][pos]) 126 + argv[index++] = &argv[0][pos+1]; 127 + } 128 + 129 + g_argv = argv; 130 + g_argc = argc; 114 131 g_loader = new MachOLoader; 115 132 116 133 autoSysrootSearch(); 117 134 118 - g_loader->run(*g_mainBinary, argc-1, argv+1, envp); 135 + g_loader->run(*g_mainBinary, argc, argv, envp); 119 136 120 137 delete g_loader; 121 138 g_loader = 0;
+2 -1
src/libobjcdarwin/CMakeLists.txt
··· 30 30 common/attribute.cpp 31 31 common/property.cpp 32 32 common/selector.cpp 33 + common/cfstring.cpp 33 34 34 35 old/category.cpp 35 36 old/class.cpp ··· 42 43 new/protocol.cpp 43 44 44 45 NSBundle_dyld.mm 45 - NSCFString.mm 46 + #NSCFString.mm 46 47 misc.mm 47 48 zero.c 48 49 )
+2
src/libobjcdarwin/ClassRegister.cpp
··· 9 9 #include "old/category.h" 10 10 #include "new/category.h" 11 11 #include "common/selector.h" 12 + #include "common/cfstring.h" 12 13 #include <map> 13 14 14 15 // Superclass references in Mach-O don't use classref ··· 67 68 68 69 ProcessCategoriesNew(mh, slide); 69 70 UpdateSelectors(mh, slide); 71 + UpdateCFStrings(mh); 70 72 } 71 73 72 74 void ProcessImageUnload(const struct mach_header* mh, intptr_t)
+8
src/libobjcdarwin/NSBundle_dyld.mm
··· 6 6 #include <string> 7 7 #include <cstring> 8 8 #include <cstdio> 9 + #include <unistd.h> 9 10 #include <algorithm> 10 11 #include "../util/log.h" 11 12 12 13 extern char g_darwin_executable_path[PATH_MAX]; 14 + extern int g_argc; 15 + extern char** g_argv; 13 16 static NSBundle* _mainBundle = 0; 14 17 static NSAutoreleasePool* g_pool = 0; 15 18 ··· 21 24 22 25 MethodSwizzle(objc_getMetaClass("NSBundle"), @selector(mainBundle), @selector(x_mainBundle)); 23 26 27 + // Many OS X apps assume that there is a "default" autorelease pool provided 24 28 g_pool = [[NSAutoreleasePool alloc] init]; 25 29 30 + GSInitializeProcess(g_argc, g_argv, environ); 31 + 32 + /* 26 33 const char* last = strrchr(g_darwin_executable_path, '/'); 27 34 if (last != 0) 28 35 { ··· 31 38 NSString* str = [NSString stringWithUTF8String:last]; 32 39 [[NSProcessInfo processInfo] setProcessName:str]; 33 40 } 41 + */ 34 42 } 35 43 36 44 __attribute__((destructor)) static void myexit()
+22
tests/src/cfbridge.m
··· 1 + // CFLAGS: -framework corefoundation -framework foundation 2 + #import <CoreFoundation/CFString.h> 3 + #import <Foundation/NSString.h> 4 + #include <stdio.h> 5 + 6 + int main() 7 + { 8 + CFStringRef str = CFSTR("Test"); 9 + const char* text = [(NSString*)str UTF8String]; 10 + puts(text); 11 + NSLog(@"%@\n", str); 12 + [str retain]; 13 + printf("%u\n", [str retainCount]); // This should output UINT_MAX 14 + 15 + CFStringRef str2 = CFStringCreateWithBytes(NULL, "Test2", 6, kCFStringEncodingASCII, 0); 16 + CFRetain(str2); 17 + printf("%u\n", [str2 retainCount]); 18 + 19 + return 0; 20 + } 21 + 22 +