To secure Win64 API I'm throwing in this minimalistic Win64 support.

This commit is contained in:
Andy Polyakov 2005-07-04 23:24:12 +00:00
parent 09c1a425a9
commit dabaea8048
8 changed files with 79 additions and 7 deletions

View File

@ -456,8 +456,8 @@ my %table=(
"OS390-Unix","c89.sh:-O -DB_ENDIAN -DCHARSET_EBCDIC -DNO_SYS_PARAM_H -D_ALL_SOURCE::(unknown):::THIRTY_TWO_BIT DES_PTR DES_UNROLL MD2_CHAR RC4_INDEX RC4_CHAR BF_PTR:::",
# Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64
"VC-WIN64I","cl::::WIN64I::SIXTY_FOUR_BIT EXPORT_VAR_AS_FN:${no_asm}:win32",
"VC-WIN64A","cl::::WIN64A::SIXTY_FOUR_BIT EXPORT_VAR_AS_FN:${no_asm}:win32",
"VC-WIN64I","cl::::WIN64I::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${no_asm}:win32",
"VC-WIN64A","cl::::WIN64A::SIXTY_FOUR_BIT RC4_CHUNK_LL DES_INT EXPORT_VAR_AS_FN:${no_asm}:win32",
# Visual C targets
"VC-NT","cl::::WINNT::BN_LLONG RC4_INDEX EXPORT_VAR_AS_FN ${x86_gcc_opts}:${no_asm}:win32",

View File

@ -545,7 +545,6 @@ const char *CRYPTO_get_lock_name(int type)
unsigned long OPENSSL_ia32cap_P=0;
unsigned long *OPENSSL_ia32cap_loc(void) { return &OPENSSL_ia32cap_P; }
int OPENSSL_NONPIC_relocated=0;
#if defined(OPENSSL_CPUID_OBJ) && !defined(OPENSSL_NO_ASM) && !defined(I386_ONLY)
#define OPENSSL_CPUID_SETUP
@ -572,6 +571,7 @@ void OPENSSL_cpuid_setup(void)
#else
unsigned long *OPENSSL_ia32cap_loc(void) { return NULL; }
#endif
int OPENSSL_NONPIC_relocated = 0;
#if !defined(OPENSSL_CPUID_SETUP)
void OPENSSL_cpuid_setup(void) {}
#endif

View File

@ -252,8 +252,16 @@ long CRYPTO_dbg_get_options(void)
/* static int mem_cmp(MEM *a, MEM *b) */
static int mem_cmp(const void *a_void, const void *b_void)
{
#ifdef _WIN64
const char *a=(const char *)((const MEM *)a_void)->addr,
*b=(const char *)((const MEM *)b_void)->addr;
if (a==b) return 0;
else if (a>b) return 1;
else return -1;
#else
return((const char *)((const MEM *)a_void)->addr
- (const char *)((const MEM *)b_void)->addr);
#endif
}
/* static unsigned long mem_hash(MEM *a) */

19
e_os.h
View File

@ -266,6 +266,16 @@ extern "C" {
# include <stddef.h>
# include <errno.h>
# include <string.h>
# ifdef _WIN64
# define strlen(s) _strlen31(s)
/* cut strings to 2GB */
static unsigned int _strlen31(const char *str)
{
unsigned int len=0;
while (*str && len<0x80000000U) str++, len++;
return len&0x7FFFFFFF;
}
# endif
# include <malloc.h>
# endif
# include <io.h>
@ -426,6 +436,15 @@ extern "C" {
# elif !defined(__DJGPP__)
# include <winsock.h>
extern HINSTANCE _hInstance;
# ifdef _WIN64
/*
* Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
* the value constitutes an index in per-process table of limited size
* and not a real pointer.
*/
# define socket(d,t,p) ((int)socket(d,t,p))
# define accept(s,f,l) ((int)accept(s,f,l))
# endif
# define SSLeay_Write(a,b,c) send((a),(b),(c),0)
# define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
# define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }

9
ms/do_win64a.bat Executable file
View File

@ -0,0 +1,9 @@
perl util\mkfiles.pl >MINFO
perl ms\uplink.pl win64a > ms\uptable.asm
ml64 -c -Foms\uptable.obj ms\uptable.asm
perl util\mk1mf.pl no-asm VC-WIN64A >ms\nt.mak
perl util\mk1mf.pl dll no-asm VC-WIN64A >ms\ntdll.mak
perl util\mkdef.pl 32 libeay > ms\libeay32.def
perl util\mkdef.pl 32 ssleay > ms\ssleay32.def

9
ms/do_win64i.bat Executable file
View File

@ -0,0 +1,9 @@
perl util\mkfiles.pl >MINFO
perl ms\uplink.pl win64i > ms\uptable.asm
ias -o ms\uptable.obj ms\uptable.asm
perl util\mk1mf.pl no-asm VC-WIN64I >ms\nt.mak
perl util\mk1mf.pl dll no-asm VC-WIN64I >ms\ntdll.mak
perl util\mkdef.pl 32 libeay > ms\libeay32.def
perl util\mkdef.pl 32 ssleay > ms\ssleay32.def

View File

@ -24,6 +24,8 @@ $infile="MINFO";
%ops=(
"VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
"VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
"VC-WIN64A", "Microsoft C/C++ - Win64/x64",
"VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
"VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
"Mingw32", "GNU C++ - Windows NT or 9x",
@ -120,9 +122,10 @@ $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
$NT=0;
push(@INC,"util/pl","pl");
if (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
if (($platform =~ /VC-(.+)/))
{
$NT = 1 if $platform eq "VC-NT";
$FLAVOR=$1;
$NT = 1 if $1 eq "NT";
require 'VC-32.pl';
}
elsif ($platform eq "VC-CE")

View File

@ -11,8 +11,27 @@ $rm='del';
# C compiler stuff
$cc='cl';
$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
$lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
if ($FLAVOR =~ /WIN64/)
{
# Note that we currently don't have /WX on Win64! There is a lot of
# warnings, but only of two types:
#
# C4344: conversion from '__int64' to 'int/long', possible loss of data
# C4267: conversion from 'size_t' to 'int/long', possible loss of data
#
# Amount of latter type is minimized by aliasing strlen to function of
# own desing and limiting its return value to 2GB-1 (see e_os.h). As
# per 0.9.8 release remaining warnings were explicitly examines and
# considered safe to ignore.
#
$cflags=' /MD /W3 /Ox /Gs0 /GF /Gy /nologo -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DOPENSSL_SYSNAME_WIN32 -DOPENSSL_SYSNAME_WINNT -DUNICODE -D_UNICODE';
$lflags="/nologo /subsystem:console /opt:ref";
}
else
{
$cflags=' /MD /W3 /WX /G5 /Ox /O2 /Ob2 /Gs0 /GF /Gy /nologo -DOPENSSL_SYSNAME_WIN32 -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32';
$lflags="/nologo /subsystem:console /machine:I386 /opt:ref";
}
$mlflags='';
$out_def="out32";
@ -38,6 +57,7 @@ $exep='.exe';
if ($no_sock)
{ $ex_libs=""; }
else { $ex_libs="wsock32.lib user32.lib gdi32.lib"; }
$ex_libs="$ex_libs bufferoverflowu.lib" if ($FLAVOR =~ /WIN64/);
# static library stuff
$mklib='lib';
@ -115,6 +135,9 @@ EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
___
$banner.=<<'___' if ($FLAVOR =~ /WIN64/);
CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
___
}
@ -140,6 +163,7 @@ sub do_lib_rule
{
local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
$ex.=' wsock32.lib gdi32.lib advapi32.lib user32.lib';
$ex.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/);
$ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
}
$ret.="\n";