Added nssm_imagepath() and nssm_unquoted_imagepath().
[nssm.git] / nssm.cpp
index 7eef69d..ddd1561 100644 (file)
--- a/nssm.cpp
+++ b/nssm.cpp
@@ -4,6 +4,9 @@ extern unsigned long tls_index;
 extern bool is_admin;\r
 extern imports_t imports;\r
 \r
+static TCHAR unquoted_imagepath[PATH_LENGTH];\r
+static TCHAR imagepath[PATH_LENGTH];\r
+\r
 /* Are two strings case-insensitively equivalent? */\r
 int str_equiv(const TCHAR *a, const TCHAR *b) {\r
   size_t len = _tcslen(a);\r
@@ -100,6 +103,14 @@ int num_cpus() {
   return (int) i;\r
 }\r
 \r
+const TCHAR *nssm_unquoted_imagepath() {\r
+  return unquoted_imagepath;\r
+}\r
+\r
+const TCHAR *nssm_imagepath() {\r
+  return imagepath;\r
+}\r
+\r
 int _tmain(int argc, TCHAR **argv) {\r
   check_console();\r
 \r
@@ -118,6 +129,11 @@ int _tmain(int argc, TCHAR **argv) {
   /* Set up function pointers. */\r
   if (get_imports()) exit(111);\r
 \r
+  /* Remember our path for later. */\r
+  GetModuleFileName(0, unquoted_imagepath, _countof(unquoted_imagepath));\r
+  GetModuleFileName(0, imagepath, _countof(imagepath));\r
+  PathQuoteSpaces(imagepath);\r
+\r
   /* Elevate */\r
   if (argc > 1) {\r
     /*\r