Skip to content

Instantly share code, notes, and snippets.

@Brandon-T
Brandon-T / MacOSInject.cxx
Last active March 15, 2024 08:52
ARM64 Injection on MacOS M1
#include <thread>
#include <utility>
#include <cstdint>
#include <string>
#include <sys/types.h>
class Injector
{
public:
static bool Inject(std::string module_path, std::int32_t pid, void* bootstrap) noexcept;
@Brandon-T
Brandon-T / MacOSKeyCodes.pas
Created May 10, 2020 15:37
Virtual KeyCodes for MacOS
function VirtualKeyCodeToMac(AKey: Word): Word;
begin
case AKey of
VK_LBUTTON: Result := $FFFF;
VK_RBUTTON: Result := $FFFF;
VK_CANCEL: Result := $FFFF;
VK_MBUTTON: Result := $FFFF;
VK_XBUTTON1: Result := $FFFF;
VK_XBUTTON2: Result := $FFFF;
VK_BACK: Result := $33;
@Brandon-T
Brandon-T / iOSProfileFinder.py
Last active November 17, 2022 02:23
Parses Provisioning Profiles and converts them to JSON
import json
import glob
import os
from datetime import datetime
from subprocess import Popen, PIPE
def plist_to_json(filename):
command = 'security cms -D -i "' + filename + '"'
cleanup_command = 'sed "s/data/string/g" | sed "s/date/string/g"'
@Brandon-T
Brandon-T / Hacking UIView Animation Blocks.md
Created January 8, 2018 00:20 — forked from nicklockwood/Hacking UIView Animation Blocks.md
This article was originally written for objc.io issue 12, but didn't make the cut. It was intended to be read in the context of the other articles, so if you aren't familiar with concepts such as CALayer property animations and the role of actionForKey:, read the articles in that issue first.

Hacking UIView animation blocks for fun and profit

In this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.

As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.

In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.

Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.