Skip to content

Instantly share code, notes, and snippets.

View zhuowei's full-sized avatar

zhuowei

View GitHub Profile
@zhuowei
zhuowei / patch_constanttype.patch
Last active September 25, 2022 12:17
Patches for unluac to disassemble (and partially decompile) Playdate's Lua 5.4.0 beta bytecode
# HG changeset patch
# User Zhuowei Zhang <zhuowei@worthdoingbadly.com>
# Date 1633490863 14400
# Tue Oct 05 23:27:43 2021 -0400
# Node ID 9a209bac7961ed4cc661f1a358d8ef2e23c74d7b
# Parent 0390d042f93125be8257ae3a0520aa6b1003145c
Add PlayDate's 0x23 integer type, fix boolean parsing for Lua 5.4 beta
diff --git a/src/unluac/parse/LConstantType.java b/src/unluac/parse/LConstantType.java
--- a/src/unluac/parse/LConstantType.java
iBoot version: iBoot-7429.40.68
Registering: IOService:/options/IODTNVRAMDiags
Registering: IOService:/options/options-system
Registering: IOService:/options/options-common
Darwin Image4 Validator Version 5.0.0: Mon Sep 6 01:31:08 PDT 2021; root:AppleImage4-157.40.6.0.2~68/AppleImage4/RELEASE_ARM64E
AppleImage4: failed to read nvram property: oblit-inprogress: 2
AMFI: UDID enforcement enabled
Registering: IOService:/
Registering: IOService:/AppleARMPE/IOSystemStateNotification
Registering: IOService:/AppleARMPE/IOPMrootDomain
iBoot version: iBoot-7429.40.68
Registering: IOService:/options/IODTNVRAMDiags
Registering: IOService:/options/options-system
Registering: IOService:/options/options-common
Darwin Image4 Validator Version 5.0.0: Mon Sep 6 01:31:08 PDT 2021; root:AppleImage4-157.40.6.0.2~68/AppleImage4/RELEASE_ARM64E
AppleImage4: failed to read nvram property: oblit-inprogress: 2
AMFI: UDID enforcement enabled
Registering: IOService:/
Registering: IOService:/AppleARMPE/IOSystemStateNotification
Registering: IOService:/AppleARMPE/IOPMrootDomain
{
"kcdata_stackshot": {
"boot_args": "-v cpus=1 debug=0x4 serial=0x3 wdt=-1 rd=md0",
"jetsam_level": 0,
"kernel_page_size": 16384,
"mach_absolute_time": 2316282317,
"mach_timebase_info": {
"denom": 3,
"numer": 125
},
@zhuowei
zhuowei / safariinject.m
Last active October 22, 2021 17:15
Restores old tab bar in Safari 15.0 (16612.1.29.41.4, 16612)
// Restores old tab bar in Safari 15.0 (16612.1.29.41.4, 16612)
// clang -fmodules -shared -Wall -Os -o libsafariinject.dylib safariinject.m
//
// If SIP off:
// DYLD_INSERT_LIBRARIES=$PWD/libsafariinject.dylib /Applications/Safari.app/Contents/MacOS/Safari
//
// If SIP on, you can demo this by manually removing Safari's code signing signature, but many
// features (eg saved logins) won't be readable by the resigned app:
// cp -a /Applications/Safari.app ./
// codesign --remove Safari.app/Contents/MacOS/Safari
@import Darwin;
@import Foundation;
@interface IMGIFUtils
+ (bool)copyGifFromPath:(NSString*)arg1 toDestinationPath:(NSString*)arg2 error:(NSError**)arg3;
@end
int main() {
dlopen(
"/System/Library/PrivateFrameworks/IMSharedUtilities.framework/Versions/A/IMSharedUtilities",
diff --git a/SortedJ517DeviceTree.txt b/../../../macos12b5/Firmware/all_flash/SortedJ274APDeviceTree.txt
index ec5063a..8248bdb 100644
--- a/SortedJ517DeviceTree.txt
+++ b/../../../macos12b5/Firmware/all_flash/SortedJ274APDeviceTree.txt
@@ -3,12 +3,12 @@ device-tree:
#size-cells (4): 2
AAPL,phandle (4): 0x1
clock-frequency (4): 0
- compatible (25): "J517AP\0iPad13,4\0AppleARM\0"
+ compatible (27): "J274AP\0Macmini9,1\0AppleARM\0"
@zhuowei
zhuowei / Ensemble.plist
Last active September 18, 2023 06:26
Put this file as /Library/Preferences/FeatureFlags/Domain/Ensemble.plist and reboot to (hopefully) turn on Universal Control on macOS 12
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- not sure which one it is, so set both -->
<key>Ensemble</key>
<dict>
<key>Enabled</key>
<true/>
</dict>
@zhuowei
zhuowei / unpackpdx.py
Last active January 2, 2024 10:43
Unpacks a .pdx/.pdz file from the PlayDate
import sys
import os
import zlib
with open(sys.argv[1], "rb") as infile:
indata = infile.read()
magic = b"Playdate PDX\0\0\0\0"
magic_new = b"Playdate PDZ\0\0\0\0"
if not indata[0:len(magic)] in [magic, magic_new]: