Output cracked hashes on Windows using \r\n and not \n
authorjsteube <jens.steube@gmail.com>
Sun, 17 Jul 2016 18:32:47 +0000 (20:32 +0200)
committerjsteube <jens.steube@gmail.com>
Sun, 17 Jul 2016 18:32:47 +0000 (20:32 +0200)
Replace RegGetValue() with RegQueryValueEx() to enable Windows XP 32 bit compatibility
This fixes https://github.com/hashcat/hashcat/issues/418

docs/changes.txt
src/ext_nvml.c
src/shared.c

index d0c8e43..ed760af 100644 (file)
@@ -16,6 +16,8 @@
 - 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
+- Output cracked hashes on Windows using \r\n and not \n
+- Replace RegGetValue() with RegQueryValueEx() to enable Windows XP 32 bit compatibility
 
 ##
 ## Bugs
index 8431354..6c3b6b4 100644 (file)
@@ -20,9 +20,35 @@ int nvml_init (NVML_PTR *nvml)
   {
     DWORD BufferSize = 1024;
 
-    char *Buffer = (char *) mymalloc (BufferSize);
+    DWORD Type = REG_SZ;
 
-    RegGetValue (HKEY_LOCAL_MACHINE, "SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI", "NVSMIPATH", RRF_RT_ANY, NULL, (PVOID) Buffer, &BufferSize);
+    char *Buffer = (char *) mymalloc (BufferSize + 1);
+
+    HKEY hKey = 0;
+
+    if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, TEXT("SOFTWARE\\NVIDIA Corporation\\Global\\NVSMI"), 0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
+    {
+      if (RegQueryValueEx (hKey, TEXT("NVSMIPATH"), NULL, &Type, (PVOID) Buffer, &BufferSize) == ERROR_SUCCESS)
+      {
+        Buffer[BufferSize] = 0;
+      }
+      else
+      {
+        if (data.quiet == 0)
+          log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
+
+        return -1;
+      }
+
+      RegCloseKey (hKey);
+    }
+    else
+    {
+      if (data.quiet == 0)
+        log_info ("WARNING: NVML library load failed, proceed without NVML HWMon enabled.");
+
+      return -1;
+    }
 
     strcat (Buffer, "\\nvml.dll");
 
index 85accce..0bb70b7 100644 (file)
@@ -5227,7 +5227,7 @@ void format_output (FILE *out_fp, char *out_buf, unsigned char *plain_ptr, const
     #endif
   }
 
-  fputc ('\n', out_fp);
+  fputs (EOL, out_fp);
 }
 
 void handle_show_request (pot_t *pot, uint pot_cnt, char *input_buf, int input_len, hash_t *hashes_buf, int (*sort_by_pot) (const void *, const void *), FILE *out_fp)