I was reviewing my GitHub gists and saw this:
#include <stdio.h>
#include <stdlib.h>
#pragma clang diagnostic ignored "-Wformat-security"
int main() {
/* 4 bytes (chars)
import Foundation | |
struct OrderedSet<Element: Hashable>: Sequence { | |
private var order: [Element] | |
private var membership: Set<Element> | |
func makeIterator() -> IndexingIterator<Array<Element>> { | |
order.makeIterator() | |
} | |
import sys | |
FAT_MAGIC = b'\xca\xfe\xba\xbe' # big endian | |
FAT_MAGIC_64 = b'\xca\xfe\xba\xbf' # big endian | |
MH_MAGIC_64 = b'\xfe\xed\xfa\xcf' # big endian | |
MH_CIGAM_64 = b'\xcf\xfa\xed\xfe' # little endian | |
CPU_TYPE_ARM64 = b'\x01\x00\x00\x0c' # big endian | |
CPU_SUBTYPE_IOS13 = b'\x00\x00\x00\x02' # big endian |
I was reviewing my GitHub gists and saw this:
#include <stdio.h>
#include <stdlib.h>
#pragma clang diagnostic ignored "-Wformat-security"
int main() {
/* 4 bytes (chars)
// | |
// Created by Leptos on 12/25/19. | |
// Copyright © 2019 Leptos. All rights reserved. | |
// | |
#import <stdio.h> | |
#import <fcntl.h> | |
#import <unistd.h> | |
#import <ctype.h> |
This article aims to describe how to hook Swift functions.
Thanks to help from @NightwindDev for discussion and testing.
Overall, the idea is simple:
Write our own Swift code that will have the same calling convention as the target code,
then get a pointer to our own code and the target code, and call MSHookFunction
with
these values.