mirror of https://github.com/GOSTSec/vanitygen
samr7
14 years ago
3 changed files with 857 additions and 251 deletions
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
CC = cl |
||||
OPENSSL_DIR = C:\OpenSSL-Win32 |
||||
PTHREADS_DIR = C:\pthreads-w32 |
||||
PCRE_DIR = C:\pcre-7.9-src |
||||
CFLAGS = /D_WIN32 /DPTW32_STATIC_LIB /DPCRE_STATIC /I$(OPENSSL_DIR)\include /I$(PTHREADS_DIR) /I$(PCRE_DIR) |
||||
LIBS = $(OPENSSL_DIR)\lib\libeay32.dll $(PTHREADS_DIR)\pthread.lib $(PCRE_DIR)\pcre.lib ws2_32.lib |
||||
OBJS = vanitygen.obj |
||||
|
||||
all: vanitygen.exe |
||||
link /nologo /out:vanitygen.exe $(LIBS) |
||||
|
||||
.c.obj: |
||||
$(CC) $(CFLAGS) /Tp$< /Fo$@ |
||||
|
||||
clean: |
||||
del vanitygen.exe |
||||
del vanitygen.obj |
@ -0,0 +1,143 @@
@@ -0,0 +1,143 @@
|
||||
#include <tchar.h> |
||||
#include <time.h> |
||||
#include <windows.h> |
||||
|
||||
#define INLINE |
||||
#define snprintf _snprintf |
||||
|
||||
/*
|
||||
* struct timeval compatibility for Win32 |
||||
*/ |
||||
|
||||
#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) |
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 |
||||
#else |
||||
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL |
||||
#endif |
||||
|
||||
struct timezone; |
||||
|
||||
int |
||||
gettimeofday(struct timeval *tv, struct timezone *tz) |
||||
{ |
||||
FILETIME ft; |
||||
unsigned __int64 tmpres = 0; |
||||
static int tzflag; |
||||
|
||||
if (NULL != tv) { |
||||
GetSystemTimeAsFileTime(&ft); |
||||
|
||||
tmpres |= ft.dwHighDateTime; |
||||
tmpres <<= 32; |
||||
tmpres |= ft.dwLowDateTime; |
||||
|
||||
tmpres -= DELTA_EPOCH_IN_MICROSECS; |
||||
tmpres /= 10; |
||||
tv->tv_sec = (long)(tmpres / 1000000UL); |
||||
tv->tv_usec = (long)(tmpres % 1000000UL); |
||||
} |
||||
|
||||
return 0; |
||||
} |
||||
|
||||
void |
||||
timersub(struct timeval *a, struct timeval *b, struct timeval *result) |
||||
{ |
||||
result->tv_sec = a->tv_sec - b->tv_sec; |
||||
result->tv_usec = a->tv_usec - b->tv_usec; |
||||
if (result->tv_usec < 0) { |
||||
result->tv_sec--; |
||||
result->tv_usec += 1000000; |
||||
} |
||||
} |
||||
|
||||
/*
|
||||
* getopt() for Win32 -- public domain ripped from codeproject.com |
||||
*/ |
||||
|
||||
TCHAR *optarg; |
||||
int optind = 0; |
||||
|
||||
int getopt(int argc, TCHAR *argv[], TCHAR *optstring) |
||||
{ |
||||
static TCHAR *next = NULL; |
||||
TCHAR c; |
||||
TCHAR *cp; |
||||
|
||||
if (optind == 0) |
||||
next = NULL; |
||||
|
||||
optarg = NULL; |
||||
|
||||
if (next == NULL || *next == _T('\0')) |
||||
{ |
||||
if (optind == 0) |
||||
optind++; |
||||
|
||||
if (optind >= argc || argv[optind][0] != _T('-') || argv[optind][1] == _T('\0')) |
||||
{ |
||||
optarg = NULL; |
||||
if (optind < argc) |
||||
optarg = argv[optind]; |
||||
return EOF; |
||||
} |
||||
|
||||
if (_tcscmp(argv[optind], _T("--")) == 0) |
||||
{ |
||||
optind++; |
||||
optarg = NULL; |
||||
if (optind < argc) |
||||
optarg = argv[optind]; |
||||
return EOF; |
||||
} |
||||
|
||||
next = argv[optind]; |
||||
next++; // skip past -
|
||||
optind++; |
||||
} |
||||
|
||||
c = *next++; |
||||
cp = _tcschr(optstring, c); |
||||
|
||||
if (cp == NULL || c == _T(':')) |
||||
return _T('?'); |
||||
|
||||
cp++; |
||||
if (*cp == _T(':')) |
||||
{ |
||||
if (*next != _T('\0')) |
||||
{ |
||||
optarg = next; |
||||
next = NULL; |
||||
} |
||||
else if (optind < argc) |
||||
{ |
||||
optarg = argv[optind]; |
||||
optind++; |
||||
} |
||||
else |
||||
{ |
||||
return _T('?'); |
||||
} |
||||
} |
||||
|
||||
return c; |
||||
} |
||||
|
||||
/*
|
||||
* If ptw32 is being linked in as a static library, make sure that |
||||
* its process attach function gets called before main(). |
||||
*/ |
||||
#if defined(PTW32_STATIC_LIB) |
||||
#pragma section(".CRT$XIC",long,read) |
||||
int __cdecl __initptw32(void); |
||||
#define _CRTALLOC(x) __declspec(allocate(x)) |
||||
_CRTALLOC(".CRT$XIC") |
||||
static pinit = __initptw32; |
||||
int __cdecl |
||||
__initptw32(void) |
||||
{ |
||||
pthread_win32_process_attach_np(); |
||||
return 0; |
||||
} |
||||
#endif /* defined(PTW32_STATIC_LIB) */ |
Loading…
Reference in new issue