Initial MESA support, needs more fixes
[hashcat.git] / src / oclHashcat.c
index bd720e8..5c0bb56 100644 (file)
@@ -805,12 +805,6 @@ void status_display_automat ()
 
     for (int i = 0; i < SPEED_CACHE; i++)
     {
-      double rec_ms;
-
-      hc_timer_get (device_param->speed_rec[i], rec_ms);
-
-      if (rec_ms > SPEED_MAXAGE) continue;
-
       speed_cnt  += device_param->speed_cnt[i];
       speed_ms   += device_param->speed_ms[i];
     }
@@ -1149,25 +1143,11 @@ void status_display ()
 
     if (device_param->skipped) continue;
 
-    // we need to clear values (set to 0) because in case the device does
-    // not get new candidates it idles around but speed display would
-    // show it as working.
-    // if we instantly set it to 0 after reading it happens that the
-    // speed can be shown as zero if the users refreshes too fast.
-    // therefore, we add a timestamp when a stat was recorded and if its
-    // too old we will not use it
-
     speed_cnt[device_id] = 0;
     speed_ms[device_id]  = 0;
 
     for (int i = 0; i < SPEED_CACHE; i++)
     {
-      double rec_ms;
-
-      hc_timer_get (device_param->speed_rec[i], rec_ms);
-
-      if (rec_ms > SPEED_MAXAGE) continue;
-
       speed_cnt[device_id] += device_param->speed_cnt[i];
       speed_ms[device_id]  += device_param->speed_ms[i];
     }
@@ -2694,6 +2674,24 @@ static void choose_kernel (hc_device_param_t *device_param, const uint attack_ex
       if (data.devices_status == STATUS_CRACKED) break;
       if (data.devices_status == STATUS_ABORTED) break;
       if (data.devices_status == STATUS_QUIT)    break;
+
+      /**
+       * speed
+       */
+
+      const float iter_part = (float) (loop_pos + loop_left) / iter;
+
+      const u64 perf_sum_all = pws_cnt * iter_part;
+
+      double speed_ms;
+
+      hc_timer_get (device_param->timer_speed, speed_ms);
+
+      const u32 speed_pos = device_param->speed_pos;
+
+      device_param->speed_cnt[speed_pos] = perf_sum_all;
+
+      device_param->speed_ms[speed_pos] = speed_ms;
     }
 
     if (opts_type & OPTS_TYPE_HOOK23)
@@ -3371,8 +3369,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
 
       device_param->speed_ms[speed_pos] = speed_ms;
 
-      device_param->speed_rec[speed_pos] = device_param->timer_speed;
-
       hc_thread_mutex_unlock (mux_display);
 
       speed_pos++;
@@ -3382,12 +3378,6 @@ static void run_cracker (hc_device_param_t *device_param, const uint pws_cnt)
         speed_pos = 0;
       }
 
-      // average speed
-
-      device_param->speed_cnt_total += perf_sum_all;
-
-      device_param->speed_ms_total += speed_ms;
-
       /**
        * benchmark
        */
@@ -11398,7 +11388,8 @@ int main (int argc, char **argv)
 
         switch (hash_mode)
         {
-          case  1500: hashes_buf[0].salt->salt_len = 2;
+          case  1500: hashes_buf[0].salt->salt_len    = 2;
+                      hashes_buf[0].salt->salt_buf[0] = 388; // pure magic
                       break;
           case  1731: hashes_buf[0].salt->salt_len = 4;
                       break;
@@ -12873,13 +12864,20 @@ int main (int argc, char **argv)
         {
           if (vendor_id == VENDOR_ID_AMD)
           {
-            cl_uint device_processor_cores = 0;
+            if (strstr (device_version, "MESA"))
+            {
+              // MESA stuff
+            }
+            else
+            {
+              cl_uint device_processor_cores = 0;
 
-            #define CL_DEVICE_WAVEFRONT_WIDTH_AMD               0x4043
+              #define CL_DEVICE_WAVEFRONT_WIDTH_AMD               0x4043
 
-            hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL);
+              hc_clGetDeviceInfo (data.ocl, device_param->device, CL_DEVICE_WAVEFRONT_WIDTH_AMD, sizeof (device_processor_cores), &device_processor_cores, NULL);
 
-            device_param->device_processor_cores = device_processor_cores;
+              device_param->device_processor_cores = device_processor_cores;
+            }
           }
           else if (vendor_id == VENDOR_ID_NV)
           {
@@ -12971,50 +12969,57 @@ int main (int argc, char **argv)
             }
             else if (vendor_id == VENDOR_ID_AMD)
             {
-              int catalyst_check = (force == 1) ? 0 : 1;
-
-              int catalyst_warn = 0;
+              if (strstr (device_version, "MESA"))
+              {
+                // MESA stuff
+              }
+              else
+              {
+                int catalyst_check = (force == 1) ? 0 : 1;
 
-              int catalyst_broken = 0;
+                int catalyst_warn = 0;
 
-              if (catalyst_check == 1)
-              {
-                catalyst_warn = 1;
+                int catalyst_broken = 0;
 
-                // v14.9 and higher
-                if (atoi (device_param->driver_version) >= 1573)
+                if (catalyst_check == 1)
                 {
-                  catalyst_warn = 0;
-                }
+                  catalyst_warn = 1;
 
-                catalyst_check = 0;
-              }
+                  // v14.9 and higher
+                  if (atoi (device_param->driver_version) >= 1573)
+                  {
+                    catalyst_warn = 0;
+                  }
 
-              if (catalyst_broken == 1)
-              {
-                log_info ("");
-                log_info ("ATTENTION! The installed catalyst driver in your system is known to be broken!");
-                log_info ("It will pass over cracked hashes and does not report them as cracked");
-                log_info ("You are STRONGLY encouraged not to use it");
-                log_info ("You can use --force to override this but do not post error reports if you do so");
-                log_info ("");
+                  catalyst_check = 0;
+                }
 
-                return (-1);
-              }
+                if (catalyst_broken == 1)
+                {
+                  log_info ("");
+                  log_info ("ATTENTION! The installed catalyst driver in your system is known to be broken!");
+                  log_info ("It will pass over cracked hashes and does not report them as cracked");
+                  log_info ("You are STRONGLY encouraged not to use it");
+                  log_info ("You can use --force to override this but do not post error reports if you do so");
+                  log_info ("");
 
-              if (catalyst_warn == 1)
-              {
-                log_info ("");
-                log_info ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!");
-                log_info ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons");
-                log_info ("See oclHashcat's homepage for official supported catalyst drivers");
-                #ifdef _WIN
-                log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
-                #endif
-                log_info ("You can use --force to override this but do not post error reports if you do so");
-                log_info ("");
+                  return (-1);
+                }
 
-                return (-1);
+                if (catalyst_warn == 1)
+                {
+                  log_info ("");
+                  log_info ("ATTENTION! Unsupported or incorrect installed catalyst driver detected!");
+                  log_info ("You are STRONGLY encouraged to use the official supported catalyst driver for good reasons");
+                  log_info ("See oclHashcat's homepage for official supported catalyst drivers");
+                  #ifdef _WIN
+                  log_info ("Also see: http://hashcat.net/wiki/doku.php?id=upgrading_amd_drivers_how_to");
+                  #endif
+                  log_info ("You can use --force to override this but do not post error reports if you do so");
+                  log_info ("");
+
+                  return (-1);
+                }
               }
             }
           }
@@ -16033,10 +16038,6 @@ int main (int argc, char **argv)
 
           memset (device_param->speed_cnt, 0, SPEED_CACHE * sizeof (u64));
           memset (device_param->speed_ms,  0, SPEED_CACHE * sizeof (double));
-          memset (device_param->speed_rec, 0, SPEED_CACHE * sizeof (hc_timer_t));
-
-          device_param->speed_cnt_total = 0;
-          device_param->speed_ms_total  = 0;
 
           device_param->exec_pos = 0;