Theos Hook Objective-C classes / methods with Unicode Characters

于是今天看到有人在问使用 THEOS 来 hook 带有汉字的 Objective-C 的方法时会有类似如下的报错。

$ make
> Making all for tweak UnicodeHook…
==> Preprocessing Tweak.xm…
==> Compiling Tweak.xm (armv7)…
Tweak.xm:3:1: error: missing context for method declaration
- (id)中文方法名 {
^
1 error generated.
THEOS complaints about unicode characters
THEOS complaints about unicode characters

于是研究了 THEOS 的源代码,给出了一个简单的解决办法,不仅可以 Hook 带有汉字的方法,带有日文、阿拉伯文等等的方法 / Objective-C 类,只要这些 identifier 在 Objective-C 的语法规则中被认可,那就都可以被 Hook。而且在写 %group 的时候也可以使用除 ACSII 以外的文字了。

Continue reading Theos Hook Objective-C classes / methods with Unicode Characters

Mastodon——What's the form of social network in the future?

最近我所在的一个 GitHub Organization 的网站上搭起了 Mastodon 实例,于是花这几天的时候从一个较为高层的角度分析了 Mastodon,这里并没有深入到最底层的代码。大概还有不少人不了解 Mastodon 这个项目,于是结合 Mastodon 官方的介绍,这里将分析 Mastodon 项目的现状以及对 Mastodon 未来的预测。

Continue reading Mastodon——What's the form of social network in the future?

Scaling Mastodon——What it takes to house 43,000 users

我的实例 mastodon.social 最近已经超过了 43,000 位用户。我不得不关掉注册以确保有足够的时间来审查 Mastodon 的基础架构,并且也是保证给已经注册的用户提供一个良好的体验(这个举动带来的更奇妙的结果是——Mastodon联邦为分布在500个以上的独立实例上、总计超过161,000人提供服务!

但是要运营一个为 43,000 位用户提供流畅且快速响应的服务是需要下点功夫的,而且其他的一些实例上的用户群体也在不断扩大,是时候分享一些提示和我在运营自己的实例时学习到的技巧了。

Continue reading Scaling Mastodon——What it takes to house 43,000 users

macOS中QQ防消息撤回

macOS下的QQ还是增加了消息撤回功能,稍微研究了一下,只需要Hook一个函数即可。

可以考虑写一个dylib然后附上去,代码如下。然后至于说是用DYLD_INSERT_LIBRARIES这个环境变量,还是说直接改load_commands就看个人喜好了,这里不展开写。

#import <Foundation/Foundation.h>
#import <objc/runtime.h>

void handleRecallNotifyIsOnline(id, SEL, void *, BOOL) {}

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"

static void __attribute__((constructor)) initialize(void) {
    method_setImplementation(class_getInstanceMethod(NSClassFromString(@"QQMessageRevokeEngine"), @selector(handleRecallNotify:isOnline:)), (IMP)&handleRecallNotifyIsOnline);
}

#pragma clang diagnostic pop