From 49e531bd7cebb01088233374dda28b7be40a4343 Mon Sep 17 00:00:00 2001 From: Sam Bingner Date: Thu, 24 Oct 2019 16:36:31 -1000 Subject: gssc was broken --- gssc.mm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gssc.mm b/gssc.mm index 74ef336..e4fb37e 100644 --- a/gssc.mm +++ b/gssc.mm @@ -59,6 +59,7 @@ static CFArrayRef (*$GSSystemCopyCapability)(CFStringRef); static CFArrayRef (*$GSSystemGetCapability)(CFStringRef); +static CFTypeRef (*$MGCopyAnswer)(CFStringRef); void OnGSCapabilityChanged( CFNotificationCenterRef center, @@ -79,7 +80,7 @@ int main(int argc, char *argv[]) { NSString *name = nil; if (argc == 2) - name = [objc_getClass("NSString") stringWithUTF8String:argv[0]]; + name = [objc_getClass("NSString") stringWithUTF8String:argv[1]]; else if (argc > 2) { fprintf(stderr, "usage: %s [capability]\n", argv[0]); exit(1); @@ -109,8 +110,13 @@ int main(int argc, char *argv[]) { } else { capability = nil; - if (void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY)) - if (CFTypeRef (*$MGCopyAnswer)(CFStringRef) = reinterpret_cast(dlsym(libMobileGestalt, "MGCopyAnswer"))) { + void *libMobileGestalt = dlopen("/usr/lib/libMobileGestalt.dylib", RTLD_GLOBAL | RTLD_LAZY); + if (libMobileGestalt && ($MGCopyAnswer = reinterpret_cast(dlsym(libMobileGestalt, "MGCopyAnswer")))) { + if (name) { + capability = reinterpret_cast($MGCopyAnswer(reinterpret_cast(name))); + if (capability != nil) + capability = [capability autorelease]; + } else { NSMutableDictionary *answers([NSMutableDictionary dictionary]); for (NSString *name in [NSArray arrayWithObjects: @"1080p", @@ -713,6 +719,7 @@ int main(int argc, char *argv[]) { } capability = answers; } + } } if (capability != nil) { -- cgit v1.2.3