Changeset 86952 in vbox
- Timestamp:
- Nov 23, 2020 9:37:24 AM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VirtualBox/src/main.cpp
r84751 r86952 62 62 # include <dlfcn.h> 63 63 # include <sys/mman.h> 64 # ifdef VBOX_RUNTIME_UI65 //# include <mach-o/dyld.h>66 extern "C" const char *_dyld_get_image_name(uint32_t);67 # endif68 64 #endif /* VBOX_WS_MAC */ 69 65 #ifdef VBOX_WS_X11 … … 136 132 # include <dlfcn.h> 137 133 # include <iprt/formats/mach-o.h> 134 135 //# include <mach-o/dyld.h> /* Not included because of definiton clashes with our own Mach-O header. */ 136 extern "C" const char *_dyld_get_image_name(uint32_t); 137 extern "C" const mach_header_64_t *_dyld_get_image_header(uint32_t); 138 extern "C" uint32_t _dyld_image_count(void); 138 139 139 140 /** … … 368 369 static void HideSetUidRootFromAppKit() 369 370 { 370 void *pvAddr;371 371 /* Find issetguid() and make it always return 0 by modifying the code: */ 372 372 # if 0 373 pvAddr = dlsym(RTLD_DEFAULT, "issetugid");373 void *pvAddr = dlsym(RTLD_DEFAULT, "issetugid"); 374 374 int rc = mprotect((void *)((uintptr_t)pvAddr & ~(uintptr_t)0xfff), 0x2000, PROT_WRITE | PROT_READ | PROT_EXEC); 375 375 if (!rc) … … 379 379 { 380 380 /* Failing that, find AppKit and patch its import table: */ 381 # if 0 /* Fails with BigSur and SIP disabled for some unknown reason (SIP enabled works fine). */ 381 382 void *pvAppKit = dlopen("/System/Library/Frameworks/AppKit.framework/AppKit", RTLD_NOLOAD); 382 pvAddr = dlsym(pvAppKit, "NSApplicationMain");383 void *pvAddr = dlsym(pvAppKit, "NSApplicationMain"); 383 384 Dl_info Info = {0}; 384 385 if ( dladdr(pvAddr, &Info) … … 394 395 else 395 396 write(2, RT_STR_TUPLE("WARNING: Failed to patch issetugid in AppKit! (dladdr)\n")); 397 # else 398 # define APP_KIT_FRAMEWORK_PATH "/System/Library/Frameworks/AppKit.framework" 399 for (uint32_t i = 0; i < _dyld_image_count(); i++) 400 { 401 const char *pszImageName = _dyld_get_image_name(i); 402 if (!strncmp(pszImageName, APP_KIT_FRAMEWORK_PATH, sizeof(APP_KIT_FRAMEWORK_PATH) - 1)) 403 { 404 if (!patchExtSym((mach_header_64_t *)_dyld_get_image_header(i), "_issetugid", (uintptr_t)&issetugid_for_AppKit)) 405 write(2, RT_STR_TUPLE("WARNING: Failed to patch issetugid in AppKit! (patchExtSym)\n")); 406 # ifdef DEBUG 407 else 408 write(2, RT_STR_TUPLE("INFO: Successfully patched _issetugid import for AppKit!\n")); 409 # endif 410 break; 411 } 412 } 413 # endif 396 414 } 397 415
Note:
See TracChangeset
for help on using the changeset viewer.