diff --git a/src/folder.c b/src/folder.c index d769ae760..a3c9a7303 100644 --- a/src/folder.c +++ b/src/folder.c @@ -38,9 +38,9 @@ static int get_exec_path (char *exec_path, const size_t exec_path_sz) #elif defined (_WIN) - const DWORD len = GetModuleFileName (NULL, exec_path, exec_path_sz - 1); + memset (exec_path, 0, exec_path_sz); - if (len == 0) return -1; + const int len = 0; #elif defined (__APPLE__) @@ -407,16 +407,9 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins hc_asprintf (&cpath, "%s\\OpenCL\\", shared_dir); - char *cpath_real = (char *) hcmalloc (HCBUFSIZ_TINY); + char *cpath_real; - if (GetFullPathName (cpath, HCBUFSIZ_TINY - 1, cpath_real, NULL) == 0) - { - event_log_error (hashcat_ctx, "%s: %s", cpath, "GetFullPathName()."); - - hcfree (cwd); - - return -1; - } + hc_asprintf (&cpath_real, "%s\\OpenCL\\", shared_dir); #else diff --git a/src/opencl.c b/src/opencl.c index 79aa1b8c5..97e32193a 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -4256,6 +4256,24 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) } } + // return back to the folder we came from initially (workaround) + + #if defined (_WIN) + if (chdir ("..") == -1) + { + event_log_error (hashcat_ctx, "%s: %s", "..", strerror (errno)); + + return -1; + } + #else + if (chdir (folder_config->cwd) == -1) + { + event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno)); + + return -1; + } + #endif + // we don't have sm_* on vendors not NV but it doesn't matter char build_opts_new[1024] = { 0 }; @@ -4798,15 +4816,6 @@ int opencl_session_begin (hashcat_ctx_t *hashcat_ctx) hcfree (device_name_chksum); hcfree (device_name_chksum_amp_mp); - // return back to the folder we came from initially (workaround) - - if (chdir (folder_config->cwd) == -1) - { - event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno)); - - return -1; - } - // some algorithm collide too fast, make that impossible if (user_options->benchmark == true) diff --git a/src/user_options.c b/src/user_options.c index 5116dec44..f0649e361 100644 --- a/src/user_options.c +++ b/src/user_options.c @@ -1670,12 +1670,21 @@ int user_options_check_files (hashcat_ctx_t *hashcat_ctx) // common folders + #if defined (_WIN) + if (hc_path_read (".") == false) + { + event_log_error (hashcat_ctx, "%s: %s", ".", strerror (errno)); + + return -1; + } + #else if (hc_path_read (folder_config->cwd) == false) { event_log_error (hashcat_ctx, "%s: %s", folder_config->cwd, strerror (errno)); return -1; } + #endif if (hc_path_read (folder_config->install_dir) == false) {