2016-09-05 19:47:26 +00:00
|
|
|
/**
|
2016-09-11 20:20:15 +00:00
|
|
|
* Author......: See docs/credits.txt
|
2016-09-05 19:47:26 +00:00
|
|
|
* License.....: MIT
|
|
|
|
*/
|
|
|
|
|
2023-01-17 19:25:40 +00:00
|
|
|
#ifndef THREAD_H
|
|
|
|
#define THREAD_H
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-09-12 10:59:40 +00:00
|
|
|
#include <signal.h>
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-09-05 19:47:26 +00:00
|
|
|
#include <windows.h>
|
2017-02-23 23:55:06 +00:00
|
|
|
#else
|
|
|
|
#include <pthread.h>
|
|
|
|
#include <semaphore.h>
|
2016-09-05 19:47:26 +00:00
|
|
|
#endif // _WIN
|
|
|
|
|
2016-09-07 20:29:57 +00:00
|
|
|
#if defined (_WIN)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-10-30 21:22:26 +00:00
|
|
|
#define hc_thread_create(t,f,a) t = CreateThread (NULL, 0, (LPTHREAD_START_ROUTINE) &f, a, 0, NULL)
|
2019-04-30 11:38:44 +00:00
|
|
|
#define hc_thread_wait(n,a) for (int i = 0; i < n; i++) WaitForSingleObject ((a)[i], INFINITE)
|
2016-09-05 19:47:26 +00:00
|
|
|
#define hc_thread_exit(t) ExitThread (t)
|
2018-08-16 12:57:10 +00:00
|
|
|
#define hc_thread_detach(t) CloseHandle (t)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2021-07-10 13:29:40 +00:00
|
|
|
#define hc_thread_mutex_init(m) InitializeCriticalSection (&m)
|
2016-09-05 19:47:26 +00:00
|
|
|
#define hc_thread_mutex_lock(m) EnterCriticalSection (&m)
|
|
|
|
#define hc_thread_mutex_unlock(m) LeaveCriticalSection (&m)
|
|
|
|
#define hc_thread_mutex_delete(m) DeleteCriticalSection (&m)
|
2018-08-16 12:57:10 +00:00
|
|
|
|
2021-07-10 13:29:40 +00:00
|
|
|
/*
|
2018-08-16 12:57:10 +00:00
|
|
|
#define hc_thread_mutex_init(m) m = CreateMutex (NULL, FALSE, NULL)
|
|
|
|
#define hc_thread_mutex_lock(m) WaitForSingleObject (m, INFINITE)
|
|
|
|
#define hc_thread_mutex_unlock(m) ReleaseMutex (m)
|
|
|
|
#define hc_thread_mutex_delete(m) CloseHandle (m)
|
2021-07-10 13:29:40 +00:00
|
|
|
*/
|
2018-08-16 12:57:10 +00:00
|
|
|
|
|
|
|
#define hc_thread_sem_init(s) s = CreateSemaphore (NULL, 0, INT_MAX, NULL)
|
|
|
|
#define hc_thread_sem_post(s) ReleaseSemaphore (s, 1, NULL)
|
|
|
|
#define hc_thread_sem_wait(s) WaitForSingleObject (s, INFINITE)
|
|
|
|
#define hc_thread_sem_close(s) CloseHandle (s)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2017-02-23 23:55:06 +00:00
|
|
|
#else
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2016-10-30 21:22:26 +00:00
|
|
|
#define hc_thread_create(t,f,a) pthread_create (&t, NULL, f, a)
|
2019-04-30 11:38:44 +00:00
|
|
|
#define hc_thread_wait(n,a) for (int i = 0; i < n; i++) pthread_join ((a)[i], NULL)
|
2016-09-05 19:47:26 +00:00
|
|
|
#define hc_thread_exit(t) pthread_exit (&t)
|
2018-08-16 12:57:10 +00:00
|
|
|
#define hc_thread_detach(t) pthread_detach (t)
|
2016-09-05 19:47:26 +00:00
|
|
|
|
2018-08-16 12:57:10 +00:00
|
|
|
#define hc_thread_mutex_init(m) pthread_mutex_init (&m, NULL)
|
2016-09-05 19:47:26 +00:00
|
|
|
#define hc_thread_mutex_lock(m) pthread_mutex_lock (&m)
|
|
|
|
#define hc_thread_mutex_unlock(m) pthread_mutex_unlock (&m)
|
|
|
|
#define hc_thread_mutex_delete(m) pthread_mutex_destroy (&m)
|
|
|
|
|
2018-08-16 12:57:10 +00:00
|
|
|
#define hc_thread_sem_init(s) sem_init (&s, 0, 0)
|
|
|
|
#define hc_thread_sem_post(s) sem_post (&s)
|
|
|
|
#define hc_thread_sem_wait(s) sem_wait (&s)
|
|
|
|
#define hc_thread_sem_close(s) sem_close (&s)
|
|
|
|
|
2016-09-05 19:47:26 +00:00
|
|
|
#endif
|
2016-09-06 16:44:05 +00:00
|
|
|
|
2016-09-30 20:52:44 +00:00
|
|
|
/*
|
2016-09-12 10:59:40 +00:00
|
|
|
#if defined (_WIN)
|
|
|
|
|
|
|
|
BOOL WINAPI sigHandler_default (DWORD sig);
|
|
|
|
BOOL WINAPI sigHandler_benchmark (DWORD sig);
|
|
|
|
void hc_signal (BOOL WINAPI (callback) (DWORD));
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void sigHandler_default (int sig);
|
|
|
|
void sigHandler_benchmark (int sig);
|
|
|
|
void hc_signal (void (callback) (int));
|
|
|
|
|
|
|
|
#endif
|
2016-09-30 20:52:44 +00:00
|
|
|
*/
|
2016-09-12 10:59:40 +00:00
|
|
|
|
2016-10-16 17:32:43 +00:00
|
|
|
int mycracked (hashcat_ctx_t *hashcat_ctx);
|
2017-01-06 07:45:40 +00:00
|
|
|
int myabort_runtime (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int myabort_checkpoint (hashcat_ctx_t *hashcat_ctx);
|
2021-05-05 20:53:04 +00:00
|
|
|
int myabort_finish (hashcat_ctx_t *hashcat_ctx);
|
2016-10-16 17:32:43 +00:00
|
|
|
int myabort (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int myquit (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int bypass (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int SuspendThreads (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int ResumeThreads (hashcat_ctx_t *hashcat_ctx);
|
|
|
|
int stop_at_checkpoint (hashcat_ctx_t *hashcat_ctx);
|
2021-05-05 20:53:04 +00:00
|
|
|
int finish_after_attack (hashcat_ctx_t *hashcat_ctx);
|
2016-09-14 18:22:38 +00:00
|
|
|
|
2023-01-17 19:25:40 +00:00
|
|
|
#endif // THREAD_H
|