A small menubar app that allows you to switch between R versions quickly (if you have multiple versions of R framework installed). https://rud.is/rswitch
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
4.0 KiB

// File: procInfo.h
// Project: Proc Info
// Created by: Patrick Wardle
// Copyright: 2017 Objective-See
// License: Creative Commons Attribution-NonCommercial 4.0 International License
#ifndef procInfo_h
#define procInfo_h
#import <libproc.h>
#import <sys/sysctl.h>
#import <Foundation/Foundation.h>
/* CLASSES */#import <Foundation/Foundation.h>
@class Binary;
@class Process;
//from audit_kevents.h
#define EVENT_EXIT 1
#define EVENT_FORK 2
#define EVENT_EXECVE 23
#define EVENT_EXEC 27
#define EVENT_SPAWN 43190
enum Signer{None, Apple, AppStore, DevID, AdHoc};
//signature status
#define KEY_SIGNATURE_STATUS @"signatureStatus"
#define KEY_SIGNATURE_SIGNER @"signatureSigner"
//signing auths
#define KEY_SIGNATURE_AUTHORITIES @"signatureAuthorities"
//code signing id
#define KEY_SIGNATURE_IDENTIFIER @"signatureIdentifier"
#define KEY_SIGNATURE_ENTITLEMENTS @"signatureEntitlements"
//block for library
typedef void (^ProcessCallbackBlock)(Process* _Nonnull);
@interface ProcInfo : NSObject
//init w/ flag
// flag dictates if CPU-intensive logic (code signing, etc) should be preformed
-(id _Nullable)init:(BOOL)goEasy;
//start monitoring
-(void)start:(ProcessCallbackBlock _Nonnull )callback;
//stop monitoring
//get list of running processes
-(NSMutableArray* _Nonnull)currentProcesses;
@interface Process : NSObject
@property pid_t pid;
@property pid_t ppid;
//user id
@property uid_t uid;
// used by process mon
@property u_int16_t type;
//exit code
@property u_int32_t exit;
@property(nonatomic, retain)NSString* _Nullable path;
@property(nonatomic, retain)NSMutableArray* _Nonnull arguments;
@property(nonatomic, retain)NSMutableArray* _Nonnull ancestors;
//signing info
@property(nonatomic, retain)NSMutableDictionary* _Nonnull signingInfo;
//Binary object
// has path, hash, etc
@property(nonatomic, retain)Binary* _Nonnull binary;
@property(nonatomic, retain)NSDate* _Nonnull timestamp;
//init with a pid
// method will then (try) fill out rest of object
-(id _Nullable)init:(pid_t)processID;
//generate signing info
// also classifies if Apple/from App Store/etc.
//set process's path
//generate list of ancestors
//class method
// get's parent of arbitrary process
@interface Binary : NSObject
@property(nonatomic, retain)NSString* _Nonnull path;
@property(nonatomic, retain)NSString* _Nonnull name;
@property(nonatomic, retain)NSImage* _Nonnull icon;
//file attributes
@property(nonatomic, retain)NSDictionary* _Nullable attributes;
//spotlight meta data
@property(nonatomic, retain)NSDictionary* _Nullable metadata;
// nil for non-apps
@property(nonatomic, retain)NSBundle* _Nullable bundle;
//signing info
@property(nonatomic, retain)NSDictionary* _Nonnull signingInfo;
@property(nonatomic, retain)NSMutableString* _Nonnull sha256;
// either signing id or sha256 hash
@property(nonatomic, retain)NSString* _Nonnull identifier;
//init w/ a path
-(id _Nonnull)init:(NSString* _Nonnull)path;
/* the following methods are rather CPU-intensive
as such, if the proc monitoring is run with the 'goEasy' option, they aren't automatically invoked
//get an icon for a process
// for apps, this will be app's icon, otherwise just a standard system one
//generate signing info (statically)
/* the following methods are not invoked automatically
as such, if you code has to manually invoke them if you want this info
//generate hash
// algo: sha256
//generate id
// either signing id, or sha256 hash