- install swift
- install ida.swift to $PATH/ida
Last active
April 18, 2025 21:40
-
-
Save ChiChou/1c8df7334c0279e3c83810afb74ec0c1 to your computer and use it in GitHub Desktop.
macOS cli shortcut to open file in IDA
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env swift | |
import AppKit | |
import Foundation | |
guard CommandLine.arguments.count > 1 else { | |
fputs("Usage: \(CommandLine.arguments[0]) <file1> <file2> ...\n", stderr) | |
exit(1) | |
} | |
let workspace = NSWorkspace.shared | |
guard let appUrl = workspace.urlForApplication(withBundleIdentifier: "com.hexrays.ida64") else { | |
fputs("Error: IDA Pro is not installed.\n", stderr) | |
exit(1) | |
} | |
var urls: [URL] = [] | |
for i in 1..<CommandLine.arguments.count { | |
let filePath = CommandLine.arguments[i] | |
if FileManager.default.fileExists(atPath: filePath) == false { | |
fputs("Error: File does not exist: \(filePath)\n", stderr) | |
exit(1) | |
} | |
urls.append(URL(fileURLWithPath: filePath)) | |
} | |
let conf = NSWorkspace.OpenConfiguration() | |
let semaphore = DispatchSemaphore(value: 0) | |
workspace.open(urls, withApplicationAt: appUrl, configuration: conf) { (app, error) in | |
if let error = error { | |
fputs("Error: \(error.localizedDescription)\n", stderr) | |
exit(1) | |
} | |
semaphore.signal() | |
} | |
semaphore.wait() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment