Workaround for OpenCL runtimes which do accept -I parameter in the OpenCL kernel...
authorjsteube <jens.steube@gmail.com>
Thu, 21 Jul 2016 08:06:31 +0000 (10:06 +0200)
committerjsteube <jens.steube@gmail.com>
Thu, 21 Jul 2016 08:06:31 +0000 (10:06 +0200)
docs/changes.txt
src/hashcat.c

index ed760af..46362ef 100644 (file)
@@ -15,7 +15,8 @@
 - Allow the use of enc_id == 0 in hash-mode 10600 and 10700 as it takes no part in the actual computation
 - Get rid of exit() calls in OpenCL wrapper library with the goal to have a better control which error can be ignored under special circumstances
 - Do not error and exit if an OpenCL platform has no devices, just print a warning and continue with the next platform
-- Workaround OpenCL runtimes that do not accept -I parameter in the OpenCL kernel build options even if this is an OpenCL standard option
+- Workaround for OpenCL runtimes which do not accept -I parameter in the OpenCL kernel build options even if this is an OpenCL standard option
+- Workaround for OpenCL runtimes which do accept -I parameter in the OpenCL kernel build options, but do not allow quotes
 - Output cracked hashes on Windows using \r\n and not \n
 - Replace RegGetValue() with RegQueryValueEx() to enable Windows XP 32 bit compatibility
 
index 40adbc6..c702d12 100644 (file)
@@ -6563,6 +6563,65 @@ int main (int argc, char **argv)
 
   myfree (exec_path);
 
+  /**
+   * There's alot of problem related to bad support -I parameters when building the kernel.
+   * Each OpenCL runtime handles it slightly different.
+   * The most problematic is with new AMD drivers on Windows, which can not handle quote characters!
+   * The best workaround found so far is to modify the TMP variable (only inside hashcat process) before the runtime is load
+   */
+
+  char cpath[1024] = { 0 };
+
+  #if _WIN
+
+  snprintf (cpath, sizeof (cpath) - 1, "%s\\OpenCL\\", shared_dir);
+
+  char *cpath_real = mymalloc (MAX_PATH);
+
+  if (GetFullPathName (cpath, MAX_PATH, cpath_real, NULL) == 0)
+  {
+    log_error ("ERROR: %s: %s", cpath, "GetFullPathName()");
+
+    return -1;
+  }
+
+  #else
+
+  snprintf (cpath, sizeof (cpath) - 1, "%s/OpenCL/", shared_dir);
+
+  char *cpath_real = mymalloc (PATH_MAX);
+
+  if (realpath (cpath, cpath_real) == NULL)
+  {
+    log_error ("ERROR: %s: %s", cpath, strerror (errno));
+
+    return -1;
+  }
+
+  #endif
+
+  if (getenv ("TMP") == NULL)
+  {
+    char tmp[1000];
+
+    snprintf (tmp, sizeof (tmp) - 1, "TMP=%s", cpath_real);
+
+    putenv (tmp);
+  }
+
+  #if _WIN
+
+  naive_replace (cpath_real, '\\', '/');
+
+  // not escaping here, windows using quotes later
+  // naive_escape (cpath_real, PATH_MAX,  ' ', '\\');
+
+  #else
+
+  naive_escape (cpath_real, PATH_MAX,  ' ', '\\');
+
+  #endif
+
   /**
    * kernel cache, we need to make sure folder exist
    */
@@ -16090,38 +16149,6 @@ int main (int argc, char **argv)
        * default building options
        */
 
-      char cpath[1024] = { 0 };
-
-      char build_opts[1024] = { 0 };
-
-      #if _WIN
-
-      snprintf (cpath, sizeof (cpath) - 1, "%s\\OpenCL\\", shared_dir);
-
-      char *cpath_real = mymalloc (MAX_PATH);
-
-      if (GetFullPathName (cpath, MAX_PATH, cpath_real, NULL) == 0)
-      {
-        log_error ("ERROR: %s: %s", cpath, "GetFullPathName()");
-
-        return -1;
-      }
-
-      #else
-
-      snprintf (cpath, sizeof (cpath) - 1, "%s/OpenCL/", shared_dir);
-
-      char *cpath_real = mymalloc (PATH_MAX);
-
-      if (realpath (cpath, cpath_real) == NULL)
-      {
-        log_error ("ERROR: %s: %s", cpath, strerror (errno));
-
-        return -1;
-      }
-
-      #endif
-
       if (chdir (cpath_real) == -1)
       {
         log_error ("ERROR: %s: %s", cpath_real, strerror (errno));
@@ -16129,20 +16156,12 @@ int main (int argc, char **argv)
         return -1;
       }
 
-      #if _WIN
-
-      naive_replace (cpath_real, '\\', '/');
-
-      // not escaping here, windows has quotes
+      char build_opts[1024] = { 0 };
 
+      #if _WIN
       snprintf (build_opts, sizeof (build_opts) - 1, "-I \"%s\"", cpath_real);
-
       #else
-
-      naive_escape (cpath_real, PATH_MAX,  ' ', '\\');
-
       snprintf (build_opts, sizeof (build_opts) - 1, "-I %s", cpath_real);
-
       #endif
 
       // include check
@@ -16195,8 +16214,6 @@ int main (int argc, char **argv)
         fclose (fd);
       }
 
-      myfree (cpath_real);
-
       // we don't have sm_* on vendors not NV but it doesn't matter
 
       char build_opts_new[1024] = { 0 };