├── .gitignore ├── DiscordExtras.plist ├── LICENSE ├── Makefile ├── README.md ├── Tweak.h ├── Tweak.x ├── Utils.h ├── Utils.x ├── control ├── discordExtras_daemonUser.h ├── discordExtras_helperUser.c ├── discordextrasserver ├── Ent.plist ├── Makefile ├── discordExtras_daemonServer.h ├── discordExtras_helperServer.c ├── main.m └── pathname_type.h ├── jsbundletools ├── Makefile └── entitlements.plist ├── layout ├── DEBIAN │ ├── postinst │ └── prerm └── Library │ └── LaunchDaemons │ ├── cy_moe.panties.discordextrasserver.plist │ └── lh_moe.panties.discordextrasserver.plist ├── mach ├── discordExtras_daemonServer.h ├── discordExtras_daemonUser.h ├── discordExtras_helperServer.c ├── discordExtras_helperUser.c ├── mig.defs └── pathname_type.h └── pathname_type.h /.gitignore: -------------------------------------------------------------------------------- 1 | # Generic ignores 2 | packages/ 3 | .theos/ 4 | .DS_Store 5 | 6 | # Specific to jsbundletools 7 | jsbundletools/layout/ 8 | jsbundletools/jsbundletools 9 | jsbundletools/main.go -------------------------------------------------------------------------------- /DiscordExtras.plist: -------------------------------------------------------------------------------- 1 | { Filter = { Bundles = ( "com.hammerandchisel.discord" ); }; } 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 2 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 3 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 4 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMNNdhdyhyyhhhhhhhhhshmmMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 5 | MMMMMMMMMMMMMMMMMMMMMMMMmdmmossoo::////+++++++/+ssdymddmNMMmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 6 | MMMMMMMMMMMMMMMMMMMMMmhhoo:/::::::::://+++++/+++++oosooyhdmsdhhyNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 7 | MMMMMMMMMMMMMMMMMMNhoo++:::::---:::/ydNNNNNmho//++++ooooymmmNmdsmmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 8 | MMMMMMMMMMMMMMMMNds+-::::---------:dMMMmddhddh+//+++++osdmmmNNMNhmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 9 | MMMMMMMMMMMMMMMdyo/:::-------------hNho/:://////++++++++oossyhmNyNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 10 | MMMMMMMMMMMMMhyo/:::---------------:/:::::////+++++++++++ooossyyoddMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 11 | MMMMMMMMMMMNyo/::::----------------::::::::///++oo+++++++++oossyyyddMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 12 | MMMMMMMMMMmo+:/:::---------------::::::--::://+oosoo++//:::/+osyyyyddNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 13 | MMMMMMMMMMys:/:::--------------:::::-------:::/+osyso/:---::/+osyhhyohmMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 14 | MMMMMMMMNhs://:::------------:::::--------::://++osys/----://+oosyhysyhMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 15 | MMMMMMMMho:///:::----------:::///:----:::///++oooossys:::/+ooosssyhhysdyMMMMMMMMMMMMMMMMMMMMMMMMMMMM 16 | MMMMMMMmss////:::::::::::::::///::://+shssy+//+++oosyhssshmdo//+oshdysmdMMMMMMMMMMMMMMMMMMMMMMMMMMMM 17 | MMMMMMMhyo++//:::::::::::::///+//++:/yNmhsdd::://+oossydhmNMd//+ossyyymMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 18 | MMMMMMM/y/++///:::::::///////++/++:-:yNNNNNd::/++ooss+odNNNNs:+ossosysmMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 19 | MMMMMMMsh+++/////////////////+++++//::+ydhs::/+oosss++o/oso+/+ossssyysmdMMMMMMMMMMMMMyssmMMMMMMMMMMM 20 | MMMMMMMoh/o++//////////+++++++++++++++/:::/++oossysoooso+++osyysssyyysdhMMMMMMMMMMNsy/:/ydmMMMMMMMMM 21 | MMMMMMMoy+o+++///////+++++++++++++++osssssssyyyyssoossooosyyyyo+syyyyodhMMMMMMMMMMo--``-/mhMMMMMMMMM 22 | MMMMMNys+ooo++//////++++++++++++++++++osyyyyssooooooooooosssssyyyyyyysmhMMMMMMMMh/o:.`.//sdMMMMMMMMM 23 | MMMMd+/``:ooo++////////++++++++++++++++++++++ooooooo++ooosssyyyyyyyyyod+MMMMMMN/:/.``-//y+dddNhhNhhN 24 | MMMMs+/--:/ooo+++//////////++++++++++++++++////+++++++ooosssyyyyyyyyshhMMMMMMM+h:```-:++o+ooomossoom 25 | MMMMNhs++::/+ooo+++/////////////+++++///:::::://+o+/++ooossyyyyyyyyyoymMMMMMMs++.```...``...--..-..- 26 | MMMMMMyd/++///+sso++++++//////////////:::::::://+o+++ooossyyyyyyyyysoydMMMMMMho-````..---....-.``..` 27 | MMMMMMMNsyo+///+oss+++++++++//////////++////++oossssssssyyyyyyyyyyy/NmMMMMMNy+.....````````.-..-..-/ 28 | Mmmdyooyyo-://++++ssoooooooooooooooooo+++++ossyyyyyyyyyyhhhyyyyyyyodhMMMMMMmhs-.::--:::////:-------/ 29 | so+++:::+/-/+/:+ososysooooooooosssssssysssso++++++ooooossyyyyhhyyohhMMMMMMMMdh++ohyyyyyydhhddddo+shy 30 | -``.:++--/+++oo/oso::+syyssssssssssyyyyyyhhhhyyyyyyyyyhhhhhhhhhyymNMMMMMMMMMMMNdhhosmMddNddNMMNyhhNd 31 | -..-//.``-/ososso+/:++osyyyyyyyyyyyyyyyhhhdddmmmmmdddddhhhhhhys+hhMMMMMMMMMMMMMNdNdNMMMMMMMMMMMMMMMM 32 | yssoyy/://osss+..-/oosssyyyhyyyyyyyyyhhhhhdddddddddddhhhhhhhyosyNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 33 | MmNsNdhhyhhyh+-..-/ossyyyhhhhhhhhhhhhhhhhhhhhhhhhddhhhhhhhyo+syNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 34 | MMMNMMNNmmmddyysossyhyhdmmmmddddddhhhhhhhhhhhhhhddddhhhhsysoyNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 35 | MMMMMMMMMMMMMNmhmNmmNmhmyddmmmmmmmmmddddddddddddddhhhsyyddmmMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 36 | MMMMMMMMMMMMMMMMMMMMMMMMMNhyhdhmNmdNmmmmmmmdddyydmdmNmdmMNMMNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 37 | MMMMMMMMMMMMMMMMMMMMMMMMMMNmNMmNMmdNmmmNNNNmmdhhdymNNNNmmdhdmhymMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 38 | MMMMMMMMMMMMMMMMMMMMMMMMMMMMMmmmMMNMNMMMMMMMNNmhhydmNNNNNNNmmhsyNdMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 39 | MMMMMMMMMMMMMMMMMMMMMMMMNdNMdyhyMMNmmMMMMMMMMMNyhyyyydNNNmmmmmdsNNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 40 | MMMMMMMMMMMMMMMMMMMMMMNm+hmNddddNNmmmmmyNNNMMMNyysyyyydNNdmmmmhNdNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 41 | MMMMMMMMMMMMMMMMMMMMMMmdssyhhmNNNNmmmmmdyhdMMMNyhssssssdNdddddhddhdhmmmmmMMMMMMMMMMMMMMMMMMMMMMMMMMM 42 | MMMMMMMMMMMMMMMMMMMMMMMNmssssydNNmmmmmmdydNMMMNhhsoooo+osyyssooososo+yhyymMMMMMMMMMMMMMMMMMMMMMMMMMM 43 | MMMMMMMMMMMMMMMMMMMMMMMNMssssssdNmdmmmmy/odMNNhhsoo+++++++/-/+/syyyyssyyhyddNMMMMMMMMMMMMMMMMMMMMMMM 44 | MMMMMMMMMMMMMMMMMMMMMMMdosoosooodmdddddhoyhsdhs/oso++++o++++o//+o+++++osyhyomNMMMMMMMMMMMMMMMMMMMMMM 45 | MMMMMMMMMMMMMMMMMMMMMMmdoooo+++++ssoooooyyyssohoooo++oooooooo++++//++ossyhhsddMMMMMMMMMMMMMMMMMMMMMM 46 | MMMMMMMMMMMMMMMMMMMMMMdysoo+++++ooo//+//ssssssssyyhy++++ooooo++++++oooossyyyddNMMMMMMMMMMMMMMMMMMMMM 47 | MMMMMMMMMMMMMMMMMMMMMNoooooo++oooooossoo++++ooossyyhy+ysoooo+++////++oosyydhmNMMMMMMMMMMMMMMMMMMMMMM 48 | MMMMMMMMMMMMMMMMMMMMM/h++ooooooooooooo++++++oosssyyhhoyddoyssosossyhyydhhmNmMMMMMMMMMMMMMMMMMMMMMMMM 49 | MMMMMMMMMMMMMMMMMMMMMdo+o+++++ooosssooooooosssssossyhs+NNMhyddmdddNNNMNNMMMMMMMMMMMMMMMMMMMMMMMMMMMM 50 | MMMMMMMMMMMMMMMMMMMMMMmsohysooo+//++oo++++///++oosyhhhhNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 51 | MMMMMMMMMMMMMMMMMMMMMMMMmmmydmhdsooo++++osssssyddsdmmNMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMMM 52 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | ARCHS := arm64 arm64e 2 | TARGET := iphone:clang:latest:14.4 3 | INSTALL_TARGET_PROCESSES = Discord 4 | 5 | include $(THEOS)/makefiles/common.mk 6 | 7 | TWEAK_NAME = DiscordExtras 8 | $(TWEAK_NAME)_FRAMEWORKS = UIKit coregraphics 9 | $(TWEAK_NAME)_FILES = Tweak.x Utils.x discordExtras_helperUser.c 10 | $(TWEAK_NAME)_CFLAGS = -fobjc-arc 11 | 12 | BUNDLE_NAME = DiscordExtrasFiles 13 | $(BUNDLE_NAME)_INSTALL_PATH = /Library/Application Support 14 | 15 | SUBPROJECTS += jsbundletools 16 | 17 | include $(THEOS_MAKE_PATH)/tweak.mk 18 | include $(THEOS_MAKE_PATH)/bundle.mk 19 | 20 | SUBPROJECTS += discordextrasserver 21 | include $(THEOS_MAKE_PATH)/aggregate.mk 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DiscordExtras 2 | 3 | An iOS tweak that lets you apply patches the iOS Discord client. 4 | Available on my repo [here](https://repo.panties.moe). 5 | 6 | # Components 7 | 8 | ## DiscordExtrasServer 9 | This includes the lightweight background service that injects into SpringBoard, since the main Tweak injects itself into Discord directly, it is impossible for me to run my tool to patch the jsbundle file within the Discord process. 10 | All it does is wait for an IPC command to run the tool in the background. 11 | 12 | ## jsbundletools 13 | This includes jsbundletools, the tool used to patch the jsbundle file, it compiles the go binary into arm64 and package it properly for the tweak. 14 | NOTE: The code isn't included in the tweak, you can copy over `main.go` from the [jsbundletools repo](https://github.com/NotZoeyDev/jsbundletools). 15 | NOTE 2: Go is required if you wanna be able to compile the tweak properly. 16 | 17 | ## DiscordExtras 18 | The tweak itself is all implemented in Tweak.x and all it does it hijack Discord loading process to get the path of the jsbundle file it's trying to load, patch it accordingly, save the patched file in its cache folder and tell the client to load that patched file instead. 19 | -------------------------------------------------------------------------------- /Tweak.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import 5 | #import "discordExtras_daemonUser.h" 6 | 7 | kern_return_t bootstrap_look_up(mach_port_t port, const char *service, mach_port_t *server_port); 8 | 9 | #define BUNDLE_PATH @"/Library/Application Support/DiscordExtrasFiles.bundle" 10 | #define CACHE_PATH [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/"] 11 | #define HASHES_PATH [CACHE_PATH stringByAppendingString:@"/hashes.plist"] 12 | #define PATCHED_PATH [CACHE_PATH stringByAppendingString:@"patched.jsbundle"] 13 | #define PATCHES_FOLDER [BUNDLE_PATH stringByAppendingString:@"/patches"] -------------------------------------------------------------------------------- /Tweak.x: -------------------------------------------------------------------------------- 1 | #import "Tweak.h" 2 | #import "Utils.h" 3 | 4 | // Check/save hashes and re-apply patches if needed 5 | BOOL checkHashes(NSString *jsbundleFile, NSString *patchedPath) { 6 | NSMutableDictionary *hashes = [NSMutableDictionary dictionary]; 7 | 8 | if ([[NSFileManager defaultManager] fileExistsAtPath:HASHES_PATH]) { 9 | hashes = [[NSMutableDictionary alloc] initWithContentsOfFile:HASHES_PATH]; 10 | } 11 | 12 | BOOL doClearPatches = false; 13 | 14 | // Check hash for bundle 15 | NSString *bundleHash = getHashForFile(jsbundleFile); 16 | NSString *savedBundleHash = [hashes objectForKey:@"bundleHash"]; 17 | 18 | #ifndef NDEBUG 19 | NSLog(@"[DE] bundleHash: %@", bundleHash); 20 | #endif 21 | 22 | if (savedBundleHash) { 23 | if (![bundleHash isEqualToString:savedBundleHash]) { 24 | NSLog(@"[DE] New bundle found"); 25 | [hashes setObject:bundleHash forKey:@"bundleHash"]; 26 | doClearPatches = true; 27 | } 28 | } else { 29 | [hashes setObject:bundleHash forKey:@"bundleHash"]; 30 | doClearPatches = true; 31 | } 32 | 33 | // Check for patches 34 | NSString *patchesHash = [[NSString alloc] init]; 35 | NSString *savedPatchesHash = [hashes objectForKey:@"patchesHash"]; 36 | NSArray* patches = getPatches(); 37 | 38 | for (NSString *patch in patches) { 39 | NSString *patchPath = [NSString stringWithFormat:@"%@/%@", PATCHES_FOLDER, patch]; 40 | NSString *patchHash = getHashForFile(patchPath); 41 | patchesHash = [patchesHash stringByAppendingString:patchHash]; 42 | } 43 | 44 | #ifndef NDEBUG 45 | NSLog(@"[DE] patchesHash: %@", patchesHash); 46 | #endif 47 | 48 | if (savedPatchesHash) { 49 | if (![patchesHash isEqualToString:savedPatchesHash]) { 50 | NSLog(@"[DE] New patches found"); 51 | [hashes setObject:patchesHash forKey:@"patchesHash"]; 52 | doClearPatches = true; 53 | } 54 | } else { 55 | [hashes setObject:patchesHash forKey:@"patchesHash"]; 56 | doClearPatches = true; 57 | } 58 | 59 | [hashes writeToFile:HASHES_PATH atomically:YES]; 60 | 61 | return doClearPatches; 62 | } 63 | 64 | // Create our patched bundle file and return the path to it 65 | NSURL* createBundleFile(NSURL *originalBundle, NSString *patchedPath) { 66 | @try { 67 | mach_port_t server_port; 68 | kern_return_t err; 69 | if ((err = bootstrap_look_up(bootstrap_port, getServiceName(), &server_port)) != KERN_SUCCESS){ 70 | NSLog(@"[DE] Failed to get server: %s", mach_error_string(err)); 71 | return originalBundle; 72 | } 73 | 74 | err = dex_discordExtras_patch(server_port, 75 | (unsigned char *)[originalBundle.path UTF8String], 76 | [originalBundle.path length], 77 | (unsigned char *)[patchedPath UTF8String], 78 | [patchedPath length], 79 | (unsigned char *)[PATCHES_FOLDER UTF8String], 80 | [PATCHES_FOLDER length]); 81 | 82 | if (err != KERN_SUCCESS) { 83 | NSLog(@"[DE] Error creating patched jsbundle"); 84 | return originalBundle; 85 | } 86 | 87 | NSLog(@"[DE] Patched jsbundle was created"); 88 | return [[NSURL alloc] initFileURLWithPath:patchedPath]; 89 | } @catch(NSException *exception) { 90 | NSLog(@"[DE] Something went really fucking wrong"); 91 | return originalBundle; 92 | } 93 | } 94 | 95 | %hook AppDelegate 96 | 97 | - (id)sourceURLForBridge:(id)arg1 { 98 | id original = %orig; 99 | 100 | NSURL *jsBundlePath = original; 101 | NSString *patchedPath = [[jsBundlePath.path stringByDeletingLastPathComponent] stringByAppendingString:@"/patched.jsbundle"]; 102 | 103 | #ifndef NDEBUG 104 | NSLog(@"[DE] jsBundlePath: %@", jsBundlePath); 105 | NSLog(@"[DE] patchedPath: %@", patchedPath); 106 | #endif 107 | 108 | if (shouldCheckHashes()) { 109 | if (checkHashes(jsBundlePath.path, patchedPath)) { 110 | NSLog(@"[DE] Hashed check failed"); 111 | return createBundleFile(jsBundlePath, patchedPath); 112 | } 113 | 114 | NSLog(@"[DE] Hashes check pass"); 115 | } else { 116 | NSLog(@"[DE] Skipping hashes check"); 117 | } 118 | 119 | if ([[NSFileManager defaultManager] fileExistsAtPath:patchedPath]) { 120 | NSLog(@"[DE] Using patched jsbundle"); 121 | return [[NSURL alloc] initFileURLWithPath:patchedPath]; 122 | } 123 | 124 | NSLog(@"[DE] Patching jsbundle"); 125 | return createBundleFile(jsBundlePath, patchedPath); 126 | } 127 | 128 | %end 129 | -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | NSArray* getPatches(); 2 | void createPatchesJSON(); 3 | void deleteFile(NSString*); 4 | NSString* getHashForFile(NSString*); 5 | BOOL shouldCheckHashes(); 6 | char* getServiceName(); -------------------------------------------------------------------------------- /Utils.x: -------------------------------------------------------------------------------- 1 | #import "Tweak.h" 2 | 3 | #define substrateService "cy:moe.panties.discordextras"; 4 | #define libhookerService "lh:moe.panties.discordextras"; 5 | 6 | // Get list of available patches 7 | NSArray* getPatches() { 8 | return [[NSFileManager defaultManager] contentsOfDirectoryAtPath:PATCHES_FOLDER error:nil]; 9 | } 10 | 11 | char* getServiceName() { 12 | char* serviceName = ""; 13 | 14 | if (access("/usr/lib/libhooker.dylib", F_OK) == 0) { 15 | serviceName = libhookerService; 16 | } else { 17 | serviceName = substrateService; 18 | } 19 | 20 | return serviceName; 21 | } 22 | 23 | // Create a patch for patches list 24 | void createPatchesJSON() {} 25 | 26 | // Delete file 27 | void deleteFile(NSString *filePath) { 28 | if ([[NSFileManager defaultManager] fileExistsAtPath:filePath]) { 29 | [[NSFileManager defaultManager] removeItemAtPath:filePath error:nil]; 30 | NSLog(@"[DE] Deleted %@", filePath); 31 | } 32 | } 33 | 34 | // Get hashes for a specific file 35 | NSString* getHashForFile(NSString *path) { 36 | NSData *data = [NSData dataWithContentsOfFile:path]; 37 | unsigned char result[CC_SHA256_DIGEST_LENGTH]; 38 | CC_SHA256(data.bytes, data.length, result); 39 | 40 | NSMutableString *output = [NSMutableString stringWithCapacity:CC_SHA256_DIGEST_LENGTH * 2]; 41 | for (int i = 0; i < CC_SHA256_DIGEST_LENGTH; i++) { 42 | [output appendFormat:@"%02x", result[i]]; 43 | } 44 | 45 | return output; 46 | } 47 | 48 | BOOL shouldCheckHashes() { 49 | NSString* checkHashFile = @".skip_hashes"; 50 | 51 | return ![[NSFileManager defaultManager] fileExistsAtPath:[CACHE_PATH stringByAppendingString:checkHashFile]]; 52 | } -------------------------------------------------------------------------------- /control: -------------------------------------------------------------------------------- 1 | Package: moe.panties.discordextras 2 | Name: DiscordExtras 3 | Version: 1.4.2 4 | Architecture: iphoneos-arm 5 | Description: Add extra features to Discord via patches! 6 | Maintainer: Zoey 7 | Author: Zoey 8 | Section: Tweaks 9 | SileoDepiction: https://repo.panties.moe/depictions/discordextras 10 | Depends: mobilesubstrate (>= 0.9.5000) 11 | Icon: https://repo.panties.moe/icons/DiscordExtras.png 12 | -------------------------------------------------------------------------------- /discordExtras_daemonUser.h: -------------------------------------------------------------------------------- 1 | mach/discordExtras_daemonUser.h -------------------------------------------------------------------------------- /discordExtras_helperUser.c: -------------------------------------------------------------------------------- 1 | mach/discordExtras_helperUser.c -------------------------------------------------------------------------------- /discordextrasserver/Ent.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | platform-application 6 | 7 | com.apple.private.memorystatus 8 | 9 | 10 | -------------------------------------------------------------------------------- /discordextrasserver/Makefile: -------------------------------------------------------------------------------- 1 | ARCHS := arm64 2 | 3 | include $(THEOS)/makefiles/common.mk 4 | 5 | TOOL_NAME = DiscordExtrasServer 6 | 7 | DiscordExtrasServer_FILES = discordExtras_helperServer.c main.m ../Utils.x 8 | DiscordExtrasServer_CFLAGS = -fobjc-arc 9 | DiscordExtrasServer_CODESIGN_FLAGS = -SEnt.plist 10 | 11 | include $(THEOS_MAKE_PATH)/tool.mk 12 | -------------------------------------------------------------------------------- /discordextrasserver/discordExtras_daemonServer.h: -------------------------------------------------------------------------------- 1 | ../mach/discordExtras_daemonServer.h -------------------------------------------------------------------------------- /discordextrasserver/discordExtras_helperServer.c: -------------------------------------------------------------------------------- 1 | ../mach/discordExtras_helperServer.c -------------------------------------------------------------------------------- /discordextrasserver/main.m: -------------------------------------------------------------------------------- 1 | #import 2 | #import 3 | #import 4 | #import "../Utils.h" 5 | extern char **environ; 6 | 7 | #import "discordExtras_daemonServer.h" 8 | 9 | #define MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT 6 10 | 11 | typedef boolean_t (*dispatch_mig_callback_t)(mach_msg_header_t *message, mach_msg_header_t *reply); 12 | mach_msg_return_t dispatch_mig_server(dispatch_source_t ds, size_t maxmsgsz, dispatch_mig_callback_t callback); 13 | kern_return_t bootstrap_check_in(mach_port_t bootstrap_port, const char *service, mach_port_t *server_port); 14 | int memorystatus_control(uint32_t command, int32_t pid, uint32_t flags, void *buffer, size_t buffersize); 15 | 16 | kern_return_t dex_discordExtras_patch(mach_port_t server_port, pathname_t bundlePathC, mach_msg_type_number_t bundlePathCnt, pathname_t patchedPathC, mach_msg_type_number_t patchedPathCnt, pathname_t patchesPathC, mach_msg_type_number_t patchesPathCnt) { 17 | NSString *bundlePath = [[NSString alloc] initWithBytes:bundlePathC length:bundlePathCnt encoding:NSUTF8StringEncoding]; 18 | NSString *patchedPath = [[NSString alloc] initWithBytes:patchedPathC length:patchedPathCnt encoding:NSUTF8StringEncoding]; 19 | NSString *patchesPath = [[NSString alloc] initWithBytes:patchesPathC length:patchesPathCnt encoding:NSUTF8StringEncoding]; 20 | 21 | pid_t pid; 22 | char *argv[] = { 23 | (char *)[@"/usr/bin/jsbundletools" UTF8String], 24 | (char *)[@"-m" UTF8String], 25 | (char *)[@"patch" UTF8String], 26 | (char *)[@"-p" UTF8String], 27 | (char *)[bundlePath UTF8String], 28 | (char *)[@"-d" UTF8String], 29 | (char *)[patchesPath UTF8String], 30 | (char *)[@"-n" UTF8String], 31 | (char *)[patchedPath UTF8String], 32 | NULL 33 | }; 34 | 35 | posix_spawnattr_t attr; 36 | int status; 37 | posix_spawnattr_init(&attr); 38 | posix_spawnattr_set_qos_class_np(&attr, QOS_CLASS_USER_INTERACTIVE); 39 | posix_spawn(&pid, argv[0], NULL, &attr, argv, environ); 40 | waitpid(pid, &status, 0); 41 | posix_spawnattr_destroy(&attr); 42 | 43 | return (status == 0) ? KERN_SUCCESS : KERN_FAILURE; 44 | } 45 | 46 | int main() { 47 | memorystatus_control(MEMORYSTATUS_CMD_SET_JETSAM_TASK_LIMIT, getpid(), 0, NULL, 0); 48 | 49 | mach_port_t server_port; 50 | kern_return_t err; 51 | if ((err = bootstrap_check_in(bootstrap_port, getServiceName(), &server_port))){ 52 | NSLog(@"[DES] Failed to check in: %s", mach_error_string(err)); 53 | return -1; 54 | } 55 | 56 | NSLog(@"[DES] Server is started!"); 57 | 58 | dispatch_source_t server = dispatch_source_create(DISPATCH_SOURCE_TYPE_MACH_RECV, server_port, 0, dispatch_get_global_queue(QOS_CLASS_USER_INTERACTIVE, 0)); 59 | dispatch_source_set_event_handler(server, ^{ 60 | dispatch_mig_server(server, MAX(sizeof(union __RequestUnion__dex_discordExtras_helper_subsystem), sizeof(union __ReplyUnion__dex_discordExtras_helper_subsystem)), discordExtras_helper_server ); 61 | }); 62 | dispatch_resume(server); 63 | dispatch_main(); 64 | 65 | return 0; 66 | } 67 | -------------------------------------------------------------------------------- /discordextrasserver/pathname_type.h: -------------------------------------------------------------------------------- 1 | ../mach/pathname_type.h -------------------------------------------------------------------------------- /jsbundletools/Makefile: -------------------------------------------------------------------------------- 1 | include $(THEOS)/makefiles/common.mk 2 | include $(THEOS_MAKE_PATH)/null.mk 3 | 4 | ARCHS := arm64 arm64e 5 | 6 | export GOOS=ios 7 | export GOARCH=arm64 8 | export CGO_ENABLED=1 9 | export CC=$(shell go env GOROOT)/misc/ios/clangwrap.sh 10 | 11 | all:: 12 | go build -o jsbundletools main.go 13 | ldid -Sentitlements.plist jsbundletools 14 | mkdir -p layout/usr/bin 15 | cp jsbundletools layout/usr/bin 16 | 17 | clean:: 18 | rm -rf layout/usr/bin/jsbundletools -------------------------------------------------------------------------------- /jsbundletools/entitlements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | platform-application 5 | 6 | com.apple.private.security.container-required 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /layout/DEBIAN/postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LH=/usr/lib/libhooker.dylib 3 | if test -f "$LH"; then 4 | launchctl load /Library/LaunchDaemons/lh_moe.panties.discordextrasserver.plist 5 | else 6 | launchctl load /Library/LaunchDaemons/cy_moe.panties.discordextrasserver.plist 7 | fi -------------------------------------------------------------------------------- /layout/DEBIAN/prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | LH=/usr/lib/libhooker.dylib 3 | if test -f "$LH"; then 4 | launchctl unload /Library/LaunchDaemons/lh_moe.panties.discordextrasserver.plist 5 | else 6 | launchctl unload /Library/LaunchDaemons/cy_moe.panties.discordextrasserver.plist 7 | fi 8 | -------------------------------------------------------------------------------- /layout/Library/LaunchDaemons/cy_moe.panties.discordextrasserver.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | POSIXSpawnType 6 | Interactive 7 | ProgramArguments 8 | 9 | /usr/bin/DiscordExtrasServer 10 | 11 | Label 12 | moe.panties.DiscordExtras 13 | EnablePressuredExit 14 | 15 | MachServices 16 | 17 | cy:moe.panties.discordextras 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /layout/Library/LaunchDaemons/lh_moe.panties.discordextrasserver.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | POSIXSpawnType 6 | Interactive 7 | ProgramArguments 8 | 9 | /usr/bin/DiscordExtrasServer 10 | 11 | Label 12 | moe.panties.DiscordExtras 13 | EnablePressuredExit 14 | 15 | MachServices 16 | 17 | lh:moe.panties.discordextras 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /mach/discordExtras_daemonServer.h: -------------------------------------------------------------------------------- 1 | #ifndef _discordExtras_helper_server_ 2 | #define _discordExtras_helper_server_ 3 | 4 | /* Module discordExtras_helper */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* BEGIN VOUCHER CODE */ 17 | 18 | #ifndef KERNEL 19 | #if defined(__has_include) 20 | #if __has_include() 21 | #ifndef USING_VOUCHERS 22 | #define USING_VOUCHERS 23 | #endif 24 | #ifndef __VOUCHER_FORWARD_TYPE_DECLS__ 25 | #define __VOUCHER_FORWARD_TYPE_DECLS__ 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg) __attribute__((weak_import)); 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif // __VOUCHER_FORWARD_TYPE_DECLS__ 34 | #endif // __has_include() 35 | #endif // __has_include 36 | #endif // !KERNEL 37 | 38 | /* END VOUCHER CODE */ 39 | 40 | 41 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ 42 | 43 | #if defined(__has_include) 44 | #if __has_include() 45 | #ifndef USING_MIG_STRNCPY_ZEROFILL 46 | #define USING_MIG_STRNCPY_ZEROFILL 47 | #endif 48 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ 49 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ 58 | #endif /* __has_include() */ 59 | #endif /* __has_include */ 60 | 61 | /* END MIG_STRNCPY_ZEROFILL CODE */ 62 | 63 | 64 | #ifdef AUTOTEST 65 | #ifndef FUNCTION_PTR_T 66 | #define FUNCTION_PTR_T 67 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); 68 | typedef struct { 69 | char *name; 70 | function_ptr_t function; 71 | } function_table_entry; 72 | typedef function_table_entry *function_table_t; 73 | #endif /* FUNCTION_PTR_T */ 74 | #endif /* AUTOTEST */ 75 | 76 | #ifndef discordExtras_helper_MSG_COUNT 77 | #define discordExtras_helper_MSG_COUNT 1 78 | #endif /* discordExtras_helper_MSG_COUNT */ 79 | 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include "pathname_type.h" 85 | 86 | #ifdef __BeforeMigServerHeader 87 | __BeforeMigServerHeader 88 | #endif /* __BeforeMigServerHeader */ 89 | 90 | #ifndef MIG_SERVER_ROUTINE 91 | #define MIG_SERVER_ROUTINE 92 | #endif 93 | 94 | 95 | /* Routine discordExtras_patch */ 96 | #ifdef mig_external 97 | mig_external 98 | #else 99 | extern 100 | #endif /* mig_external */ 101 | MIG_SERVER_ROUTINE 102 | kern_return_t dex_discordExtras_patch 103 | ( 104 | mach_port_t server_port, 105 | pathname_t bundlePath, 106 | mach_msg_type_number_t bundlePathCnt, 107 | pathname_t patchedPath, 108 | mach_msg_type_number_t patchedPathCnt, 109 | pathname_t patchesPath, 110 | mach_msg_type_number_t patchesPathCnt 111 | ); 112 | 113 | #ifdef mig_external 114 | mig_external 115 | #else 116 | extern 117 | #endif /* mig_external */ 118 | boolean_t discordExtras_helper_server( 119 | mach_msg_header_t *InHeadP, 120 | mach_msg_header_t *OutHeadP); 121 | 122 | #ifdef mig_external 123 | mig_external 124 | #else 125 | extern 126 | #endif /* mig_external */ 127 | mig_routine_t discordExtras_helper_server_routine( 128 | mach_msg_header_t *InHeadP); 129 | 130 | 131 | /* Description of this subsystem, for use in direct RPC */ 132 | extern const struct dex_discordExtras_helper_subsystem { 133 | mig_server_routine_t server; /* Server routine */ 134 | mach_msg_id_t start; /* Min routine number */ 135 | mach_msg_id_t end; /* Max routine number + 1 */ 136 | unsigned int maxsize; /* Max msg size */ 137 | vm_address_t reserved; /* Reserved */ 138 | struct routine_descriptor /*Array of routine descriptors */ 139 | routine[1]; 140 | } dex_discordExtras_helper_subsystem; 141 | 142 | /* typedefs for all requests */ 143 | 144 | #ifndef __Request__discordExtras_helper_subsystem__defined 145 | #define __Request__discordExtras_helper_subsystem__defined 146 | 147 | #ifdef __MigPackStructs 148 | #pragma pack(push, 4) 149 | #endif 150 | typedef struct { 151 | mach_msg_header_t Head; 152 | NDR_record_t NDR; 153 | mach_msg_type_number_t bundlePathCnt; 154 | uint8_t bundlePath[2048]; 155 | mach_msg_type_number_t patchedPathCnt; 156 | uint8_t patchedPath[2048]; 157 | mach_msg_type_number_t patchesPathCnt; 158 | uint8_t patchesPath[2048]; 159 | } __Request__discordExtras_patch_t __attribute__((unused)); 160 | #ifdef __MigPackStructs 161 | #pragma pack(pop) 162 | #endif 163 | #endif /* !__Request__discordExtras_helper_subsystem__defined */ 164 | 165 | 166 | /* union of all requests */ 167 | 168 | #ifndef __RequestUnion__dex_discordExtras_helper_subsystem__defined 169 | #define __RequestUnion__dex_discordExtras_helper_subsystem__defined 170 | union __RequestUnion__dex_discordExtras_helper_subsystem { 171 | __Request__discordExtras_patch_t Request_discordExtras_patch; 172 | }; 173 | #endif /* __RequestUnion__dex_discordExtras_helper_subsystem__defined */ 174 | /* typedefs for all replies */ 175 | 176 | #ifndef __Reply__discordExtras_helper_subsystem__defined 177 | #define __Reply__discordExtras_helper_subsystem__defined 178 | 179 | #ifdef __MigPackStructs 180 | #pragma pack(push, 4) 181 | #endif 182 | typedef struct { 183 | mach_msg_header_t Head; 184 | NDR_record_t NDR; 185 | kern_return_t RetCode; 186 | } __Reply__discordExtras_patch_t __attribute__((unused)); 187 | #ifdef __MigPackStructs 188 | #pragma pack(pop) 189 | #endif 190 | #endif /* !__Reply__discordExtras_helper_subsystem__defined */ 191 | 192 | 193 | /* union of all replies */ 194 | 195 | #ifndef __ReplyUnion__dex_discordExtras_helper_subsystem__defined 196 | #define __ReplyUnion__dex_discordExtras_helper_subsystem__defined 197 | union __ReplyUnion__dex_discordExtras_helper_subsystem { 198 | __Reply__discordExtras_patch_t Reply_discordExtras_patch; 199 | }; 200 | #endif /* __ReplyUnion__dex_discordExtras_helper_subsystem__defined */ 201 | 202 | #ifndef subsystem_to_name_map_discordExtras_helper 203 | #define subsystem_to_name_map_discordExtras_helper \ 204 | { "discordExtras_patch", 500 } 205 | #endif 206 | 207 | #ifdef __AfterMigServerHeader 208 | __AfterMigServerHeader 209 | #endif /* __AfterMigServerHeader */ 210 | 211 | #endif /* _discordExtras_helper_server_ */ 212 | -------------------------------------------------------------------------------- /mach/discordExtras_daemonUser.h: -------------------------------------------------------------------------------- 1 | #ifndef _discordExtras_helper_user_ 2 | #define _discordExtras_helper_user_ 3 | 4 | /* Module discordExtras_helper */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | /* BEGIN VOUCHER CODE */ 17 | 18 | #ifndef KERNEL 19 | #if defined(__has_include) 20 | #if __has_include() 21 | #ifndef USING_VOUCHERS 22 | #define USING_VOUCHERS 23 | #endif 24 | #ifndef __VOUCHER_FORWARD_TYPE_DECLS__ 25 | #define __VOUCHER_FORWARD_TYPE_DECLS__ 26 | #ifdef __cplusplus 27 | extern "C" { 28 | #endif 29 | extern boolean_t voucher_mach_msg_set(mach_msg_header_t *msg) __attribute__((weak_import)); 30 | #ifdef __cplusplus 31 | } 32 | #endif 33 | #endif // __VOUCHER_FORWARD_TYPE_DECLS__ 34 | #endif // __has_include() 35 | #endif // __has_include 36 | #endif // !KERNEL 37 | 38 | /* END VOUCHER CODE */ 39 | 40 | 41 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ 42 | 43 | #if defined(__has_include) 44 | #if __has_include() 45 | #ifndef USING_MIG_STRNCPY_ZEROFILL 46 | #define USING_MIG_STRNCPY_ZEROFILL 47 | #endif 48 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ 49 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ 50 | #ifdef __cplusplus 51 | extern "C" { 52 | #endif 53 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); 54 | #ifdef __cplusplus 55 | } 56 | #endif 57 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ 58 | #endif /* __has_include() */ 59 | #endif /* __has_include */ 60 | 61 | /* END MIG_STRNCPY_ZEROFILL CODE */ 62 | 63 | 64 | #ifdef AUTOTEST 65 | #ifndef FUNCTION_PTR_T 66 | #define FUNCTION_PTR_T 67 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); 68 | typedef struct { 69 | char *name; 70 | function_ptr_t function; 71 | } function_table_entry; 72 | typedef function_table_entry *function_table_t; 73 | #endif /* FUNCTION_PTR_T */ 74 | #endif /* AUTOTEST */ 75 | 76 | #ifndef discordExtras_helper_MSG_COUNT 77 | #define discordExtras_helper_MSG_COUNT 1 78 | #endif /* discordExtras_helper_MSG_COUNT */ 79 | 80 | #include 81 | #include 82 | #include 83 | #include 84 | #include "pathname_type.h" 85 | 86 | #ifdef __BeforeMigUserHeader 87 | __BeforeMigUserHeader 88 | #endif /* __BeforeMigUserHeader */ 89 | 90 | #include 91 | __BEGIN_DECLS 92 | 93 | 94 | /* Routine discordExtras_patch */ 95 | #ifdef mig_external 96 | mig_external 97 | #else 98 | extern 99 | #endif /* mig_external */ 100 | kern_return_t dex_discordExtras_patch 101 | ( 102 | mach_port_t server_port, 103 | pathname_t bundlePath, 104 | mach_msg_type_number_t bundlePathCnt, 105 | pathname_t patchedPath, 106 | mach_msg_type_number_t patchedPathCnt, 107 | pathname_t patchesPath, 108 | mach_msg_type_number_t patchesPathCnt 109 | ); 110 | 111 | __END_DECLS 112 | 113 | /********************** Caution **************************/ 114 | /* The following data types should be used to calculate */ 115 | /* maximum message sizes only. The actual message may be */ 116 | /* smaller, and the position of the arguments within the */ 117 | /* message layout may vary from what is presented here. */ 118 | /* For example, if any of the arguments are variable- */ 119 | /* sized, and less than the maximum is sent, the data */ 120 | /* will be packed tight in the actual message to reduce */ 121 | /* the presence of holes. */ 122 | /********************** Caution **************************/ 123 | 124 | /* typedefs for all requests */ 125 | 126 | #ifndef __Request__discordExtras_helper_subsystem__defined 127 | #define __Request__discordExtras_helper_subsystem__defined 128 | 129 | #ifdef __MigPackStructs 130 | #pragma pack(push, 4) 131 | #endif 132 | typedef struct { 133 | mach_msg_header_t Head; 134 | NDR_record_t NDR; 135 | mach_msg_type_number_t bundlePathCnt; 136 | uint8_t bundlePath[2048]; 137 | mach_msg_type_number_t patchedPathCnt; 138 | uint8_t patchedPath[2048]; 139 | mach_msg_type_number_t patchesPathCnt; 140 | uint8_t patchesPath[2048]; 141 | } __Request__discordExtras_patch_t __attribute__((unused)); 142 | #ifdef __MigPackStructs 143 | #pragma pack(pop) 144 | #endif 145 | #endif /* !__Request__discordExtras_helper_subsystem__defined */ 146 | 147 | /* union of all requests */ 148 | 149 | #ifndef __RequestUnion__dex_discordExtras_helper_subsystem__defined 150 | #define __RequestUnion__dex_discordExtras_helper_subsystem__defined 151 | union __RequestUnion__dex_discordExtras_helper_subsystem { 152 | __Request__discordExtras_patch_t Request_dex_discordExtras_patch; 153 | }; 154 | #endif /* !__RequestUnion__dex_discordExtras_helper_subsystem__defined */ 155 | /* typedefs for all replies */ 156 | 157 | #ifndef __Reply__discordExtras_helper_subsystem__defined 158 | #define __Reply__discordExtras_helper_subsystem__defined 159 | 160 | #ifdef __MigPackStructs 161 | #pragma pack(push, 4) 162 | #endif 163 | typedef struct { 164 | mach_msg_header_t Head; 165 | NDR_record_t NDR; 166 | kern_return_t RetCode; 167 | } __Reply__discordExtras_patch_t __attribute__((unused)); 168 | #ifdef __MigPackStructs 169 | #pragma pack(pop) 170 | #endif 171 | #endif /* !__Reply__discordExtras_helper_subsystem__defined */ 172 | 173 | /* union of all replies */ 174 | 175 | #ifndef __ReplyUnion__dex_discordExtras_helper_subsystem__defined 176 | #define __ReplyUnion__dex_discordExtras_helper_subsystem__defined 177 | union __ReplyUnion__dex_discordExtras_helper_subsystem { 178 | __Reply__discordExtras_patch_t Reply_dex_discordExtras_patch; 179 | }; 180 | #endif /* !__RequestUnion__dex_discordExtras_helper_subsystem__defined */ 181 | 182 | #ifndef subsystem_to_name_map_discordExtras_helper 183 | #define subsystem_to_name_map_discordExtras_helper \ 184 | { "discordExtras_patch", 500 } 185 | #endif 186 | 187 | #ifdef __AfterMigUserHeader 188 | __AfterMigUserHeader 189 | #endif /* __AfterMigUserHeader */ 190 | 191 | #endif /* _discordExtras_helper_user_ */ 192 | -------------------------------------------------------------------------------- /mach/discordExtras_helperServer.c: -------------------------------------------------------------------------------- 1 | /* 2 | * IDENTIFICATION: 3 | * stub generated Thu Apr 29 20:51:21 2021 4 | * with a MiG generated by bootstrap_cmds-117 5 | * OPTIONS: 6 | */ 7 | 8 | /* Module discordExtras_helper */ 9 | 10 | #define __MIG_check__Request__discordExtras_helper_subsystem__ 1 11 | 12 | #include "discordExtras_daemonServer.h" 13 | 14 | #ifndef mig_internal 15 | #define mig_internal static __inline__ 16 | #endif /* mig_internal */ 17 | 18 | #ifndef mig_external 19 | #define mig_external 20 | #endif /* mig_external */ 21 | 22 | #if !defined(__MigTypeCheck) && defined(TypeCheck) 23 | #define __MigTypeCheck TypeCheck /* Legacy setting */ 24 | #endif /* !defined(__MigTypeCheck) */ 25 | 26 | #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) 27 | #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ 28 | #endif /* !defined(__MigKernelSpecificCode) */ 29 | 30 | #ifndef LimitCheck 31 | #define LimitCheck 0 32 | #endif /* LimitCheck */ 33 | 34 | #ifndef min 35 | #define min(a,b) ( ((a) < (b))? (a): (b) ) 36 | #endif /* min */ 37 | 38 | #if !defined(_WALIGN_) 39 | #define _WALIGN_(x) (((x) + 3) & ~3) 40 | #endif /* !defined(_WALIGN_) */ 41 | 42 | #if !defined(_WALIGNSZ_) 43 | #define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) 44 | #endif /* !defined(_WALIGNSZ_) */ 45 | 46 | #ifndef UseStaticTemplates 47 | #define UseStaticTemplates 0 48 | #endif /* UseStaticTemplates */ 49 | 50 | #ifndef MIG_SERVER_ROUTINE 51 | #define MIG_SERVER_ROUTINE 52 | #endif 53 | 54 | #ifndef __DeclareRcvRpc 55 | #define __DeclareRcvRpc(_NUM_, _NAME_) 56 | #endif /* __DeclareRcvRpc */ 57 | 58 | #ifndef __BeforeRcvRpc 59 | #define __BeforeRcvRpc(_NUM_, _NAME_) 60 | #endif /* __BeforeRcvRpc */ 61 | 62 | #ifndef __AfterRcvRpc 63 | #define __AfterRcvRpc(_NUM_, _NAME_) 64 | #endif /* __AfterRcvRpc */ 65 | 66 | #ifndef __DeclareRcvSimple 67 | #define __DeclareRcvSimple(_NUM_, _NAME_) 68 | #endif /* __DeclareRcvSimple */ 69 | 70 | #ifndef __BeforeRcvSimple 71 | #define __BeforeRcvSimple(_NUM_, _NAME_) 72 | #endif /* __BeforeRcvSimple */ 73 | 74 | #ifndef __AfterRcvSimple 75 | #define __AfterRcvSimple(_NUM_, _NAME_) 76 | #endif /* __AfterRcvSimple */ 77 | 78 | #define novalue void 79 | 80 | #define msgh_request_port msgh_local_port 81 | #define MACH_MSGH_BITS_REQUEST(bits) MACH_MSGH_BITS_LOCAL(bits) 82 | #define msgh_reply_port msgh_remote_port 83 | #define MACH_MSGH_BITS_REPLY(bits) MACH_MSGH_BITS_REMOTE(bits) 84 | 85 | #define MIG_RETURN_ERROR(X, code) {\ 86 | ((mig_reply_error_t *)X)->RetCode = code;\ 87 | ((mig_reply_error_t *)X)->NDR = NDR_record;\ 88 | return;\ 89 | } 90 | 91 | /* Forward Declarations */ 92 | 93 | 94 | mig_internal novalue _XdiscordExtras_patch 95 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP); 96 | 97 | 98 | #if ( __MigTypeCheck ) 99 | #if __MIG_check__Request__discordExtras_helper_subsystem__ 100 | #if !defined(__MIG_check__Request__discordExtras_patch_t__defined) 101 | #define __MIG_check__Request__discordExtras_patch_t__defined 102 | 103 | mig_internal kern_return_t __MIG_check__Request__discordExtras_patch_t(__attribute__((__unused__)) __Request__discordExtras_patch_t *In0P, __attribute__((__unused__)) __Request__discordExtras_patch_t **In1PP, __attribute__((__unused__)) __Request__discordExtras_patch_t **In2PP) 104 | { 105 | 106 | typedef __Request__discordExtras_patch_t __Request; 107 | __Request *In1P; 108 | __Request *In2P; 109 | #if __MigTypeCheck 110 | unsigned int msgh_size; 111 | #endif /* __MigTypeCheck */ 112 | unsigned int msgh_size_delta; 113 | 114 | #if __MigTypeCheck 115 | msgh_size = In0P->Head.msgh_size; 116 | if ((In0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || 117 | (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 6144)) || (msgh_size > (mach_msg_size_t)sizeof(__Request))) 118 | return MIG_BAD_ARGUMENTS; 119 | #endif /* __MigTypeCheck */ 120 | 121 | #if defined(__NDR_convert__int_rep__Request__discordExtras_patch_t__bundlePathCnt__defined) 122 | if (In0P->NDR.int_rep != NDR_record.int_rep) 123 | __NDR_convert__int_rep__Request__discordExtras_patch_t__bundlePathCnt(&In0P->bundlePathCnt, In0P->NDR.int_rep); 124 | #endif /* __NDR_convert__int_rep__Request__discordExtras_patch_t__bundlePathCnt__defined */ 125 | msgh_size_delta = _WALIGN_(In0P->bundlePathCnt); 126 | #if __MigTypeCheck 127 | if ( In0P->bundlePathCnt > 2048 ) 128 | return MIG_BAD_ARGUMENTS; 129 | if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 6144)) < In0P->bundlePathCnt) || 130 | (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 6144) + _WALIGN_(In0P->bundlePathCnt))) 131 | return MIG_BAD_ARGUMENTS; 132 | msgh_size -= msgh_size_delta; 133 | #endif /* __MigTypeCheck */ 134 | 135 | *In1PP = In1P = (__Request *) ((pointer_t) In0P + msgh_size_delta - 2048); 136 | 137 | #if defined(__NDR_convert__int_rep__Request__discordExtras_patch_t__patchedPathCnt__defined) 138 | if (In0P->NDR.int_rep != NDR_record.int_rep) 139 | __NDR_convert__int_rep__Request__discordExtras_patch_t__patchedPathCnt(&In1P->patchedPathCnt, In1P->NDR.int_rep); 140 | #endif /* __NDR_convert__int_rep__Request__discordExtras_patch_t__patchedPathCnt__defined */ 141 | msgh_size_delta = _WALIGN_(In1P->patchedPathCnt); 142 | #if __MigTypeCheck 143 | if ( In1P->patchedPathCnt > 2048 ) 144 | return MIG_BAD_ARGUMENTS; 145 | if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 6144)) < In1P->patchedPathCnt) || 146 | (msgh_size < (mach_msg_size_t)(sizeof(__Request) - 6144) + _WALIGN_(In1P->patchedPathCnt))) 147 | return MIG_BAD_ARGUMENTS; 148 | msgh_size -= msgh_size_delta; 149 | #endif /* __MigTypeCheck */ 150 | 151 | *In2PP = In2P = (__Request *) ((pointer_t) In1P + msgh_size_delta - 2048); 152 | 153 | #if defined(__NDR_convert__int_rep__Request__discordExtras_patch_t__patchesPathCnt__defined) 154 | if (In0P->NDR.int_rep != NDR_record.int_rep) 155 | __NDR_convert__int_rep__Request__discordExtras_patch_t__patchesPathCnt(&In2P->patchesPathCnt, In2P->NDR.int_rep); 156 | #endif /* __NDR_convert__int_rep__Request__discordExtras_patch_t__patchesPathCnt__defined */ 157 | #if __MigTypeCheck 158 | if ( In2P->patchesPathCnt > 2048 ) 159 | return MIG_BAD_ARGUMENTS; 160 | if (((msgh_size - (mach_msg_size_t)(sizeof(__Request) - 6144)) < In2P->patchesPathCnt) || 161 | (msgh_size != (mach_msg_size_t)(sizeof(__Request) - 6144) + _WALIGN_(In2P->patchesPathCnt))) 162 | return MIG_BAD_ARGUMENTS; 163 | #endif /* __MigTypeCheck */ 164 | 165 | return MACH_MSG_SUCCESS; 166 | } 167 | #endif /* !defined(__MIG_check__Request__discordExtras_patch_t__defined) */ 168 | #endif /* __MIG_check__Request__discordExtras_helper_subsystem__ */ 169 | #endif /* ( __MigTypeCheck ) */ 170 | 171 | 172 | /* Routine discordExtras_patch */ 173 | mig_internal novalue _XdiscordExtras_patch 174 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) 175 | { 176 | 177 | #ifdef __MigPackStructs 178 | #pragma pack(push, 4) 179 | #endif 180 | typedef struct { 181 | mach_msg_header_t Head; 182 | NDR_record_t NDR; 183 | mach_msg_type_number_t bundlePathCnt; 184 | uint8_t bundlePath[2048]; 185 | mach_msg_type_number_t patchedPathCnt; 186 | uint8_t patchedPath[2048]; 187 | mach_msg_type_number_t patchesPathCnt; 188 | uint8_t patchesPath[2048]; 189 | mach_msg_trailer_t trailer; 190 | } Request __attribute__((unused)); 191 | #ifdef __MigPackStructs 192 | #pragma pack(pop) 193 | #endif 194 | typedef __Request__discordExtras_patch_t __Request; 195 | typedef __Reply__discordExtras_patch_t Reply __attribute__((unused)); 196 | 197 | /* 198 | * typedef struct { 199 | * mach_msg_header_t Head; 200 | * NDR_record_t NDR; 201 | * kern_return_t RetCode; 202 | * } mig_reply_error_t; 203 | */ 204 | 205 | Request *In0P = (Request *) InHeadP; 206 | Request *In1P; 207 | Request *In2P; 208 | Reply *OutP = (Reply *) OutHeadP; 209 | #ifdef __MIG_check__Request__discordExtras_patch_t__defined 210 | kern_return_t check_result; 211 | #endif /* __MIG_check__Request__discordExtras_patch_t__defined */ 212 | 213 | __DeclareRcvRpc(500, "discordExtras_patch") 214 | __BeforeRcvRpc(500, "discordExtras_patch") 215 | 216 | #if defined(__MIG_check__Request__discordExtras_patch_t__defined) 217 | check_result = __MIG_check__Request__discordExtras_patch_t((__Request *)In0P, (__Request **)&In1P, (__Request **)&In2P); 218 | if (check_result != MACH_MSG_SUCCESS) 219 | { MIG_RETURN_ERROR(OutP, check_result); } 220 | #endif /* defined(__MIG_check__Request__discordExtras_patch_t__defined) */ 221 | 222 | OutP->RetCode = dex_discordExtras_patch(In0P->Head.msgh_request_port, In0P->bundlePath, In0P->bundlePathCnt, In1P->patchedPath, In1P->patchedPathCnt, In2P->patchesPath, In2P->patchesPathCnt); 223 | 224 | OutP->NDR = NDR_record; 225 | 226 | 227 | __AfterRcvRpc(500, "discordExtras_patch") 228 | } 229 | 230 | 231 | 232 | /* Description of this subsystem, for use in direct RPC */ 233 | const struct dex_discordExtras_helper_subsystem dex_discordExtras_helper_subsystem = { 234 | discordExtras_helper_server_routine, 235 | 500, 236 | 501, 237 | (mach_msg_size_t)sizeof(union __ReplyUnion__dex_discordExtras_helper_subsystem), 238 | (vm_address_t)0, 239 | { 240 | { (mig_impl_routine_t) 0, 241 | (mig_stub_routine_t) _XdiscordExtras_patch, 7, 0, (routine_arg_descriptor_t)0, (mach_msg_size_t)sizeof(__Reply__discordExtras_patch_t)}, 242 | } 243 | }; 244 | 245 | mig_external boolean_t discordExtras_helper_server 246 | (mach_msg_header_t *InHeadP, mach_msg_header_t *OutHeadP) 247 | { 248 | /* 249 | * typedef struct { 250 | * mach_msg_header_t Head; 251 | * NDR_record_t NDR; 252 | * kern_return_t RetCode; 253 | * } mig_reply_error_t; 254 | */ 255 | 256 | mig_routine_t routine; 257 | 258 | OutHeadP->msgh_bits = MACH_MSGH_BITS(MACH_MSGH_BITS_REPLY(InHeadP->msgh_bits), 0); 259 | OutHeadP->msgh_remote_port = InHeadP->msgh_reply_port; 260 | /* Minimal size: routine() will update it if different */ 261 | OutHeadP->msgh_size = (mach_msg_size_t)sizeof(mig_reply_error_t); 262 | OutHeadP->msgh_local_port = MACH_PORT_NULL; 263 | OutHeadP->msgh_id = InHeadP->msgh_id + 100; 264 | OutHeadP->msgh_reserved = 0; 265 | 266 | if ((InHeadP->msgh_id > 500) || (InHeadP->msgh_id < 500) || 267 | ((routine = dex_discordExtras_helper_subsystem.routine[InHeadP->msgh_id - 500].stub_routine) == 0)) { 268 | ((mig_reply_error_t *)OutHeadP)->NDR = NDR_record; 269 | ((mig_reply_error_t *)OutHeadP)->RetCode = MIG_BAD_ID; 270 | return FALSE; 271 | } 272 | (*routine) (InHeadP, OutHeadP); 273 | return TRUE; 274 | } 275 | 276 | mig_external mig_routine_t discordExtras_helper_server_routine 277 | (mach_msg_header_t *InHeadP) 278 | { 279 | int msgh_id; 280 | 281 | msgh_id = InHeadP->msgh_id - 500; 282 | 283 | if ((msgh_id > 0) || (msgh_id < 0)) 284 | return 0; 285 | 286 | return dex_discordExtras_helper_subsystem.routine[msgh_id].stub_routine; 287 | } 288 | -------------------------------------------------------------------------------- /mach/discordExtras_helperUser.c: -------------------------------------------------------------------------------- 1 | /* 2 | * IDENTIFICATION: 3 | * stub generated Thu Apr 29 20:51:21 2021 4 | * with a MiG generated by bootstrap_cmds-117 5 | * OPTIONS: 6 | */ 7 | #define __MIG_check__Reply__discordExtras_helper_subsystem__ 1 8 | 9 | #include "discordExtras_daemonUser.h" 10 | 11 | /* TODO: #include */ 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif /* __cplusplus */ 15 | extern void mach_msg_destroy(mach_msg_header_t *); 16 | #ifdef __cplusplus 17 | } 18 | #endif /* __cplusplus */ 19 | 20 | #ifndef mig_internal 21 | #define mig_internal static __inline__ 22 | #endif /* mig_internal */ 23 | 24 | #ifndef mig_external 25 | #define mig_external 26 | #endif /* mig_external */ 27 | 28 | #if !defined(__MigTypeCheck) && defined(TypeCheck) 29 | #define __MigTypeCheck TypeCheck /* Legacy setting */ 30 | #endif /* !defined(__MigTypeCheck) */ 31 | 32 | #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) 33 | #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ 34 | #endif /* !defined(__MigKernelSpecificCode) */ 35 | 36 | #ifndef LimitCheck 37 | #define LimitCheck 0 38 | #endif /* LimitCheck */ 39 | 40 | #ifndef min 41 | #define min(a,b) ( ((a) < (b))? (a): (b) ) 42 | #endif /* min */ 43 | 44 | #if !defined(_WALIGN_) 45 | #define _WALIGN_(x) (((x) + 3) & ~3) 46 | #endif /* !defined(_WALIGN_) */ 47 | 48 | #if !defined(_WALIGNSZ_) 49 | #define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) 50 | #endif /* !defined(_WALIGNSZ_) */ 51 | 52 | #ifndef UseStaticTemplates 53 | #define UseStaticTemplates 0 54 | #endif /* UseStaticTemplates */ 55 | 56 | #ifndef MIG_SERVER_ROUTINE 57 | #define MIG_SERVER_ROUTINE 58 | #endif 59 | 60 | #ifndef __MachMsgErrorWithTimeout 61 | #define __MachMsgErrorWithTimeout(_R_) { \ 62 | switch (_R_) { \ 63 | case MACH_SEND_INVALID_DATA: \ 64 | case MACH_SEND_INVALID_DEST: \ 65 | case MACH_SEND_INVALID_HEADER: \ 66 | mig_put_reply_port(InP->Head.msgh_reply_port); \ 67 | break; \ 68 | case MACH_SEND_TIMED_OUT: \ 69 | case MACH_RCV_TIMED_OUT: \ 70 | default: \ 71 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ 72 | } \ 73 | } 74 | #endif /* __MachMsgErrorWithTimeout */ 75 | 76 | #ifndef __MachMsgErrorWithoutTimeout 77 | #define __MachMsgErrorWithoutTimeout(_R_) { \ 78 | switch (_R_) { \ 79 | case MACH_SEND_INVALID_DATA: \ 80 | case MACH_SEND_INVALID_DEST: \ 81 | case MACH_SEND_INVALID_HEADER: \ 82 | mig_put_reply_port(InP->Head.msgh_reply_port); \ 83 | break; \ 84 | default: \ 85 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ 86 | } \ 87 | } 88 | #endif /* __MachMsgErrorWithoutTimeout */ 89 | 90 | #ifndef __DeclareSendRpc 91 | #define __DeclareSendRpc(_NUM_, _NAME_) 92 | #endif /* __DeclareSendRpc */ 93 | 94 | #ifndef __BeforeSendRpc 95 | #define __BeforeSendRpc(_NUM_, _NAME_) 96 | #endif /* __BeforeSendRpc */ 97 | 98 | #ifndef __AfterSendRpc 99 | #define __AfterSendRpc(_NUM_, _NAME_) 100 | #endif /* __AfterSendRpc */ 101 | 102 | #ifndef __DeclareSendSimple 103 | #define __DeclareSendSimple(_NUM_, _NAME_) 104 | #endif /* __DeclareSendSimple */ 105 | 106 | #ifndef __BeforeSendSimple 107 | #define __BeforeSendSimple(_NUM_, _NAME_) 108 | #endif /* __BeforeSendSimple */ 109 | 110 | #ifndef __AfterSendSimple 111 | #define __AfterSendSimple(_NUM_, _NAME_) 112 | #endif /* __AfterSendSimple */ 113 | 114 | #define msgh_request_port msgh_remote_port 115 | #define msgh_reply_port msgh_local_port 116 | 117 | 118 | 119 | #if ( __MigTypeCheck ) 120 | #if __MIG_check__Reply__discordExtras_helper_subsystem__ 121 | #if !defined(__MIG_check__Reply__discordExtras_patch_t__defined) 122 | #define __MIG_check__Reply__discordExtras_patch_t__defined 123 | 124 | mig_internal kern_return_t __MIG_check__Reply__discordExtras_patch_t(__Reply__discordExtras_patch_t *Out0P) 125 | { 126 | 127 | typedef __Reply__discordExtras_patch_t __Reply __attribute__((unused)); 128 | if (Out0P->Head.msgh_id != 600) { 129 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) 130 | { return MIG_SERVER_DIED; } 131 | else 132 | { return MIG_REPLY_MISMATCH; } 133 | } 134 | 135 | #if __MigTypeCheck 136 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || 137 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply))) 138 | { return MIG_TYPE_ERROR ; } 139 | #endif /* __MigTypeCheck */ 140 | 141 | #if __MigTypeCheck 142 | if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) { 143 | return MIG_TYPE_ERROR; 144 | } 145 | #endif /* __MigTypeCheck */ 146 | { 147 | return Out0P->RetCode; 148 | } 149 | } 150 | #endif /* !defined(__MIG_check__Reply__discordExtras_patch_t__defined) */ 151 | #endif /* __MIG_check__Reply__discordExtras_helper_subsystem__ */ 152 | #endif /* ( __MigTypeCheck ) */ 153 | 154 | 155 | /* Routine discordExtras_patch */ 156 | mig_external kern_return_t dex_discordExtras_patch 157 | ( 158 | mach_port_t server_port, 159 | pathname_t bundlePath, 160 | mach_msg_type_number_t bundlePathCnt, 161 | pathname_t patchedPath, 162 | mach_msg_type_number_t patchedPathCnt, 163 | pathname_t patchesPath, 164 | mach_msg_type_number_t patchesPathCnt 165 | ) 166 | { 167 | 168 | #ifdef __MigPackStructs 169 | #pragma pack(push, 4) 170 | #endif 171 | typedef struct { 172 | mach_msg_header_t Head; 173 | NDR_record_t NDR; 174 | mach_msg_type_number_t bundlePathCnt; 175 | uint8_t bundlePath[2048]; 176 | mach_msg_type_number_t patchedPathCnt; 177 | uint8_t patchedPath[2048]; 178 | mach_msg_type_number_t patchesPathCnt; 179 | uint8_t patchesPath[2048]; 180 | } Request __attribute__((unused)); 181 | #ifdef __MigPackStructs 182 | #pragma pack(pop) 183 | #endif 184 | 185 | #ifdef __MigPackStructs 186 | #pragma pack(push, 4) 187 | #endif 188 | typedef struct { 189 | mach_msg_header_t Head; 190 | NDR_record_t NDR; 191 | kern_return_t RetCode; 192 | mach_msg_trailer_t trailer; 193 | } Reply __attribute__((unused)); 194 | #ifdef __MigPackStructs 195 | #pragma pack(pop) 196 | #endif 197 | 198 | #ifdef __MigPackStructs 199 | #pragma pack(push, 4) 200 | #endif 201 | typedef struct { 202 | mach_msg_header_t Head; 203 | NDR_record_t NDR; 204 | kern_return_t RetCode; 205 | } __Reply __attribute__((unused)); 206 | #ifdef __MigPackStructs 207 | #pragma pack(pop) 208 | #endif 209 | /* 210 | * typedef struct { 211 | * mach_msg_header_t Head; 212 | * NDR_record_t NDR; 213 | * kern_return_t RetCode; 214 | * } mig_reply_error_t; 215 | */ 216 | 217 | union { 218 | Request In; 219 | Reply Out; 220 | } Mess; 221 | 222 | Request *InP = &Mess.In; 223 | Reply *Out0P = &Mess.Out; 224 | 225 | mach_msg_return_t msg_result; 226 | unsigned int msgh_size; 227 | unsigned int msgh_size_delta; 228 | 229 | 230 | #ifdef __MIG_check__Reply__discordExtras_patch_t__defined 231 | kern_return_t check_result; 232 | #endif /* __MIG_check__Reply__discordExtras_patch_t__defined */ 233 | 234 | __DeclareSendRpc(500, "discordExtras_patch") 235 | 236 | InP->NDR = NDR_record; 237 | 238 | if (bundlePathCnt > 2048) { 239 | { return MIG_ARRAY_TOO_LARGE; } 240 | } 241 | (void)memcpy((char *) InP->bundlePath, (const char *) bundlePath, bundlePathCnt); 242 | 243 | InP->bundlePathCnt = bundlePathCnt; 244 | 245 | msgh_size_delta = _WALIGN_(bundlePathCnt); 246 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 6144) + msgh_size_delta; 247 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 2048); 248 | 249 | if (patchedPathCnt > 2048) { 250 | { return MIG_ARRAY_TOO_LARGE; } 251 | } 252 | (void)memcpy((char *) InP->patchedPath, (const char *) patchedPath, patchedPathCnt); 253 | 254 | InP->patchedPathCnt = patchedPathCnt; 255 | 256 | msgh_size_delta = _WALIGN_(patchedPathCnt); 257 | msgh_size += msgh_size_delta; 258 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 2048); 259 | 260 | if (patchesPathCnt > 2048) { 261 | { return MIG_ARRAY_TOO_LARGE; } 262 | } 263 | (void)memcpy((char *) InP->patchesPath, (const char *) patchesPath, patchesPathCnt); 264 | 265 | InP->patchesPathCnt = patchesPathCnt; 266 | 267 | msgh_size += _WALIGN_(patchesPathCnt); 268 | InP = &Mess.In; 269 | InP->Head.msgh_bits = 270 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); 271 | /* msgh_size passed as argument */ 272 | InP->Head.msgh_request_port = server_port; 273 | InP->Head.msgh_reply_port = mig_get_reply_port(); 274 | InP->Head.msgh_id = 500; 275 | InP->Head.msgh_reserved = 0; 276 | 277 | /* BEGIN VOUCHER CODE */ 278 | 279 | #ifdef USING_VOUCHERS 280 | if (voucher_mach_msg_set != NULL) { 281 | voucher_mach_msg_set(&InP->Head); 282 | } 283 | #endif // USING_VOUCHERS 284 | 285 | /* END VOUCHER CODE */ 286 | 287 | __BeforeSendRpc(500, "discordExtras_patch") 288 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); 289 | __AfterSendRpc(500, "discordExtras_patch") 290 | if (msg_result != MACH_MSG_SUCCESS) { 291 | __MachMsgErrorWithoutTimeout(msg_result); 292 | } 293 | if (msg_result != MACH_MSG_SUCCESS) { 294 | { return msg_result; } 295 | } 296 | 297 | 298 | #if defined(__MIG_check__Reply__discordExtras_patch_t__defined) 299 | check_result = __MIG_check__Reply__discordExtras_patch_t((__Reply__discordExtras_patch_t *)Out0P); 300 | if (check_result != MACH_MSG_SUCCESS) { 301 | mach_msg_destroy(&Out0P->Head); 302 | { return check_result; } 303 | } 304 | #endif /* defined(__MIG_check__Reply__discordExtras_patch_t__defined) */ 305 | 306 | return KERN_SUCCESS; 307 | } 308 | -------------------------------------------------------------------------------- /mach/mig.defs: -------------------------------------------------------------------------------- 1 | // mig -sheader discordExtras_daemonServer.h -header discordExtras_daemonUser.h mig.defs 2 | 3 | subsystem discordExtras_helper 500; 4 | userprefix dex_; 5 | serverprefix dex_; 6 | 7 | #include 8 | #include 9 | 10 | import "pathname_type.h"; 11 | type pathname_t = array[*: 2048] of uint8_t; 12 | 13 | routine discordExtras_patch(server_port : mach_port_t; 14 | in bundlePath: pathname_t; 15 | in patchedPath: pathname_t; 16 | in patchesPath: pathname_t); -------------------------------------------------------------------------------- /mach/pathname_type.h: -------------------------------------------------------------------------------- 1 | typedef uint8_t *pathname_t; 2 | -------------------------------------------------------------------------------- /pathname_type.h: -------------------------------------------------------------------------------- 1 | mach/pathname_type.h --------------------------------------------------------------------------------