Seulement dans patch2/bin: ARMV4 Seulement dans patch2/bin: emulator Les fichiers patch1/bin/win32/stunnel.exe et patch2/bin/win32/stunnel.exe sont différents. Les fichiers patch1/bin/win32/stunnel.exp et patch2/bin/win32/stunnel.exp sont différents. Les fichiers patch1/bin/win32/stunnel.lib et patch2/bin/win32/stunnel.lib sont différents. Les fichiers patch1/bin/win32/tstunnel.exe et patch2/bin/win32/tstunnel.exe sont différents. Les fichiers patch1/bin/win32/tstunnel.exp et patch2/bin/win32/tstunnel.exp sont différents. Les fichiers patch1/bin/win32/tstunnel.lib et patch2/bin/win32/tstunnel.lib sont différents. Seulement dans patch2/bin: X86 Seulement dans patch2/obj: ARMV4 Seulement dans patch2/obj: emulator Les fichiers patch1/obj/win32/client.obj et patch2/obj/win32/client.obj sont différents. Les fichiers patch1/obj/win32/ctx.obj et patch2/obj/win32/ctx.obj sont différents. Les fichiers patch1/obj/win32/fd.obj et patch2/obj/win32/fd.obj sont différents. Les fichiers patch1/obj/win32/file.obj et patch2/obj/win32/file.obj sont différents. Les fichiers patch1/obj/win32/log.obj et patch2/obj/win32/log.obj sont différents. Les fichiers patch1/obj/win32/network.obj et patch2/obj/win32/network.obj sont différents. Les fichiers patch1/obj/win32/options.obj et patch2/obj/win32/options.obj sont différents. Les fichiers patch1/obj/win32/protocol.obj et patch2/obj/win32/protocol.obj sont différents. Les fichiers patch1/obj/win32/resolver.obj et patch2/obj/win32/resolver.obj sont différents. Les fichiers patch1/obj/win32/resources.res et patch2/obj/win32/resources.res sont différents. Les fichiers patch1/obj/win32/ssl.obj et patch2/obj/win32/ssl.obj sont différents. Les fichiers patch1/obj/win32/sthreads.obj et patch2/obj/win32/sthreads.obj sont différents. Les fichiers patch1/obj/win32/str.obj et patch2/obj/win32/str.obj sont différents. Les fichiers patch1/obj/win32/stunnel.obj et patch2/obj/win32/stunnel.obj sont différents. Les fichiers patch1/obj/win32/ui_win_cli.obj et patch2/obj/win32/ui_win_cli.obj sont différents. Les fichiers patch1/obj/win32/ui_win_gui.obj et patch2/obj/win32/ui_win_gui.obj sont différents. Les fichiers patch1/obj/win32/verify.obj et patch2/obj/win32/verify.obj sont différents. Seulement dans patch2/obj: X86 diff -cr patch1/src/client.c patch2/src/client.c *** patch1/src/client.c 2014-04-12 20:55:57.000000000 +0200 --- patch2/src/client.c 2014-06-10 09:23:03.812500000 +0200 *************** *** 929,934 **** --- 929,935 ---- default: sockerror(text); longjmp(c->err, 1); + return 1; /* 20140610 pdelaage to avoid warning on W32/WCE */ } } diff -cr patch1/src/common.h patch2/src/common.h *** patch1/src/common.h 2014-04-14 13:40:40.000000000 +0200 --- patch2/src/common.h 2014-06-10 08:49:06.406250000 +0200 *************** *** 222,228 **** --- 222,230 ---- #include #include /* _beginthread */ + #ifndef _WIN32_WCE /* pdelaage 20140520 : this file does not exist in WCE; if needed, a replacement for SHGetFolderPath will be provided for WCE */ #include /* SHGetFolderPath */ + #endif #include #include "resources.h" diff -cr patch1/src/evc.mak patch2/src/evc.mak *** patch1/src/evc.mak 2013-05-20 07:23:11.000000000 +0200 --- patch2/src/evc.mak 2014-06-21 20:57:18.828125000 +0200 *************** *** 1,8 **** # wce.mak for stunnel.exe by Michal Trojnara 2006-2012 # with help of Pierre Delaage # # DEFAULTLIB management: only 2 are necessary ! # defaultlibS as given for CLxxx in the MS doc ARE WRONG # !!!!!!!!!!!!!! # CUSTOMIZE THIS according to your wcecompat and openssl directories --- 1,25 ---- # wce.mak for stunnel.exe by Michal Trojnara 2006-2012 # with help of Pierre Delaage + # pdelaage 20140610 : added UNICODE optional FLAG, always ACTIVE on WCE because of poor ANSI support + # pdelaage 20140610 : added _WIN32_WCE flag for RC compilation, to preprocess out "HELP" unsupported menu flag on WCE + # pdelaage 20140610 : added new source mywcedefs.c for more WCE equivalent to some W32 services + # pdelaage 20140610 : ws2 lib is required to get WSAGetLastError routine (absent from winsock lib) + # pdelaage 20140610 : /Dx86 flag required for X86/Emulator targets, to get proper definition for InterlockedExchange + # pdelaage 20140610 : /MT flag is NON-SENSE for X86-WCE platforms, it is only meaningful for X86-W32-Desktop. + # for X86-WCE targets, although compiler "cl.exe" is REALLY the same as desktop W32 VS6 C++ compiler, + # the MT flags relating to LIBCMT is useless BECAUSE LIBCMT does NOT exist on WCE. No msvcrt on WCE either... + + # pdelaage 20140610 : Note on /MC flag + # For other targets than X86/Emulator, /MC flag is redundant with "/nodefaultlib coredll.lib corelibc.lib" LD lib list. + # For << X86 / Emulator >> target, as the cl.exe compiler IS the SAME as the standard VS6.0 C++ compiler for Desktop Pentium processor, + # /MC flag is in fact NOT existing, thus requiring an explicit linking with core libs by using : + # /NODEFAULTLIB coredll.lib corelibc.lib, + # something that is correct for any WCE target, X86 and other, and leading /MC flag to be useless ALSO for other target than X86. + + # # DEFAULTLIB management: only 2 are necessary ! # defaultlibS, as given for CLxxx in the MS doc, ARE WRONG # !!!!!!!!!!!!!! # CUSTOMIZE THIS according to your wcecompat and openssl directories *************** *** 10,19 **** # Modify this to point to your actual openssl compile directory # (You did already compile openssl, didn't you???) ! SSLDIR=C:\Users\standard\Documents\Dvts\Contrib\openssl\v1.0.0a\patched3 # Note that we currently use a multi-target customized version of legacy Essemer/wcecompat lib ! COMPATDIR=C:\Users\standard\Documents\Dvts\Contrib\wcecompat\v12\patchedX86 WCEVER=420 --- 27,36 ---- # Modify this to point to your actual openssl compile directory # (You did already compile openssl, didn't you???) ! SSLDIR=C:\Users\pdelaage\Dvts\Contrib\openssl\v1.0.2-stable-SNAP-20121213\patch3 # Note that we currently use a multi-target customized version of legacy Essemer/wcecompat lib ! COMPATDIR=C:\Users\pdelaage\Dvts\Contrib\wcecompat\v12\patched3emu WCEVER=420 *************** *** 24,30 **** !IF "$(TARGETCPU)"=="X86" WCETARGETCPU=_X86_ LDTARGETCPU=X86 ! MORECFLAGS=/MT # TODO: continue list for other targets : see wcecompat/wcedefs.mak for a good ref. # see also openssl/util/pl/vc-32.pl, also link /? --- 41,48 ---- !IF "$(TARGETCPU)"=="X86" WCETARGETCPU=_X86_ LDTARGETCPU=X86 ! #pdelaage 20140621 /Dx86 for inline defs of InterlockedExchange inline in winbase.h; no more /MT ! MORECFLAGS=/Dx86 # TODO: continue list for other targets : see wcecompat/wcedefs.mak for a good ref. # see also openssl/util/pl/vc-32.pl, also link /? *************** *** 34,50 **** !ELSEIF "$(TARGETCPU)"=="emulator" WCETARGETCPU=_X86_ LDTARGETCPU=X86 ! MORECFLAGS=/MT !ELSEIF "$(TARGETCPU)"=="MIPS16" || "$(TARGETCPU)"=="MIPSII" || "$(TARGETCPU)"=="MIPSII_FP" || "$(TARGETCPU)"=="MIPSIV" || "$(TARGETCPU)"=="MIPSIV_FP" WCETARGETCPU=_MIPS_ LDTARGETCPU=MIPS ! MORECFLAGS=/DMIPS /MC !ELSEIF "$(TARGETCPU)"=="SH3" || "$(TARGETCPU)"=="SH4" WCETARGETCPU=SHx LDTARGETCPU=$(TARGETCPU) ! MORECFLAGS=/MC !ELSE # default is ARM ! --- 52,71 ---- !ELSEIF "$(TARGETCPU)"=="emulator" WCETARGETCPU=_X86_ LDTARGETCPU=X86 ! #pdelaage 20140621 /Dx86 for inline defs of InterlockedExchange inline in winbase.h; no more /MT ! MORECFLAGS=/Dx86 !ELSEIF "$(TARGETCPU)"=="MIPS16" || "$(TARGETCPU)"=="MIPSII" || "$(TARGETCPU)"=="MIPSII_FP" || "$(TARGETCPU)"=="MIPSIV" || "$(TARGETCPU)"=="MIPSIV_FP" WCETARGETCPU=_MIPS_ LDTARGETCPU=MIPS ! #pdelaage 20140621 no more /MC required ! MORECFLAGS=/DMIPS !ELSEIF "$(TARGETCPU)"=="SH3" || "$(TARGETCPU)"=="SH4" WCETARGETCPU=SHx LDTARGETCPU=$(TARGETCPU) ! #pdelaage 20140621 no more /MC required ! MORECFLAGS= !ELSE # default is ARM ! *************** *** 52,59 **** # the following flag is required by (eg) winnt.h, and is different from targetcpu (armV4) WCETARGETCPU=ARM LDTARGETCPU=ARM ! MORECFLAGS=/MC ! !ENDIF # ceutilsdir probably useless (nb : were tools from essemer; but ms delivers a cecopy anyway, see ms dld site) --- 73,80 ---- # the following flag is required by (eg) winnt.h, and is different from targetcpu (armV4) WCETARGETCPU=ARM LDTARGETCPU=ARM ! #pdelaage 20140621 no more /MC required ! MORECFLAGS= !ENDIF # ceutilsdir probably useless (nb : were tools from essemer; but ms delivers a cecopy anyway, see ms dld site) *************** *** 65,76 **** INCLUDES=-I$(SSLDIR)\inc32 -I$(COMPATDIR)\include -I"$(SDKDIR)\include\$(TARGETCPU)" # for X86 and other it appears that /MC or /ML flags are absurd, # we always have to override runtime lib list to coredll and corelibc ! LIBS=/NODEFAULTLIB winsock.lib wcecompatex.lib libeay32.lib ssleay32.lib coredll.lib corelibc.lib DEFINES=/DHOST=\"$(TARGETCPU)-WCE-eVC-$(WCEVER)\" # /O1 /Oi more correct vs MS doc ! CFLAGS=/nologo $(MORECFLAGS) /O1 /Oi /W3 /WX /GF /Gy $(DEFINES) /D$(WCETARGETCPU) /D$(TARGETCPU) /DUNDER_CE=$(WCEVER) /D_WIN32_WCE=$(WCEVER) /DUNICODE -D_UNICODE $(INCLUDES) ! RFLAGS=$(DEFINES) $(INCLUDES) # LDFLAGS: since openssl >> 098a (eg 098h) out32dll is out32dll_targetCPU for WCE # delaage added $(TARGETCPU) in legacy Essemer/wcecompat libpath # to ease multitarget compilation without recompiling everything --- 86,102 ---- INCLUDES=-I$(SSLDIR)\inc32 -I$(COMPATDIR)\include -I"$(SDKDIR)\include\$(TARGETCPU)" # for X86 and other it appears that /MC or /ML flags are absurd, # we always have to override runtime lib list to coredll and corelibc ! #LIBS=/NODEFAULTLIB winsock.lib wcecompatex.lib libeay32.lib ssleay32.lib coredll.lib corelibc.lib ! LIBS=/NODEFAULTLIB ws2.lib wcecompatex.lib libeay32.lib ssleay32.lib coredll.lib corelibc.lib DEFINES=/DHOST=\"$(TARGETCPU)-WCE-eVC-$(WCEVER)\" + # pdelaage 20140610 added unicode flag : ALWAYS ACTIVE on WCE, because of poor ANSI support by the MS SDK + UNICODEFLAGS=/DUNICODE -D_UNICODE # /O1 /Oi more correct vs MS doc ! CFLAGS=/nologo $(MORECFLAGS) /O1 /Oi /W3 /WX /GF /Gy $(DEFINES) /D$(WCETARGETCPU) /D$(TARGETCPU) /DUNDER_CE=$(WCEVER) /D_WIN32_WCE=$(WCEVER) $(UNICODEFLAGS) $(INCLUDES) ! # pdelaage 20140610 : RC compilation requires D_WIN32_WCE flag to comment out unsupported "HELP" flag in menu definition, in resources.rc file ! RFLAGS=$(DEFINES) /D_WIN32_WCE=$(WCEVER) $(INCLUDES) ! # LDFLAGS: since openssl >> 098a (eg 098h) out32dll is out32dll_targetCPU for WCE # delaage added $(TARGETCPU) in legacy Essemer/wcecompat libpath # to ease multitarget compilation without recompiling everything *************** *** 90,96 **** OBJS=$(OBJ)\stunnel.obj $(OBJ)\ssl.obj $(OBJ)\ctx.obj $(OBJ)\verify.obj \ $(OBJ)\file.obj $(OBJ)\client.obj $(OBJ)\protocol.obj $(OBJ)\sthreads.obj \ $(OBJ)\log.obj $(OBJ)\options.obj $(OBJ)\network.obj \ ! $(OBJ)\resolver.obj $(OBJ)\str.obj $(OBJ)\fd.obj GUIOBJS=$(OBJ)\ui_win_gui.obj $(OBJ)\resources.res NOGUIOBJS=$(OBJ)\ui_win_cli.obj --- 116,122 ---- OBJS=$(OBJ)\stunnel.obj $(OBJ)\ssl.obj $(OBJ)\ctx.obj $(OBJ)\verify.obj \ $(OBJ)\file.obj $(OBJ)\client.obj $(OBJ)\protocol.obj $(OBJ)\sthreads.obj \ $(OBJ)\log.obj $(OBJ)\options.obj $(OBJ)\network.obj \ ! $(OBJ)\resolver.obj $(OBJ)\str.obj $(OBJ)\fd.obj $(OBJ)\mywcedefs.obj GUIOBJS=$(OBJ)\ui_win_gui.obj $(OBJ)\resources.res NOGUIOBJS=$(OBJ)\ui_win_cli.obj diff -cr patch1/src/file.c patch2/src/file.c *** patch1/src/file.c 2014-03-06 00:25:33.000000000 +0100 --- patch2/src/file.c 2014-06-12 09:21:45.875000000 +0200 *************** *** 49,65 **** /* open file */ switch(mode) { case FILE_MODE_READ: ! desired_access=FILE_READ_DATA; creation_disposition=OPEN_EXISTING; break; case FILE_MODE_APPEND: ! desired_access=FILE_APPEND_DATA; ! creation_disposition=OPEN_ALWAYS; break; case FILE_MODE_OVERWRITE: ! desired_access=FILE_WRITE_DATA; creation_disposition=CREATE_ALWAYS; ! break; default: /* invalid mode */ return NULL; } --- 49,66 ---- /* open file */ switch(mode) { case FILE_MODE_READ: ! desired_access=GENERIC_READ;/* pdelaage 20140610 WCE: good old flags supported on w32/WCE, while FILE_READ_DATA is FAILING on WCE; ! this FILE_READ_DATA flag PREVENTS read from various folders on WCE phones such as \stunnel\ or \Storage card\, or on WCE emulator \stunnel\.... where we find stunnel.conf file sometimes...*/ creation_disposition=OPEN_EXISTING; break; case FILE_MODE_APPEND: ! desired_access=GENERIC_WRITE; /* pdelaage 20140610: FILE_APPEND_DATA; back to old code W32/WCE compatible */ ! creation_disposition=OPEN_ALWAYS;/* pdelaage 20140610 : I disagree with OPEN_ALWAYS that creates the file if not existing. I suggest : OPEN_EXISTING */ break; case FILE_MODE_OVERWRITE: ! desired_access=GENERIC_WRITE; /* pdelaage 20140610:FILE_WRITE_DATA; back to old code W32/WCE compatible */ creation_disposition=CREATE_ALWAYS; ! break; default: /* invalid mode */ return NULL; } Seulement dans patch2/src: mywcedefs.c Seulement dans patch2/src: mywcedefs.h diff -cr patch1/src/protocol.c patch2/src/protocol.c *** patch1/src/protocol.c 2014-04-13 13:15:21.000000000 +0200 --- patch2/src/protocol.c 2014-06-10 09:29:17.406250000 +0200 *************** *** 535,540 **** --- 535,542 ---- } str_free(line); longjmp(c->err, 2); /* don't reset */ + + return NULL; /* pdelaage 20140610 : just to avoid compilation warning on W32/WCE */ } /**************************************** nntp */ diff -cr patch1/src/resources.h patch2/src/resources.h *** patch1/src/resources.h 2014-01-02 09:13:37.000000000 +0100 --- patch2/src/resources.h 2014-06-23 16:37:20.562500000 +0200 *************** *** 31,33 **** --- 31,35 ---- #define IDM_HOMEPAGE 52 #define IDM_PEER_MENU 60 + + #define IDS_SERVICE_DESC 70 /* pdelaage 20140623 : added description for Win32 Service Manager */ diff -cr patch1/src/resources.rc patch2/src/resources.rc *** patch1/src/resources.rc 2014-06-09 20:56:52.031250000 +0200 --- patch2/src/resources.rc 2014-06-23 16:39:47.156250000 +0200 *************** *** 45,60 **** MENUITEM SEPARATOR MENUITEM "&Close", IDM_CLOSE END POPUP "&Configuration" BEGIN MENUITEM "&Edit Configuration", IDM_EDIT_CONFIG MENUITEM "&Reload Configuration", IDM_RELOAD_CONFIG END POPUP "&Save Peer Certificate" BEGIN MENUITEM "dummy", 0, GRAYED END ! POPUP "&Help", HELP BEGIN MENUITEM "&About", IDM_ABOUT MENUITEM SEPARATOR --- 45,73 ---- MENUITEM SEPARATOR MENUITEM "&Close", IDM_CLOSE END + /* pdelaage 20140610: in WCE, this menu is too large for smart phones */ + #ifdef _WIN32_WCE + POPUP "&Config." + #else POPUP "&Configuration" + #endif BEGIN MENUITEM "&Edit Configuration", IDM_EDIT_CONFIG MENUITEM "&Reload Configuration", IDM_RELOAD_CONFIG END + /* pdelaage 20140610: in WCE, this menu is too large for smart phones */ + #ifdef _WIN32_WCE + POPUP "&Save Peer Certs." + #else POPUP "&Save Peer Certificate" + #endif + BEGIN MENUITEM "dummy", 0, GRAYED END ! /* pdelaage 20140610: in WCE, the HELP flag, although documented, is NOT SUPPORTED, use addornements instead ? */ ! /* pdelaage 20140610: in W32, the HELP flag is nowadays useless : with wide screens, it is painful to go the right end to get help */ ! POPUP "&?" /* pdelaage 20140610: both to fit space on WCE phones, and for "standard" look and feel on W32, ? replaces "Help" */ BEGIN MENUITEM "&About", IDM_ABOUT MENUITEM SEPARATOR *************** *** 126,128 **** --- 139,145 ---- PUSHBUTTON "Cancel",IDCANCEL, 101, 30, 50, 14 END + STRINGTABLE + { + IDS_SERVICE_DESC "SSL encryption wrapper between local/remote clients and local/remote servers" + } diff -cr patch1/src/ui_win_cli.c patch2/src/ui_win_cli.c *** patch1/src/ui_win_cli.c 2014-06-09 22:15:17.343750000 +0200 --- patch2/src/ui_win_cli.c 2014-06-11 00:22:46.343750000 +0200 *************** *** 37,42 **** --- 37,45 ---- #include "common.h" #include "prototypes.h" + #ifdef _WIN32_WCE + #include "mywcedefs.h" /* pdelaage 20140610 for _tputenv_s */ + #endif int main(int argc, char *argv[]) { static struct WSAData wsa_state; *************** *** 58,64 **** 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)) --- 61,67 ---- return 1; } #endif ! _tputenv_s(TEXT("OPENSSL_ENGINES"), stunnel_exe_path);/* pdelaage 20140526 UNICODE *//* pdelaage 20140610 : WCE implementation in mywcedefs.c */ str_init(); /* initialize per-thread string management */ if(WSAStartup(MAKEWORD(1, 1), &wsa_state)) *************** *** 112,119 **** /* log to Windows CE debug output stream */ LPTSTR tstr; ! tstr=str2tstr(line); ! RETAILMSG(TRUE, (TEXT("%s\r\n"), tstr)); str_free(tstr); #else fputs(line, stderr); --- 115,122 ---- /* log to Windows CE debug output stream */ LPTSTR tstr; ! tstr=str2tstr((LPSTR) line);/* pdelaage 20140610 : str2tstr strictly expects a "const LPSTR" */ ! RETAILMSG(TRUE, (TEXT("%s\r\n"), tstr)); str_free(tstr); #else fputs(line, stderr); diff -cr patch1/src/ui_win_gui.c patch2/src/ui_win_gui.c *** patch1/src/ui_win_gui.c 2014-06-09 22:26:24.812500000 +0200 --- patch2/src/ui_win_gui.c 2014-06-23 18:02:39.828125000 +0200 *************** *** 44,49 **** --- 44,61 ---- #endif #include "resources.h" + #ifdef _WIN32_WCE /* pdelaage 20140610 : some ports of win32 services to WCE, or some specific WCE services */ + #include "mywcedefs.h" + #endif + + #ifdef UNICODE /* pdelaage 20140623 : TSTR and TCAR ansi-printf format specs : YES ansi-printf can print Wchar strings ...*/ + #define TCAR_PRINTF_FORMAT "%lc" + #define TSTR_PRINTF_FORMAT "%ls" + #else + #define TCAR_PRINTF_FORMAT "%hc" + #define TSTR_PRINTF_FORMAT "%hs" + #endif + #define LOG_LINES 1000 #ifdef _WIN32_WCE *************** *** 56,62 **** #endif #define SERVICE_NAME TEXT("stunnel") /* pdelaage 20140609 UNICODE */ ! #endif /* mingw-Patches-1825044 is missing in Debian Squeeze */ --- 68,74 ---- #endif #define SERVICE_NAME TEXT("stunnel") /* pdelaage 20140609 UNICODE */ ! #define SERVICE_DISPLAY_NAME TEXT("Stunnel SSL wrapper") /* pdelaage 20140623: Nicer name to be displayed in Service Control Manager */ #endif /* mingw-Patches-1825044 is missing in Debian Squeeze */ *************** *** 129,135 **** static SERVICE_STATUS_HANDLE serviceStatusHandle=0; #endif ! static volatile int visible=0; static volatile int error_mode=1; /* no valid configuration was ever loaded */ static HANDLE config_ready=NULL; /* reload without a valid configuration */ static LONG new_logs=0; --- 141,148 ---- static SERVICE_STATUS_HANDLE serviceStatusHandle=0; #endif ! /* pdelaage 20140610: now visible is more appropriately a BOOL, as stated by MSDN */ ! static volatile BOOL visible = FALSE;/* int visible=0; */ static volatile int error_mode=1; /* no valid configuration was ever loaded */ static HANDLE config_ready=NULL; /* reload without a valid configuration */ static LONG new_logs=0; *************** *** 164,172 **** str_init(); /* initialize per-thread string management */ ghInst=this_instance; #ifdef _WIN32_WCE ! command_line=tstr2str(lpCmdLine); #else ! command_line=lpCmdLine; #endif parse_cmdline(command_line); /* setup global cmdline structure */ --- 177,185 ---- str_init(); /* initialize per-thread string management */ ghInst=this_instance; #ifdef _WIN32_WCE ! command_line=wstr2str(lpCmdLine);/* pdelaage 20140610 : on WCE, even in <> compilation mode that is ALSO possible on WCE, lpCmdline is ALWAYS WCHAR, so that WCE ALWAYS need a WCHAR to STR conversion, but in ANSI mode tstr2str INAPPROPRIATELY here expects a char* so that we need another conversion function : see extra source in mywcedefs.c */ #else ! command_line=lpCmdLine; /* pdelaage 20140610, on win32 lpcmdline is always ANSI string...for the moment.*/ #endif parse_cmdline(command_line); /* setup global cmdline structure */ *************** *** 189,199 **** 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; --- 202,209 ---- c[1]=TEXT('\0'); /* truncate program name */ #ifndef _WIN32_WCE if(!SetCurrentDirectory(stunnel_exe_path)) { ! /* pdelaage 20140609 : UNICODE in printf format spec */ ! errmsg=str_printf("Cannot set directory to "TSTR_PRINTF_FORMAT, stunnel_exe_path); message_box(errmsg, MB_ICONERROR); str_free(errmsg); return 1; *************** *** 323,328 **** --- 333,341 ---- MSG msg; LPTSTR classname=TEXT("stunnel_main_window_class"); + /* Ensure commctrl.dll is loaded *//* pdelaage 20140621 addition, needed -eg- for WCE commandbars ... */ + InitCommonControls(); /* pdelaage 20140621 : Good practice before using common controls, both for WCE and W32 */ + /* register the class */ #ifndef _WIN32_WCE wc.cbSize=sizeof wc; *************** *** 391,397 **** s_log(LOG_DEBUG, "Window message: %d", message); #endif switch(message) { ! case WM_CREATE: #ifdef _WIN32_WCE /* create command bar */ command_bar_handle=CommandBar_Create(ghInst, main_window_handle, 1); --- 404,410 ---- s_log(LOG_DEBUG, "Window message: %d", message); #endif switch(message) { ! case WM_CREATE: #ifdef _WIN32_WCE /* create command bar */ command_bar_handle=CommandBar_Create(ghInst, main_window_handle, 1); *************** *** 404,412 **** #endif /* create child edit window */ ! edit_handle=CreateWindow(TEXT("EDIT"), NULL, ! WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY, ! 0, 0, 0, 0, main_window_handle, (HMENU)IDE_EDIT, ghInst, NULL); #ifndef _WIN32_WCE SendMessage(edit_handle, WM_SETFONT, (WPARAM)CreateFont(-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, --- 417,426 ---- #endif /* create child edit window */ ! edit_handle=CreateWindowEx(WS_EX_STATICEDGE, /* pdelaage 20140610 : for better look and feel, 3D edges to separate from menubar...over Win31 flat style */ ! TEXT("EDIT"), NULL, ! WS_CHILD|WS_VISIBLE|WS_HSCROLL|WS_VSCROLL|ES_MULTILINE|ES_READONLY, ! 0, 0, 0, 0, main_window_handle, (HMENU)IDE_EDIT, ghInst, NULL); #ifndef _WIN32_WCE SendMessage(edit_handle, WM_SETFONT, (WPARAM)CreateFont(-12, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, *************** *** 421,432 **** #ifdef _WIN32_WCE MoveWindow(edit_handle, 0, CommandBar_Height(command_bar_handle), rect.right, rect.bottom-CommandBar_Height(command_bar_handle), TRUE); #else MoveWindow(edit_handle, 0, 0, rect.right, rect.bottom, TRUE); #endif UpdateWindow(edit_handle); /* CommandBar_Show(command_bar_handle, TRUE); */ ! return TRUE; case WM_SETFOCUS: SetFocus(edit_handle); --- 435,451 ---- #ifdef _WIN32_WCE MoveWindow(edit_handle, 0, CommandBar_Height(command_bar_handle), rect.right, rect.bottom-CommandBar_Height(command_bar_handle), TRUE); + + /* pdelaage 20140610 WCE : dixit MSDN, and indeed, commandbars do not resize automatically unless providing this code, necessary on "sliding-keyboard" OR "auto-rotating screen orientation" smart phones when switching from portrait to landscape display and vice/versa */ + SendMessage(command_bar_handle, TB_AUTOSIZE, 0L, 0L); + CommandBar_AlignAdornments(command_bar_handle);/* pdelaage 20140610 WCE: MSDN says we have to repeat this for auto-repositioning of Help btn */ + #else MoveWindow(edit_handle, 0, 0, rect.right, rect.bottom, TRUE); #endif UpdateWindow(edit_handle); /* CommandBar_Show(command_bar_handle, TRUE); */ ! return TRUE;/* pdelaage 20140621, TODO: both for W32 and WCE, this should be "return 0", not "TRUE"... dixit MSDN. Same remark for most of the msg processing here */ case WM_SETFOCUS: SetFocus(edit_handle); *************** *** 441,454 **** ShowWindow(main_window_handle, SW_HIDE); return TRUE; ! case WM_SHOWWINDOW: ! visible=wParam; /* setup global variable */ if(tray_menu_handle) CheckMenuItem(tray_menu_handle, IDM_SHOW_LOG, visible ? MF_CHECKED : MF_UNCHECKED); if(visible) ! update_logs(); ! return TRUE; case WM_DESTROY: #ifdef _WIN32_WCE --- 460,478 ---- ShowWindow(main_window_handle, SW_HIDE); return TRUE; ! /* pdelaage 20140610: I made "visible" a real BOOL, as defined by MSDN doc on WM_SHOWWINDOW...instead of an int between 0 and 1...*/ ! /* case WM_SHOWWINDOW: ! visible= (BOOL) wParam; *//* setup global variable ! */ ! /* pdelaage 20140610: WM_SHOWWINDOW does NOT exist on WCE, so replaced by WM_WINDOWPOSCHANGED W32/WCE compatible */ ! case WM_WINDOWPOSCHANGED : ! visible = IsWindowVisible(main_window_handle);/* setup global variable *//* pdelaage 20140610: more reliable than msg content */ if(tray_menu_handle) CheckMenuItem(tray_menu_handle, IDM_SHOW_LOG, visible ? MF_CHECKED : MF_UNCHECKED); if(visible) ! update_logs(); ! break;/* return TRUE;*//* pdelaage 20140610: WM_WINDOWPOSCHANGED MUST go to DefProc to properly refresh window appearance (WM_SIZE/WM_MOVE)*/ case WM_DESTROY: #ifdef _WIN32_WCE *************** *** 903,909 **** HMENU tray_peer_list=NULL; char *str; unsigned int section_number; ! MENUITEMINFO mii; /* purge menu peer lists */ #ifndef _WIN32_WCE --- 927,934 ---- HMENU tray_peer_list=NULL; char *str; unsigned int section_number; ! ! /* 20140610 pdelaage unsupported on WCE, useless with common code in W32 (and thus generates a compilation warning) : MENUITEMINFO mii; */ /* purge menu peer lists */ #ifndef _WIN32_WCE *************** *** 916,923 **** if(tray_menu_handle) tray_peer_list=GetSubMenu(GetSubMenu(tray_menu_handle, 0), 2); if(tray_peer_list) ! while(GetMenuItemCount(tray_peer_list)) /* purge old menu */ ! DeleteMenu(tray_peer_list, 0, MF_BYPOSITION); /* initialize data structures */ number_of_sections=0; --- 941,948 ---- if(tray_menu_handle) tray_peer_list=GetSubMenu(GetSubMenu(tray_menu_handle, 0), 2); if(tray_peer_list) ! /* pdelaage 20140610 : W32/WCE trick because GetMenuItemCount does not exist on WCE */ ! while (DeleteMenu(tray_peer_list, 0, MF_BYPOSITION) == TRUE) {;}; /* purge old menu */ /* initialize data structures */ number_of_sections=0; *************** *** 950,955 **** --- 975,981 ---- section->chain=NULL; /* insert new menu item */ + /* pdelaage 20140610 : this code is not supported by WCE, and the same can be achieved by a SHORTER common code for W32/WCE mii.cbSize=sizeof mii; mii.fMask=MIIM_STRING|MIIM_DATA|MIIM_ID|MIIM_STATE; mii.fType=MFT_STRING; *************** *** 965,970 **** --- 991,1007 ---- if(tray_peer_list) if(!InsertMenuItem(tray_peer_list, section_number, TRUE, &mii)) ioerror("InsertMenuItem"); + */ + /* pdelaage 20140610, W32/WCE short COMMON code to create menuitems */ + #ifndef _WIN32_WCE + if(main_peer_list) + if(InsertMenu(main_peer_list, section_number, MF_BYPOSITION | MF_STRING | MF_GRAYED, IDM_PEER_MENU+section_number, section->file) == 0) + ioerror("InsertMenu"); + #endif + if(tray_peer_list) + if(InsertMenu(tray_peer_list, section_number, MF_BYPOSITION | MF_STRING | MF_GRAYED, IDM_PEER_MENU+section_number, section->file) == 0) + ioerror("InsertMenu"); + ++section_number; } if(hwnd) *************** *** 994,1003 **** ICON_IMAGE load_icon_file(const char *name) { LPTSTR tname; ICON_IMAGE icon; ! tname=str2tstr((LPSTR)name); icon=LoadImage(NULL, tname, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_LOADFROMFILE); str_free(tname); return icon; } --- 1031,1044 ---- ICON_IMAGE load_icon_file(const char *name) { LPTSTR tname; ICON_IMAGE icon; ! tname=str2tstr((LPSTR)name); + #ifdef _WIN32_WCE /* pdelaage 20140610 : LR_LOADFROMFILE unsupported in WCE, cannot be replaced by SHLoadDIBitmap in this context, but... */ + icon=wceLoadIconFromFile(tname);/* pdelaage 20140610 : ...with some standard W32 coding, an equivalent to loadimage for BMP files (not ICO) is possible, for WCE...working also for W32 if needed */ + #else icon=LoadImage(NULL, tname, IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_LOADFROMFILE); + #endif str_free(tname); return icon; } *************** *** 1006,1011 **** --- 1047,1054 ---- NOTIFYICONDATA nid; static ICON_TYPE previous_icon=ICON_NONE; ICON_TYPE current_icon; + HICON prevIcon_l = (HICON) NULL; /* pdelaage 20140610 WCE */ + BOOL retval_l = FALSE; /* pdelaage 20140610 WCE */ if(!global_options.option.taskbar) { /* save menu resources */ if(tray_menu_handle) { /* disabled in the new configuration */ *************** *** 1026,1032 **** nid.uCallbackMessage=WM_SYSTRAY; /* notification message */ nid.hWnd=hwnd; /* window to receive notifications */ if(num<0) { ! _stprintf(nid.szTip, TEXT("Server is down")); current_icon=ICON_ERROR; } else if(num>0) { _stprintf(nid.szTip, TEXT("%d active session(s)"), num); --- 1069,1075 ---- nid.uCallbackMessage=WM_SYSTRAY; /* notification message */ nid.hWnd=hwnd; /* window to receive notifications */ if(num<0) { ! _stprintf(nid.szTip, TEXT("Server is down"));/* pdelaage 20140621 : Be careful that on WCE, szTip is ALWAYS WCHAR. Anyway ANSI version of stunnel for WCE, although possible with some port effort, is of no practical interest since UNICODE covers ANSI... */ current_icon=ICON_ERROR; } else if(num>0) { _stprintf(nid.szTip, TEXT("%d active session(s)"), num); *************** *** 1037,1046 **** } nid.hIcon=global_options.icon[current_icon]; if(current_icon!=previous_icon) { ! nid.uFlags|=NIF_ICON; ! previous_icon=current_icon; ! } ! if(Shell_NotifyIcon(NIM_MODIFY, &nid)) /* modify tooltip */ return; /* OK: taskbar icon exists */ /* tooltip update failed - try to create the icon */ nid.uFlags|=NIF_ICON; --- 1080,1097 ---- } nid.hIcon=global_options.icon[current_icon]; if(current_icon!=previous_icon) { ! #ifdef _WIN32_WCE /* pdelaage 20140610 : on WCE, the replaced Icon will be DELETED and LOST from the system resources, so that we have to duplicate it before losing it, and in the objective to restore it later. */ ! if (previous_icon != ICON_NONE) ! { ! prevIcon_l = global_options.icon[previous_icon]; ! global_options.icon[previous_icon] = DuplicateIcon((HINSTANCE) NULL, prevIcon_l); ! DestroyIcon(prevIcon_l);/* pdelaage 20140610: ok, the WCE system will do that, but it is better to do it explicitely, either if one day WCE doesn't do it anymore AND/OR if this code is reused in W32: something absolutely possible ...*/ ! } ! #endif ! nid.uFlags|=NIF_ICON; ! previous_icon=current_icon; ! } ! if(Shell_NotifyIcon(NIM_MODIFY, &nid)) /* modify tooltip */ return; /* OK: taskbar icon exists */ /* tooltip update failed - try to create the icon */ nid.uFlags|=NIF_ICON; *************** *** 1096,1106 **** 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); --- 1147,1159 ---- TCHAR *conf_string; /* pdelaage 20140609 : needed for UNICODE ShellExecute, because "configuration_file" is JUST ASCII !! */ /* TODO: port it to WCE */ + /* pdelaage 20140610 : DONE ! for ShellExecute in mywcedefs.c */ if(is_admin()) { conf_string = str2tstr(configuration_file); ! ShellExecute(main_window_handle, TEXT("open"), /* pdelaage 20140610 : reimplemenred for WCE, see mywcedefs.c */ TEXT("notepad.exe"), conf_string,/* pdelaage 20140609 : now UNICODE correct */ + /* pdelaage 20140610 : TODO : notepad is NOT available on CE, we have to find/suggest a free replacement: some exist. */ NULL, SW_SHOWNORMAL); str_free(conf_string); *************** *** 1109,1122 **** if(strchr(configuration_file, '\\')) { conf_path=str_dup(configuration_file); } else { ! 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); --- 1162,1177 ---- if(strchr(configuration_file, '\\')) { conf_path=str_dup(configuration_file); } else { ! GetCurrentDirectory(MAX_PATH, cwd);/* pdelaage 20140610 : reimplemenred for WCE, see mywcedefs.c */ ! /* pdelaage 20140621 : UNICODE in printf format spec */ ! conf_path=str_printf(TSTR_PRINTF_FORMAT"\\%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 */ + /* pdelaage 20140610 : TODO : notepad is NOT available on CE, we have to find/suggest a free replacement: some exist. */ NULL, SW_SHOWNORMAL); str_free(conf_string); *************** *** 1125,1130 **** --- 1180,1186 ---- } NOEXPORT BOOL is_admin(void) { + #ifndef _WIN32_WCE SID_IDENTIFIER_AUTHORITY NtAuthority={SECURITY_NT_AUTHORITY}; PSID admin_group; BOOL retval; *************** *** 1138,1143 **** --- 1194,1202 ---- FreeSid(admin_group); } return retval; + #else + return TRUE; /* pdelaage 20140610 :on WCE, user is always admin */ + #endif } /**************************************** windows service */ *************** *** 1161,1182 **** 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) { error_box("OpenSCManager"); 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); --- 1220,1242 ---- SC_HANDLE scm, service; TCHAR stunnel_exe_path[MAX_PATH], *tservice_path;/* pdelaage 20140609: UNICODE for GetModuleFileName, CreateService */ char *service_path; ! ! TCHAR service_description_string[256];/* pdelaage 20140621: Added service description for Services Manager */ ! SERVICE_DESCRIPTION service_description; ! scm=OpenSCManager(0, 0, SC_MANAGER_CREATE_SERVICE); if(!scm) { error_box("OpenSCManager"); return 1; } GetModuleFileName(0, stunnel_exe_path, MAX_PATH); ! /* pdelaage 20140609 : we CAN mix TCHAR* and char* in printf...provided we use the proper h or l FORMAT SPEC */ ! service_path=str_printf("\""TSTR_PRINTF_FORMAT"\" -service %hs", stunnel_exe_path, command_line); tservice_path = str2tstr(service_path); ! service=CreateService(scm, SERVICE_NAME, SERVICE_DISPLAY_NAME, /* pdelaage 20140623: Added service display-name for Service Manager */ ! SERVICE_ALL_ACCESS, SERVICE_WIN32_OWN_PROCESS|SERVICE_INTERACTIVE_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_NORMAL, tservice_path, NULL, NULL, NULL, NULL, NULL); *************** *** 1187,1192 **** --- 1247,1260 ---- CloseServiceHandle(scm); return 1; } + + /* pdelaage 20140623 : set more explicit description for the service, in Windows Service Control Manager */ + if (LoadString(ghInst, IDS_SERVICE_DESC, service_description_string, sizeof(service_description_string))) + { + service_description.lpDescription = service_description_string; + ChangeServiceConfig2(service, SERVICE_CONFIG_DESCRIPTION, &service_description); + } + message_box("Service installed", MB_ICONINFORMATION); CloseServiceHandle(service); CloseServiceHandle(scm); diff -cr patch1/src/vc.mak patch2/src/vc.mak *** patch1/src/vc.mak 2014-06-09 21:32:43.031250000 +0200 --- patch2/src/vc.mak 2014-06-21 17:54:40.734375000 +0200 *************** *** 4,9 **** --- 4,12 ---- # 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 + # pdelaage 20140610 : BUG FIX : no clean working because of a typo in GUIOBJS and NOGUIOBJS names in clean rule + # pdelaage 20140610 : BUG FIX : no clean working because of a typo in SHAREOBJS list ($(OBJ)/fd.obj instead of xx\xx) + # pdelaage 20140610 : Explicit link to comctl32.lib for InitCommonControls call # the compilation requires: # - Visual C++ 2005 Express Edition with Platform SDK *************** *** 50,56 **** $(OBJ)\verify.obj $(OBJ)\file.obj $(OBJ)\client.obj \ $(OBJ)\protocol.obj $(OBJ)\sthreads.obj $(OBJ)\log.obj \ $(OBJ)\options.obj $(OBJ)\network.obj $(OBJ)\resolver.obj \ ! $(OBJ)\str.obj $(OBJ)/fd.obj GUIOBJS=$(OBJ)\ui_win_gui.obj $(OBJ)\resources.res NOGUIOBJS=$(OBJ)\ui_win_cli.obj --- 53,59 ---- $(OBJ)\verify.obj $(OBJ)\file.obj $(OBJ)\client.obj \ $(OBJ)\protocol.obj $(OBJ)\sthreads.obj $(OBJ)\log.obj \ $(OBJ)\options.obj $(OBJ)\network.obj $(OBJ)\resolver.obj \ ! $(OBJ)\str.obj $(OBJ)\fd.obj GUIOBJS=$(OBJ)\ui_win_gui.obj $(OBJ)\resources.res NOGUIOBJS=$(OBJ)\ui_win_cli.obj *************** *** 70,76 **** LDFLAGS=/NOLOGO SHAREDLIBS=ws2_32.lib user32.lib shell32.lib ! GUILIBS=advapi32.lib comdlg32.lib crypt32.lib gdi32.lib psapi.lib NOGUILIBS= SSLLIBS=/LIBPATH:"$(LIBDIR)" libeay32.lib ssleay32.lib # static linking: --- 73,79 ---- LDFLAGS=/NOLOGO SHAREDLIBS=ws2_32.lib user32.lib shell32.lib ! GUILIBS=advapi32.lib comctl32.lib comdlg32.lib crypt32.lib gdi32.lib psapi.lib NOGUILIBS= SSLLIBS=/LIBPATH:"$(LIBDIR)" libeay32.lib ssleay32.lib # static linking: *************** *** 88,95 **** clean: -@ del $(SHAREDOBJS) >NUL 2>&1 ! -@ del $(GUIBJS) >NUL 2>&1 ! -@ del $(NOGUIBJS) >NUL 2>&1 # -@ del *.manifest >NUL 2>&1 -@ del $(BIN)\stunnel.exe >NUL 2>&1 -@ del $(BIN)\stunnel.exe.manifest >NUL 2>&1 --- 91,98 ---- clean: -@ del $(SHAREDOBJS) >NUL 2>&1 ! -@ del $(GUIOBJS) >NUL 2>&1 ! -@ del $(NOGUIOBJS) >NUL 2>&1 # -@ del *.manifest >NUL 2>&1 -@ del $(BIN)\stunnel.exe >NUL 2>&1 -@ del $(BIN)\stunnel.exe.manifest >NUL 2>&1