#import <CaptainHook/CaptainHook.h>
CHDeclareClass(UIDevice);
CHDeclareClass(NSString);
CHConstructor {
CHLoadLateClass(NSString);
}
CHMethod(0, NSString *, UIDevice, systemVersion)
{
NSString *fakeSystemVersion=@
"9.3.3"
;
return
fakeSystemVersion;
}
__attribute__((constructor))
static
void
EntryCaptainHook()
{
NSLog(@
"hello patch!"
);
CHLoadLateClass(UIDevice);
CHClassHook(0, UIDevice, systemVersion);
}
#include <fishhook/fishhook.h>
#include <CoreFoundation/CoreFoundation.h>
#include <dlfcn.h>
#include <mach-o/dyld.h>
CF_EXPORT CFDictionaryRef _CFCopySystemVersionDictionary(
void
);
CFDictionaryRef (*orig_CFCopySystemVersionDictionary)(
void
);
#define CONST_STRING_DECL(S, V) const CFStringRef S = (const CFStringRef)__builtin___CFStringMakeConstantString(V);
CONST_STRING_DECL(_kCFSystemVersionBuildVersionKey,
"ProductBuildVersion"
)
CONST_STRING_DECL(_FakeProductBuildVersion,
"13G34"
)
CONST_STRING_DECL(_kCFSystemVersionProductVersionKey,
"ProductVersion"
)
CONST_STRING_DECL(_FakeProductVersion,
"9.3.3"
)
CFDictionaryRef fake_CFCopySystemVersionDictionary(
void
) {
CFDictionaryRef tmp_dict = orig_CFCopySystemVersionDictionary();
CFDictionarySetValue((CFMutableDictionaryRef)tmp_dict, _kCFSystemVersionBuildVersionKey, _FakeProductBuildVersion);
CFDictionarySetValue((CFMutableDictionaryRef)tmp_dict, _kCFSystemVersionProductVersionKey, _FakeProductVersion);
return
tmp_dict;
}
__attribute__((constructor))
static
void
EntryFishHook()
{
intptr_t
(*pub_dyld_get_image_slide)(
const
struct
mach_header *mh);
pub_dyld_get_image_slide = dlsym((
void
*)dlopen(0, RTLD_LAZY),
"_dyld_get_image_slide"
);
const
struct
mach_header *header = _dyld_get_image_header(0);
intptr_t
slide = pub_dyld_get_image_slide(header);
rebind_symbols_image((
void
*)header, slide, (
struct
rebinding[1]){{
"_CFCopySystemVersionDictionary"
, fake_CFCopySystemVersionDictionary, (
void
*)&orig_CFCopySystemVersionDictionary}}, 1);
}