theos/logos

Can't hook variadic methods.

uroboro opened this issue · 0 comments

%hook H
- (void)format:(NSString *)format, ... {
	%orig;
}
%end

Generates the following code:

#line 1 "Tweak.x"

#include <substrate.h>
#if defined(__clang__)
#if __has_feature(objc_arc)
#define _LOGOS_SELF_TYPE_NORMAL __unsafe_unretained
#define _LOGOS_SELF_TYPE_INIT __attribute__((ns_consumed))
#define _LOGOS_SELF_CONST const
#define _LOGOS_RETURN_RETAINED __attribute__((ns_returns_retained))
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif
#else
#define _LOGOS_SELF_TYPE_NORMAL
#define _LOGOS_SELF_TYPE_INIT
#define _LOGOS_SELF_CONST
#define _LOGOS_RETURN_RETAINED
#endif

@class H;
static void (*_logos_orig$_ungrouped$H$format$)(
    _LOGOS_SELF_TYPE_NORMAL H *_LOGOS_SELF_CONST, SEL, NSString *);
static void
_logos_method$_ungrouped$H$format$(_LOGOS_SELF_TYPE_NORMAL H *_LOGOS_SELF_CONST,
                                   SEL, NSString *);

#line 1 "Tweak.x"

static void _logos_method$_ungrouped$H$format$(
    _LOGOS_SELF_TYPE_NORMAL H *_LOGOS_SELF_CONST __unused self,
    SEL __unused _cmd, NSString *format),
    ... {
  _logos_orig$_ungrouped$H$format$(self, _cmd, format);
}

static __attribute__((constructor)) void _logosLocalInit() {
  {
    Class _logos_class$_ungrouped$H = objc_getClass("H");
    MSHookMessageEx(_logos_class$_ungrouped$H, @selector(format:),
                    (IMP)&_logos_method$_ungrouped$H$format$,
                    (IMP *)&_logos_orig$_ungrouped$H$format$);
  }
}
#line 6 "Tweak.x"

The function prototypes don't contain the , ... and the function definition itself is wrongly formatted NSString *format), ... {.