-
Notifications
You must be signed in to change notification settings - Fork 13
/
Utilities.h
101 lines (71 loc) · 2.5 KB
/
Utilities.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//
// Utilities.h
// DHS
//
// Created by Patrick Wardle on 2/7/15.
// Copyright (c) 2015 Objective-See. All rights reserved.
//
#ifndef DHS_Utilities_h
#define DHS_Utilities_h
#import <AppKit/AppKit.h>
#import <Foundation/Foundation.h>
/* FUNCTIONS */
//disable std err
void disableSTDERR(void);
//loads a framework
// note: assumes it is in 'Framework' dir
NSBundle* loadFramework(NSString* name);
//init crash reporting
void initCrashReporting(void);
//check if OS is supported
BOOL isSupportedOS(void);
//get OS's major or minor version
SInt32 getVersion(OSType selector);
//given a path to binary
// parse it back up to find app's bundle
NSBundle* findAppBundle(NSString* binaryPath);
//given a directory and a filter predicate
// ->return all matches
NSArray* directoryContents(NSString* directory, NSString* predicate);
//hash (sha1/md5) a file
NSDictionary* hashFile(NSString* filePath);
//get app's version
// ->extracted from Info.plist
NSString* getAppVersion();
//convert a textview to a clickable hyperlink
void makeTextViewHyperlink(NSTextField* textField, NSURL* url);
//determine if a file is signed by Apple proper
BOOL isApple(NSString* path);
//set the color of an attributed string
NSMutableAttributedString* setStringColor(NSAttributedString* string, NSColor* color);
//exec a process and grab it's output
NSMutableDictionary* execTask(NSString* binaryPath, NSArray* arguments, BOOL shouldWait);
//wait until a window is non nil
// ->then make it modal
void makeModal(NSWindowController* windowController);
//given a pid, get its parent (ppid)
pid_t getParentID(int pid);
//get path to XPC service
NSString* getPath2XPC();
//get path to kernel
NSString* path2Kernel();
//determine if process is (still) alive
BOOL isAlive(pid_t targetPID);
//check if computer has network connection
BOOL isNetworkConnected();
//set or unset button's highlight
void buttonAppearance(NSTableView* table, NSEvent* event, BOOL shouldReset);
//check if remote process is i386
BOOL Is32Bit(pid_t targetPID);
//check if app is translocated
// ->based on http://lapcatsoftware.com/articles/detect-app-translocation.html
NSURL* getUnTranslocatedURL();
//give a list of paths
// convert any `~` to all or current user
NSMutableArray* expandPaths(const __strong NSString* const paths[], int count);
//check if (full) dark mode
// meaning, Mojave+ and dark mode enabled
BOOL isDarkMode();
//bring an app to foreground (to get an icon in the dock) or background
void transformProcess(ProcessApplicationTransformState location);
#endif