Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mumble-voip/mach_override.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbert Zeyer <albert.zeyer@rwth-aachen.de>2011-09-06 03:52:52 +0400
committerAlbert Zeyer <albert.zeyer@rwth-aachen.de>2011-09-18 03:14:19 +0400
commit66c5b412a95384a44f104e162d2902a45432e5cd (patch)
treeea3301830a5e9824633fedf938eae4bdd824e4f8
parent87f491f8acef924d2ba90dd55fc23ad64f9d5bbd (diff)
mach_error message only if we really have an error
-rw-r--r--mach_inject/mach_inject.c5
-rw-r--r--mach_inject_bundle_stub/load_bundle.c15
2 files changed, 13 insertions, 7 deletions
diff --git a/mach_inject/mach_inject.c b/mach_inject/mach_inject.c
index 6bb9f61..4c30514 100644
--- a/mach_inject/mach_inject.c
+++ b/mach_inject/mach_inject.c
@@ -37,6 +37,9 @@ void* fixedUpImageFromImage (
ptrdiff_t fixUpOffset);
#endif /* __i386__ */
+#include <mach/MACH_ERROR.h>
+#define MACH_ERROR(msg, err) { if(err != err_none) mach_error(msg, err); }
+
/*******************************************************************************
*
* Interface
@@ -76,7 +79,7 @@ mach_inject(
if( !err ) {
err = task_for_pid( mach_task_self(), targetProcess, &remoteTask );
#if defined(__i386__) || defined(__x86_64__)
- mach_error("mach_inject failing..", err);
+ MACH_ERROR("mach_inject failing..", err);
if (err == 5) fprintf(stderr, "Could not access task for pid %d. You probably need to add user to procmod group\n", targetProcess);
#endif
}
diff --git a/mach_inject_bundle_stub/load_bundle.c b/mach_inject_bundle_stub/load_bundle.c
index 14039af..ca7d1da 100644
--- a/mach_inject_bundle_stub/load_bundle.c
+++ b/mach_inject_bundle_stub/load_bundle.c
@@ -11,6 +11,9 @@
#include <mach-o/dyld.h>
#include <dlfcn.h>
+#include <mach/MACH_ERROR.h>
+#define MACH_ERROR(msg, err) { if(err != err_none) mach_error(msg, err); }
+
mach_error_t
load_bundle_package(
const char *bundlePackageFileSystemRepresentation )
@@ -20,7 +23,7 @@ load_bundle_package(
assert( strlen( bundlePackageFileSystemRepresentation ) );
mach_error_t err = err_none;
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
// Morph the FSR into a URL.
CFURLRef bundlePackageURL = NULL;
@@ -33,7 +36,7 @@ load_bundle_package(
if( bundlePackageURL == NULL )
err = err_load_bundle_url_from_path;
}
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
// Create bundle.
CFBundleRef bundle = NULL;
@@ -42,7 +45,7 @@ load_bundle_package(
if( bundle == NULL )
err = err_load_bundle_create_bundle;
}
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
// Discover the bundle's executable file.
CFURLRef bundleExecutableURL = NULL;
@@ -52,7 +55,7 @@ load_bundle_package(
if( bundleExecutableURL == NULL )
err = err_load_bundle_package_executable_url;
}
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
// Morph the executable's URL into an FSR.
char bundleExecutableFileSystemRepresentation[PATH_MAX];
@@ -67,7 +70,7 @@ load_bundle_package(
err = err_load_bundle_path_from_url;
}
}
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
// Do the real work.
if( !err ) {
@@ -83,7 +86,7 @@ load_bundle_package(
if( bundlePackageURL )
CFRelease( bundlePackageURL );
- mach_error("mach error on bundle load", err);
+ MACH_ERROR("mach error on bundle load", err);
return err;
}