diff options
author | Matt Caswell <matt@openssl.org> | 2015-01-22 02:47:42 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2015-01-22 09:52:55 +0000 |
commit | 40720ce3caf44294b5b87a18856b7aef06123314 (patch) | |
tree | 30d57dec407c05fe6ea57275517805e8c79a7dcc /ms | |
parent | 9d03aabea3ead1fe6a194297ddffd4a87f89b93c (diff) |
Run util/openssl-format-source -v -c .
Reviewed-by: Tim Hudson <tjh@openssl.org>
Diffstat (limited to 'ms')
-rw-r--r-- | ms/applink.c | 176 | ||||
-rw-r--r-- | ms/tlhelp32.h | 230 | ||||
-rw-r--r-- | ms/uplink.c | 171 |
3 files changed, 309 insertions, 268 deletions
diff --git a/ms/applink.c b/ms/applink.c index 76f1c40d0a..2831b39e9a 100644 --- a/ms/applink.c +++ b/ms/applink.c @@ -1,43 +1,73 @@ -#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_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_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 */ +#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); } +# 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" { @@ -45,50 +75,52 @@ extern "C" { __declspec(dllexport) void ** -#if defined(__BORLANDC__) +# 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 + __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; +{ + 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; + return OPENSSL_ApplinkTable; } #ifdef __cplusplus diff --git a/ms/tlhelp32.h b/ms/tlhelp32.h index e15b7e2282..9408dc3244 100644 --- a/ms/tlhelp32.h +++ b/ms/tlhelp32.h @@ -1,136 +1,136 @@ /*- - tlhelp32.h - Include file for Tool help functions. + tlhelp32.h - Include file for Tool help functions. - Written by Mumit Khan <khan@nanotech.wisc.edu> + Written by Mumit Khan <khan@nanotech.wisc.edu> - This file is part of a free library for the Win32 API. + 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. + 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 +# 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 +# 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; + 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; + 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; + 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; + 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; + 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; + 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); + 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 */ +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 */ - +#endif /* _TLHELP32_H */ diff --git a/ms/uplink.c b/ms/uplink.c index 6d59cb1f87..e58ab9d8f5 100644 --- a/ms/uplink.c +++ b/ms/uplink.c @@ -1,117 +1,126 @@ #if (defined(_WIN64) || defined(_WIN32_WCE)) && !defined(UNICODE) -#define UNICODE +# define UNICODE #endif #if defined(UNICODE) && !defined(_UNICODE) -#define _UNICODE +# define _UNICODE #endif #if defined(_UNICODE) && !defined(UNICODE) -#define UNICODE +# define UNICODE #endif #include <windows.h> #include <tchar.h> #include <stdio.h> #include "uplink.h" -void OPENSSL_showfatal(const char *,...); +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); +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; +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]. */ + /* + * 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")); + 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 ((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)(); + 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; + 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 (index > (int)p[0]) + break; - if (p[index]) func = p[index]; + if (p[index]) + func = p[index]; } while (0); table[index] = func; -} +} #if defined(_MSC_VER) && defined(_M_IX86) && !defined(OPENSSL_NO_INLINE_ASM) -#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 } +# 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 +# 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) +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, + (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"); } +main() +{ + UP_fprintf(UP_stdout, "hello, world!\n"); +} #endif |