diff -urN openvpn-2.0_rc16-orig/chartable.h openvpn-2.0_rc16/chartable.h
--- openvpn-2.0_rc16-orig/chartable.h	Thu Jan  1 00:00:00 1970
+++ openvpn-2.0_rc16/chartable.h	Wed Mar  2 23:17:50 2005
@@ -0,0 +1,286 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+#ifdef WIN32
+ 
+WCHAR unicode_to_ascii[256] = {
+0x0000,
+0x0001,
+0x0002,
+0x0003,
+0x0004,
+0x0005,
+0x0006,
+0x0007,
+0x0008,
+0x0009,
+0x000a,
+0x000b,
+0x000c,
+0x000d,
+0x000e,
+0x000f,
+0x0010,
+0x0011,
+0x0012,
+0x0013,
+0x0014,
+0x0015,
+0x0016,
+0x0017,
+0x0018,
+0x0019,
+0x001a,
+0x001b,
+0x001c,
+0x001d,
+0x001e,
+0x001f,
+0x0020,
+0x0021,
+0x0022,
+0x0023,
+0x0024,
+0x0025,
+0x0026,
+0x0027,
+0x0028,
+0x0029,
+0x002a,
+0x002b,
+0x002c,
+0x002d,
+0x002e,
+0x002f,
+0x0030,
+0x0031,
+0x0032,
+0x0033,
+0x0034,
+0x0035,
+0x0036,
+0x0037,
+0x0038,
+0x0039,
+0x003a,
+0x003b,
+0x003c,
+0x003d,
+0x003e,
+0x003f,
+0x0040,
+0x0041,
+0x0042,
+0x0043,
+0x0044,
+0x0045,
+0x0046,
+0x0047,
+0x0048,
+0x0049,
+0x004a,
+0x004b,
+0x004c,
+0x004d,
+0x004e,
+0x004f,
+0x0050,
+0x0051,
+0x0052,
+0x0053,
+0x0054,
+0x0055,
+0x0056,
+0x0057,
+0x0058,
+0x0059,
+0x005a,
+0x005b,
+0x005c,
+0x005d,
+0x005e,
+0x005f,
+0x0060,
+0x0061,
+0x0062,
+0x0063,
+0x0064,
+0x0065,
+0x0066,
+0x0067,
+0x0068,
+0x0069,
+0x006a,
+0x006b,
+0x006c,
+0x006d,
+0x006e,
+0x006f,
+0x0070,
+0x0071,
+0x0072,
+0x0073,
+0x0074,
+0x0075,
+0x0076,
+0x0077,
+0x0078,
+0x0079,
+0x007a,
+0x007b,
+0x007c,
+0x007d,
+0x007e,
+0x007f,
+0x00c7,
+0x00fc,
+0x00e9,
+0x00e2,
+0x00e4,
+0x00e0,
+0x00e5,
+0x00e7,
+0x00ea,
+0x00eb,
+0x00e8,
+0x00ef,
+0x00ee,
+0x00ec,
+0x00c4,
+0x00c5,
+0x00c9,
+0x00e6,
+0x00c6,
+0x00f4,
+0x00f6,
+0x00f2,
+0x00fb,
+0x00f9,
+0x00ff,
+0x00d6,
+0x00dc,
+0x00f8,
+0x00a3,
+0x00d8,
+0x00d7,
+0x0192,
+0x00e1,
+0x00ed,
+0x00f3,
+0x00fa,
+0x00f1,
+0x00d1,
+0x00aa,
+0x00ba,
+0x00bf,
+0x00ae,
+0x00ac,
+0x00bd,
+0x00bc,
+0x00a1,
+0x00ab,
+0x00bb,
+0x2591,
+0x2592,
+0x2593,
+0x2502,
+0x2524,
+0x00c1,
+0x00c2,
+0x00c0,
+0x00a9,
+0x2563,
+0x2551,
+0x2557,
+0x255d,
+0x00a2,
+0x00a5,
+0x2510,
+0x2514,
+0x2534,
+0x252c,
+0x251c,
+0x2500,
+0x253c,
+0x00e3,
+0x00c3,
+0x255a,
+0x2554,
+0x2569,
+0x2566,
+0x2560,
+0x2550,
+0x256c,
+0x00a4,
+0x00f0,
+0x00d0,
+0x00ca,
+0x00cb,
+0x00c8,
+0x0131,
+0x00cd,
+0x00ce,
+0x00cf,
+0x2518,
+0x250c,
+0x2588,
+0x2584,
+0x00a6,
+0x00cc,
+0x2580,
+0x00d3,
+0x00df,
+0x00d4,
+0x00d2,
+0x00f5,
+0x00d5,
+0x00b5,
+0x00fe,
+0x00de,
+0x00da,
+0x00db,
+0x00d9,
+0x00fd,
+0x00dd,
+0x00af,
+0x00b4,
+0x00ad,
+0x00b1,
+0x2017,
+0x00be,
+0x00b6,
+0x00a7,
+0x00f7,
+0x00b8,
+0x00b0,
+0x00a8,
+0x00b7,
+0x00b9,
+0x00b3,
+0x00b2,
+0x25a0,
+0x00a0
+};
+
+#endif
diff -urN openvpn-2.0_rc16-orig/config-win32.h openvpn-2.0_rc16/config-win32.h
--- openvpn-2.0_rc16-orig/config-win32.h	Sun Feb 20 10:46:46 2005
+++ openvpn-2.0_rc16/config-win32.h	Wed Mar  2 23:00:26 2005
@@ -222,7 +222,7 @@
 #define PACKAGE_TARNAME "openvpn"
 
 /* Define to the version of this package. */
-#define PACKAGE_VERSION "2.0_rc16" /* AUTO_VERSION */
+#define PACKAGE_VERSION "2.0_rc16ms1" /* AUTO_VERSION */
 
 /* Define to the full name and version of this package. */
 #ifdef DEBUG_LABEL
diff -urN openvpn-2.0_rc16-orig/makefile.w32 openvpn-2.0_rc16/makefile.w32
--- openvpn-2.0_rc16-orig/makefile.w32	Sun Feb 20 10:49:50 2005
+++ openvpn-2.0_rc16/makefile.w32	Wed Mar  2 23:21:00 2005
@@ -54,6 +54,8 @@
 
 LIB_DIRS_DMALLOC = ${LIB_DIRS} -L${DMALLOC}
 
+WINDRES = windres.exe
+
 EXE = openvpn.exe
 
 HEADERS = \
@@ -61,6 +63,7 @@
 	basic.h \
 	buffer.h \
 	circ_list.h \
+	chartable.h \
 	common.h \
 	tap-win32/common.h \
         config-win32.h \
@@ -119,7 +122,8 @@
 	syshead.h \
         thread.h \
 	tun.h \
-	win32.h
+	win32.h \
+	win32gui.h
 
 OBJS =  base64.o \
 	buffer.o \
@@ -170,7 +174,9 @@
 	status.o \
 	thread.o \
 	tun.o \
-	win32.o
+	win32.o \
+	win32gui.o \
+	win32gui.res
 
 dynamic : MY_CC = ${CC}
 dynamic : MY_INCLUDE_DIRS = ${INCLUDE_DIRS}
@@ -192,3 +198,6 @@
 
 %.o : %.c ${HEADERS}
 	${MY_CC} ${MY_INCLUDE_DIRS} -c $< -o $@
+
+win32gui.res : win32gui.rc win32gui-res.h
+	$(WINDRES) -i win32gui.rc -J rc -o win32gui.res -O coff
diff -urN openvpn-2.0_rc16-orig/options.c openvpn-2.0_rc16/options.c
--- openvpn-2.0_rc16-orig/options.c	Thu Feb 10 18:18:08 2005
+++ openvpn-2.0_rc16/options.c	Wed Mar  2 23:01:35 2005
@@ -30,6 +30,7 @@
 
 #ifdef WIN32
 #include "config-win32.h"
+#include "win32gui.h"
 #else
 #include "config.h"
 #endif
@@ -486,6 +487,7 @@
   "                       optional parameter controls the initial state of ex.\n"
   "--show-net-up   : Show " PACKAGE_NAME "'s view of routing table and net adapter list\n"
   "                  after TAP adapter is up and routes have been added.\n"
+  "--win32-gui     : Get user input via a GUI dialog instead of console window.\n"
   "Windows Standalone Options:\n"
   "\n"
   "--show-adapters : Show all TAP-Win32 adapters.\n"
@@ -4031,6 +4033,11 @@
 	  ++i;
 	  options->exit_event_initial_state = (atoi(p[2]) != 0);
 	}
+    }
+  else if (streq (p[0], "win32-gui"))
+    {
+      VERIFY_PERMISSION (OPT_P_GENERAL);
+      enable_userinput_via_dialog_win32();
     }
   else if (streq (p[0], "user") && p[1])
     {
diff -urN openvpn-2.0_rc16-orig/win32.c openvpn-2.0_rc16/win32.c
--- openvpn-2.0_rc16-orig/win32.c	Sun Jan  9 16:46:42 2005
+++ openvpn-2.0_rc16/win32.c	Wed Mar  2 23:01:15 2005
@@ -38,6 +38,7 @@
 #include "mtu.h"
 #include "sig.h"
 #include "win32.h"
+#include "win32gui.h"
 
 #include "memdbg.h"
 
@@ -684,7 +685,7 @@
 }
 
 /*
- * Get input from console.
+ * Get input from console or a dialog(--win32-gui).
  *
  * Return false on input error, or if service
  * exit event is signaled.
@@ -705,6 +706,9 @@
 
   in = GetStdHandle (STD_INPUT_HANDLE);
   err = get_orig_stderr ();
+
+  if (use_userinput_dialog_win32())
+    return get_userinput_dialog_win32(prompt, input, capacity);
 
   if (in != INVALID_HANDLE_VALUE
       && err != INVALID_HANDLE_VALUE
diff -urN openvpn-2.0_rc16-orig/win32gui-res.h openvpn-2.0_rc16/win32gui-res.h
--- openvpn-2.0_rc16-orig/win32gui-res.h	Thu Jan  1 00:00:00 1970
+++ openvpn-2.0_rc16/win32gui-res.h	Wed Mar  2 22:58:56 2005
@@ -0,0 +1,29 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single TCP/UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* Ask for User Input Dialog */
+#define	IDD_USERINPUT			100
+#define	EDIT_TEXTBOX			101
+#define TEXT_LABEL                      102
diff -urN openvpn-2.0_rc16-orig/win32gui.c openvpn-2.0_rc16/win32gui.c
--- openvpn-2.0_rc16-orig/win32gui.c	Thu Jan  1 00:00:00 1970
+++ openvpn-2.0_rc16/win32gui.c	Wed Mar  2 23:24:12 2005
@@ -0,0 +1,153 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single TCP/UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+/* This file contains code to get user input from
+ * a windows dialog instead of the console window.
+ * Written by Mathias Sundman, Mar 02, 2005.
+ */
+
+#ifdef WIN32
+
+#include "config-win32.h"
+#include "basic.h"
+#include "win32gui-res.h"
+#include "chartable.h"
+#include <windows.h>
+
+int get_userinput_from_dialog = 0;
+
+struct user_input
+{
+  char response[100];
+  char prompt[100];
+};
+
+int ConvertUnicode2Ascii(WCHAR str_unicode[], char str_ascii[], unsigned int str_ascii_size)
+{
+  unsigned int i;
+  unsigned int j;
+  int illegal_chars = false;
+  char *str_unicode_ptr = (char *) str_unicode;
+  for (i=0; (i < wcslen(str_unicode)) && (i < (str_ascii_size - 1)); i++)
+    {
+      for (j=0; j <= 256; j++)
+        {
+          if (j == 256)
+            {
+              illegal_chars = true;
+              j = 0x2e;
+              break;
+            }
+          if (str_unicode[i] == unicode_to_ascii[j]) break;
+        }
+      str_ascii[i] = (char) j;
+   }
+  str_ascii[i] = '\0';
+
+  if (illegal_chars)
+    return(false);
+  else
+    return(true);
+} 
+
+BOOL CALLBACK UserInputDialogFunc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+  static struct user_input *user_input;
+  static char empty_string[100];
+  WCHAR unicode_input[100];
+
+  switch (msg) {
+
+    case WM_INITDIALOG:
+      user_input = (struct user_input *) lParam;
+      SetDlgItemText(hwndDlg, TEXT_LABEL, user_input->prompt);
+      SetForegroundWindow(hwndDlg);
+      break;
+
+    case WM_COMMAND:
+      switch (LOWORD(wParam)) {
+
+        case IDOK:			// button
+          GetDlgItemTextW(hwndDlg, EDIT_TEXTBOX, unicode_input, sizeof(unicode_input)/2 - 1);
+
+          /* Convert user input from Unicode to Ascii (CP850) */
+          ConvertUnicode2Ascii(unicode_input, user_input->response, sizeof(user_input->response) - 1); 
+
+          /* Clear buffers */
+          SetDlgItemText(hwndDlg, EDIT_TEXTBOX, empty_string);
+	  CLEAR(unicode_input);
+
+          EndDialog(hwndDlg, LOWORD(wParam));
+          return TRUE;
+
+        case IDCANCEL:
+          EndDialog(hwndDlg, LOWORD(wParam));
+          return TRUE;
+      }
+      break;
+    case WM_CLOSE:
+      EndDialog(hwndDlg, LOWORD(wParam));
+      return TRUE;
+     
+  }
+  return FALSE;
+}
+
+int
+get_userinput_dialog_win32(const char *prompt, char *input, const int capacity)
+{
+
+  struct user_input user_input;
+
+  CLEAR (user_input);
+  strncpy(user_input.prompt, prompt, sizeof(user_input.prompt));
+
+  Sleep(200);
+  if (DialogBoxParam(NULL, (LPCTSTR)IDD_USERINPUT, NULL, 
+     (DLGPROC)UserInputDialogFunc, (LPARAM)&user_input) == IDCANCEL)
+    { 
+      CLEAR(user_input);
+      return false;
+    }
+
+  strncpy(input, user_input.response, capacity);
+  CLEAR(user_input);
+  return true;
+}
+
+void
+enable_userinput_via_dialog_win32()
+{
+  get_userinput_from_dialog = 1;
+}
+
+int
+use_userinput_dialog_win32()
+{
+  return get_userinput_from_dialog;
+}
+
+#endif
+
diff -urN openvpn-2.0_rc16-orig/win32gui.h openvpn-2.0_rc16/win32gui.h
--- openvpn-2.0_rc16-orig/win32gui.h	Thu Jan  1 00:00:00 1970
+++ openvpn-2.0_rc16/win32gui.h	Wed Mar  2 22:56:46 2005
@@ -0,0 +1,32 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef WIN32
+
+int get_userinput_dialog_win32(const char *prompt, char *input, const int capacity);
+int use_userinput_dialog_win32();
+void enable_userinput_via_dialog_win32();
+
+#endif
diff -urN openvpn-2.0_rc16-orig/win32gui.rc openvpn-2.0_rc16/win32gui.rc
--- openvpn-2.0_rc16-orig/win32gui.rc	Thu Jan  1 00:00:00 1970
+++ openvpn-2.0_rc16/win32gui.rc	Wed Mar  2 22:58:34 2005
@@ -0,0 +1,39 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single TCP/UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "win32gui-res.h"
+#include <windows.h>
+
+IDD_USERINPUT DIALOGEX 6, 18, 120, 51
+STYLE WS_POPUP | WS_VISIBLE | WS_CAPTION | DS_CENTER | DS_SETFOREGROUND
+EXSTYLE WS_EX_TOPMOST
+CAPTION "OpenVPN"
+FONT 8, "MS Sans Serif"
+BEGIN
+    LTEXT           "", TEXT_LABEL, 6, 6, 100, 10
+    EDITTEXT        EDIT_TEXTBOX, 6, 17, 107, 12, ES_PASSWORD | ES_AUTOHSCROLL
+    PUSHBUTTON      "OK", IDOK, 6, 33, 50, 14
+    PUSHBUTTON      "Cancel", IDCANCEL, 64, 33, 50, 14
+END

