From: Jay Freeman (saurik) Date: Wed, 4 Jun 2014 10:15:23 +0000 (-0700) Subject: Add $snprintfp trampoline helper, "just in case". X-Git-Tag: v0.9.502~18 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/d24f0f421bf518370eb241d7666d59469e740996 Add $snprintfp trampoline helper, "just in case". --- diff --git a/Trampoline.t.cpp b/Trampoline.t.cpp index b3bf31d..4ebf820 100644 --- a/Trampoline.t.cpp +++ b/Trampoline.t.cpp @@ -66,6 +66,24 @@ static void $strlcpy(char *dst, const char *src, size_t size) { } dst[i] = '\0'; } +__attribute__((__unused__)) +static void $snprintfp(char *dst, size_t size, const void *pointer) { + uintptr_t value(reinterpret_cast(pointer)); + char buffer[32]; + char *end(buffer + sizeof(buffer)); + *--end = '\0'; + if (value == 0) + *--end = '0'; + else do { + unsigned digit(value & 0xf); + value >>= 4; + *--end = (digit < 10 ? '0' : 'a' - 10) + digit; + } while (value != 0); + *--end = 'x'; + *--end = '0'; + $strlcpy(dst, end, size); +} + #ifdef __LP64__ typedef struct mach_header_64 mach_header_xx; typedef struct nlist_64 nlist_xx;