Skip to content

Instantly share code, notes, and snippets.

View hym3242's full-sized avatar
💭
still lovin' TIOCSTI

hym3242 hym3242

💭
still lovin' TIOCSTI
View GitHub Profile
@hym3242
hym3242 / SkyLightInternals.c
Created May 20, 2024 09:02
Uses some SkyLight private symbols to print some useful stuff
//cc SLsymtest.c -g -o SLsymtest -framework Carbon -undefined dynamic_lookup
#include <unistd.h>
#include <stdio.h>
#include <CoreFoundation/CoreFoundation.h>
#include <CoreGraphics/CoreGraphics.h>
#include <ApplicationServices/ApplicationServices.h>
void SLDisplayDefaultVisualBell();
void SLSGetDebugOptions(int* options);
@hym3242
hym3242 / clickScreenshotWindowMarkupButton.m
Last active May 16, 2024 01:14
A objc program that clicks the "markup" button in "com.apple.screencaptureui" application 's "ScreenshotAnnotationWindow" (titled "Screenshot")
// compile with: cc clickScreenshotWindowMarkupButton.m -o clickScreenshotWindowMarkupButton -framework Cocoa
// This program clicks the "markup" button in "com.apple.screencaptureui" application 's "ScreenshotAnnotationWindow" (titled "Screenshot")
// Mostly written by the obviously-dumber-than-first-launched ChatGPT 4 Classic. No rights reserved.
#import <Foundation/Foundation.h>
#import <AppKit/AppKit.h>
// Function to find the PID using bundle identifier
pid_t pidForBundleIdentifier(NSString *bundleIdentifier) {
NSArray *apps = [NSRunningApplication runningApplicationsWithBundleIdentifier:bundleIdentifier];
@hym3242
hym3242 / StandardKeyBinding.dict.dump
Last active May 15, 2024 23:52
Dump of /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict on macOS Ventura 13.4, plus some notes
$ # plz forgive this dumb method of visualization.
$ cp /System/Library/Frameworks/AppKit.framework/Resources/StandardKeyBinding.dict .
$ plutil -convert xml1 StandardKeyBinding.dict
$ plutil -p StandardKeyBinding.dict | unicode-vis | cat -v | tr '\t' '+'
{
"^C" => "insertNewline:"
"^H" => "deleteBackward:"
"^Y" => "insertBacktab:" //shift+tab
"^[" => "cancelOperation:"
"^?" => "deleteBackward:"
@hym3242
hym3242 / macos_interesting_tools.md
Last active May 11, 2024 13:49
macOS interesting tools

macOS interesting tools

many are discovered by scouring the manpages apropos -s 1/8/? .

  • nettop
  • nscurl
  • (arp)
  • textutil
  • wish, tcl/tk etc.
  • last
@hym3242
hym3242 / dumpTerminalWindowByPartialName.m
Last active May 10, 2024 19:45
Dump full text content (incl. scrollback) of a window of Terminal.app with partial name of the window title.
// I have set my terminal to set wintitle with escape sequence every time a new window is created so that I can dump window by just tty name.
// I have this command in .profile: wintitle $(basename $(tty))
// where wintitle is:
// $ type wintitle
// wintitle is a function
// wintitle ()
// {
// echo -en "\e]0;$1\x01\e\\"
// }
@hym3242
hym3242 / SkyLight_private_newloginsession.c
Last active May 10, 2024 17:40
Create and switch WindowServer sessions with SkyLight private functions (no need for Fast User Switching, hooray!!!), compile with `cc xxx.c -g -o xxx -framework Carbon -undefined dynamic_lookup`.
#include <stdio.h>
int SLSCreateLoginSession(int *outSession); //courtesy of NUIKit/CGSInternal
int main(){
int outsession;
int ret = SLSCreateLoginSession(&outsession);
printf("login session created: %d\n",outsession);
return ret;
}
@hym3242
hym3242 / SLsymtest.c
Last active April 22, 2024 17:26
macOS privateframework SkyLight.framework private external function test: flash your screen with a visual bell!
//compile with
//cc SLsymtest.c -o SLsymtest -framework Carbon -undefined dynamic_lookup
// -framework for macho loading commands for SkyLight to be loaded otherwise dyld at runtime will complain and abort
// -undefined dynamic_lookup to prevent linker from complaining it can't find a definition/implementation for symbol
void SLDisplayDefaultVisualBell();
int main(){
SLDisplayDefaultVisualBell(); //via default mach port to WindowServer (after SkyLight bootstraps)
return 0;
@hym3242
hym3242 / macOS.10.15.AppKit.symbols.dump!grep.NSKeyBindingCommands.txt
Last active April 18, 2024 17:14
dump of macOS 10.15 AppKit symbols (grep NSKeyBindingCommands)
0x000000000041e50d ( 0x205) -[NSTextView(NSKeyBindingCommands) insertTab:] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x000000000046d4ee ( 0x22d) -[NSTextView(NSKeyBindingCommands) insertNewline:] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x000000000046e21a ( 0x35a) -[NSTextView(NSKeyBindingCommands) deleteBackward:] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x000000000046e574 ( 0x358) -[NSTextView(NSKeyBindingCommands) _checkInList:listStart:markerRange:emptyItem:atEnd:inBlock:blockStart:forCharacterRange:] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x0000000000471d20 ( 0x9e) -[NSTextView(NSKeyBindingCommands) deleteWordBackward:] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x000000000084cf2c ( 0xe5) -[NSTextView(NSKeyBindingCommands) _verticalDistanceForPageScroll] [FUNC, OBJC, NameNList, MangledNameNList, Merged, NList, FunctionStarts]
0x
@hym3242
hym3242 / BetterFormattedDescription.txt
Last active April 9, 2024 08:54
Better formatted description of NARA record "Private Motion Pictures of Adolf Hitler and Eva Braun" https://catalog.archives.gov/id/43461
Reel 1
Part 1, b&w, Eva Braun swims with her parents and others at Hitler's mountain retreat at Berchtesgaden. Hitler and Eva greet guests. Eva swims and performs gymnastics.
Part 2, color, shows Hitler, Eva, and the mountains surrounding the retreat. Eva and others swim, surfboard, and play at nearby lakes. Shows Hitler and others on a terrace overlooking the mountains.
Part 3, b&w, Hitler stands with officers as a guard forms and departs.
Part 4, color, shows Eva picking flowers.
Part 5, b&w, Hitler talks to Himmler and other officers.
Reel 2
Part 1, color, shows a panoramic view from the terrace of Hitler's retreat. Eva greets Goebbels. Hitler talks to Himmler and others.
Part 2, b&w, Hitler greets a group of women and children.
Part 3, color, shows the surrounding mountains. Hitler plays with a dog, children play in the snow, and Eva and others swim and play in the water.
@hym3242
hym3242 / Download ChromeStandaloneInstaller.exe with Google.com URL
Last active March 31, 2024 20:54
Download ChromeStandaloneInstaller.exe from google.com. keywords: google chrome standalone installer link url download
https://www.google.com/chrome/?system=true&standalone=1&platform=win64
https://www.google.com/chrome/?system=true&standalone=1&platform=win
https://www.google.com/chrome/?system=true&standalone=1&platform=mac
https://google.cn/chrome/?standalone=1&platform=mac
https://google.cn/chrome/?standalone=1&platform=win
https://google.cn/chrome/?standalone=1&platform=win64