namespace/project cleanup

added PI_ to C function to avoid namespace issues
added 'lib' group to Xcode project
This commit is contained in:
Patrick Wardle
2017-08-09 13:26:24 -10:00
parent b842609bfc
commit f1333b9ccc
7 changed files with 42 additions and 23 deletions
BIN
View File
Binary file not shown.
+24 -5
View File
@@ -7,6 +7,7 @@
objects = {
/* Begin PBXBuildFile section */
7D6E87771F3BD0FA00D6BD7C /* libprocInfo.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 7D6E87761F3BD0FA00D6BD7C /* libprocInfo.a */; };
7DD0A92D1F35A04B000EA15D /* ProcessMonitor.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A91F1F35A04B000EA15D /* ProcessMonitor.m */; };
7DD0A92F1F35A04B000EA15D /* Binary.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9211F35A04B000EA15D /* Binary.m */; };
7DD0A9301F35A04B000EA15D /* Process.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DD0A9221F35A04B000EA15D /* Process.m */; };
@@ -21,7 +22,7 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
7D6E876B1F392B3B00D6BD7C /* libprocInfo.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libprocInfo.a; sourceTree = BUILT_PRODUCTS_DIR; };
7D6E87761F3BD0FA00D6BD7C /* libprocInfo.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libprocInfo.a; path = lib/libprocInfo.a; sourceTree = SOURCE_ROOT; };
7DD0A91F1F35A04B000EA15D /* ProcessMonitor.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ProcessMonitor.m; path = procInfo/ProcessMonitor.m; sourceTree = SOURCE_ROOT; };
7DD0A9211F35A04B000EA15D /* Binary.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Binary.m; path = procInfo/Binary.m; sourceTree = SOURCE_ROOT; };
7DD0A9221F35A04B000EA15D /* Process.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = Process.m; path = procInfo/Process.m; sourceTree = SOURCE_ROOT; };
@@ -40,6 +41,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7D6E87771F3BD0FA00D6BD7C /* libprocInfo.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -54,12 +56,21 @@
name = include;
sourceTree = "<group>";
};
7D6E87751F3BD0C200D6BD7C /* lib */ = {
isa = PBXGroup;
children = (
7D6E87761F3BD0FA00D6BD7C /* libprocInfo.a */,
);
name = lib;
path = processMonitor;
sourceTree = "<group>";
};
7D83A9DB1EB6465D001506F0 = {
isa = PBXGroup;
children = (
7D6E875D1F381BC600D6BD7C /* include */,
7D83A9E61EB6465D001506F0 /* src */,
7D6E876B1F392B3B00D6BD7C /* libprocInfo.a */,
7D6E875D1F381BC600D6BD7C /* include */,
7D6E87751F3BD0C200D6BD7C /* lib */,
);
sourceTree = "<group>";
};
@@ -114,7 +125,7 @@
);
name = procInfo;
productName = processMonitor;
productReference = 7D6E876B1F392B3B00D6BD7C /* libprocInfo.a */;
productReference = 7D6E87781F3BD0FA00D6BD7C /* libprocInfo.a */;
productType = "com.apple.product-type.library.static";
};
/* End PBXNativeTarget section */
@@ -162,7 +173,7 @@
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "#copy library into top-level lib folder\ncp $CODESIGNING_FOLDER_PATH $SRCROOT/lib/";
shellScript = "#move library into top-level lib folder\nmv $CODESIGNING_FOLDER_PATH $SRCROOT/lib/";
};
/* End PBXShellScriptBuildPhase section */
@@ -276,6 +287,10 @@
CODE_SIGN_IDENTITY = "";
DEVELOPMENT_TEAM = VBG97UB4TA;
EXECUTABLE_PREFIX = lib;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/lib",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -286,6 +301,10 @@
CODE_SIGN_IDENTITY = "";
DEVELOPMENT_TEAM = VBG97UB4TA;
EXECUTABLE_PREFIX = lib;
LIBRARY_SEARCH_PATHS = (
"$(inherited)",
"$(PROJECT_DIR)/lib",
);
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
+1 -1
View File
@@ -60,7 +60,7 @@
{
//find app bundle from binary
// ->likely not an application if this fails
appBundle = findAppBundle(path);
appBundle = PI_findAppBundle(path);
}
//found app bundle?
+4 -4
View File
@@ -51,10 +51,10 @@
{
//make sure OS is supported
// ->for now, OS X 10.8+ though could be earlier?
if(YES != isSupportedOS())
if(YES != PI_isSupportedOS())
{
//err msg
NSLog(@"ERROR: %@ is not a supported OS", getOSVersion());
NSLog(@"ERROR: %@ is not a supported OS", PI_getOSVersion());
//unset
self = nil;
@@ -80,7 +80,7 @@ bail:
self.processCallback = callback;
//get OS version info
osVersionInfo = getOSVersion();
osVersionInfo = PI_getOSVersion();
//for full monitoring, gotta be root and macOS 10.12.4 ('safe', as fixed kernel crash)
if( (0 == geteuid()) &&
@@ -707,7 +707,7 @@ bail:
//iterate over all pids
// ->init process object w/ pid/path, etc
for(NSNumber* pid in enumerateProcesses())
for(NSNumber* pid in PI_enumerateProcesses())
{
//skip 'blank' pids
if(0 == pid.unsignedShortValue)
+1 -1
View File
@@ -504,7 +504,7 @@ BOOL fromAppStore(NSString* path)
{
//find app bundle from binary
// ->likely not an application if this fails
appBundle = findAppBundle(path);
appBundle = PI_findAppBundle(path);
if(nil == appBundle)
{
//bail
+6 -6
View File
@@ -14,23 +14,23 @@
//given a path to binary
// parse it back up to find app's bundle
NSBundle* findAppBundle(NSString* binaryPath);
NSBundle* PI_findAppBundle(NSString* binaryPath);
//check if current OS version is supported
// ->for now, just...?
BOOL isSupportedOS();
BOOL PI_isSupportedOS();
//get OS version
NSDictionary* getOSVersion();
NSDictionary* PI_getOSVersion();
//enumerate all running processes
NSMutableArray* enumerateProcesses();
NSMutableArray* PI_enumerateProcesses();
//given a bundle
// ->find its executable
NSString* findAppBinary(NSString* appPath);
NSString* PI_findAppBinary(NSString* appPath);
//sha256 a file
NSString* hashFile(NSString* filePath);
NSString* PI_hashFile(NSString* filePath);
#endif
+6 -6
View File
@@ -19,7 +19,7 @@
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
//get OS version
NSDictionary* getOSVersion()
NSDictionary* PI_getOSVersion()
{
//os version info
NSMutableDictionary* osVersionInfo = nil;
@@ -82,7 +82,7 @@ bail:
//is current OS version supported?
// ->for now, just OS X 10.8+
BOOL isSupportedOS()
BOOL PI_isSupportedOS()
{
//support flag
BOOL isSupported = NO;
@@ -91,7 +91,7 @@ BOOL isSupportedOS()
NSDictionary* osVersionInfo = nil;
//get OS version info
osVersionInfo = getOSVersion();
osVersionInfo = PI_getOSVersion();
if(nil == osVersionInfo)
{
//bail
@@ -121,7 +121,7 @@ bail:
}
//enumerate all running processes
NSMutableArray* enumerateProcesses()
NSMutableArray* PI_enumerateProcesses()
{
//status
int status = -1;
@@ -186,7 +186,7 @@ bail:
//given a path to binary
// ->parse it back up to find app's bundle
NSBundle* findAppBundle(NSString* binaryPath)
NSBundle* PI_findAppBundle(NSString* binaryPath)
{
//app's bundle
NSBundle* appBundle = nil;
@@ -230,7 +230,7 @@ NSBundle* findAppBundle(NSString* binaryPath)
}
//sha256 a file
NSString* hashFile(NSString* filePath)
NSString* PI_hashFile(NSString* filePath)
{
//file's contents
NSData* fileContents = nil;