diff --git a/include/common.h b/include/common.h index 99014ba98..2fb98e8ad 100644 --- a/include/common.h +++ b/include/common.h @@ -12,7 +12,6 @@ #define _POSIX #elif defined (__WINNT__) #define _WIN 1 -#define WIN 1 #else #error Your Operating System is not supported or detected #endif diff --git a/include/dynloader.h b/include/dynloader.h index 534883afd..923ecbad9 100644 --- a/include/dynloader.h +++ b/include/dynloader.h @@ -8,16 +8,14 @@ #include -#if defined (_POSIX) +#ifdef _WIN +#include +#else #include #if defined (__APPLE__) #include #endif // __APPLE__ -#endif // _POSIX - -#ifdef _WIN -#include -#endif +#endif // _WIN #ifdef _WIN HMODULE hc_dlopen (LPCSTR lpLibFileName); diff --git a/include/folder.h b/include/folder.h index e41f79f76..70ab60240 100644 --- a/include/folder.h +++ b/include/folder.h @@ -10,19 +10,16 @@ #include #include -#if defined (_POSIX) -#include -#include -#endif - -#if defined (__APPLE__) -#include -#endif // __APPLE__ - #if defined (_WIN) #include #include -#endif +#else +#include +#include +#if defined (__APPLE__) +#include +#endif // __APPLE__ +#endif // _WIN #define DOT_HASHCAT ".hashcat" #define SESSIONS_FOLDER "sessions" diff --git a/include/pidfile.h b/include/pidfile.h index 7a024689e..3fa07bcae 100644 --- a/include/pidfile.h +++ b/include/pidfile.h @@ -10,14 +10,12 @@ #include #include -#if defined (_POSIX) -#include -#include -#endif // _POSIX - #if defined (_WIN) #include #include +#else +#include +#include #endif // _WIN int pidfile_ctx_init (hashcat_ctx_t *hashcat_ctx); diff --git a/include/restore.h b/include/restore.h index 21c388a40..d43e1b14c 100644 --- a/include/restore.h +++ b/include/restore.h @@ -10,14 +10,12 @@ #include #include -#if defined (_POSIX) -#include -#include -#endif // _POSIX - #if defined (_WIN) #include #include +#else +#include +#include #endif // _WIN #define RESTORE_VERSION_MIN 340 diff --git a/include/terminal.h b/include/terminal.h index 4b66bf6be..ba69a5d69 100644 --- a/include/terminal.h +++ b/include/terminal.h @@ -12,15 +12,13 @@ #include #include -#if defined (_POSIX) +#if defined (_WIN) +#include +#else #include #if defined (__APPLE__) #include #endif // __APPLE__ -#endif // _POSIX - -#if defined (_WIN) -#include #endif // _WIN void welcome_screen (hashcat_ctx_t *hashcat_ctx, const char *version_tag); diff --git a/include/thread.h b/include/thread.h index 4c9547917..863f00e44 100644 --- a/include/thread.h +++ b/include/thread.h @@ -8,12 +8,11 @@ #include -#if defined (_POSIX) -#include -#include -#endif // _POSIX #if defined (_WIN) #include +#else +#include +#include #endif // _WIN #if defined (_WIN) @@ -27,7 +26,7 @@ #define hc_thread_mutex_init(m) InitializeCriticalSection (&m) #define hc_thread_mutex_delete(m) DeleteCriticalSection (&m) -#elif defined (_POSIX) +#else #define hc_thread_create(t,f,a) pthread_create (&t, NULL, f, a) #define hc_thread_wait(n,a) for (u32 i = 0; i < n; i++) pthread_join ((a)[i], NULL) diff --git a/include/types.h b/include/types.h index e0a15ed0b..6bb5e1a0e 100644 --- a/include/types.h +++ b/include/types.h @@ -41,7 +41,7 @@ typedef uint64_t u64; #if defined (_WIN) typedef LARGE_INTEGER hc_timer_t; -#elif defined (_POSIX) +#else typedef struct timeval hc_timer_t; #endif @@ -54,19 +54,17 @@ typedef struct timeval hc_timer_t; #if defined (_WIN) typedef HANDLE hc_thread_t; typedef CRITICAL_SECTION hc_thread_mutex_t; -#elif defined (_POSIX) +#else typedef pthread_t hc_thread_t; typedef pthread_mutex_t hc_thread_mutex_t; #endif // stat -#if defined (_POSIX) -typedef struct stat hc_stat_t; -#endif - #if defined (_WIN) typedef struct _stat64 hc_stat_t; +#else +typedef struct stat hc_stat_t; #endif // enums @@ -1205,10 +1203,10 @@ typedef struct dictstat_ctx dictstat_t *base; - #if defined (_POSIX) - size_t cnt; - #else + #if defined (_WIN) u32 cnt; + #else + size_t cnt; #endif } dictstat_ctx_t; diff --git a/src/folder.c b/src/folder.c index 3985c8822..427f5b8f5 100644 --- a/src/folder.c +++ b/src/folder.c @@ -304,7 +304,7 @@ int folder_config_init (hashcat_ctx_t *hashcat_ctx, MAYBE_UNUSED const char *ins return -1; } - #if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined (__CYGWIN__) + #if defined (_POSIX) static const char SLASH[] = "/"; diff --git a/src/hwmon.c b/src/hwmon.c index 09ff11a72..53d93981c 100644 --- a/src/hwmon.c +++ b/src/hwmon.c @@ -1420,7 +1420,7 @@ static int xnvctrl_init (hashcat_ctx_t *hashcat_ctx) // unsupport platform? return -1; - #elif defined (_POSIX) + #else xnvctrl->lib_x11 = dlopen ("libX11.so", RTLD_LAZY); diff --git a/src/main.c b/src/main.c index 5b3710084..6cce33b42 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,7 @@ #include "interface.h" #include "event.h" -#if defined(__MINGW64__) || defined(__MINGW32__) +#if defined (__MINGW64__) || defined (__MINGW32__) int _dowildcard = -1; #endif diff --git a/src/opencl.c b/src/opencl.c index f7b2a0a4d..801dc674d 100644 --- a/src/opencl.c +++ b/src/opencl.c @@ -392,9 +392,9 @@ int ocl_init (hashcat_ctx_t *hashcat_ctx) memset (ocl, 0, sizeof (OCL_PTR)); - #if defined(_WIN) + #if defined (_WIN) ocl->lib = hc_dlopen ("OpenCL"); - #elif defined(__APPLE__) + #elif defined (__APPLE__) ocl->lib = hc_dlopen ("/System/Library/Frameworks/OpenCL.framework/OpenCL", RTLD_NOW); #elif defined (__CYGWIN__) ocl->lib = hc_dlopen ("opencl.dll", RTLD_NOW); @@ -1800,15 +1800,13 @@ int run_cracker (hashcat_ctx_t *hashcat_ctx, hc_device_param_t *device_param, co u32 speed_pos = device_param->speed_pos; - #if defined (_POSIX) - if (device_param->timer_speed.tv_sec == 0) + #if defined (_WIN) + if (device_param->timer_speed.QuadPart == 0) { hc_timer_set (&device_param->timer_speed); } - #endif - - #if defined (_WIN) - if (device_param->timer_speed.QuadPart == 0) + #else + if (device_param->timer_speed.tv_sec == 0) { hc_timer_set (&device_param->timer_speed); } diff --git a/src/pidfile.c b/src/pidfile.c index 421040c6a..6ee51420e 100644 --- a/src/pidfile.c +++ b/src/pidfile.c @@ -38,26 +38,7 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) if (pd->pid) { - #if defined (_POSIX) - - char *pidbin; - - hc_asprintf (&pidbin, "/proc/%u/cmdline", pd->pid); - - if (hc_path_exist (pidbin) == true) - { - event_log_error (hashcat_ctx, "Already an instance running on pid %u", pd->pid); - - hcfree (pd); - - hcfree (pidbin); - - return -1; - } - - hcfree (pidbin); - - #elif defined (_WIN) + #if defined (_WIN) HANDLE hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pd->pid); @@ -88,6 +69,25 @@ static int check_running_process (hashcat_ctx_t *hashcat_ctx) hcfree (pidbin); hcfree (pidbin2); + #else + + char *pidbin; + + hc_asprintf (&pidbin, "/proc/%u/cmdline", pd->pid); + + if (hc_path_exist (pidbin) == true) + { + event_log_error (hashcat_ctx, "Already an instance running on pid %u", pd->pid); + + hcfree (pd); + + hcfree (pidbin); + + return -1; + } + + hcfree (pidbin); + #endif } @@ -108,10 +108,10 @@ static int init_pidfile (hashcat_ctx_t *hashcat_ctx) if (rc == -1) return -1; - #if defined (_POSIX) - pd->pid = getpid (); - #elif defined (_WIN) + #if defined (_WIN) pd->pid = GetCurrentProcessId (); + #else + pd->pid = getpid (); #endif return 0; diff --git a/src/shared.c b/src/shared.c index e3f696eca..d60f586ff 100644 --- a/src/shared.c +++ b/src/shared.c @@ -143,18 +143,6 @@ void hc_asprintf (char **strp, const char *fmt, ...) va_end (args); } -#if defined (_POSIX) -int hc_stat (const char *pathname, hc_stat_t *buf) -{ - return stat (pathname, buf); -} - -int hc_fstat (int fd, hc_stat_t *buf) -{ - return fstat (fd, buf); -} -#endif - #if defined (_WIN) int hc_stat (const char *pathname, hc_stat_t *buf) { @@ -165,6 +153,16 @@ int hc_fstat (int fd, hc_stat_t *buf) { return fstat64 (fd, buf); } +#else +int hc_stat (const char *pathname, hc_stat_t *buf) +{ + return stat (pathname, buf); +} + +int hc_fstat (int fd, hc_stat_t *buf) +{ + return fstat (fd, buf); +} #endif void hc_sleep_msec (const u32 msec) diff --git a/src/stdout.c b/src/stdout.c index 1dc060fe3..5f64c533e 100644 --- a/src/stdout.c +++ b/src/stdout.c @@ -27,19 +27,19 @@ static void out_push (out_t *out, const u8 *pw_buf, const int pw_len) memcpy (ptr, pw_buf, pw_len); - #if defined (_POSIX) - - ptr[pw_len] = '\n'; - - out->len += pw_len + 1; - - #else + #if defined (_WIN) ptr[pw_len + 0] = '\r'; ptr[pw_len + 1] = '\n'; out->len += pw_len + 2; + #else + + ptr[pw_len] = '\n'; + + out->len += pw_len + 1; + #endif if (out->len >= BUFSIZ - 100) diff --git a/src/terminal.c b/src/terminal.c index e2ed2e4bd..906d3a92c 100644 --- a/src/terminal.c +++ b/src/terminal.c @@ -351,7 +351,7 @@ int tty_fix() } #endif -#if defined(__APPLE__) || defined(__FreeBSD__) +#if defined (__APPLE__) || defined (__FreeBSD__) static struct termios savemodes; static int havemodes = 0; diff --git a/src/timer.c b/src/timer.c index 9c3c43bbe..c3511d079 100644 --- a/src/timer.c +++ b/src/timer.c @@ -27,7 +27,7 @@ inline double hc_timer_get (hc_timer_t a) return (double) ((double) (hr_tmp.QuadPart - a.QuadPart) / (double) (hr_freq.QuadPart / 1000)); } -#elif defined(_POSIX) +#else inline void hc_timer_set (hc_timer_t* a) {