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

github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikkel Krautz <mikkel@krautz.dk>2017-03-19 23:35:26 +0300
committerMikkel Krautz <mikkel@krautz.dk>2017-03-19 23:35:26 +0300
commitde6e9ec0cf02ea85d13d4403a169d27930c7af43 (patch)
tree8e5e8abbdc6d8227be9d71a34e03046f0407efa7 /overlay
parent2f07778a0eaf349b6a80489007ac31b7e54064f2 (diff)
overlay: move procname parsing to separate function.
This is a small code-cleanup commit that moves the procname parsing to a separate function. This makes the code clearer, and we're able to properly document it.
Diffstat (limited to 'overlay')
-rw-r--r--overlay/lib.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/overlay/lib.cpp b/overlay/lib.cpp
index fd030bebe..8080729b1 100644
--- a/overlay/lib.cpp
+++ b/overlay/lib.cpp
@@ -474,11 +474,39 @@ extern "C" __declspec(dllexport) int __cdecl OverlayHelperProcessMain(unsigned i
static bool createSharedDataMap();
+// Given the absolute path to the current process's executable via |procname|,
+// return the absolute path to the executable in |absExeName|, the directory
+// that the executable lives in in |dir| and the basename of the executable in
+// |exeName|.
+//
+// Returns true on success and fills out |absExeName|, |dir| and |exeName|.
+// Returns false on failure, and does not touch |absExeName|, |dir| and |exeName|.
+static bool parseProcName(char *procname, std::string &absExeName, std::string &dir, std::string &exeName) {
+ if (procname == NULL) {
+ return false;
+ }
+
+ char *p = strrchr(procname, '\\');
+ if (p == NULL) {
+ return false;
+ }
+
+ absExeName = std::string(procname);
+ dir = std::string(procname, p - procname);
+ exeName = std::string(p + 1);
+
+ return true;
+}
+
static bool dllmainProcAttach(char *procname) {
Mutex::init();
- char *p = strrchr(procname, '\\');
- if (!p) {
+ std::string absExeName;
+ std::string dir;
+ std::string exeName;
+ bool ok = parseProcName(procname, absExeName, dir, exeName);
+
+ if (!ok) {
// No blacklisting if the file has no path
} else if (GetProcAddress(NULL, "mumbleSelfDetection") != NULL) {
ods("Lib: Attached to overlay helper or Mumble process. Blacklisted - no overlay injection.");