- Operating System: Windows 10 x64 Build 21H2
- Compiler Suite: Visual Studio 2019
- unpack "OpenVPN_v2.5.4\openvpn-2.5.4.7z" to "C:\openvpn-2.5.4"
This step is not necessary if you compiled OpenVPN v2.5.4 include files before!
- start Visual Studio 2019 > Create a new project > Empty Project > Next >
Project name: openvpn
Location: C:\Users\Public
Solution name: openvpn
check "Place solution and project in the same directory"
> Create
- copy all files and directories from "C:\openvpn-2.5.4\src\openvpn" to "C:\Users\Public\openvpn"
Do not overwrite the files "openvpn.vcxproj" and "openvpn.vcxproj.filters".
- delete the following files from the directory "C:\Users\Public\openvpn":
Makefile.am
Makefile.in
- copy the file "C:\openvpn-2.5.4\config-msvc.h" to "C:\Users\Public\openvpn"
- copy the file "C:\openvpn-2.5.4\include\openvpn-msg.h" to "C:\Users\Public\openvpn"
- copy the file "C:\openvpn-2.5.4\include\openvpn-plugin.h" to "C:\Users\Public\openvpn"
- copy the file "OpenVPN_v2.5.4\block_dns.c" to "C:\Users\Public\openvpn" and overwrite
the existing file
This newly created C source file contains code to support DNS leak blocking for Windows XP.
- copy the file "OpenVPN_v2.5.4\config-msvc-version.h" to "C:\Users\Public\openvpn"
- copy the file "OpenVPN_v2.5.4\route.c" to "C:\Users\Public\openvpn" and overwrite the
existing file
This changes the function get_default_gateway_ipv6 and simply returns, because Windows XP does not
support IPv6 at all correctly without a dual stack in combination with IPv4. We can discard this
completely and simply return from the function. The implementation of GetBestRoute in Windows XP
does not support IPv6 at all.
- copy the file "OpenVPN_v2.5.4\tap-windows.h" to "C:\Users\Public\openvpn"
- copy the file "OpenVPN_v2.5.4\tun.c" to "C:\Users\Public\openvpn" and overwrite the
existing file
This changes the function windows_set_mtu to compile on Windows XP. The patch and function will
not work at all. We tried several methods to set the MTU without success. Read the comments inside
the code for more details.
- copy the file "OpenVPN_v2.5.4\versionhelpers.h" to "C:\Users\Public\openvpn"
- copy "C:\openssl-v1.1.1m-shared" to "C:\Users\Public\openvpn\OpenSSL_v1.1.1m"
- delete the following directories:
C:\Users\Public\openvpn\OpenSSL_v1.1.1m\bin
C:\Users\Public\openvpn\OpenSSL_v1.1.1m\html
- copy "C:\lzo-2.10" to "C:\Users\Public\openvpn\lzo-2.10"
- delete all files and directories in the folder "C:\Users\Public\openvpn\lzo-2.10"
except "include", "lzo2.dll" and "lzo2.lib"
- copy "C:\pkcs11-helper-1.28.0" to "C:\Users\Public\openvpn\pkcs11-helper-1.28.0"
- delete all files and directories in the folder "C:\Users\Public\openvpn\pkcs11-helper-1.28.0"
except "include" and "lib"
- delete the following files:
C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\Makefile.am
C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\Makefile.in
C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\pkcs11-helper-1.0\Makefile.am
C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\pkcs11-helper-1.0\Makefile.in
C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\pkcs11-helper-1.0\pkcs11h-version.h.in
- delete all files in the folder "C:\Users\Public\openvpn\pkcs11-helper-1.28.0\lib" except
"libpkcs11-helper-1.dll" and "pkcs11-helper.dll.lib"
- in VS2019 Solution Explorer right click on openvpn "Header Files" > Add > Existing Item... > in the
"File name" field enter "*.h" and press Enter > select first header file press Shift and click on
the last header file > Add
- right click on openvpn "Resource Files" > Add > Existing Item... > select "openvpn_win32_resources.rc" > Add
- right click on openvpn "Source Files" > Add > Existing Item... > in the "File name" field enter "*.c" and
press Enter > select first C source file press Shift and click on the last C source file > Add
- in Solution Explorer right click on "Solution 'openvpn' (1 project)" > Add > New Project... >
Empty Project > Next >
Project Name: compat
Location: C:\Users\Public
> Create
- copy all files from "C:\openvpn-2.5.4\src\compat" to "C:\Users\Public\compat"
Do not overwrite the files "openvpn.vcxproj" and "openvpn.vcxproj.filters".
- delete the following files from the directory "C:\Users\Public\compat":
Debug.props
Makefile.am
Makefile.in
PropertySheet.props
Release.props
- copy the file "C:\openvpn-2.5.4\config-msvc.h" to "C:\Users\Public\compat"
- copy the file "OpenVPN_v2.5.4\config-msvc-version.h" to "C:\Users\Public\compat"
- in VS2019 Solution Explorer right click on compat "Header Files" > Add > Existing Item... > in the
"File name" field enter "*.h" and press Enter > select first header file press Shift and click on
the last header file > Add
- right click on compat "Source Files" > Add > Existing Item... > in the "File name" field enter "*.c" and
press Enter > select first C source file press Shift and click on the last C source file > Add
- in Solution Explorer select compat > Menu > Project > Properties > choose Configuration:
All Configurations > Platform: All Platforms and change the following values:
Configuration Properties > General
- Platform Toolset: Visual Studio 2017 - Windows XP (v141_xp)
- Configuration Type: Static library (.lib)
Configuration Properties > C/C++ > Preprocessor
- Preprocessor Definitions > choose arrow > <Edit...> > enter
_CRT_SECURE_NO_WARNINGS
> OK
Configuration Properties > C/C++ > Command Line
- Additional Options > enter
/D_WIN32_WINNT=0x0501
Configuration Properties > Linker > Manifest File
- Generate Manifest: No (/MANIFEST:NO)
> OK
- open the file "C:\Users\Public\compat\config-msvc.h" and change code line 1 from
#include <config-msvc-version.h>
to
#include "config-msvc-version.h"
in addition add a new line before line 172 and insert the following code
#define _WIN32_WINNT_VISTA 0x0600
to solve the warning "Support for targeting Windows XP is deprecated and will not be present in
future releases of Visual Studio." do the following steps:
In Solution Explorer select compat > Menu > View > Property Manager > right click "compat" >
Add New Project Property Sheet... > Add > expand "compat" > expand "Debug | Win32" > right
click on PropertySheet > Properties > Common Properties > User Macros > button "Add Macro":
Name: XPDeprecationWarning
Value: false
> 2 x OK
This property sheets gets added to every build configuration automatically.
in Solution Explorer select openvpn > Menu > Project > Properties > choose Configuration:
All Configurations > Platform: All Platforms and change the following values:
Configuration Properties > General
- Platform Toolset: Visual Studio 2017 - Windows XP (v141_xp)
Configuration Properties > VC++ Directories
- Include Directories > choose arrow > <Edit...> > choose a new line for every value listed here > enter
..\compat
$(SolutionDir)\lzo-2.10\include
$(SolutionDir)\OpenSSL_v1.1.1m\include
$(SolutionDir)\pkcs11-helper-1.28.0\include
> OK
- Library Directories > choose arrow > <Edit...> > choose a new line for every value listed here > enter
$(OutDir)
This is used for compat.lib static library, otherwise the library is not found.
$(SolutionDir)\lzo-2.10
$(SolutionDir)\OpenSSL_v1.1.1m\lib
$(SolutionDir)\pkcs11-helper-1.28.0\lib
> OK
Configuration Properties > C/C++ > General
- Warning Level: Level2 (/W2)
This will suppress 238 warnings. The developers also do this in the original openvpn VS2019 solution.
Configuration Properties > C/C++ > Preprocessor
- Preprocessor Definitions > choose arrow > <Edit...> > enter
_CRT_NONSTDC_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS
> OK
Configuration Properties > C/C++ > Command Line
- Additional Options > enter
/D_WIN32_WINNT=0x0501
Configuration Properties > Linker > Input
- Additional Dependencies > choose arrow > <Edit...> > enter
compat.lib
libssl.lib
libcrypto.lib
lzo2.lib
pkcs11-helper.dll.lib
gdi32.lib
ws2_32.lib
wininet.lib
crypt32.lib
iphlpapi.lib
winmm.lib
rpcrt4.lib
setupapi.lib
advapi32.lib
> OK
Configuration Properties > Linker > Manifest File
- Generate Manifest: No (/MANIFEST:NO)
> OK
in Solution Explorer select openvpn > Menu > Project > Project Dependencies... > tab Dependencies
> Project: choose openvpn > Depends on: check compat > OK
open the file "C:\Users\Public\openvpn\config-msvc.h" and change code line 1 from
#include <config-msvc-version.h>
to
#include "config-msvc-version.h"
in addition add a new line before line 172 and insert the following code
#define _WIN32_WINNT_VISTA 0x0600
open file "C:\Users\Public\openvpn\tun.h" and change the code line 29 from
#include <tap-windows.h>
to
#include "tap-windows.h"
open file "C:\Users\Public\openvpn\win32.c" and change the code line 50 from
#include <versionhelpers.h>
to
#include "versionhelpers.h"
open file "C:\Users\Public\openvpn\syshead.h" and change the code line 586 from
#define ENABLE_CRYPTOAPI
to
open file "C:\Users\Public\openvpn\console_systemd.c" and change the code line 30 from
#include "config.h"
to
open file "C:\Users\Public\openvpn\ssl_ncp.h" and change code line 53 from
check_pull_client_ncp(struct context *c, int found);
to
check_pull_client_ncp(struct context *c, const int found);
open file "C:\Users\Public\openvpn\auth_token.c" and change code line 62 from
const char *state;
to
const char *state = "Invalid";
open file "C:\Users\Public\openvpn\pkcs11-helper-1.28.0\include\pkcs11-helper-1.0\pkcs11.h"
and change code line 1213 from
struct ck_interface **interface,
to
struct ck_interface **Interface,
to solve the warning "Support for targeting Windows XP is deprecated and will not be present in
future releases of Visual Studio." do the following steps:
In Solution Explorer select openvpn > Menu > View > Property Manager > right click "openvpn" >
Add New Project Property Sheet... > Add > expand "openvpn" > expand "Debug | Win32" > right
click on PropertySheet > Properties > Common Properties > User Macros > button "Add Macro":
Name: XPDeprecationWarning
Value: false
> 2 x OK
This property sheets gets added to every build configuration automatically.
choose Menu > Build > Configuration Manager... > Active solution configuration: Release >
Active solution platform: x86 > Close
in Solution Explorer select compat > Menu > Project > Properties > choose Configuration:
Active(Release) > Platform: Active(Win32) and change the following values:
Configuration Properties > C/C++ > Optimization
- Optimization: Maximum Optimization (Favor Size) (/O1)
- Enable Intrinsic Functions: No
- Favor Size Or Speed: Favor small code (/Os)
> OK
in Solution Explorer select openvpn > Menu > Project > Properties > choose Configuration:
Active(Release) > Platform: Active(Win32) and change the following values:
Configuration Properties > C/C++ > Optimization
- Optimization: Maximum Optimization (Favor Size) (/O1)
- Enable Intrinsic Functions: No
- Favor Size Or Speed: Favor small code (/Os)
Linker > Debugging
> OK
choose Menu > Build > Rebuild Solution
We can now compile the debug and release configuration for Windows XP without any errors or warnings.
The final source code package is located at "OpenVPN_v2.5.4\openvpn_v2.5.4_20220123_for_XP.7z".
- Operating System: Windows 10 x64 Build 21H2
- Compiler Suite: Visual Studio 2019
- unpack "OpenVPN-GUI_v11.26\openvpn-gui-11.7z" to "C:\openvpn-gui"
- start Visual Studio 2019 > Create a new project > Empty Project > Next >
Project name: openvpn-gui
Location: C:\Users\Public
Solution name: openvpn-gui
check "Place solution and project in the same directory"
> Create
- copy all files and directories from "C:\openvpn-gui" to "C:\Users\Public\openvpn-gui"
- delete the following files from the directory "C:\Users\Public\openvpn-gui":
aclocal.m4
compile
config.guess
config.h.in
config.sub
configure
configure.ac
COPYING
COPYRIGHT.GPL
depcomp
install-sh
Makefile.am
Makefile.in
missing
- move all files from the directory "C:\Users\Public\openvpn-gui\res" to
"C:\Users\Public\openvpn-gui"
- delete the directory "C:\Users\Public\openvpn-gui\res"
- copy the file "OpenVPN-GUI_v11.26\config.h" to "C:\Users\Public\openvpn-gui"
- copy the file "OpenVPN-GUI_v11.26\versionhelpers.h" to "C:\Users\Public\openvpn-gui"
- delete the directory "C:\OpenSSL_v1.1.1m" if it is present
- unpack "OpenSSL_v1.1.1m\openssl-v1.1.1m-shared.7z" to "C:\OpenSSL_v1.1.1m"
- copy "C:\OpenSSL_v1.1.1m" to "C:\Users\Public\openvpn-gui\OpenSSL_v1.1.1m"
- delete the following directories:
C:\Users\Public\openvpn-gui\OpenSSL_v1.1.1m\bin
C:\Users\Public\openvpn-gui\OpenSSL_v1.1.1m\html
- in VS2019 Solution Explorer right click on openvpn-gui "Header Files" > Add > Existing Item... >
in the "File name" field enter "*.h" and press Enter > select first header file press Shift and
click on the last header file > Add
- right click on "Resource Files" > Add > Existing Item... > select "openvpn-gui-res.rc" > Add
- right click on "Source Files" > Add > Existing Item... > in the "File name" field enter "*.c" and
press Enter > select first C source file press Shift and click on the last C source file > Add
- in Solution Explorer select openvpn-gui > Menu > Project > Properties > choose Configuration:
All Configurations > Platform: All Platforms and change the following values:
Configuration Properties > General
- Platform Toolset: Visual Studio 2017 - Windows XP (v141_xp)
- Character Set: Use Unicode Character Set
Configuration Properties > VC++ Directories
- Include Directories > choose arrow > <Edit...> > choose New Line > enter
$(SolutionDir)\OpenSSL_v1.1.1m\include
> OK
- Library Directories > choose arrow > <Edit...> > choose New Line > enter
$(SolutionDir)\OpenSSL_v1.1.1m\lib
> OK
Configuration Properties > C/C++ > Preprocessor
- Preprocessor Definitions > choose arrow > <Edit...> > enter
_CRT_NONSTDC_NO_DEPRECATE
_CRT_SECURE_NO_WARNINGS
> OK
Configuration Properties > C/C++ > Command Line
- Additional Options > enter
/D "HAVE_CONFIG_H" /D "WIN32_LEAN_AND_MEAN" /D_WIN32_WINNT=0x0501
Configuration Properties > Linker > Input
- Additional Dependencies > choose arrow > <Edit...> > enter
ws2_32.lib
libcrypto.lib
libssl.lib
secur32.lib
netapi32.lib
comctl32.lib
wininet.lib
wtsapi32.lib
crypt32.lib
shlwapi.lib
winhttp.lib
> OK
Configuration Properties > Linker > Manifest File
- Generate Manifest: No (/MANIFEST:NO)
Configuration Properties > Linker > System
- SubSystem: Windows (/SUBSYSTEM:WINDOWS)
Configuration Properties > Resources > Command Line
- Additional Options > enter
/D "HAVE_CONFIG_H"
> OK
- Menu > Build > Rebuild Solution > Menu > View > Error List
- click on all errors "Cannot open include file: 'config.h': No such file or directory" and change
the line from
#include <config.h>
to
#include "config.h"
click on all errors "'wcstok': too few arguments for call" and change the first code location from
pch = wcstok(buf, L"\r\n");
to
wchar_t *state;
pch = wcstok(buf, L"\r\n", &state);
change the second code location from
pch = wcstok(NULL, L"\r\n");
to
pch = wcstok(NULL, L"\r\n", &state);
Menu > Build > Rebuild Solution > Menu > View > Error List
click on all errors "'wcstok': too few arguments for call" and change the first code location from
LPWSTR token = wcstok(proxy_str, delim);
to
wchar_t *state;
LPWSTR token = wcstok(proxy_str, delim, &state);
change the second code location from
token = wcstok(NULL, delim);
to
token = wcstok(NULL, delim, &state);
click on error "'AURL_ENABLEURL': undeclared identifier" and change the code from
SendMessage(hmsg, EM_AUTOURLDETECT, AURL_ENABLEURL, 0);
to
#define AURL_ENABLEURL 1
SendMessage(hmsg, EM_AUTOURLDETECT, AURL_ENABLEURL, 0);
click on both errors "Cannot open include file 'versionhelpers.h': No such file or directory" and
change the code location from
#include <versionhelpers.h>
to
#include "versionhelpers.h"
click on error "Cannot open include file 'combaseapi.h': No such file or directory" and change the
code location from
#include <combaseapi.h>
to
Menu > Build > Rebuild Solution > Menu > View > Error List
click on warning "formal parameter 2 different from declaration" right click on the function
IsUserInGroup > Go To Declaration > change code location from
static BOOL IsUserInGroup(PSID sid, PTOKEN_GROUPS token_groups, const WCHAR *group_name);
to
static BOOL IsUserInGroup(PSID sid, const PTOKEN_GROUPS token_groups, const WCHAR *group_name);
click on warning "'CompareStringOrdinal' undefined; assuming extern returning int" and change the
code location from
int cmp = CompareStringOrdinal(nameval1, (int)len1, nameval2, (int)len2, ignore_case);
to
int cmp = wcsncmp(nameval1, nameval2, (len1 > len2 ? len2 : len1));
click on warning "'=': conversion from 'DWORD' to 'LANGID', possible loss of data" and change code
location from
gui_language = ( value != 0 ? value : GetUserDefaultUILanguage() );
to
gui_language = (LANGID)( value != 0 ? value : GetUserDefaultUILanguage() );
click on warning "formal parameter 2 different from declaration" and change code location from
LoadLocalizedStringBuf(PTSTR buffer, int bufferSize, const UINT stringId, ...)
to
LoadLocalizedStringBuf(PTSTR buffer, const int bufferSize, const UINT stringId, ...)
click on warning "'function': conversion from 'DWORD' to 'u_short', possible loss of data and
change code location from
c->manage.skaddr.sin_port = htons(o.mgmt_port_offset + config);
to
c->manage.skaddr.sin_port = htons((u_short)o.mgmt_port_offset + config);
click on warning "'RegGetValueW' undefined; assuming extern returning int" and change code location
from
if (RegGetValueW (regkey, NULL, L"version", RRF_RT_REG_BINARY, NULL, v, &len)
to
if (RegQueryValueEx(regkey, L"version", NULL, NULL, (LPBYTE)v, &len)
click on warning "'RegCopyTree' undefined; assuming extern returning int" and change code location
from
status = RegCopyTree (regkey_nilings, NULL, regkey_proxy);
to
status = SHCopyKey(regkey_nilings, NULL, regkey_proxy, 0);
click on warning "'RegDeleteTree' undefined; assuming extern returning int" and change code
location from
RegDeleteTree (HKEY_CURRENT_USER, GUI_REGKEY_HKCU);
to
SHDeleteKey(HKEY_CURRENT_USER, GUI_REGKEY_HKCU);
go to the start of the C source file registry.c and place the following include after <shlobj.h>
#include <shlwapi.h>
Menu > Build > Rebuild Solution > Menu > View > Error List
click on error "'TTI_ERROR_LARGE': undeclared identifier" and change the code location from
bt.ttiIcon = TTI_ERROR_LARGE;
to
#define TTI_ERROR_LARGE 6
bt.ttiIcon = TTI_ERROR_LARGE;
click on error "'IID_IFileOpenDialog': undeclared identifier", comment out the complete
function "BrowseFolder" and add the following replacement functions
INT CALLBACK BrowseCallbackProc(HWND hwnd, UINT uMsg, LPARAM lp, LPARAM pData)
{
if (uMsg == BFFM_INITIALIZED) SendMessage(hwnd, BFFM_SETSELECTION, TRUE, pData);
return 0;
}
static BOOL BrowseFolder(const WCHAR * initial_path, WCHAR * selected_path, size_t selected_path_size)
{
HRESULT initResult = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
if (FAILED(initResult))
{
return false;
}
BROWSEINFO br;
ZeroMemory(&br, sizeof(BROWSEINFO));
br.lpfn = BrowseCallbackProc;
br.ulFlags = BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE;
br.hwndOwner = NULL;
br.lParam = (LPARAM)initial_path;
LPITEMIDLIST pidl = NULL;
if ((pidl = SHBrowseForFolder(&br)) != NULL)
{
wchar_t path[MAX_PATH];
if (SHGetPathFromIDList(pidl, path))
{
wcsncpy(selected_path, path, wcslen(path));
}
}
CoUninitialize();
return true;
}
Menu > Build > Rebuild Solution > Menu > View > Error List
click on error "cannot open include file '../openvpn-gui-res.h'." and change the code location
from
#include "../openvpn-gui-res.h"
to
#include "openvpn-gui-res.h"
click on warning "'function': conversion from 'time_t' to 'unsigned int', possible loss of data"
and change the code location from
srand(time(NULL));
to
srand((unsigned int)time(NULL));
click on warning "'initializing': conversion from 'unsigned __int64' to 'double', possible loss of
data" and change the code location from
double x = c;
to
double x = (double)c;
click on warning "'function': conversion from 'time_t' to 'unsigned int', possible loss of data"
and change the code location from
srand(time(NULL));
to
srand((unsigned int)time(NULL));
click on warning "'function': different 'const' qualifiers" and change the code location from
void *tmp = realloc(options->auto_connect, sizeof(wchar_t *)*options->max_auto_connect);
to
void *tmp = realloc((void*)options->auto_connect, sizeof(wchar_t *)*options->max_auto_connect);
to solve the warning "Support for targeting Windows XP is deprecated and will not be present in
future releases of Visual Studio." do the following steps:
Menu > View > Property Manager > right click "openvpn-gui" > Add New Project Property Sheet... >
Add > expand "openvpn-gui" > expand "Debug | Win32" > right click on PropertySheet > Properties >
Common Properties > User Macros > button "Add Macro":
Name: XPDeprecationWarning
Value: false
> 2 x OK
This property sheets gets added to every build configuration automatically.
choose Menu > Build > Configuration Manager... > Active solution configuration: Release >
Active solution platform: x86 > Close
in Solution Explorer select openvpn-gui > Menu > Project > Properties > choose Configuration:
Active(Release) > Platform: Active(Win32) and change the following values:
Configuration Properties > C/C++ > Optimization
- Optimization: Maximum Optimization (Favor Size) (/O1)
- Enable Intrinsic Functions: No
- Favor Size Or Speed: Favor small code (/Os)
Linker > Debugging
> OK
choose Menu > Build > Rebuild Solution
We can now compile the debug and release configuration for Windows XP without any errors or warnings.
The final source code package is located at "OpenVPN-GUI_v11.26\openvpn-gui_v11.26_20220123_for_XP.7z".