this repo has no description
1
fork

Configure Feed

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

Integrated a .pkg installer/uninstaller

+51 -11
+19 -1
src/dyld/darling-so-start.S
··· 17 17 _start: 18 18 // Get path to self 19 19 leaq proc_self_exe(%rip), %rdi 20 - leaq -256(%rsp), %rsi // buffer 20 + leaq -512(%rsp), %rsi // buffer 21 21 movl $255, %edx // buffer size 22 22 movl $__NR_readlink, %eax 23 23 syscall ··· 26 26 jl fail 27 27 28 28 movb $0, (%rsi, %rax, 1) // null terminate 29 + movq 8(%rsp), %rbx // argv[0] to rbx 30 + 31 + // Append '!' to /proc/self/exe name 32 + // and then append original argv[0] 33 + xorl %ecx, %ecx 34 + movb $'!', (%rsi, %rax, 1) 35 + incl %eax 36 + 37 + strcat_start: 38 + movb (%rbx, %rcx, 1), %dl 39 + movb %dl, (%rsi, %rax, 1) 29 40 movq %rsi, 8(%rsp) // orig argv[0] 41 + testb %dl, %dl 42 + jz strcat_end 43 + incl %ecx 44 + incl %eax 45 + jmp strcat_start 46 + strcat_end: 47 + movq %rsi, 8(%rsp) 30 48 31 49 // Execute self through dyld 32 50 leaq dyld_path(%rip), %rdi // exec path
+21 -1
src/dyld/dyld.cpp
··· 36 36 static void printHelp(const char* argv0); 37 37 static bool isELF(const char* path); 38 38 static std::string locateBundleExecutable(std::string bundlePath); 39 + static const char* findFakeArgv0(char* a0); 39 40 40 41 using namespace Darling; 41 42 ··· 54 55 { 55 56 MachOMgr* mgr = MachOMgr::instance(); 56 57 std::string executable, unprefixed_argv0; 58 + const char* pretendArgv0; 59 + 60 + pretendArgv0 = findFakeArgv0(argv[1]); 57 61 58 62 executable = locateBundleExecutable(argv[1]); 59 63 argv[1] = const_cast<char*>(executable.c_str()); ··· 99 103 if (!main) 100 104 throw std::runtime_error("No entry point found in Darling-native executable"); 101 105 102 - if (!unprefixed_argv0.empty()) 106 + if (pretendArgv0 != nullptr) 107 + argv[1] = (char*) pretendArgv0; 108 + else if (!unprefixed_argv0.empty()) 103 109 argv[1] = (char*) unprefixed_argv0.c_str(); 104 110 exit(main(argc-1, &argv[1], envp)); 105 111 } ··· 190 196 return signature == *((const uint32_t*) "\177ELF"); 191 197 } 192 198 199 + // Original argv0 is passed inside argv[1] by darling-so-start.S 200 + static const char* findFakeArgv0(char* a0) 201 + { 202 + char* excl; 203 + 204 + excl = strchr(a0, '!'); 205 + if (excl == nullptr) 206 + return nullptr; 207 + else 208 + { 209 + *excl = '\0'; 210 + return excl+1; 211 + } 212 + }
+2 -2
src/kernel/emulation/linux/process/execve.c
··· 76 76 // Allocate a new argvp, execute dyld_path 77 77 modargvp = (char**) __builtin_alloca(sizeof(void*) * (len+1)); 78 78 modargvp[0] = dyld_path; 79 - modargvp[1] = (char*) __prefix_translate_path(fname); 79 + modargvp[1] = (char*) __prefix_translate_path_link(fname); 80 80 81 81 for (i = 2; i < len+1; i++) 82 82 modargvp[i] = argvp[i-1]; ··· 140 140 } 141 141 else 142 142 { 143 - fname = (char*) __prefix_translate_path(fname); 143 + fname = (char*) __prefix_translate_path_link(fname); 144 144 } 145 145 } 146 146
+4 -2
src/kernel/emulation/linux/unistd/access.c
··· 2 2 #include "../base.h" 3 3 #include "../errno.h" 4 4 #include <asm/unistd.h> 5 + #include <libdyld/VirtualPrefix.h> 5 6 6 7 long sys_access(const char* filename, int amode) 7 8 { 8 9 int ret; 9 10 10 11 #ifdef __NR_access 11 - ret = LINUX_SYSCALL(__NR_access, filename, amode); 12 + ret = LINUX_SYSCALL(__NR_access, __prefix_translate_path(filename), amode); 12 13 #else 13 - ret = LINUX_SYSCALL(__NR_faccessat, LINUX_AT_FDCWD, filename, amode, 0); 14 + ret = LINUX_SYSCALL(__NR_faccessat, LINUX_AT_FDCWD, 15 + __prefix_translate_path(filename), amode, 0); 14 16 #endif 15 17 16 18 if (ret < 0)
+4 -4
src/kernel/emulation/linux/unistd/symlink.c
··· 10 10 long sys_symlink(const char* path, const char* link) 11 11 { 12 12 int ret; 13 - char resolved_path[1024]; 13 + //char resolved_path[1024]; 14 14 char resolved_link[1024]; 15 15 16 16 if (!path || !link) 17 17 return -EINVAL; 18 18 19 - strcpy(resolved_path, __prefix_translate_path(path)); 20 - strcpy(resolved_link, __prefix_translate_path(link)); 19 + //strcpy(resolved_path, __prefix_translate_path(path)); 20 + strcpy(resolved_link, __prefix_translate_path_link(link)); 21 21 22 - ret = LINUX_SYSCALL(__NR_symlink, resolved_path, resolved_link); 22 + ret = LINUX_SYSCALL(__NR_symlink, path, resolved_link); 23 23 if (ret < 0) 24 24 ret = errno_linux_to_bsd(ret); 25 25
+1 -1
src/kernel/emulation/linux/unistd/unlink.c
··· 8 8 { 9 9 int ret; 10 10 11 - ret = LINUX_SYSCALL(__NR_unlink, __prefix_translate_path(path)); 11 + ret = LINUX_SYSCALL(__NR_unlink, __prefix_translate_path_link(path)); 12 12 if (ret < 0) 13 13 ret = errno_linux_to_bsd(ret); 14 14