MCPcopy Create free account
hub / github.com/MhmRdd/NoHello / NoHello

Class NoHello

module/src/main/cpp/nohello.cpp:294–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294class NoHello : public zygisk::ModuleBase {
295public:
296 void onLoad(Api *_api, JNIEnv *_env) override {
297 this->api = _api;
298 this->env = _env;
299 }
300
301 void preAppSpecialize(AppSpecializeArgs *args) override {
302 preSpecialize(args);
303 }
304
305 void postAppSpecialize(const AppSpecializeArgs *args) override {
306 const char *process = env->GetStringUTFChars(args->nice_name, nullptr);
307 postSpecialize(process);
308 env->ReleaseStringUTFChars(args->nice_name, process);
309 }
310
311 void preServerSpecialize(ServerSpecializeArgs *args) override {
312 //preSpecialize("system_server"); // System server usually doesn't need this level of hiding
313 api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
314 }
315
316private:
317 Api *api{};
318 JNIEnv *env{};
319 int cfd{};
320 dev_t rundev{};
321 ino_t runinode{};
322 dev_t cdev{};
323 ino_t cinode{};
324
325
326 void preSpecialize(AppSpecializeArgs *args) {
327 unsigned int flags = api->getFlags();
328 const bool whitelist = access("/data/adb/nohello/whitelist", F_OK) == 0;
329 const bool nodirtyro = access("/data/adb/nohello/no_dirtyro_ar", F_OK) == 0;
330 if (flags & zygisk::StateFlag::PROCESS_GRANTED_ROOT) {
331 api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);
332 return;
333 }
334 auto fn = [this](const std::string& lib) {
335 auto di = devinoby(lib.c_str());
336 if (di) {
337 return *di;
338 } else {
339 LOGW("#[zygisk::?] devino[dl_iterate_phdr]: Failed to get device & inode for %s", lib.c_str());
340 LOGI("#[zygisk::?] Fallback to use `/proc/self/maps`");
341 return devinobymap(lib);
342 }
343 };
344 if ((whitelist && isuserapp(args->uid)) || flags & zygisk::StateFlag::PROCESS_ON_DENYLIST) {
345 pid_t pid = getpid(), ppid = getppid();
346 cfd = api->connectCompanion(); // Companion FD
347 api->exemptFd(cfd);
348 if (write(cfd, &ppid, sizeof(ppid)) != sizeof(ppid)) {
349 LOGE("#[zygisk::preSpecialize] write: [-> ppid]: %s", strerror(errno));
350 close(cfd);
351 api->setOption(zygisk::Option::DLCLOSE_MODULE_LIBRARY);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected