theos / logos

Preprocessor that simplifies Objective-C hooking.
https://theos.dev/docs/logos
Other
206 stars 34 forks source link

Fix double ", ..." in _methodPrototype of MobileSubstrate Generator #74

Closed brendonjkding closed 2 years ago

brendonjkding commented 3 years ago

When trying to hook objc variadic method with default configuration(generator=MobileSubstrate),

%hook NSString
+(id)stringWithFormat:(NSString *)format, ...
{
    va_list args;
        va_start(args, format); 
    id ret=[[NSString alloc] initWithFormat:format arguments:args];
    va_end(args);

    NSLog(@"%@",ret);
        return ret;
}
%end

compilation failed with log:

XXRootViewController.x:28:172: error: expected ')'
static id _logos_meta_method$_ungrouped$NSString$stringWithFormat$(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, NSString * format, ..., ...) {
                                                                                                                                                                           ^
XXRootViewController.x:28:67: note: to match this '('
static id _logos_meta_method$_ungrouped$NSString$stringWithFormat$(_LOGOS_SELF_TYPE_NORMAL Class _LOGOS_SELF_CONST __unused self, SEL __unused _cmd, NSString * format, ..., ...) {

Obviously there are two , ... at the end of method arg list.

This PR fix this issue.