Skip to content

Commit

Permalink
Disable Hyperscan on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
DesWurstes committed Apr 23, 2018
1 parent 9d1d274 commit 157a745
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 115 deletions.
5 changes: 2 additions & 3 deletions Makefile.Win32
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
CC = cl
OPENSSL_DIR = C:\OpenSSL-Win32
PTHREADS_DIR = C:\pthreads
PCRE_DIR = C:\pcre-7.9-dll
CURL_DIR = C:\curl-7.26.0-x86\builds\libcurl-release-static-ssl-static-ipv6-sspi
OPENCL_DIR = "C:\Program Files (x86)\AMD APP SDK\3.0"
OPENCL_INCLUDE = /I$(OPENCL_DIR)\include
OPENCL_LIBS = $(OPENCL_DIR)\lib\x86\OpenCL.lib
CURL_INCLUDE = /I$(CURL_DIR)\include /DCURL_STATICLIB
CURL_LIBS = $(CURL_DIR)\lib\libcurl_a.lib
CFLAGS_BASE = /EHsc /D_WIN32 /DPTW32_STATIC_LIB /DPCRE_STATIC /I$(OPENSSL_DIR)\include /I$(PTHREADS_DIR)\include /I$(PCRE_DIR) /Ox /Zi
CFLAGS_BASE = /EHsc /D_WIN32 /DPTW32_STATIC_LIB /I$(OPENSSL_DIR)\include /I$(PTHREADS_DIR)\include /Ox /Zi
CFLAGS = $(CFLAGS_BASE) /GL
LIBS = $(OPENSSL_DIR)\lib\libcrypto.lib $(PTHREADS_DIR)\lib\x86\pthreadVC2.lib $(PCRE_DIR)\pcre.lib ws2_32.lib user32.lib advapi32.lib gdi32.lib /LTCG /DEBUG
LIBS = $(OPENSSL_DIR)\lib\libcrypto.lib $(PTHREADS_DIR)\lib\x86\pthreadVC2.lib ws2_32.lib user32.lib advapi32.lib gdi32.lib /LTCG /DEBUG
OBJS = vanitygen.obj oclvanitygen.obj oclengine.obj oclvanityminer.obj keyconv.obj pattern.obj util.obj winglue.obj cashaddr.obj

all: vanitygen-cash.exe oclvanitygen-cash.exe
Expand Down
105 changes: 42 additions & 63 deletions oclvanitygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,71 +33,50 @@ const char *version = VANITYGEN_VERSION;
const int debug = 0;

void usage(const char *name) {
// clang-format off
fprintf(stderr,
"\x1B[44moclVanitygen Cash %s\x1B[0m (" OPENSSL_VERSION_TEXT
")\n"
"Usage: %s [-vcqk1NTS] [-d <device>] [-f <filename>|-] "
"[<pattern>...]\n"
"Generates a bitcoin receiving address matching <pattern>, and "
"outputs "
"the\n"
"address and associated private key. The private key may be "
"stored in a "
"safe\n"
"location or imported into a bitcoin client to spend any "
"balance "
"received "
"on\n"
"the address.\n"
"By default, <pattern> is interpreted as an exact prefix.\n"
"By default, if no device is specified, and the system has "
"exactly one "
"OpenCL\n"
"device, it will be selected automatically, otherwise if the "
"system has\n"
"multiple OpenCL devices and no device is specified, an error "
"will be\n"
"reported. To use multiple devices simultaneously, specify "
"the -D "
"option "
"for\n"
"each device.\n"
"\n"
"Options:\n"
"-v Verbose output\n"
"-c Print conditions for a valid address prefix "
"(e.g. "
"alphabet) "
"and quit\n"
"-q Quiet output\n"
"-k Keep pattern and continue search after finding "
"a match\n"
"-1 Stop after first match\n"
"-T Generate Bitcoin Cash testnet address\n"
"-P <pubkey> Specify base public key for piecewise key "
"generation\n"
"-p <platform> Select OpenCL platform\n"
"-d <device> Select OpenCL device\n"
"-D <devstr> Use OpenCL device, identified by device string\n"
" Form: <platform>:<devicenumber>[,<options>]\n"
" Example: 0:0,grid=1024x1024\n"
"-S Safe mode, disable OpenCL loop unrolling "
"optimizations\n"
"-w <worksize> Set work items per thread in a work unit\n"
"-t <threads> Set target thread count per multiprocessor\n"
"-g <x>x<y> Set grid size\n"
"-b <invsize> Set modular inverse ops per thread\n"
"-V Enable kernel/OpenCL/hardware verification "
"(SLOW)\n"
"-f <file> File containing list of patterns, one per line\n"
" (Use \"-\" as the file name for stdin)\n"
"-o <file> Write pattern matches to <file> in TSV format "
"(readable)\n"
"-O <file> Write pattern matches to <file> in CSV format "
"(importable "
"e.g. Excel)\n"
"-s <file> Seed random number generator from <file>\n",
COLOR44
"oclVanitygen Cash" COLOR0 " (" OPENSSL_VERSION_TEXT ")\n"
"Usage: %s [-vcqk1NTS] [-d <device>] [-f <filename>|-] [<pattern>...]\n"
"Generates a Bitcoin Cash receiving address matching <pattern>, and outputs\n"
"the address and associated private key. The private key may be stored in a\n"
"safe location or imported into a wallet client to spend any balance\n"
"received on the address.\n"
"By default, <pattern> is interpreted as an exact prefix.\n"
"By default, if no device is specified, and the system has exactly one OpenCL\n"
"device, it will be selected automatically, otherwise if the system has\n"
"multiple OpenCL devices and no device is specified, an error will be\n"
"reported. To use multiple devices simultaneously, specify the -D option for\n"
"each device.\n"
"\n"
"Options:\n"
"-v Verbose output\n"
"-c Print conditions for a valid address prefix\n"
" (i.e. alphabet) and quit\n"
"-q Quiet output\n"
"-k Keep pattern and continue search after finding a match\n"
"-1 Stop after first match\n"
"-T Generate Bitcoin Cash testnet address\n"
"-P <pubkey> Specify base public key for piecewise key generation\n"
"-p <platform> Select OpenCL platform\n"
"-d <device> Select OpenCL device\n"
"-D <devstr> Use OpenCL device, identified by device string\n"
" Form: <platform>:<devicenumber>[,<options>]\n"
" Example: 0:0,grid=1024x1024\n"
"-S Safe mode, disable OpenCL loop unrolling optimizations\n"
"-w <worksize> Set work items per thread in a work unit\n"
"-t <threads> Set target thread count per multiprocessor\n"
"-g <x>x<y> Set grid size\n"
"-b <invsize> Set modular inverse ops per thread\n"
"-V Enable kernel/OpenCL/hardware verification (SLOW)\n"
"-f <file> File containing list of patterns, one per line\n"
" (Use \"-\" as the file name for stdin)\n"
"-o <file> Write pattern matches to <file> in TSV format (readable)\n"
"-O <file> Write pattern matches to <file> in CSV format\n"
" (importable e.g. Excel)\n"
"-s <file> Seed random number generator from <file>\n",
version, name);
// clang-format on
}

#define MAX_DEVS 32
Expand Down
4 changes: 4 additions & 0 deletions pattern.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
#include <openssl/ripemd.h>
#include <openssl/sha.h>

#ifndef _WIN32
#include <hs/hs.h>
#endif

#include "avl.h"
#include "cashaddr.h"
Expand Down Expand Up @@ -1142,6 +1144,7 @@ vg_context_t *vg_prefix_context_new(int addrtype, int privtype, int testnet) {
return &vcpp->base;
}

#ifndef _WIN32
typedef struct _vg_regex_context_s {
vg_context_t base;
hs_database_t *vcr_db;
Expand Down Expand Up @@ -1384,3 +1387,4 @@ vg_context_t *vg_regex_context_new(int addrtype, int privtype, int testnet) {
}
return &vcrp->base;
}
#endif // Win32
6 changes: 5 additions & 1 deletion pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#define INLINE inline
#define PRSIZET "z"

#ifndef _WIN32
#include <hs/hs.h>
#endif

#include <errno.h>
#include <sys/stat.h>
Expand Down Expand Up @@ -79,7 +81,7 @@
#endif
#endif

#define VANITYGEN_VERSION "0.24"
#define VANITYGEN_VERSION "0.25"

typedef struct _vg_context_s vg_context_t;

Expand All @@ -103,7 +105,9 @@ struct _vg_exec_context_s {
vg_exec_context_threadfunc_t vxc_threadfunc;
pthread_t vxc_pthread;
int vxc_thread_active;
#ifndef _WIN32
hs_scratch_t *vxc_scratch;
#endif

/* Thread synchronization */
struct _vg_exec_context_s *vxc_next;
Expand Down
93 changes: 46 additions & 47 deletions vanitygen.c
Original file line number Diff line number Diff line change
Expand Up @@ -302,55 +302,43 @@ int start_threads(vg_context_t *vcp, int nthreads) {
}

void usage(const char *name) {
// clang-format off
fprintf(stderr,
COLOR44
"Vanitygen Cash %s" COLOR0 " (" OPENSSL_VERSION_TEXT
")\n"
"Usage: %s [-vcqnrk1T] [-t <threads>] [-f <filename>|-] "
"[<pattern>...]\n"
"Generates a bitcoin receiving address matching <pattern>, and "
"outputs "
"the\n"
"address and associated private key. The private key may be "
"stored in a "
"safe\n"
"location or imported into a bitcoin client to spend any "
"balance "
"received "
"on\n"
"the address.\n"
"By default, <pattern> is interpreted as an exact prefix.\n"
"\n"
"Options:\n"
"-v Verbose output\n"
"-c Print conditions for a valid address prefix "
"(e.g. "
"alphabet) "
"and quit\n"
"-q Quiet output\n"
"-n Simulate\n"
"-r Use regular expression match instead of prefix\n"
" (Feasibility of expression is not checked)\n"
"-k Keep pattern and continue search after finding "
"a match\n"
"-1 Stop after first match\n"
"-T Generate Bitcoin Cash testnet address\n"
"-F <format> Generate address with the given format (pubkey "
"or script) "
"(EXPERTS ONLY!)\n"
"-P <pubkey> Specify base public key for piecewise key "
"generation\n"
"-t <threads> Set number of worker threads (Default: number "
"of CPUs)\n"
"-f <file> File containing list of patterns, one per line\n"
" (Use \"-\" as the file name for stdin)\n"
"-o <file> Write pattern matches to <file> in TSV format "
"(readable)\n"
"-O <file> Write pattern matches to <file> in CSV format "
"(importable "
"e.g. Excel)\n"
"-s <file> Seed random number generator from <file>\n",
"Vanitygen Cash %s" COLOR0 " (" OPENSSL_VERSION_TEXT ")\n"
"Usage: %s [-vcqnrk1T] [-t <threads>] [-f <filename>|-] [<pattern>...]\n"
"Generates a Bitcoin Cash receiving address matching <pattern>, and outputs\n"
"the address and associated private key. The private key may be stored in a\n"
"safe location or imported into a wallet client to spend any balance\n"
"received on the address.\n"
"By default, <pattern> is interpreted as an exact prefix.\n"
"\n"
"Options:\n"
"-v Verbose output\n"
"-c Print conditions for a valid address prefix\n"
" (i.e. alphabet) and quit\n"
"-q Quiet output\n"
"-n Simulate\n"
"-r Use regular expression match instead of prefix\n"
#ifdef _WIN32
" (Disabled on Windows)\n"
#endif
" (Feasibility of expression is not checked)\n"
"-k Keep pattern and continue search after finding a match\n"
"-1 Stop after first match\n"
"-T Generate Bitcoin Cash testnet address\n"
"-F <format> Generate address with the given format (pubkey or script)\n"
" (EXPERTS ONLY!)\n"
"-P <pubkey> Specify base public key for piecewise key generation\n"
"-t <threads> Set number of worker threads (Default: number of CPUs)\n"
"-f <file> File containing list of patterns, one per line\n"
" (Use \"-\" as the file name for stdin)\n"
"-o <file> Write pattern matches to <file> in TSV format (readable)\n"
"-O <file> Write pattern matches to <file> in CSV format\n"
" (importable e.g. Excel)\n"
"-s <file> Seed random number generator from <file>\n",
version, name);
// clang-format on
}

#define MAX_FILE 4
Expand Down Expand Up @@ -500,7 +488,12 @@ int main(int argc, char **argv) {
}
}

#if !defined(_WIN32)
#ifdef _WIN32
if (regex) {
fprintf(stderr, "regex pattern matching is not possible on Windows!\n");
return 1;
}
#else
if (!seedfile) {
struct stat st1;
if (stat("/dev/urandom", &st1) == 0) {
Expand Down Expand Up @@ -530,11 +523,15 @@ int main(int argc, char **argv) {
}
}

#ifdef _WIN32
vcp = vg_prefix_context_new(addrtype, privtype, testnet);
#else
if (regex) {
vcp = vg_regex_context_new(addrtype, privtype, testnet);
} else {
vcp = vg_prefix_context_new(addrtype, privtype, testnet);
}
#endif

if (result_file) {
FILE *fp = fopen(result_file, "a");
Expand Down Expand Up @@ -637,9 +634,11 @@ int main(int argc, char **argv) {
fprintf(stderr, "Regular expressions: %ld\n",
vcp->vc_npatterns);

#ifndef _WIN32
if (regex && !vg_regex_context_prep_scratch(vcp)) {
return 1;
}
#endif

if (simulate) return 0;

Expand Down
5 changes: 4 additions & 1 deletion winglue.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
#include <time.h>
#include <windows.h>

#define INLINE
#ifndef INLINE
#define INLINE inline
#endif

#define snprintf _snprintf

struct timezone;
Expand Down

0 comments on commit 157a745

Please sign in to comment.