From f0562441d9736b01f331f817318959fa5503a969 Mon Sep 17 00:00:00 2001 From: Patrick Wardle Date: Fri, 21 Dec 2018 21:58:49 -1000 Subject: [PATCH] UI improvements (center title image) improved CLI --- 3rdParty/TAAdaptiveSpaceItem.h | 15 --- 3rdParty/TAAdaptiveSpaceItem.m | 91 ------------------- 3rdParty/TAAdaptiveSpaceItemView.h | 16 ---- 3rdParty/TAAdaptiveSpaceItemView.m | 35 ------- AppDelegate.h | 4 - AppDelegate.m | 5 - TaskExplorer.xcodeproj/project.pbxproj | 12 --- .../xcschemes/TaskExplorer.xcscheme | 10 +- TaskTableController.h | 2 - UI/SearchWindow.xib | 6 +- en.lproj/MainMenu.xib | 25 ++--- main.h | 4 +- main.m | 23 ++++- 13 files changed, 34 insertions(+), 214 deletions(-) delete mode 100755 3rdParty/TAAdaptiveSpaceItem.h delete mode 100755 3rdParty/TAAdaptiveSpaceItem.m delete mode 100755 3rdParty/TAAdaptiveSpaceItemView.h delete mode 100755 3rdParty/TAAdaptiveSpaceItemView.m diff --git a/3rdParty/TAAdaptiveSpaceItem.h b/3rdParty/TAAdaptiveSpaceItem.h deleted file mode 100755 index 0da4869..0000000 --- a/3rdParty/TAAdaptiveSpaceItem.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// TAAdaptiveSpaceItem.h -// TAAdaptiveSpaceItem -// -// Created by Timothy Armes on 17/02/2014. -// Copyright (c) 2014 Timothy Armes. All rights reserved. -// - -#import - -@interface TAAdaptiveSpaceItem : NSToolbarItem - -- (void)updateWidth; - -@end diff --git a/3rdParty/TAAdaptiveSpaceItem.m b/3rdParty/TAAdaptiveSpaceItem.m deleted file mode 100755 index e33d2ed..0000000 --- a/3rdParty/TAAdaptiveSpaceItem.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// TAAdaptiveSpaceItem.m -// TAAdaptiveSpaceItem -// -// Created by Timothy Armes on 17/02/2014. -// Copyright (c) 2014 Timothy Armes. All rights reserved. -// - -#import "TAAdaptiveSpaceItem.h" -#import "TAAdaptiveSpaceItemView.h" - -// Private -@interface TAAdaptiveSpaceItem () -- ( void ) doAdaptiveSpaceItemInit_; -@end // Private - -@implementation TAAdaptiveSpaceItem - -- (instancetype ) initWithItemIdentifier:(NSString *)itemIdentifier -{ - if ( self = [ super initWithItemIdentifier: itemIdentifier ] ) - [ self doAdaptiveSpaceItemInit_ ]; - return self; -} - -- (void) awakeFromNib - { - [ self doAdaptiveSpaceItemInit_ ]; - } - -- (NSString *)label -{ - return @""; -} - -- (NSString *)paletteLabel -{ - return NSLocalizedString(@"Adaptive Space Item", @"Palette name when customising toolbar"); -} - -- (NSSize)minSize -{ - NSArray *items = [self.toolbar items]; - NSInteger index = [items indexOfObject:self]; - - if (index != NSNotFound) { - NSRect thisFrame = self.view.superview.frame; - if (thisFrame.origin.x > 0) { - - CGFloat space = 0; - if (items.count > index + 1) { - - NSToolbarItem *nextItem = [items objectAtIndex:index + 1]; - NSRect nextFrame = nextItem.view.superview.frame; - NSRect toolbarFrame = nextItem.view.superview.superview.frame; - - space = (toolbarFrame.size.width - nextFrame.size.width) / 2 - thisFrame.origin.x - 6; - if (space < 0) - space = 0; - } - - NSSize size = [super minSize]; - return NSMakeSize(space, size.height); - } - } - - return [super minSize]; -} - -- (NSSize)maxSize -{ - NSSize size = [super maxSize]; - return NSMakeSize([self minSize].width, size.height); -} - -- (void)updateWidth -{ - [self setMinSize:[self minSize]]; - [self setMaxSize:[self maxSize]]; -} - -// Private - -- ( void ) doAdaptiveSpaceItemInit_ - { - TAAdaptiveSpaceItemView *adaptiveSpaceItemView = [[TAAdaptiveSpaceItemView alloc] initWithFrame:NSMakeRect(0, 0, 1, 1)]; - adaptiveSpaceItemView.adaptiveSpaceItem = self; - self.view = adaptiveSpaceItemView; - } - -@end diff --git a/3rdParty/TAAdaptiveSpaceItemView.h b/3rdParty/TAAdaptiveSpaceItemView.h deleted file mode 100755 index c976094..0000000 --- a/3rdParty/TAAdaptiveSpaceItemView.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// TAAdaptiveSpaceItemView.h -// TAAdaptiveSpaceItem -// -// Created by Timothy Armes on 17/02/2014. -// Copyright (c) 2014 Timothy Armes. All rights reserved. -// - -#import - -@class TAAdaptiveSpaceItem; -@interface TAAdaptiveSpaceItemView : NSView - -@property (weak) TAAdaptiveSpaceItem *adaptiveSpaceItem; - -@end diff --git a/3rdParty/TAAdaptiveSpaceItemView.m b/3rdParty/TAAdaptiveSpaceItemView.m deleted file mode 100755 index 4473532..0000000 --- a/3rdParty/TAAdaptiveSpaceItemView.m +++ /dev/null @@ -1,35 +0,0 @@ -// -// TAAdaptiveSpaceItemView.m -// TAAdaptiveSpaceItem -// -// Created by Timothy Armes on 17/02/2014. -// Copyright (c) 2014 Timothy Armes. All rights reserved. -// - -#import "TAAdaptiveSpaceItemView.h" -#import "TAAdaptiveSpaceItem.h" - -@implementation TAAdaptiveSpaceItemView - -- (BOOL)acceptsFirstMouse:(NSEvent *)theEvent -{ - return NO; -} - -- (void)viewDidMoveToWindow -{ - [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(windowResized:) name:NSWindowDidResizeNotification object:[self window]]; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)windowResized:(NSNotification *)notification; -{ - [_adaptiveSpaceItem updateWidth]; -} - - -@end diff --git a/AppDelegate.h b/AppDelegate.h index 5fed390..0124e77 100755 --- a/AppDelegate.h +++ b/AppDelegate.h @@ -43,9 +43,6 @@ extern BOOL isConnected; //friends @property (weak) IBOutlet NSWindow *friends; -//start time -@property NSTimeInterval startTime; - //'filter task' search box // ->top pane @property (weak) IBOutlet NSSearchField *filterTasksBox; @@ -64,7 +61,6 @@ extern BOOL isConnected; @property NSUInteger taskViewFormat; //drop-down view selector - @property (weak) IBOutlet NSPopUpButton *viewSelector; //segmented button for button pane diff --git a/AppDelegate.m b/AppDelegate.m index 92cce31..5860f39 100755 --- a/AppDelegate.m +++ b/AppDelegate.m @@ -17,14 +17,12 @@ #import "TaskTableController.h" #import "RequestRootWindowController.h" -//TODO: filter out dup'd networks (airportd 0:0..) -not sure want to do this //TODO: autolayout vertically @implementation AppDelegate @synthesize topPane; @synthesize filterObj; -@synthesize startTime; @synthesize vtThreads; @synthesize bottomPane; @synthesize saveButton; @@ -80,9 +78,6 @@ //set field editor for items [self.customItemsFilter setFieldEditor:YES]; - //set start time - self.startTime = [NSDate timeIntervalSinceReferenceDate]; - //center [self.window center]; diff --git a/TaskExplorer.xcodeproj/project.pbxproj b/TaskExplorer.xcodeproj/project.pbxproj index 21f8cff..5bf35d6 100755 --- a/TaskExplorer.xcodeproj/project.pbxproj +++ b/TaskExplorer.xcodeproj/project.pbxproj @@ -105,8 +105,6 @@ CDAB98A11AEAFAFA00C75B4B /* authorizationIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = CDAB98A01AEAFAFA00C75B4B /* authorizationIcon.png */; }; CDAB98A31AEB413C00C75B4B /* dylibIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = CDAB98A21AEB413C00C75B4B /* dylibIcon.png */; }; CDBE49181B58DC9B0031FC22 /* NSApplicationKeyEvents.m in Sources */ = {isa = PBXBuildFile; fileRef = CDBE49171B58DC9B0031FC22 /* NSApplicationKeyEvents.m */; }; - CDD248341AF5947300232422 /* TAAdaptiveSpaceItem.m in Sources */ = {isa = PBXBuildFile; fileRef = CDD248311AF5947300232422 /* TAAdaptiveSpaceItem.m */; }; - CDD248351AF5947300232422 /* TAAdaptiveSpaceItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = CDD248331AF5947300232422 /* TAAdaptiveSpaceItemView.m */; }; CDD2483B1AF5CC4D00232422 /* Task.m in Sources */ = {isa = PBXBuildFile; fileRef = CDD2483A1AF5CC4D00232422 /* Task.m */; }; CDEE76FC1B3FD44500763826 /* saveIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = CDEE76FB1B3FD44500763826 /* saveIcon.png */; }; CDEE76FF1B3FD4B000763826 /* saveIconBG.png in Resources */ = {isa = PBXBuildFile; fileRef = CDEE76FD1B3FD4B000763826 /* saveIconBG.png */; }; @@ -318,10 +316,6 @@ CDAB98A21AEB413C00C75B4B /* dylibIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = dylibIcon.png; path = images/dylibIcon.png; sourceTree = SOURCE_ROOT; }; CDBE49161B58DC9B0031FC22 /* NSApplicationKeyEvents.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSApplicationKeyEvents.h; sourceTree = ""; }; CDBE49171B58DC9B0031FC22 /* NSApplicationKeyEvents.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSApplicationKeyEvents.m; sourceTree = ""; }; - CDD248301AF5947300232422 /* TAAdaptiveSpaceItem.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TAAdaptiveSpaceItem.h; path = 3rdParty/TAAdaptiveSpaceItem.h; sourceTree = ""; }; - CDD248311AF5947300232422 /* TAAdaptiveSpaceItem.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TAAdaptiveSpaceItem.m; path = 3rdParty/TAAdaptiveSpaceItem.m; sourceTree = ""; }; - CDD248321AF5947300232422 /* TAAdaptiveSpaceItemView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TAAdaptiveSpaceItemView.h; path = 3rdParty/TAAdaptiveSpaceItemView.h; sourceTree = ""; }; - CDD248331AF5947300232422 /* TAAdaptiveSpaceItemView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = TAAdaptiveSpaceItemView.m; path = 3rdParty/TAAdaptiveSpaceItemView.m; sourceTree = ""; }; CDD248391AF5CC4D00232422 /* Task.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Task.h; sourceTree = SOURCE_ROOT; }; CDD2483A1AF5CC4D00232422 /* Task.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Task.m; sourceTree = SOURCE_ROOT; }; CDEE76FB1B3FD44500763826 /* saveIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = saveIcon.png; path = images/saveIcon.png; sourceTree = SOURCE_ROOT; }; @@ -657,10 +651,6 @@ children = ( CD3F4CE91AF6D948002A2647 /* OrderedDictionary.h */, CD3F4CEA1AF6D948002A2647 /* OrderedDictionary.m */, - CDD248301AF5947300232422 /* TAAdaptiveSpaceItem.h */, - CDD248311AF5947300232422 /* TAAdaptiveSpaceItem.m */, - CDD248321AF5947300232422 /* TAAdaptiveSpaceItemView.h */, - CDD248331AF5947300232422 /* TAAdaptiveSpaceItemView.m */, CDF08CE41AC89FE1009B3423 /* HyperlinkTextField.h */, CDF08CE51AC89FE1009B3423 /* HyperlinkTextField.m */, ); @@ -881,12 +871,10 @@ CD3F4CFA1AF71B58002A2647 /* Binary.m in Sources */, CD3F4CFC1AF71B58002A2647 /* File.m in Sources */, CDA81D5E1A95B4B4009790E2 /* main.m in Sources */, - CDD248341AF5947300232422 /* TAAdaptiveSpaceItem.m in Sources */, CD0219531AD34D9A005148A2 /* AboutWindowController.m in Sources */, CD1508D921BA4B9D0081F1AF /* UpdateWindowController.m in Sources */, CDF08CC61AC46E75009B3423 /* VTButton.m in Sources */, CD3F4CFB1AF71B58002A2647 /* Connection.m in Sources */, - CDD248351AF5947300232422 /* TAAdaptiveSpaceItemView.m in Sources */, CDBE49181B58DC9B0031FC22 /* NSApplicationKeyEvents.m in Sources */, CDA81D531A95B492009790E2 /* Utilities.m in Sources */, CD7B9FAB1AD08FA100DF3C71 /* KKRow.m in Sources */, diff --git a/TaskExplorer.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/TaskExplorer.xcscheme b/TaskExplorer.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/TaskExplorer.xcscheme index 671cdd1..b40ed0e 100644 --- a/TaskExplorer.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/TaskExplorer.xcscheme +++ b/TaskExplorer.xcodeproj/xcuserdata/patrick.xcuserdatad/xcschemes/TaskExplorer.xcscheme @@ -47,17 +47,9 @@ - - - - + isEnabled = "NO"> diff --git a/TaskTableController.h b/TaskTableController.h index 2f5c963..903b0e1 100644 --- a/TaskTableController.h +++ b/TaskTableController.h @@ -11,8 +11,6 @@ #import "VTInfoWindowController.h" #import "3rdParty/OrderedDictionary.h" - - #import @interface TaskTableController : NSViewController diff --git a/UI/SearchWindow.xib b/UI/SearchWindow.xib index 545d148..5966851 100644 --- a/UI/SearchWindow.xib +++ b/UI/SearchWindow.xib @@ -113,7 +113,7 @@ - + @@ -249,7 +249,7 @@ - + @@ -321,7 +321,7 @@ - + diff --git a/en.lproj/MainMenu.xib b/en.lproj/MainMenu.xib index f051c1c..5067a23 100755 --- a/en.lproj/MainMenu.xib +++ b/en.lproj/MainMenu.xib @@ -236,10 +236,17 @@ - + - + + + + + + + + @@ -283,21 +290,9 @@ - - - - - - - - - - - - - + diff --git a/main.h b/main.h index 895c8ee..9832900 100644 --- a/main.h +++ b/main.h @@ -43,8 +43,8 @@ NSArray* protectedDirectories = nil; //print usage void usage(void); -//perform a cmdline enumeration -void cmdlineExplore(void); +//perform a cmdline actions +void cmdlineInterface(void); //block until vt queries are done void completeVTQuery(void); diff --git a/main.m b/main.m index 3fd1bb0..39c353f 100755 --- a/main.m +++ b/main.m @@ -83,8 +83,8 @@ int main(int argc, char *argv[]) //set flag cmdlineMode = YES; - //scan - cmdlineExplore(); + //cli + cmdlineInterface(); //happy status = 0; @@ -123,15 +123,15 @@ void usage() printf(" -explore enumerate all tasks and dylibs\n"); printf("\noptions:\n"); printf(" -pretty json output is 'pretty-printed'\n"); - printf(" -pid [pid] just scan/explore the specified task'\n"); + printf(" -pid [pid] just scan/explore the specified task\n"); printf(" -skipVT do not query VirusTotal (when '-explore' is specified)\n"); printf(" -detailed for each task; include dylibs, files, & network connections\n\n"); return; } -//perform a cmdline enumeration of all things -void cmdlineExplore() +//perform a cmdline interface +void cmdlineInterface() { //args NSArray* arguments = nil; @@ -196,6 +196,17 @@ void cmdlineExplore() //extract/convert pid pid = [formatter numberFromString:arguments[[arguments indexOfObject:@"-pid"] + 1]]; + + //sanity check + if( (nil == pid) || + (YES != isAlive(pid.intValue)) ) + { + //err msg + printf("{\"ERROR\" : \"specified pid, %s, does not exist\"}\n", [arguments[[arguments indexOfObject:@"-pid"] + 1] UTF8String]); + + //bail + goto bail; + } } //enumerate all tasks/dylibs/files/etc @@ -330,6 +341,8 @@ void cmdlineExplore() //output printf("%s\n", output.UTF8String); } + +bail: return; }