Missing save of original platform id
[hashcat.git] / src / hashcat.c
index 3400ee2..f7b33f4 100644 (file)
@@ -6,7 +6,7 @@
  * License.....: MIT
  */
 
-#ifdef DARWIN
+#if defined(DARWIN) || defined(__FreeBSD__)
 #include <stdio.h>
 #endif
 
@@ -86,7 +86,7 @@ double TARGET_MS_PROFILE[4]     = { 2, 12, 96, 480 };
 #define KERNEL_COMBS            1024
 #define KERNEL_BFS              1024
 #define KERNEL_THREADS_MAX      256
-#define KERNEL_THREADS_MAX_CPU  16
+#define KERNEL_THREADS_MAX_CPU  1
 #define POWERTUNE_ENABLE        0
 #define LOGFILE_DISABLE         0
 #define SCRYPT_TMTO             0
@@ -6171,7 +6171,8 @@ int main (int argc, char **argv)
 
   char *exec_path = get_exec_path ();
 
-  #if defined(LINUX) || defined(__APPLE__)
+
+  #if defined(LINUX) || defined(__APPLE__) || defined(__FreeBSD__)
 
   char *resolved_install_folder = realpath (INSTALL_FOLDER, NULL);
   char *resolved_exec_path      = realpath (exec_path, NULL);
@@ -13017,6 +13018,7 @@ int main (int argc, char **argv)
                   // here we have in line_buf: ESSID:MAC1:MAC2   (without the plain)
                   // manipulate salt_buf
 
+                  memset (line_buf_cpy, 0, HCBUFSIZ);
                   memcpy (line_buf_cpy, line_buf, i);
 
                   char *mac2_pos = strrchr (line_buf_cpy, ':');
@@ -13915,6 +13917,8 @@ int main (int argc, char **argv)
 
         device_param->platform_devices_id = platform_devices_id;
 
+        device_param->platform = platform;
+
         // device_type
 
         cl_device_type device_type;
@@ -15034,7 +15038,13 @@ int main (int argc, char **argv)
        * create context for each device
        */
 
-      device_param->context = hc_clCreateContext (data.ocl, NULL, 1, &device_param->device, NULL, NULL);
+      cl_context_properties properties[3];
+
+      properties[0] = CL_CONTEXT_PLATFORM;
+      properties[1] = (cl_context_properties) device_param->platform;
+      properties[2] = 0;
+
+      device_param->context = hc_clCreateContext (data.ocl, properties, 1, &device_param->device, NULL, NULL);
 
       /**
        * create command-queue
@@ -15053,6 +15063,9 @@ int main (int argc, char **argv)
 
       uint kernel_threads = MIN (KERNEL_THREADS_MAX, device_param->device_maxworkgroup_size);
 
+      if (hash_mode ==  8900) kernel_threads = 64; // Scrypt
+      if (hash_mode ==  9300) kernel_threads = 64; // Scrypt
+
       if (device_param->device_type & CL_DEVICE_TYPE_CPU)
       {
         kernel_threads = KERNEL_THREADS_MAX_CPU;
@@ -15062,9 +15075,7 @@ int main (int argc, char **argv)
       if (hash_mode ==  3000) kernel_threads = 64; // DES
       if (hash_mode ==  3200) kernel_threads = 8;  // Blowfish
       if (hash_mode ==  7500) kernel_threads = 64; // RC4
-      if (hash_mode ==  8900) kernel_threads = 64; // Scrypt
       if (hash_mode ==  9000) kernel_threads = 8;  // Blowfish
-      if (hash_mode ==  9300) kernel_threads = 64; // Scrypt
       if (hash_mode ==  9700) kernel_threads = 64; // RC4
       if (hash_mode ==  9710) kernel_threads = 64; // RC4
       if (hash_mode ==  9800) kernel_threads = 64; // RC4
@@ -18392,6 +18403,10 @@ int main (int argc, char **argv)
         if (induction_dictionaries_cnt)
         {
           qsort (induction_dictionaries, induction_dictionaries_cnt, sizeof (char *), sort_by_mtime);
+
+          // yeah, this next statement is a little hack to make sure that --loopback runs correctly (because with it we guarantee that the loop iterates one more time)
+
+          dictpos--;
         }
 
         time_t runtime_stop;