Skip to content

Commit

Permalink
Merge pull request #18 from bR34Kr/master
Browse files Browse the repository at this point in the history
Symbol hooking
  • Loading branch information
joeyjurjens authored Jul 10, 2020
2 parents 14beee1 + 4426300 commit e161b23
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions template/Macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include <substrate.h>
#include <mach-o/dyld.h>
#include <dlfcn.h>

// definition at Menu.h
extern Menu *menu;
Expand All @@ -21,6 +22,11 @@ extern Switches *switches;
#define HOOK(offset, ptr, orig) MSHookFunction((void *)getRealOffset(offset), (void *)ptr, (void **)&orig)
#define HOOK_NO_ORIG(offset, ptr) MSHookFunction((void *)getRealOffset(offset), (void *)ptr, NULL)

// Note to not prepend an underscore to the symbol. See Notes on the Apple manpage (https://developer.apple.com/library/archive/documentation/System/Conceptual/ManPages_iPhoneOS/man3/dlsym.3.html)
#define HOOKSYM(sym, ptr, org) MSHookFunction((void*)dlsym((void *)-2, sym), (void *)ptr, (void **)&org)
#define HOOKSYM_NO_ORIG(sym, ptr) MSHookFunction((void*)dlsym((void *)-2, sym), (void *)ptr, NULL)
#define getSym(symName) dlsym((void *)-2, symName)

// Convert hex color to UIColor, usage: For the color #BD0000 you'd use: UIColorFromHex(0xBD0000)
#define UIColorFromHex(hexColor) [UIColor colorWithRed:((float)((hexColor & 0xFF0000) >> 16))/255.0 green:((float)((hexColor & 0xFF00) >> 8))/255.0 blue:((float)(hexColor & 0xFF))/255.0 alpha:1.0]

Expand Down
12 changes: 11 additions & 1 deletion template/sample.xm
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ int get_Gems(void *this_) {
return old_get_Gems(this_);
}

void (*old_gl_draw_elements)(GLenum mode, GLsizei count, GLenum type, const void *indices);

void gl_draw_elements(GLenum mode, GLsizei count, GLenum type, const void *indices) {
// This hook is absolutely useless. Just to show a PoC
old_gl_draw_elements(mode, count type, indices);
}

void setup() {

//public virtual void UpdateCharacter(float deltaTime); // RVA: 0x10194DE30 Offset: 0x194DE30 -> CharacterBase
Expand All @@ -79,6 +86,9 @@ void setup() {

//public int get_Gems(); // RVA: 0x1018A3F24 Offset: 0x18A3F24
HOOK(0x1018A3F24, get_Gems, old_get_Gems);

// This entry is fictional but is just there to show a PoC.
HOOKSYM("glDrawElements", gl_draw_elements, old_gl_draw_elements);

[switches addTextfieldSwitch:@"Custom Coins:"
description:@"Here you can enter your own coins amount!"
Expand Down Expand Up @@ -173,4 +183,4 @@ static void didFinishLaunching(CFNotificationCenterRef center, void *observer, C

%ctor {
CFNotificationCenterAddObserver(CFNotificationCenterGetLocalCenter(), NULL, &didFinishLaunching, (CFStringRef)UIApplicationDidFinishLaunchingNotification, NULL, CFNotificationSuspensionBehaviorDeliverImmediately);
}
}
2 changes: 1 addition & 1 deletion template/versionCheck.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/bash
VERSION='0.6.6'
VERSION='0.6.7'
# Don't remove the above line. Serves as the version this script will fetch. Only update when a new version is out.

ERROR='\033[1;31m[*] Error:\033[1;37m '
Expand Down

0 comments on commit e161b23

Please sign in to comment.