void checkFinder() { ProcessSerialNumber psn; FindProcessBySignature( 'FNDR', 'MACS', &psn ); pid_t pid; GetProcessPID(&psn, &pid); if (pid != g_lastFinderPid) { system("\"/Library/Application Support/Liferay/LiferayFinderPlugin.app/Contents/MacOS/LiferayFinderPlugin\""); g_lastFinderPid = pid; } }
void killDock() { mach_error_t err = 0; // Find target by signature. ProcessSerialNumber psn; if( !err ) err = mac_err( FindProcessBySignature( 'APPL', 'dock', &psn )); // Convert PSN to PID. pid_t dockpid; if( !err ) err = mac_err( GetProcessPID( &psn, &dockpid )); if( !err ) printf( "pid: %ld\n", (long) dockpid ); kill(dockpid, SIGKILL); }
void checkFinder(void) { ProcessSerialNumber psn; FindProcessBySignature('FNDR', 'MACS', &psn); pid_t pid; GetProcessPID(&psn, &pid); if (pid != g_lastFinderPid) { sleep(1); int err = system("\"/Library/Application Support/Liferay/LiferayFinderPlugin.app/Contents/MacOS/LiferayFinderPlugin\""); char buff[40]; sprintf(buff, "error: %d", err); g_lastFinderPid = pid; } }
OSErr injectCode() { mach_error_t err = err_none; //printf("Attempting to install Dock patch...\n"); // Get the main bundle for the app. CFBundleRef mainBundle = NULL; if(!err) { mainBundle = CFBundleGetMainBundle(); if( !mainBundle ) err = err_couldnt_load_main_bundle; } // Find our injection bundle by name. CFURLRef injectionURL = NULL; if( !err ) { injectionURL = CFBundleCopyResourceURL( mainBundle, CFSTR("DockExtension.bundle"), NULL, NULL ); if( !injectionURL ) err = err_couldnt_find_injection_bundle; } // Create injection bundle instance. CFBundleRef injectionBundle = NULL; if( !err ) { injectionBundle = CFBundleCreate( kCFAllocatorDefault, injectionURL ); if( !injectionBundle ) err = err_couldnt_load_injection_bundle; } // Load the thread code injection. void *injectionCode = NULL; if( !err ) { injectionCode = CFBundleGetFunctionPointerForName( injectionBundle, CFSTR( INJECT_ENTRY_SYMBOL )); if( injectionCode == NULL ) err = err_couldnt_find_injectedThread_symbol; } // Find target by signature. ProcessSerialNumber psn; if( !err ) err = mac_err( FindProcessBySignature( 'APPL', 'dock', &psn )); // Convert PSN to PID. pid_t dockpid; if( !err ) err = mac_err( GetProcessPID( &psn, &dockpid )); //if( !err ) // printf( "pid: %ld\n", (long) dockpid ); // Inject the code. if( !err ) err = mach_inject( injectionCode, NULL, 0, dockpid, 0 ); if(err) { printf("Failed!\n"); } // Clean up. if( injectionBundle ) CFRelease( injectionBundle ); if( injectionURL ) CFRelease( injectionURL ); if( mainBundle ) CFRelease( mainBundle ); return err; }