Seulement dans patch1: bin Seulement dans patch1: obj diff -cr orig/src/makew32.bat patch1/src/makew32.bat *** orig/src/makew32.bat 2010-11-17 21:20:14.000000000 +0100 --- patch1/src/makew32.bat 2014-06-09 15:49:25.546875000 +0200 *************** *** 2,7 **** --- 2,8 ---- TITLE W32 STUNNEL ::pdelaage 20101026: for use with MS VCexpress 2008 (v9) ::some trick to avoid re-pollution of env vars as much as possible + ::pdelaage 20140609: makew32 "UNICODESUPPORT=" to compile a UNICODE version :: In multitarget compilation environment, it is better to open a new cmd.exe window :: to avoid pollution of PATH from, eg, some previous WCE compilation attempts. diff -cr orig/src/resolver.c patch1/src/resolver.c *** orig/src/resolver.c 2014-04-11 09:44:10.000000000 +0200 --- patch1/src/resolver.c 2014-06-09 15:57:21.406250000 +0200 *************** *** 92,98 **** #if defined(USE_WIN32) && !defined(_WIN32_WCE) HINSTANCE handle; ! handle=LoadLibrary("ws2_32.dll"); /* IPv6 in Windows XP or higher */ if(handle) { s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo"); s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo"); --- 92,98 ---- #if defined(USE_WIN32) && !defined(_WIN32_WCE) HINSTANCE handle; ! handle=LoadLibrary(TEXT("ws2_32.dll")); /* IPv6 in Windows XP or higher *//* pdelaage 20140529...unicode ! */ if(handle) { s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo"); s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo"); *************** *** 101,107 **** return; /* IPv6 detected -> OK */ FreeLibrary(handle); } ! handle=LoadLibrary("wship6.dll"); /* experimental IPv6 for Windows 2000 */ if(handle) { s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo"); s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo"); --- 101,107 ---- return; /* IPv6 detected -> OK */ FreeLibrary(handle); } ! handle=LoadLibrary(TEXT("wship6.dll")); /* experimental IPv6 for Windows 2000 *//* pdelaage 20140609...unicode ! */ if(handle) { s_getaddrinfo=(GETADDRINFO)GetProcAddress(handle, "getaddrinfo"); s_freeaddrinfo=(FREEADDRINFO)GetProcAddress(handle, "freeaddrinfo"); diff -cr orig/src/resources.rc patch1/src/resources.rc *** orig/src/resources.rc 2014-03-06 00:27:52.000000000 +0100 --- patch1/src/resources.rc 2014-06-09 20:56:52.031250000 +0200 *************** *** 89,94 **** --- 89,96 ---- ABOUTBOX DIALOG DISCARDABLE 0, 0, 140, 68 STYLE DS_MODALFRAME|DS_CENTER|WS_POPUP|WS_CAPTION|WS_SYSMENU CAPTION "About stunnel" + /* pdelaage 20140609 : no more ugly font a la windows 3.1...stunnel deserves to look more "smart" */ + FONT 8, "MS Sans Serif" BEGIN ICON IDI_STUNNEL_MAIN, -1, 9, 8, 18, 20 LTEXT "stunnel version", -1, 30, 4, 52, 8 *************** *** 103,108 **** --- 105,112 ---- PASSBOX DIALOG DISCARDABLE 0, 0, 158, 51 STYLE DS_MODALFRAME|DS_CENTER|WS_POPUP|WS_CAPTION|WS_SYSMENU CAPTION "" + /* pdelaage 20140609 : no more ugly font a la windows 3.1...stunnel deserves to look more "smart" */ + FONT 8, "MS Sans Serif" BEGIN ICON IDI_STUNNEL_MAIN, -1, 8, 6, 18, 20 LTEXT "Pass phrase:", -1, 33, 9, 50, 8 diff -cr orig/src/ui_win_cli.c patch1/src/ui_win_cli.c *** orig/src/ui_win_cli.c 2014-03-26 18:13:01.000000000 +0100 --- patch1/src/ui_win_cli.c 2014-06-09 22:15:17.343750000 +0200 *************** *** 40,59 **** int main(int argc, char *argv[]) { static struct WSAData wsa_state; ! char *c, stunnel_exe_path[MAX_PATH]; /* set current working directory and engine path */ GetModuleFileName(0, stunnel_exe_path, MAX_PATH); ! c=strrchr(stunnel_exe_path, '\\'); /* last backslash */ if(c) /* found */ ! c[1]='\0'; /* truncate program name */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { ! fprintf(stderr, "Cannot set directory to %s", stunnel_exe_path); return 1; } #endif ! _putenv_s("OPENSSL_ENGINES", stunnel_exe_path); str_init(); /* initialize per-thread string management */ if(WSAStartup(MAKEWORD(1, 1), &wsa_state)) --- 40,64 ---- int main(int argc, char *argv[]) { static struct WSAData wsa_state; ! TCHAR *c, stunnel_exe_path[MAX_PATH];/* pdelaage 20140609 UNICODE : TCHAR for both vars, because of GetModuleFileName */ /* set current working directory and engine path */ GetModuleFileName(0, stunnel_exe_path, MAX_PATH); ! c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash *//* pdelaage 20140526 UNICODE : strrchr replaced by _tcsrchr */ if(c) /* found */ ! c[1]=TEXT('\0'); /* truncate program name *//* pdelaage 20140526 UNICODE : strrchr replaced by _tcsrchr, because of SetCurrentDirectory and stunnel_exe_path */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { ! #ifdef UNICODE /* pdelaage 20140526 QUESTION : shoud'nt we use s_log instead of fprintf ?? */ ! fprintf(stderr, "Cannot set directory to %ls", stunnel_exe_path);/* pdelaage 20140526 UNICODE format spec support */ ! #else ! fprintf(stderr, "Cannot set directory to %hs", stunnel_exe_path); ! #endif ! return 1; } #endif ! _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);/* pdelaage 20140526 UNICODE */ str_init(); /* initialize per-thread string management */ if(WSAStartup(MAKEWORD(1, 1), &wsa_state)) diff -cr orig/src/ui_win_gui.c patch1/src/ui_win_gui.c *** orig/src/ui_win_gui.c 2014-05-12 08:31:13.000000000 +0200 --- patch1/src/ui_win_gui.c 2014-06-09 22:26:24.812500000 +0200 *************** *** 54,60 **** #else /* MSDN claims that _WIN32 is always defined */ #define STUNNEL_PLATFORM "Win32" #endif ! #define SERVICE_NAME "stunnel" #endif /* mingw-Patches-1825044 is missing in Debian Squeeze */ --- 54,62 ---- #else /* MSDN claims that _WIN32 is always defined */ #define STUNNEL_PLATFORM "Win32" #endif ! ! #define SERVICE_NAME TEXT("stunnel") /* pdelaage 20140609 UNICODE */ ! #endif /* mingw-Patches-1825044 is missing in Debian Squeeze */ *************** *** 89,95 **** /* NT Service related function */ #ifndef _WIN32_WCE NOEXPORT int service_initialize(void); ! NOEXPORT int service_install(LPTSTR); NOEXPORT int service_uninstall(void); NOEXPORT int service_start(void); NOEXPORT int service_stop(void); --- 91,98 ---- /* NT Service related function */ #ifndef _WIN32_WCE NOEXPORT int service_initialize(void); ! /* pdelaage 20140609 : wrong prototype, the DEFINITION code further in that file is with LPSTR only, not lpTstr...static int service_install(LPTSTR); */ ! NOEXPORT int service_install(LPSTR); NOEXPORT int service_uninstall(void); NOEXPORT int service_start(void); NOEXPORT int service_stop(void); *************** *** 149,155 **** #endif int nCmdShow) { LPSTR command_line; ! char *c, stunnel_exe_path[MAX_PATH]; #ifndef _WIN32_WCE char *errmsg; #endif --- 152,159 ---- #endif int nCmdShow) { LPSTR command_line; ! /* 20140609 pdelaage char *c, stunnel_exe_path[MAX_PATH]; */ ! TCHAR *c, stunnel_exe_path[MAX_PATH];/* 20140609 pdelaage : UNICODE support for GetModuleFileName on W32/WCE */ #ifndef _WIN32_WCE char *errmsg; #endif *************** *** 167,197 **** parse_cmdline(command_line); /* setup global cmdline structure */ ! GetModuleFileName(0, stunnel_exe_path, MAX_PATH); #ifndef _WIN32_WCE /* find previous instances of the same executable */ if(!cmdline.service && !cmdline.install && !cmdline.uninstall && !cmdline.start && !cmdline.stop) { ! EnumWindows(enum_windows, (LPARAM)stunnel_exe_path); if(cmdline.exit) return 0; /* in case EnumWindows didn't find a previous instance */ } #endif /* set current working directory and engine path */ ! c=strrchr(stunnel_exe_path, '\\'); /* last backslash */ if(c) /* found */ ! c[1]='\0'; /* truncate program name */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { ! errmsg=str_printf("Cannot set directory to %s", stunnel_exe_path); message_box(errmsg, MB_ICONERROR); str_free(errmsg); return 1; } #endif ! _putenv_s("OPENSSL_ENGINES", stunnel_exe_path); if(initialize_winsock()) return 1; --- 171,205 ---- parse_cmdline(command_line); /* setup global cmdline structure */ ! GetModuleFileName(0, stunnel_exe_path, MAX_PATH);/* 20140609 pdelaage : requires UNICODE strings */ #ifndef _WIN32_WCE /* find previous instances of the same executable */ if(!cmdline.service && !cmdline.install && !cmdline.uninstall && !cmdline.start && !cmdline.stop) { ! EnumWindows(enum_windows, (LPARAM)stunnel_exe_path);/* 20140609 pdelaage : BE CAREFUL that enum_windows will CORRECTLY CAST to UNICODE ! done by my contribution there ...*/ if(cmdline.exit) return 0; /* in case EnumWindows didn't find a previous instance */ } #endif /* set current working directory and engine path */ ! c=_tcsrchr(stunnel_exe_path, TEXT('\\')); /* last backslash *//* pdelaage 20140609 unicode */ if(c) /* found */ ! c[1]=TEXT('\0'); /* truncate program name */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { ! #ifdef UNICODE /* pdelaage 20140609 : UNICODE in printf format spec */ ! errmsg=str_printf("Cannot set directory to %ls", stunnel_exe_path); ! #else ! errmsg=str_printf("Cannot set directory to %hs", stunnel_exe_path); ! #endif message_box(errmsg, MB_ICONERROR); str_free(errmsg); return 1; } #endif ! _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);/* pdelaage 20140609 : UNICODE */ if(initialize_winsock()) return 1; *************** *** 216,224 **** NOEXPORT BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) { DWORD pid; HINSTANCE hInstance; ! char window_exe_path[MAX_PATH]; HANDLE process_handle; ! char *stunnel_exe_path=(char *)lParam; if(!other_window_handle) return TRUE; --- 224,232 ---- NOEXPORT BOOL CALLBACK enum_windows(HWND other_window_handle, LPARAM lParam) { DWORD pid; HINSTANCE hInstance; ! TCHAR window_exe_path[MAX_PATH];/* pdelaage 20140609 UNICODE */ HANDLE process_handle; ! TCHAR *stunnel_exe_path=(TCHAR *)lParam;/* pdelaage 20140529 UNICODE */ if(!other_window_handle) return TRUE; *************** *** 235,241 **** CloseHandle(process_handle); return TRUE; } ! if(strcmp(stunnel_exe_path, window_exe_path)) { CloseHandle(process_handle); return TRUE; } --- 243,249 ---- CloseHandle(process_handle); return TRUE; } ! if(_tcscmp(stunnel_exe_path, window_exe_path)) { /* pdelaage 20140529 UNICODE */ CloseHandle(process_handle); return TRUE; } *************** *** 1083,1095 **** } NOEXPORT void edit_config(HWND main_window_handle) { ! char cwd[MAX_PATH], *conf_path; ! /* TODO: port it to WCE */ if(is_admin()) { ShellExecute(main_window_handle, TEXT("open"), ! TEXT("notepad.exe"), configuration_file, NULL, SW_SHOWNORMAL); } else { /* UAC workaround */ if(strchr(configuration_file, '\\')) { conf_path=str_dup(configuration_file); --- 1091,1110 ---- } NOEXPORT void edit_config(HWND main_window_handle) { ! TCHAR cwd[MAX_PATH];/* pdelaage 20140609 : unicode because of GetCurrentDirectory */ ! char *conf_path; ! TCHAR *conf_string; /* pdelaage 20140609 : needed for UNICODE ShellExecute, because "configuration_file" is JUST ASCII !! */ ! /* TODO: port it to WCE */ if(is_admin()) { + conf_string = str2tstr(configuration_file); + ShellExecute(main_window_handle, TEXT("open"), ! TEXT("notepad.exe"), conf_string,/* pdelaage 20140609 : now UNICODE correct */ NULL, SW_SHOWNORMAL); + + str_free(conf_string); + } else { /* UAC workaround */ if(strchr(configuration_file, '\\')) { conf_path=str_dup(configuration_file); *************** *** 1097,1105 **** GetCurrentDirectory(MAX_PATH, cwd); conf_path=str_printf("%s\\%s", cwd, configuration_file); } ShellExecute(main_window_handle, TEXT("runas"), ! TEXT("notepad.exe"), conf_path, ! NULL, SW_SHOWNORMAL); str_free(conf_path); } } --- 1112,1125 ---- GetCurrentDirectory(MAX_PATH, cwd); conf_path=str_printf("%s\\%s", cwd, configuration_file); } + + conf_string = str2tstr(conf_path); + ShellExecute(main_window_handle, TEXT("runas"), ! TEXT("notepad.exe"), conf_string, /* pdelaage 20140609 : now UNICODE correct */ ! NULL, SW_SHOWNORMAL); ! ! str_free(conf_string); str_free(conf_path); } } *************** *** 1127,1133 **** NOEXPORT int service_initialize(void) { SERVICE_TABLE_ENTRY serviceTable[]={{0, 0}, {0, 0}}; ! serviceTable[0].lpServiceName=SERVICE_NAME; serviceTable[0].lpServiceProc=service_main; global_options.option.taskbar=0; /* disable taskbar for security */ if(!StartServiceCtrlDispatcher(serviceTable)) { --- 1147,1153 ---- NOEXPORT int service_initialize(void) { SERVICE_TABLE_ENTRY serviceTable[]={{0, 0}, {0, 0}}; ! serviceTable[0].lpServiceName=SERVICE_NAME;/* pdelaage 20140525 : UNICODE */ serviceTable[0].lpServiceProc=service_main; global_options.option.taskbar=0; /* disable taskbar for security */ if(!StartServiceCtrlDispatcher(serviceTable)) { *************** *** 1139,1145 **** NOEXPORT int service_install(LPSTR command_line) { SC_HANDLE scm, service; ! char stunnel_exe_path[MAX_PATH], *service_path; scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); if(!scm) { --- 1159,1166 ---- NOEXPORT int service_install(LPSTR command_line) { SC_HANDLE scm, service; ! TCHAR stunnel_exe_path[MAX_PATH], *tservice_path;/* pdelaage 20140609: UNICODE for GetModuleFileName, CreateService */ ! char *service_path; scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); if(!scm) { *************** *** 1147,1157 **** return 1; } GetModuleFileName(0, stunnel_exe_path, MAX_PATH); ! service_path=str_printf("\"%s\" -service %s", stunnel_exe_path, command_line); service=CreateService(scm, SERVICE_NAME, SERVICE_NAME, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS, ! SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, service_path, NULL, NULL, NULL, NULL, NULL); str_free(service_path); if(!service) { error_box("CreateService"); --- 1168,1186 ---- return 1; } GetModuleFileName(0, stunnel_exe_path, MAX_PATH); ! #ifdef UNICODE /* pdelaage 20140609 : we CAN mix TCHAR* and char* in printf...provided we use the proper h or l FORMAT SPEC */ ! service_path=str_printf("\"%ls\" -service %hs", stunnel_exe_path, command_line); ! #else ! service_path=str_printf("\"%hs\" -service %hs", stunnel_exe_path, command_line); ! #endif ! ! tservice_path = str2tstr(service_path); ! service=CreateService(scm, SERVICE_NAME, SERVICE_NAME, SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS, ! SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, tservice_path, NULL, NULL, NULL, NULL, NULL); + str_free(tservice_path); str_free(service_path); if(!service) { error_box("CreateService"); diff -cr orig/src/vc.mak patch1/src/vc.mak *** orig/src/vc.mak 2014-06-09 01:15:37.000000000 +0200 --- patch1/src/vc.mak 2014-06-09 21:32:43.031250000 +0200 *************** *** 1,6 **** --- 1,9 ---- # vc.mak by Michal Trojnara 1998-2014 # with help of David Gillingham # with help of Pierre Delaage + # pdelaage 20140609 : added UNICODE optional FLAG + # pdelaage 20140609 : added WX (fails on warning) flag to detect subtle error prone cast + # pdelaage 20140609 : added _CRT_NON_CONFORMING_SWPRINTFS to explicitely support old fashioned stprintf in ui_win_gui.c # the compilation requires: # - Visual C++ 2005 Express Edition with Platform SDK *************** *** 8,13 **** --- 11,18 ---- # - Visual C++ 2005 Professional Edition # - Visual C++ 2008 Express Edition + + !IF [ml64.exe /help >NUL 2>&1] TARGET=win32 !ELSE *************** *** 24,30 **** #FIPSDIR=$(SSLDIR)\include #LIBDIR=$(SSLDIR)\lib # or compile one yourself ! SSLDIR=..\..\openssl-1.0.1h-$(TARGET) INCDIR=$(SSLDIR)\inc32 FIPSDIR=$(SSLDIR)\inc32 LIBDIR=$(SSLDIR)\out32dll --- 29,36 ---- #FIPSDIR=$(SSLDIR)\include #LIBDIR=$(SSLDIR)\lib # or compile one yourself ! # pdelaage 20140609 SSLDIR=..\..\openssl-1.0.1h-$(TARGET) ! SSLDIR=C:\Users\pdelaage\Dvts\Contrib\openssl\v1.0.2-stable-SNAP-20121213\patch1 INCDIR=$(SSLDIR)\inc32 FIPSDIR=$(SSLDIR)\inc32 LIBDIR=$(SSLDIR)\out32dll *************** *** 51,57 **** CC=cl LINK=link ! CFLAGS=/MD /W3 /O2 /nologo /I"$(INCDIR)" /I"$(FIPSDIR)" LDFLAGS=/NOLOGO SHAREDLIBS=ws2_32.lib user32.lib shell32.lib --- 57,72 ---- CC=cl LINK=link ! # pdelaage 20140529 added unicode flag : because w32 unicode version helps to debug...W32/WCE ansi/unicode version... ! !ifdef UNICODESUPPORT ! UNICODEFLAGS=/DUNICODE -D_UNICODE ! !else ! UNICODEFLAGS= ! !endif ! ! # pdelaage 20140609 WX warning as error to detect subtle cast problems in ansi/unicode management. ! MORECFLAGS=/WX $(UNICODEFLAGS) /D_CRT_NON_CONFORMING_SWPRINTFS ! CFLAGS=/MD /W3 /O2 /nologo $(MORECFLAGS) /I"$(INCDIR)" /I"$(FIPSDIR)" LDFLAGS=/NOLOGO SHAREDLIBS=ws2_32.lib user32.lib shell32.lib