diff -ur moab-4-orig/Moab.c moab-4/Moab.c --- moab-4-orig/Moab.c 2007-01-05 00:02:47.000000000 -0500 +++ moab-4/Moab.c 2007-01-05 13:13:56.000000000 -0500 @@ -42,30 +42,44 @@ #include "qhref_handler.h" #include "iphoto_rss_handler.h" +static int _suffixMatch(const char *suffix, int suffixLen, const char *path) +{ + int pathLen = strlen(path); + + if(pathLen < suffixLen) + return 0; + + return strncmp(path + pathLen - suffixLen, suffix, suffixLen) == 0; +} + /* - * Locate a mach_header using a regular expression. - * Provided by Rosyna of Unsanity. + * Locate a mach_header using a suffix match. + * By John Bafford. Thanks also to William Carrel. + * This is significantly faster when a regex isn't needed. + * Based on the regex version provided by Rosyna of Unsanity. */ -struct mach_header *MOABGetImageHeader(const char *regex, const char **imageName) { - unsigned long count,index; - struct mach_header *header = NULL; - const char *path; - regex_t rx; - - regcomp(&rx,regex,REG_NOSUB); - count = _dyld_image_count(); - - for (index = 0;(header == NULL) && (index < count);index += 1) { - path = _dyld_get_image_name(index); - if (!regexec(&rx, path, 0, NULL, 0)) { - header = (struct mach_header*)_dyld_get_image_header(index); - if (imageName) - *imageName = path; - } - } +struct mach_header *MOABGetImageHeaderSuffix(const char *suffix, const char **imageName) { + unsigned long count,index; + struct mach_header *header = NULL; + const char *path; + int suffixLen = strlen(suffix); + + count = _dyld_image_count(); + + for (index = 0; index < count; index += 1) { + path = _dyld_get_image_name(index); + + if(_suffixMatch(suffix, suffixLen, path)) { + header = (struct mach_header*)_dyld_get_image_header(index); + + if (imageName) + *imageName = path; + + break; + } + } - regfree(&rx); - return header; + return header; } /* diff -ur moab-4-orig/Moab.h moab-4/Moab.h --- moab-4-orig/Moab.h 2007-01-04 23:18:59.000000000 -0500 +++ moab-4/Moab.h 2007-01-05 13:16:26.000000000 -0500 @@ -32,5 +32,6 @@ #include #include -struct mach_header *MOABGetImageHeader(const char *regex, const char **imageName); -CFBundleRef MOABCreateBundleForImagePath(const char *imagePath); \ No newline at end of file +struct mach_header *MOABGetImageHeaderSuffix(const char *suffix, const char **imageName); + +CFBundleRef MOABCreateBundleForImagePath(const char *imagePath); diff -ur moab-4-orig/qhref_handler.c moab-4/qhref_handler.c --- moab-4-orig/qhref_handler.c 2007-01-04 23:55:06.000000000 -0500 +++ moab-4/qhref_handler.c 2007-01-05 13:10:02.000000000 -0500 @@ -96,7 +96,7 @@ */ if (!orig_qtp_rNPN_GetURL) { - qtp_header = MOABGetImageHeader(".*QuickTime Plugin\\.plugin/Contents/MacOS/QuickTime Plugin$", &imagePath); + qtp_header = MOABGetImageHeaderSuffix("/QuickTime Plugin.plugin/Contents/MacOS/QuickTime Plugin", &imagePath); if (qtp_header) { if (!imagePath || !qhref_should_patch_image(imagePath, QTP_VERSION)) { apeprintf("[MOAB] Skipping unsupported version of the QuickTime Plugin.\n"); diff -ur moab-4-orig/rtsp_handler.c moab-4/rtsp_handler.c --- moab-4-orig/rtsp_handler.c 2007-01-04 23:18:59.000000000 -0500 +++ moab-4/rtsp_handler.c 2007-01-05 13:09:50.000000000 -0500 @@ -94,7 +94,7 @@ /* * A new image was added, try to find the QTSC image header. */ - qtsc_header = MOABGetImageHeader(".*QuickTimeStreaming\\.component/Contents/MacOS/QuickTimeStreaming$", &imagePath); + qtsc_header = MOABGetImageHeaderSuffix("/QuickTimeStreaming.component/Contents/MacOS/QuickTimeStreaming", &imagePath); if (qtsc_header) { if (!imagePath || !rtsp_should_patch_image(imagePath)) { apeprintf("[MOAB] Skipping unsupported version of the QuickTimeStreaming component.\n"); diff -ur moab-4-orig/vlc_udp_handler.c moab-4/vlc_udp_handler.c --- moab-4-orig/vlc_udp_handler.c 2007-01-04 23:34:11.000000000 -0500 +++ moab-4/vlc_udp_handler.c 2007-01-05 13:09:38.000000000 -0500 @@ -85,7 +85,7 @@ /* * A new image was added, try to find our image headers. */ - vcdx_header = MOABGetImageHeader(".*VLC\\.app/Contents/MacOS/modules/libvcdx_plugin.dylib$", NULL); + vcdx_header = MOABGetImageHeaderSuffix("/VLC.app/Contents/MacOS/modules/libvcdx_plugin.dylib", NULL); if (vcdx_header) { if (!orig_cdio_log_handler_vcdx) { /* Found the header, now find the symbol */