aboutsummaryrefslogtreecommitdiff
path: root/openssl-1.1.0h/ms
diff options
context:
space:
mode:
Diffstat (limited to 'openssl-1.1.0h/ms')
-rw-r--r--openssl-1.1.0h/ms/applink.c138
-rwxr-xr-xopenssl-1.1.0h/ms/cmp.pl53
-rwxr-xr-xopenssl-1.1.0h/ms/segrenam.pl71
-rw-r--r--openssl-1.1.0h/ms/tlhelp32.h136
-rwxr-xr-xopenssl-1.1.0h/ms/uplink-common.pl28
-rwxr-xr-xopenssl-1.1.0h/ms/uplink-ia64.pl61
-rwxr-xr-xopenssl-1.1.0h/ms/uplink-x86.pl44
-rwxr-xr-xopenssl-1.1.0h/ms/uplink-x86_64.pl71
-rw-r--r--openssl-1.1.0h/ms/uplink.c135
-rw-r--r--openssl-1.1.0h/ms/uplink.h38
10 files changed, 775 insertions, 0 deletions
diff --git a/openssl-1.1.0h/ms/applink.c b/openssl-1.1.0h/ms/applink.c
new file mode 100644
index 0000000..238dbff
--- /dev/null
+++ b/openssl-1.1.0h/ms/applink.c
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#define APPLINK_STDIN 1
+#define APPLINK_STDOUT 2
+#define APPLINK_STDERR 3
+#define APPLINK_FPRINTF 4
+#define APPLINK_FGETS 5
+#define APPLINK_FREAD 6
+#define APPLINK_FWRITE 7
+#define APPLINK_FSETMOD 8
+#define APPLINK_FEOF 9
+#define APPLINK_FCLOSE 10 /* should not be used */
+
+#define APPLINK_FOPEN 11 /* solely for completeness */
+#define APPLINK_FSEEK 12
+#define APPLINK_FTELL 13
+#define APPLINK_FFLUSH 14
+#define APPLINK_FERROR 15
+#define APPLINK_CLEARERR 16
+#define APPLINK_FILENO 17 /* to be used with below */
+
+#define APPLINK_OPEN 18 /* formally can't be used, as flags can vary */
+#define APPLINK_READ 19
+#define APPLINK_WRITE 20
+#define APPLINK_LSEEK 21
+#define APPLINK_CLOSE 22
+#define APPLINK_MAX 22 /* always same as last macro */
+
+#ifndef APPMACROS_ONLY
+# include <stdio.h>
+# include <io.h>
+# include <fcntl.h>
+
+static void *app_stdin(void)
+{
+ return stdin;
+}
+
+static void *app_stdout(void)
+{
+ return stdout;
+}
+
+static void *app_stderr(void)
+{
+ return stderr;
+}
+
+static int app_feof(FILE *fp)
+{
+ return feof(fp);
+}
+
+static int app_ferror(FILE *fp)
+{
+ return ferror(fp);
+}
+
+static void app_clearerr(FILE *fp)
+{
+ clearerr(fp);
+}
+
+static int app_fileno(FILE *fp)
+{
+ return _fileno(fp);
+}
+
+static int app_fsetmod(FILE *fp, char mod)
+{
+ return _setmode(_fileno(fp), mod == 'b' ? _O_BINARY : _O_TEXT);
+}
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+__declspec(dllexport)
+void **
+# if defined(__BORLANDC__)
+/*
+ * __stdcall appears to be the only way to get the name
+ * decoration right with Borland C. Otherwise it works
+ * purely incidentally, as we pass no parameters.
+ */
+__stdcall
+# else
+__cdecl
+# endif
+OPENSSL_Applink(void)
+{
+ static int once = 1;
+ static void *OPENSSL_ApplinkTable[APPLINK_MAX + 1] =
+ { (void *)APPLINK_MAX };
+
+ if (once) {
+ OPENSSL_ApplinkTable[APPLINK_STDIN] = app_stdin;
+ OPENSSL_ApplinkTable[APPLINK_STDOUT] = app_stdout;
+ OPENSSL_ApplinkTable[APPLINK_STDERR] = app_stderr;
+ OPENSSL_ApplinkTable[APPLINK_FPRINTF] = fprintf;
+ OPENSSL_ApplinkTable[APPLINK_FGETS] = fgets;
+ OPENSSL_ApplinkTable[APPLINK_FREAD] = fread;
+ OPENSSL_ApplinkTable[APPLINK_FWRITE] = fwrite;
+ OPENSSL_ApplinkTable[APPLINK_FSETMOD] = app_fsetmod;
+ OPENSSL_ApplinkTable[APPLINK_FEOF] = app_feof;
+ OPENSSL_ApplinkTable[APPLINK_FCLOSE] = fclose;
+
+ OPENSSL_ApplinkTable[APPLINK_FOPEN] = fopen;
+ OPENSSL_ApplinkTable[APPLINK_FSEEK] = fseek;
+ OPENSSL_ApplinkTable[APPLINK_FTELL] = ftell;
+ OPENSSL_ApplinkTable[APPLINK_FFLUSH] = fflush;
+ OPENSSL_ApplinkTable[APPLINK_FERROR] = app_ferror;
+ OPENSSL_ApplinkTable[APPLINK_CLEARERR] = app_clearerr;
+ OPENSSL_ApplinkTable[APPLINK_FILENO] = app_fileno;
+
+ OPENSSL_ApplinkTable[APPLINK_OPEN] = _open;
+ OPENSSL_ApplinkTable[APPLINK_READ] = _read;
+ OPENSSL_ApplinkTable[APPLINK_WRITE] = _write;
+ OPENSSL_ApplinkTable[APPLINK_LSEEK] = _lseek;
+ OPENSSL_ApplinkTable[APPLINK_CLOSE] = _close;
+
+ once = 0;
+ }
+
+ return OPENSSL_ApplinkTable;
+}
+
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/openssl-1.1.0h/ms/cmp.pl b/openssl-1.1.0h/ms/cmp.pl
new file mode 100755
index 0000000..265ce56
--- /dev/null
+++ b/openssl-1.1.0h/ms/cmp.pl
@@ -0,0 +1,53 @@
+#! /usr/bin/env perl
+# Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+($#ARGV == 1) || die "usage: cmp.pl <file1> <file2>\n";
+
+open(IN0,"<$ARGV[0]") || die "unable to open $ARGV[0]\n";
+open(IN1,"<$ARGV[1]") || die "unable to open $ARGV[1]\n";
+binmode IN0;
+binmode IN1;
+
+$tot=0;
+$ret=1;
+for (;;)
+{
+ $n1=sysread(IN0,$b1,4096);
+ $n2=sysread(IN1,$b2,4096);
+
+ last if ($n1 != $n2);
+ last if ($b1 ne $b2);
+ last if ($n1 < 0);
+ if ($n1 == 0)
+ {
+ $ret=0;
+ last;
+ }
+ $tot+=$n1;
+}
+
+close(IN0);
+close(IN1);
+if ($ret)
+{
+ printf STDERR "$ARGV[0] and $ARGV[1] are different\n";
+ @a1=unpack("C*",$b1);
+ @a2=unpack("C*",$b2);
+ for ($i=0; $i<=$#a1; $i++)
+ {
+ if ($a1[$i] ne $a2[$i])
+ {
+ printf "%02X %02X <<\n",$a1[$i],$a2[$i];
+ last;
+ }
+ }
+ $nm=$tot+$n1;
+ $tot+=$i+1;
+ printf STDERR "diff at char $tot of $nm\n";
+}
+exit($ret);
diff --git a/openssl-1.1.0h/ms/segrenam.pl b/openssl-1.1.0h/ms/segrenam.pl
new file mode 100755
index 0000000..372444a
--- /dev/null
+++ b/openssl-1.1.0h/ms/segrenam.pl
@@ -0,0 +1,71 @@
+#! /usr/bin/env perl
+# Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+my $quiet = 1;
+
+unpack("L",pack("N",1))!=1 || die "only little-endian hosts are supported";
+
+# first argument can specify custom suffix...
+$suffix=(@ARGV[0]=~/^\$/) ? shift(@ARGV) : "\$m";
+#################################################################
+# rename segments in COFF modules according to %map table below #
+%map=( ".text" => "fipstx$suffix", #
+ ".text\$"=> "fipstx$suffix", #
+ ".rdata" => "fipsrd$suffix", #
+ ".data" => "fipsda$suffix" ); #
+#################################################################
+
+# collect file list
+foreach (@ARGV) {
+ if (/\*/) { push(@files,glob($_)); }
+ else { push(@files,$_); }
+}
+
+use Fcntl;
+use Fcntl ":seek";
+
+foreach (@files) {
+ $file=$_;
+ print "processing $file\n" unless $quiet;
+
+ sysopen(FD,$file,O_RDWR|O_BINARY) || die "sysopen($file): $!";
+
+ # read IMAGE_DOS_HEADER
+ sysread(FD,$mz,64)==64 || die "$file is too short";
+ @dos_header=unpack("a2C58I",$mz);
+ if (@dos_header[0] eq "MZ") {
+ $e_lfanew=pop(@dos_header);
+ sysseek(FD,$e_lfanew,SEEK_SET) || die "$file is too short";
+ sysread(FD,$Magic,4)==4 || die "$file is too short";
+ unpack("I",$Magic)==0x4550 || die "$file is not COFF image";
+ } elsif ($file =~ /\.obj$/i) {
+ # .obj files have no IMAGE_DOS_HEADER
+ sysseek(FD,0,SEEK_SET) || die "unable to rewind $file";
+ } else { next; }
+
+ # read IMAGE_FILE_HEADER
+ sysread(FD,$coff,20)==20 || die "$file is too short";
+ ($Machine,$NumberOfSections,$TimeDateStamp,
+ $PointerToSymbolTable,$NumberOfSysmbols,
+ $SizeOfOptionalHeader,$Characteristics)=unpack("SSIIISS",$coff);
+
+ # skip over IMAGE_OPTIONAL_HEADER
+ sysseek(FD,$SizeOfOptionalHeader,SEEK_CUR) || die "$file is too short";
+
+ # traverse IMAGE_SECTION_HEADER table
+ for($i=0;$i<$NumberOfSections;$i++) {
+ sysread(FD,$SectionHeader,40)==40 || die "$file is too short";
+ ($Name,@opaque)=unpack("Z8C*",$SectionHeader);
+ if ($map{$Name}) {
+ sysseek(FD,-40,SEEK_CUR) || die "unable to rewind $file";
+ syswrite(FD,pack("a8C*",$map{$Name},@opaque))==40 || die "syswrite failed: $!";
+ printf " %-8s -> %.8s\n",$Name,$map{$Name} unless $quiet;
+ }
+ }
+ close(FD);
+}
diff --git a/openssl-1.1.0h/ms/tlhelp32.h b/openssl-1.1.0h/ms/tlhelp32.h
new file mode 100644
index 0000000..9408dc3
--- /dev/null
+++ b/openssl-1.1.0h/ms/tlhelp32.h
@@ -0,0 +1,136 @@
+/*-
+ tlhelp32.h - Include file for Tool help functions.
+
+ Written by Mumit Khan <khan@nanotech.wisc.edu>
+
+ This file is part of a free library for the Win32 API.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+*/
+#ifndef _TLHELP32_H
+# define _TLHELP32_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+# define HF32_DEFAULT 1
+# define HF32_SHARED 2
+# define LF32_FIXED 0x1
+# define LF32_FREE 0x2
+# define LF32_MOVEABLE 0x4
+# define MAX_MODULE_NAME32 255
+# define TH32CS_SNAPHEAPLIST 0x1
+# define TH32CS_SNAPPROCESS 0x2
+# define TH32CS_SNAPTHREAD 0x4
+# define TH32CS_SNAPMODULE 0x8
+# define TH32CS_SNAPALL (TH32CS_SNAPHEAPLIST|TH32CS_SNAPPROCESS|TH32CS_SNAPTHREAD|TH32CS_SNAPMODULE)
+# define TH32CS_INHERIT 0x80000000
+typedef struct tagHEAPLIST32 {
+ DWORD dwSize;
+ DWORD th32ProcessID;
+ DWORD th32HeapID;
+ DWORD dwFlags;
+} HEAPLIST32, *PHEAPLIST32, *LPHEAPLIST32;
+typedef struct tagHEAPENTRY32 {
+ DWORD dwSize;
+ HANDLE hHandle;
+ DWORD dwAddress;
+ DWORD dwBlockSize;
+ DWORD dwFlags;
+ DWORD dwLockCount;
+ DWORD dwResvd;
+ DWORD th32ProcessID;
+ DWORD th32HeapID;
+} HEAPENTRY32, *PHEAPENTRY32, *LPHEAPENTRY32;
+typedef struct tagPROCESSENTRY32W {
+ DWORD dwSize;
+ DWORD cntUsage;
+ DWORD th32ProcessID;
+ DWORD th32DefaultHeapID;
+ DWORD th32ModuleID;
+ DWORD cntThreads;
+ DWORD th32ParentProcessID;
+ LONG pcPriClassBase;
+ DWORD dwFlags;
+ WCHAR szExeFile[MAX_PATH];
+} PROCESSENTRY32W, *PPROCESSENTRY32W, *LPPROCESSENTRY32W;
+typedef struct tagPROCESSENTRY32 {
+ DWORD dwSize;
+ DWORD cntUsage;
+ DWORD th32ProcessID;
+ DWORD th32DefaultHeapID;
+ DWORD th32ModuleID;
+ DWORD cntThreads;
+ DWORD th32ParentProcessID;
+ LONG pcPriClassBase;
+ DWORD dwFlags;
+ CHAR szExeFile[MAX_PATH];
+} PROCESSENTRY32, *PPROCESSENTRY32, *LPPROCESSENTRY32;
+typedef struct tagTHREADENTRY32 {
+ DWORD dwSize;
+ DWORD cntUsage;
+ DWORD th32ThreadID;
+ DWORD th32OwnerProcessID;
+ LONG tpBasePri;
+ LONG tpDeltaPri;
+ DWORD dwFlags;
+} THREADENTRY32, *PTHREADENTRY32, *LPTHREADENTRY32;
+typedef struct tagMODULEENTRY32W {
+ DWORD dwSize;
+ DWORD th32ModuleID;
+ DWORD th32ProcessID;
+ DWORD GlblcntUsage;
+ DWORD ProccntUsage;
+ BYTE *modBaseAddr;
+ DWORD modBaseSize;
+ HMODULE hModule;
+ WCHAR szModule[MAX_MODULE_NAME32 + 1];
+ WCHAR szExePath[MAX_PATH];
+} MODULEENTRY32W, *PMODULEENTRY32W, *LPMODULEENTRY32W;
+typedef struct tagMODULEENTRY32 {
+ DWORD dwSize;
+ DWORD th32ModuleID;
+ DWORD th32ProcessID;
+ DWORD GlblcntUsage;
+ DWORD ProccntUsage;
+ BYTE *modBaseAddr;
+ DWORD modBaseSize;
+ HMODULE hModule;
+ char szModule[MAX_MODULE_NAME32 + 1];
+ char szExePath[MAX_PATH];
+} MODULEENTRY32, *PMODULEENTRY32, *LPMODULEENTRY32;
+BOOL WINAPI Heap32First(LPHEAPENTRY32, DWORD, DWORD);
+BOOL WINAPI Heap32ListFirst(HANDLE, LPHEAPLIST32);
+BOOL WINAPI Heap32ListNext(HANDLE, LPHEAPLIST32);
+BOOL WINAPI Heap32Next(LPHEAPENTRY32);
+BOOL WINAPI Module32First(HANDLE, LPMODULEENTRY32);
+BOOL WINAPI Module32FirstW(HANDLE, LPMODULEENTRY32W);
+BOOL WINAPI Module32Next(HANDLE, LPMODULEENTRY32);
+BOOL WINAPI Module32NextW(HANDLE, LPMODULEENTRY32W);
+BOOL WINAPI Process32First(HANDLE, LPPROCESSENTRY32);
+BOOL WINAPI Process32FirstW(HANDLE, LPPROCESSENTRY32W);
+BOOL WINAPI Process32Next(HANDLE, LPPROCESSENTRY32);
+BOOL WINAPI Process32NextW(HANDLE, LPPROCESSENTRY32W);
+BOOL WINAPI Thread32First(HANDLE, LPTHREADENTRY32);
+BOOL WINAPI Thread32Next(HANDLE, LPTHREADENTRY32);
+BOOL WINAPI Toolhelp32ReadProcessMemory(DWORD, LPCVOID, LPVOID, DWORD,
+ LPDWORD);
+HANDLE WINAPI CreateToolhelp32Snapshot(DWORD, DWORD);
+# ifdef UNICODE
+# define LPMODULEENTRY32 LPMODULEENTRY32W
+# define LPPROCESSENTRY32 LPPROCESSENTRY32W
+# define MODULEENTRY32 MODULEENTRY32W
+# define Module32First Module32FirstW
+# define Module32Next Module32NextW
+# define PMODULEENTRY32 PMODULEENTRY32W
+# define PPROCESSENTRY32 PPROCESSENTRY32W
+# define PROCESSENTRY32 PROCESSENTRY32W
+# define Process32First Process32FirstW
+# define Process32Next Process32NextW
+# endif /* UNICODE */
+#ifdef __cplusplus
+}
+#endif
+#endif /* _TLHELP32_H */
diff --git a/openssl-1.1.0h/ms/uplink-common.pl b/openssl-1.1.0h/ms/uplink-common.pl
new file mode 100755
index 0000000..e2ab594
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink-common.pl
@@ -0,0 +1,28 @@
+#! /usr/bin/env perl
+# Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+# pull APPLINK_MAX value from applink.c...
+$applink_c=$0;
+$applink_c=~s|[^/\\]+$||g;
+$applink_c.="applink.c";
+open(INPUT,$applink_c) || die "can't open $applink_c: $!";
+@max=grep {/APPLINK_MAX\s+(\d+)/} <INPUT>;
+close(INPUT);
+($#max==0) or die "can't find APPLINK_MAX in $applink_c";
+
+$max[0]=~/APPLINK_MAX\s+(\d+)/;
+$N=$1; # number of entries in OPENSSL_UplinkTable not including
+ # OPENSSL_UplinkTable[0], which contains this value...
+
+1;
+
+# Idea is to fill the OPENSSL_UplinkTable with pointers to stubs
+# which invoke 'void OPENSSL_Uplink (ULONG_PTR *table,int index)';
+# and then dereference themselves. Latter shall result in endless
+# loop *unless* OPENSSL_Uplink does not replace 'table[index]' with
+# something else, e.g. as 'table[index]=unimplemented;'...
diff --git a/openssl-1.1.0h/ms/uplink-ia64.pl b/openssl-1.1.0h/ms/uplink-ia64.pl
new file mode 100755
index 0000000..0636f13
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink-ia64.pl
@@ -0,0 +1,61 @@
+#! /usr/bin/env perl
+# Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+$output = pop;
+open STDOUT,">$output";
+
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC,"${dir}.");
+
+require "uplink-common.pl";
+
+local $V=8; # max number of args uplink functions may accept...
+my $loc0 = "r".(32+$V);
+print <<___;
+.text
+.global OPENSSL_Uplink#
+.type OPENSSL_Uplink#,\@function
+
+___
+for ($i=1;$i<=$N;$i++) {
+print <<___;
+.proc lazy$i#
+lazy$i:
+ .prologue
+{ .mii; .save ar.pfs,$loc0
+ alloc loc0=ar.pfs,$V,3,2,0
+ .save b0,loc1
+ mov loc1=b0
+ addl loc2=\@ltoff(OPENSSL_UplinkTable#),gp };;
+ .body
+{ .mmi; ld8 out0=[loc2]
+ mov out1=$i };;
+{ .mib; add loc2=8*$i,out0
+ br.call.sptk.many b0=OPENSSL_Uplink# };;
+{ .mmi; ld8 r31=[loc2];;
+ ld8 r30=[r31],8 };;
+{ .mii; ld8 gp=[r31]
+ mov b6=r30
+ mov b0=loc1 };;
+{ .mib; mov ar.pfs=loc0
+ br.many b6 };;
+.endp lazy$i#
+
+___
+}
+print <<___;
+.data
+.global OPENSSL_UplinkTable#
+OPENSSL_UplinkTable: data8 $N // amount of following entries
+___
+for ($i=1;$i<=$N;$i++) { print " data8 \@fptr(lazy$i#)\n"; }
+print <<___;
+.size OPENSSL_UplinkTable,.-OPENSSL_UplinkTable#
+___
+
+close STDOUT;
diff --git a/openssl-1.1.0h/ms/uplink-x86.pl b/openssl-1.1.0h/ms/uplink-x86.pl
new file mode 100755
index 0000000..e25668e
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink-x86.pl
@@ -0,0 +1,44 @@
+#! /usr/bin/env perl
+# Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+push(@INC, "${dir}.", "${dir}../crypto/perlasm");
+require "x86asm.pl";
+
+require "uplink-common.pl";
+
+$output = pop;
+open STDOUT,">$output";
+
+&asm_init($ARGV[0],"uplink-x86");
+
+&external_label("OPENSSL_Uplink");
+&public_label("OPENSSL_UplinkTable");
+
+for ($i=1;$i<=$N;$i++) {
+&function_begin_B("_\$lazy${i}");
+ &lea ("eax",&DWP(&label("OPENSSL_UplinkTable")));
+ &push ($i);
+ &push ("eax");
+ &call (&label("OPENSSL_Uplink"));
+ &pop ("eax");
+ &add ("esp",4);
+ &jmp_ptr(&DWP(4*$i,"eax"));
+&function_end_B("_\$lazy${i}");
+}
+
+&dataseg();
+&align(4);
+&set_label("OPENSSL_UplinkTable");
+&data_word($N);
+for ($i=1;$i<=$N;$i++) {
+&data_word(&label("_\$lazy${i}"));
+}
+&asm_finish();
+
+close OUTPUT;
diff --git a/openssl-1.1.0h/ms/uplink-x86_64.pl b/openssl-1.1.0h/ms/uplink-x86_64.pl
new file mode 100755
index 0000000..1f24450
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink-x86_64.pl
@@ -0,0 +1,71 @@
+#! /usr/bin/env perl
+# Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved.
+#
+# Licensed under the OpenSSL license (the "License"). You may not use
+# this file except in compliance with the License. You can obtain a copy
+# in the file LICENSE in the source distribution or at
+# https://www.openssl.org/source/license.html
+
+$output=pop;
+$0 =~ m/(.*[\/\\])[^\/\\]+$/; $dir=$1;
+open OUT,"| \"$^X\" \"${dir}../crypto/perlasm/x86_64-xlate.pl\" \"$output\"";
+*STDOUT=*OUT;
+push(@INC,"${dir}.");
+
+require "uplink-common.pl";
+
+$prefix="_lazy";
+
+print <<___;
+.text
+.extern OPENSSL_Uplink
+.globl OPENSSL_UplinkTable
+___
+for ($i=1;$i<=$N;$i++) {
+print <<___;
+.type $prefix${i},\@abi-omnipotent
+.align 16
+$prefix${i}:
+ .byte 0x48,0x83,0xEC,0x28 # sub rsp,40
+ mov %rcx,48(%rsp)
+ mov %rdx,56(%rsp)
+ mov %r8,64(%rsp)
+ mov %r9,72(%rsp)
+ lea OPENSSL_UplinkTable(%rip),%rcx
+ mov \$$i,%rdx
+ call OPENSSL_Uplink
+ mov 48(%rsp),%rcx
+ mov 56(%rsp),%rdx
+ mov 64(%rsp),%r8
+ mov 72(%rsp),%r9
+ lea OPENSSL_UplinkTable(%rip),%rax
+ add \$40,%rsp
+ jmp *8*$i(%rax)
+$prefix${i}_end:
+.size $prefix${i},.-$prefix${i}
+___
+}
+print <<___;
+.data
+OPENSSL_UplinkTable:
+ .quad $N
+___
+for ($i=1;$i<=$N;$i++) { print " .quad $prefix$i\n"; }
+print <<___;
+.section .pdata,"r"
+.align 4
+___
+for ($i=1;$i<=$N;$i++) {
+print <<___;
+ .rva $prefix${i},$prefix${i}_end,${prefix}_unwind_info
+___
+}
+print <<___;
+.section .xdata,"r"
+.align 8
+${prefix}_unwind_info:
+ .byte 0x01,0x04,0x01,0x00
+ .byte 0x04,0x42,0x00,0x00
+___
+
+close STDOUT;
diff --git a/openssl-1.1.0h/ms/uplink.c b/openssl-1.1.0h/ms/uplink.c
new file mode 100644
index 0000000..7f7abfb
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink.c
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#if (defined(_WIN64) || defined(_WIN32_WCE)) && !defined(UNICODE)
+# define UNICODE
+#endif
+#if defined(UNICODE) && !defined(_UNICODE)
+# define _UNICODE
+#endif
+#if defined(_UNICODE) && !defined(UNICODE)
+# define UNICODE
+#endif
+
+#include <windows.h>
+#include <tchar.h>
+#include <stdio.h>
+#include "uplink.h"
+void OPENSSL_showfatal(const char *, ...);
+
+static TCHAR msg[128];
+
+static void unimplemented(void)
+{
+ OPENSSL_showfatal(sizeof(TCHAR) == sizeof(char) ? "%s\n" : "%S\n", msg);
+ ExitProcess(1);
+}
+
+void OPENSSL_Uplink(volatile void **table, int index)
+{
+ static HMODULE volatile apphandle = NULL;
+ static void **volatile applinktable = NULL;
+ int len;
+ void (*func) (void) = unimplemented;
+ HANDLE h;
+ void **p;
+
+ /*
+ * Note that the below code is not MT-safe in respect to msg buffer, but
+ * what's the worst thing that can happen? Error message might be
+ * misleading or corrupted. As error condition is fatal and should never
+ * be risen, I accept the risk...
+ */
+ /*
+ * One can argue that I should have used InterlockedExchangePointer or
+ * something to update static variables and table[]. Well, store
+ * instructions are as atomic as they can get and assigned values are
+ * effectively constant... So that volatile qualifier should be
+ * sufficient [it prohibits compiler to reorder memory access
+ * instructions].
+ */
+ do {
+ len = _sntprintf(msg, sizeof(msg) / sizeof(TCHAR),
+ _T("OPENSSL_Uplink(%p,%02X): "), table, index);
+ _tcscpy(msg + len, _T("unimplemented function"));
+
+ if ((h = apphandle) == NULL) {
+ if ((h = GetModuleHandle(NULL)) == NULL) {
+ apphandle = (HMODULE) - 1;
+ _tcscpy(msg + len, _T("no host application"));
+ break;
+ }
+ apphandle = h;
+ }
+ if ((h = apphandle) == (HMODULE) - 1) /* revalidate */
+ break;
+
+ if (applinktable == NULL) {
+ void **(*applink) ();
+
+ applink = (void **(*)())GetProcAddress(h, "OPENSSL_Applink");
+ if (applink == NULL) {
+ apphandle = (HMODULE) - 1;
+ _tcscpy(msg + len, _T("no OPENSSL_Applink"));
+ break;
+ }
+ p = (*applink) ();
+ if (p == NULL) {
+ apphandle = (HMODULE) - 1;
+ _tcscpy(msg + len, _T("no ApplinkTable"));
+ break;
+ }
+ applinktable = p;
+ } else
+ p = applinktable;
+
+ if (index > (int)p[0])
+ break;
+
+ if (p[index])
+ func = p[index];
+ } while (0);
+
+ table[index] = func;
+}
+
+#if defined(_MSC_VER) && defined(_M_IX86)
+# define LAZY(i) \
+__declspec(naked) static void lazy##i (void) { \
+ _asm push i \
+ _asm push OFFSET OPENSSL_UplinkTable \
+ _asm call OPENSSL_Uplink \
+ _asm add esp,8 \
+ _asm jmp OPENSSL_UplinkTable+4*i }
+
+# if APPLINK_MAX>25
+# error "Add more stubs..."
+# endif
+/* make some in advance... */
+LAZY(1) LAZY(2) LAZY(3) LAZY(4) LAZY(5)
+ LAZY(6) LAZY(7) LAZY(8) LAZY(9) LAZY(10)
+ LAZY(11) LAZY(12) LAZY(13) LAZY(14) LAZY(15)
+ LAZY(16) LAZY(17) LAZY(18) LAZY(19) LAZY(20)
+ LAZY(21) LAZY(22) LAZY(23) LAZY(24) LAZY(25)
+void *OPENSSL_UplinkTable[] = {
+ (void *)APPLINK_MAX,
+ lazy1, lazy2, lazy3, lazy4, lazy5,
+ lazy6, lazy7, lazy8, lazy9, lazy10,
+ lazy11, lazy12, lazy13, lazy14, lazy15,
+ lazy16, lazy17, lazy18, lazy19, lazy20,
+ lazy21, lazy22, lazy23, lazy24, lazy25,
+};
+#endif
+
+#ifdef SELFTEST
+main()
+{
+ UP_fprintf(UP_stdout, "hello, world!\n");
+}
+#endif
diff --git a/openssl-1.1.0h/ms/uplink.h b/openssl-1.1.0h/ms/uplink.h
new file mode 100644
index 0000000..f6cd038
--- /dev/null
+++ b/openssl-1.1.0h/ms/uplink.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2004-2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL license (the "License"). You may not use
+ * this file except in compliance with the License. You can obtain a copy
+ * in the file LICENSE in the source distribution or at
+ * https://www.openssl.org/source/license.html
+ */
+
+#define APPMACROS_ONLY
+#include "applink.c"
+
+extern void *OPENSSL_UplinkTable[];
+
+#define UP_stdin (*(void *(*)(void))OPENSSL_UplinkTable[APPLINK_STDIN])()
+#define UP_stdout (*(void *(*)(void))OPENSSL_UplinkTable[APPLINK_STDOUT])()
+#define UP_stderr (*(void *(*)(void))OPENSSL_UplinkTable[APPLINK_STDERR])()
+#define UP_fprintf (*(int (*)(void *,const char *,...))OPENSSL_UplinkTable[APPLINK_FPRINTF])
+#define UP_fgets (*(char *(*)(char *,int,void *))OPENSSL_UplinkTable[APPLINK_FGETS])
+#define UP_fread (*(size_t (*)(void *,size_t,size_t,void *))OPENSSL_UplinkTable[APPLINK_FREAD])
+#define UP_fwrite (*(size_t (*)(const void *,size_t,size_t,void *))OPENSSL_UplinkTable[APPLINK_FWRITE])
+#define UP_fsetmod (*(int (*)(void *,char))OPENSSL_UplinkTable[APPLINK_FSETMOD])
+#define UP_feof (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FEOF])
+#define UP_fclose (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FCLOSE])
+
+#define UP_fopen (*(void *(*)(const char *,const char *))OPENSSL_UplinkTable[APPLINK_FOPEN])
+#define UP_fseek (*(int (*)(void *,long,int))OPENSSL_UplinkTable[APPLINK_FSEEK])
+#define UP_ftell (*(long (*)(void *))OPENSSL_UplinkTable[APPLINK_FTELL])
+#define UP_fflush (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FFLUSH])
+#define UP_ferror (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FERROR])
+#define UP_clearerr (*(void (*)(void *))OPENSSL_UplinkTable[APPLINK_CLEARERR])
+#define UP_fileno (*(int (*)(void *))OPENSSL_UplinkTable[APPLINK_FILENO])
+
+#define UP_open (*(int (*)(const char *,int,...))OPENSSL_UplinkTable[APPLINK_OPEN])
+#define UP_read (*(ossl_ssize_t (*)(int,void *,size_t))OPENSSL_UplinkTable[APPLINK_READ])
+#define UP_write (*(ossl_ssize_t (*)(int,const void *,size_t))OPENSSL_UplinkTable[APPLINK_WRITE])
+#define UP_lseek (*(long (*)(int,long,int))OPENSSL_UplinkTable[APPLINK_LSEEK])
+#define UP_close (*(int (*)(int))OPENSSL_UplinkTable[APPLINK_CLOSE])