Skip to contentSkip to conversation

Make openvpnserv compilable under Visual Studio.

PATCH Superseded [email protected]... 3 participants 7 messages Feb 22, 2016 – Feb 25, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Make openvpnserv compilable under Visual Studio.

From: Fish <[email protected]...>

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Use the correct typedef construct to define function types.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.

---
 src/openvpnserv/common.c                    |  2 +-
 src/openvpnserv/interactive.c               | 16 ++++++++--------
 src/openvpnserv/openvpnserv.vcxproj         | 12 ++++++++----
 src/openvpnserv/openvpnserv.vcxproj.filters | 10 ++++++++--
 4 files changed, 25 insertions(+), 15 deletions(-)
src/openvpnserv/common.c +1 -1
index a293796..9a58e39 100644
@@ -22,7 +22,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <service.h>
+#include "service.h"
 
 /*
  * These are necessary due to certain buggy implementations of (v)snprintf,
src/openvpnserv/interactive.c +8 -8
index 0f3d1d4..96a15f6 100644
@@ -390,7 +390,7 @@ InterfaceLuid (const char *iface_name, PNET_LUID luid)
   LPWSTR wide_name;
   int n;
 
-  typedef NETIO_STATUS WINAPI (*ConvertInterfaceAliasToLuidFn) (LPCWSTR, PNET_LUID);
+  typedef NETIO_STATUS (WINAPI *ConvertInterfaceAliasToLuidFn) (LPCWSTR, PNET_LUID);
   static ConvertInterfaceAliasToLuidFn ConvertInterfaceAliasToLuid = NULL;
   if (!ConvertInterfaceAliasToLuid)
     {
@@ -421,7 +421,7 @@ CmpAddress (LPVOID item, LPVOID address)
 static DWORD
 DeleteAddress (PMIB_UNICASTIPADDRESS_ROW addr_row)
 {
-  typedef NETIOAPI_API (*DeleteUnicastIpAddressEntryFn) (const PMIB_UNICASTIPADDRESS_ROW);
+  typedef NETIO_STATUS (NETIOAPI_API_ *DeleteUnicastIpAddressEntryFn) (const PMIB_UNICASTIPADDRESS_ROW);
   static DeleteUnicastIpAddressEntryFn DeleteUnicastIpAddressEntry = NULL;
 
   if (!DeleteUnicastIpAddressEntry)
@@ -445,8 +445,8 @@ HandleAddressMessage (address_message_t *msg, undo_lists_t *lists)
   PMIB_UNICASTIPADDRESS_ROW addr_row;
   BOOL add = msg->header.type == msg_add_address;
 
-  typedef NETIOAPI_API (*CreateUnicastIpAddressEntryFn) (const PMIB_UNICASTIPADDRESS_ROW);
-  typedef NETIOAPI_API (*InitializeUnicastIpAddressEntryFn) (PMIB_UNICASTIPADDRESS_ROW);
+  typedef NETIO_STATUS (NETIOAPI_API_ *CreateUnicastIpAddressEntryFn) (const PMIB_UNICASTIPADDRESS_ROW);
+  typedef NETIO_STATUS (NETIOAPI_API_ *InitializeUnicastIpAddressEntryFn) (PMIB_UNICASTIPADDRESS_ROW);
   static CreateUnicastIpAddressEntryFn CreateUnicastIpAddressEntry = NULL;
   static InitializeUnicastIpAddressEntryFn InitializeUnicastIpAddressEntry = NULL;
 
@@ -522,7 +522,7 @@ CmpRoute (LPVOID item, LPVOID route)
 static DWORD
 DeleteRoute (PMIB_IPFORWARD_ROW2 fwd_row)
 {
-  typedef NETIOAPI_API (*DeleteIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
+  typedef NETIO_STATUS (NETIOAPI_API_ *DeleteIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
   static DeleteIpForwardEntry2Fn DeleteIpForwardEntry2 = NULL;
 
   if (!DeleteIpForwardEntry2)
@@ -546,7 +546,7 @@ HandleRouteMessage (route_message_t *msg, undo_lists_t *lists)
   PMIB_IPFORWARD_ROW2 fwd_row;
   BOOL add = msg->header.type == msg_add_route;
 
-  typedef NETIOAPI_API (*CreateIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
+  typedef NETIO_STATUS (NETIOAPI_API_ *CreateIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
   static CreateIpForwardEntry2Fn CreateIpForwardEntry2 = NULL;
 
   if (!CreateIpForwardEntry2)
@@ -616,7 +616,7 @@ out:
 static DWORD
 HandleFlushNeighborsMessage (flush_neighbors_message_t *msg)
 {
-  typedef NETIOAPI_API (*FlushIpNetTable2Fn) (ADDRESS_FAMILY, NET_IFINDEX);
+  typedef NETIO_STATUS (NETIOAPI_API_ *FlushIpNetTable2Fn) (ADDRESS_FAMILY, NET_IFINDEX);
   static FlushIpNetTable2Fn flush_fn = NULL;
 
   if (msg->family == AF_INET)
@@ -1154,6 +1154,7 @@ FreeWaitHandles (LPHANDLE h)
   free (h);
 }
 
+BOOL CmpHandle(LPVOID item, LPVOID hnd) { return item == hnd; }
 
 VOID WINAPI
 ServiceStartInteractive (DWORD dwArgc, LPTSTR *lpszArgv)
@@ -1254,7 +1255,6 @@ ServiceStartInteractive (DWORD dwArgc, LPTSTR *lpszArgv)
             }
 
           /* Worker thread ended */
-          BOOL CmpHandle (LPVOID item, LPVOID hnd) { return item == hnd; }
           HANDLE thread = RemoveListItem (&threads, CmpHandle, handles[error]);
           UpdateWaitHandles (&handles, &handle_count, io_event, exit_event, threads);
           CloseHandleEx (&thread);
src/openvpnserv/openvpnserv.vcxproj +8 -4
index c6760da..545a846 100644
@@ -49,7 +49,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -66,13 +66,14 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Console</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -90,10 +91,13 @@
       <OptimizeReferences>true</OptimizeReferences>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c" />
+    <ClCompile Include="automatic.c" />
+    <ClCompile Include="common.c" />
+    <ClCompile Include="interactive.c" />
     <ClCompile Include="service.c" />
   </ItemGroup>
   <ItemGroup>
@@ -111,4 +115,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
src/openvpnserv/openvpnserv.vcxproj.filters +8 -2
index 0c89b4f..a016c52 100644
@@ -15,10 +15,16 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c">
+    <ClCompile Include="service.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="service.c">
+    <ClCompile Include="automatic.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="common.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="interactive.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
Signature · 1 line
2.6.4
#1 lore raw

Hi,

I think we can just delete all those function typedefs and run-time lookups as this is targeted towards Vista+ only.

Selva

Quoted 227 lines · On Mon, Feb 22, 2016 at 11:37 AM, <[email protected]...> wrote:

From: Fish <[email protected]...>

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Use the correct typedef construct to define function types.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.

---
 src/openvpnserv/common.c                    |  2 +-
 src/openvpnserv/interactive.c               | 16 ++++++++--------
 src/openvpnserv/openvpnserv.vcxproj         | 12 ++++++++----
 src/openvpnserv/openvpnserv.vcxproj.filters | 10 ++++++++--
 4 files changed, 25 insertions(+), 15 deletions(-)
src/openvpnserv/common.c +1 -1
index a293796..9a58e39 100644
@@ -22,7 +22,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <service.h>
+#include "service.h"
 
 /*
  * These are necessary due to certain buggy implementations of

(v)snprintf,

src/openvpnserv/interactive.c +1 -1
index 0f3d1d4..96a15f6 100644
@@ -390,7 +390,7 @@ InterfaceLuid (const char *iface_name, PNET_LUID luid)
   LPWSTR wide_name;
   int n;
 
-  typedef NETIO_STATUS WINAPI (*ConvertInterfaceAliasToLuidFn) (LPCWSTR,
 PNET_LUID);
+  typedef NETIO_STATUS (WINAPI *ConvertInterfaceAliasToLuidFn) (LPCWSTR,
 PNET_LUID);
   static ConvertInterfaceAliasToLuidFn ConvertInterfaceAliasToLuid = NULL;
   if (!ConvertInterfaceAliasToLuid)
     {
src/openvpnserv/interactive.c +1 -1
@@ -421,7 +421,7 @@ CmpAddress (LPVOID item, LPVOID address)
 static DWORD
 DeleteAddress (PMIB_UNICASTIPADDRESS_ROW addr_row)
 {
-  typedef NETIOAPI_API (*DeleteUnicastIpAddressEntryFn) (const
 PMIB_UNICASTIPADDRESS_ROW);
+  typedef NETIO_STATUS (NETIOAPI_API_ *DeleteUnicastIpAddressEntryFn)
 (const PMIB_UNICASTIPADDRESS_ROW);
   static DeleteUnicastIpAddressEntryFn DeleteUnicastIpAddressEntry = NULL;

if (!DeleteUnicastIpAddressEntry)

src/openvpnserv/interactive.c +1 -2
@@ -445,8 +445,8 @@ HandleAddressMessage (address_message_t *msg,
 undo_lists_t *lists)
   PMIB_UNICASTIPADDRESS_ROW addr_row;
   BOOL add = msg->header.type == msg_add_address;
 
-  typedef NETIOAPI_API (*CreateUnicastIpAddressEntryFn) (const
 PMIB_UNICASTIPADDRESS_ROW);
-  typedef NETIOAPI_API (*InitializeUnicastIpAddressEntryFn)
 (PMIB_UNICASTIPADDRESS_ROW);
+  typedef NETIO_STATUS (NETIOAPI_API_ *CreateUnicastIpAddressEntryFn)

(const PMIB_UNICASTIPADDRESS_ROW);
+ typedef NETIO_STATUS (NETIOAPI_API_ *InitializeUnicastIpAddressEntryFn)

(PMIB_UNICASTIPADDRESS_ROW);
   static CreateUnicastIpAddressEntryFn CreateUnicastIpAddressEntry = NULL;
   static InitializeUnicastIpAddressEntryFn

InitializeUnicastIpAddressEntry = NULL;

src/openvpnserv/interactive.c +1 -1
@@ -522,7 +522,7 @@ CmpRoute (LPVOID item, LPVOID route)
 static DWORD
 DeleteRoute (PMIB_IPFORWARD_ROW2 fwd_row)
 {
-  typedef NETIOAPI_API (*DeleteIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
+  typedef NETIO_STATUS (NETIOAPI_API_ *DeleteIpForwardEntry2Fn)
 (PMIB_IPFORWARD_ROW2);
   static DeleteIpForwardEntry2Fn DeleteIpForwardEntry2 = NULL;
 

if (!DeleteIpForwardEntry2)

src/openvpnserv/interactive.c +1 -1
@@ -546,7 +546,7 @@ HandleRouteMessage (route_message_t *msg, undo_lists_t
 *lists)
   PMIB_IPFORWARD_ROW2 fwd_row;
   BOOL add = msg->header.type == msg_add_route;
 
-  typedef NETIOAPI_API (*CreateIpForwardEntry2Fn) (PMIB_IPFORWARD_ROW2);
+  typedef NETIO_STATUS (NETIOAPI_API_ *CreateIpForwardEntry2Fn)
 (PMIB_IPFORWARD_ROW2);
   static CreateIpForwardEntry2Fn CreateIpForwardEntry2 = NULL;

if (!CreateIpForwardEntry2)

src/openvpnserv/interactive.c +1 -1
@@ -616,7 +616,7 @@ out:
 static DWORD
 HandleFlushNeighborsMessage (flush_neighbors_message_t *msg)
 {
-  typedef NETIOAPI_API (*FlushIpNetTable2Fn) (ADDRESS_FAMILY,
 NET_IFINDEX);
+  typedef NETIO_STATUS (NETIOAPI_API_ *FlushIpNetTable2Fn)
 (ADDRESS_FAMILY, NET_IFINDEX);
   static FlushIpNetTable2Fn flush_fn = NULL;
   if (msg->family == AF_INET)
src/openvpnserv/interactive.c +1 -1
@@ -1154,6 +1154,7 @@ FreeWaitHandles (LPHANDLE h)
   free (h);
 }
 
+BOOL CmpHandle(LPVOID item, LPVOID hnd) { return item == hnd; }
 
 VOID WINAPI
 ServiceStartInteractive (DWORD dwArgc, LPTSTR *lpszArgv)
@@ -1254,7 +1255,6 @@ ServiceStartInteractive (DWORD dwArgc, LPTSTR
 *lpszArgv)
             }
 
           /* Worker thread ended */
-          BOOL CmpHandle (LPVOID item, LPVOID hnd) { return item == hnd; }
           HANDLE thread = RemoveListItem (&threads, CmpHandle,
 handles[error]);

UpdateWaitHandles (&handles, &handle_count, io_event,

exit_event, threads);
           CloseHandleEx (&thread);
src/openvpnserv/openvpnserv.vcxproj +0 -0
index c6760da..545a846 100644
@@ -49,7 +49,7 @@
   <ItemDefinitionGroup

Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
- <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>

src/openvpnserv/openvpnserv.vcxproj +1 -0
@@ -66,13 +66,14 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Console</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+

<AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>

     </Link>

</ItemDefinitionGroup>
<ItemDefinitionGroup
Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
- <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>

<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <FunctionLevelLinking>true</FunctionLevelLinking>

src/openvpnserv/openvpnserv.vcxproj +1 -0
@@ -90,10 +91,13 @@
       <OptimizeReferences>true</OptimizeReferences>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
+

<AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>

     </Link>

</ItemDefinitionGroup>
<ItemGroup>

src/openvpnserv/openvpnserv.vcxproj +4 -2
-    <ClCompile Include="openvpnserv.c" />
+    <ClCompile Include="automatic.c" />
+    <ClCompile Include="common.c" />
+    <ClCompile Include="interactive.c" />
     <ClCompile Include="service.c" />
   </ItemGroup>
   <ItemGroup>
@@ -111,4 +115,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
src/openvpnserv/openvpnserv.vcxproj.filters +8 -3
index 0c89b4f..a016c52 100644
@@ -15,10 +15,16 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c">
+    <ClCompile Include="service.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="service.c">
+    <ClCompile Include="automatic.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="common.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="interactive.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
--

2.6.4

------------------------------------------------------------------------------
Site24x7 APM Insight: Get Deep Visibility into Application Performance APM + Mobile APM + RUM: Monitor 3 App instances at just $35/Month Monitor end-to-end web transactions and take corrective actions now Troubleshoot faster and improve end-user experience. Signup Now!
http://pubads.g.doubleclick.net/gampad/clk?id=272487151&iu=/4140
_______________________________________________
Openvpn-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel

author
#2 lore raw

PATCH v2 1/1 Make openvpnserv compilable under Visual Studio.

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Remove all runtime function resolving code since OpenVPN 2.4 is targeting Vista+.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.

---
 src/openvpnserv/common.c                    |  2 +-
 src/openvpnserv/interactive.c               | 97 +----------------------------
 src/openvpnserv/openvpnserv.vcxproj         | 12 ++--
 src/openvpnserv/openvpnserv.vcxproj.filters | 10 ++-
 4 files changed, 19 insertions(+), 102 deletions(-)
src/openvpnserv/common.c +1 -1
index a293796..9a58e39 100644
@@ -22,7 +22,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <service.h>
+#include "service.h"
 
 /*
  * These are necessary due to certain buggy implementations of (v)snprintf,
src/openvpnserv/interactive.c +2 -95

148 lines not on this page · raw message

src/openvpnserv/openvpnserv.vcxproj +8 -4
index c6760da..545a846 100644
@@ -49,7 +49,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -66,13 +66,14 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Console</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -90,10 +91,13 @@
       <OptimizeReferences>true</OptimizeReferences>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c" />
+    <ClCompile Include="automatic.c" />
+    <ClCompile Include="common.c" />
+    <ClCompile Include="interactive.c" />
     <ClCompile Include="service.c" />
   </ItemGroup>
   <ItemGroup>
@@ -111,4 +115,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
src/openvpnserv/openvpnserv.vcxproj.filters +8 -2
index 0c89b4f..a016c52 100644
@@ -15,10 +15,16 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c">
+    <ClCompile Include="service.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="service.c">
+    <ClCompile Include="automatic.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="common.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="interactive.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
Signature · 1 line
2.6.4
author
#3 lore raw

PATCH v3 1/1 Make openvpn and openvpnserv compilable under Visual Studio.

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Remove all runtime function resolving code since OpenVPN 2.4 is targeting Vista+.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.
- Include <netioapi.h> in two source files.

---
 src/openvpn/route.c                         |  1 +
 src/openvpnserv/common.c                    |  2 +-
 src/openvpnserv/interactive.c               | 98 +----------------------------
 src/openvpnserv/openvpnserv.vcxproj         | 12 ++--
 src/openvpnserv/openvpnserv.vcxproj.filters | 10 ++-
 5 files changed, 21 insertions(+), 102 deletions(-)
src/openvpn/route.c +1 -0
index a90195f..9a67276 100644
@@ -50,6 +50,7 @@
 #endif
 
 #ifdef WIN32
+#include <netioapi.h>
 #include "openvpn-msg.h"
 
 #define METRIC_NOT_USED ((DWORD)-1)
src/openvpnserv/common.c +1 -1
index a293796..9a58e39 100644
@@ -22,7 +22,7 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <service.h>
+#include "service.h"
 
 /*
  * These are necessary due to certain buggy implementations of (v)snprintf,
src/openvpnserv/interactive.c +3 -95

155 lines not on this page · raw message

src/openvpnserv/openvpnserv.vcxproj +8 -4
index c6760da..545a846 100644
@@ -49,7 +49,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -66,13 +66,14 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Console</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -90,10 +91,13 @@
       <OptimizeReferences>true</OptimizeReferences>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c" />
+    <ClCompile Include="automatic.c" />
+    <ClCompile Include="common.c" />
+    <ClCompile Include="interactive.c" />
     <ClCompile Include="service.c" />
   </ItemGroup>
   <ItemGroup>
@@ -111,4 +115,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
src/openvpnserv/openvpnserv.vcxproj.filters +8 -2
index 0c89b4f..a016c52 100644
@@ -15,10 +15,16 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c">
+    <ClCompile Include="service.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="service.c">
+    <ClCompile Include="automatic.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="common.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="interactive.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
Signature · 1 line
2.6.4
#4 lore raw

Re: [Openvpn-devel] [PATCH v3] Make openvpn and openvpnserv compilable under Visual Studio.

Hi,

Quoted 10 lines · Fish

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Remove all runtime function resolving code since OpenVPN 2.4 is targeting Vista+.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.
- Include <netioapi.h> in two source files.

I'm all willing to merge this (it makes sense) but want to ask you for a v4 nevertheless - I've just merged & pushed Selva's "validate options" patch, which adds new source files (validate.c, validate.h) so more changes are needed. So it would be nice to have this all in one slightly larger change set...

(The patch itself looks good, it just conflicted with the other change)

thanks,

gert

Signature · 4 lines
USENET is *not* the non-clickable part of WWW!
                                                           //www.muc.de/~gert/
Gert Doering - Munich, Germany                             [email protected]...
fax: +49-89-35655025                        [email protected]...
author
#5 lore raw

PATCH v4 1/1 Make openvpnserv compilable under Visual Studio.

Compiled under VS 2010/2013 and Windows 10.

The following major changes are made:
- Remove all runtime function resolving code since OpenVPN 2.4 is targeting Vista+.
- Make sure local header inclusion uses double-quotes instead of angle brackets.
- Update openvpnserv.vcxproj to include new source files and headers, as well as additional lib files.
- Include <netioapi.h> in two source files.

---
 src/openvpn/route.c                         |   1 +
 src/openvpnserv/common.c                    |   5 +-
 src/openvpnserv/interactive.c               | 107 +++-------------------------
 src/openvpnserv/openvpnserv.vcxproj         |  14 ++--
 src/openvpnserv/openvpnserv.vcxproj.filters |  16 ++++-
 src/openvpnserv/validate.c                  |   2 +
 src/openvpnserv/win32.h                     |  32 +++++++++
 7 files changed, 70 insertions(+), 107 deletions(-)
 create mode 100644 src/openvpnserv/win32.h
src/openvpn/route.c +1 -0
index a90195f..9a67276 100644
@@ -50,6 +50,7 @@
 #endif
 
 #ifdef WIN32
+#include <netioapi.h>
 #include "openvpn-msg.h"
 
 #define METRIC_NOT_USED ((DWORD)-1)
src/openvpnserv/common.c +3 -2
index dba4724..15e3a68 100644
@@ -22,8 +22,9 @@
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  */
 
-#include <service.h>
-#include <validate.h>
+#include "service.h"
+#include "validate.h"
+
 /*
  * These are necessary due to certain buggy implementations of (v)snprintf,
  * that don't guarantee null termination for size > 0.
src/openvpnserv/interactive.c +8 -99

175 lines not on this page · raw message

src/openvpnserv/openvpnserv.vcxproj +10 -4
index c6760da..4154fe9 100644
@@ -49,7 +49,7 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <ClCompile>
       <Optimization>Disabled</Optimization>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <MinimalRebuild>true</MinimalRebuild>
       <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
@@ -66,13 +66,14 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <SubSystem>Console</SubSystem>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;Netapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <ClCompile>
       <Optimization>MaxSpeed</Optimization>
       <IntrinsicFunctions>true</IntrinsicFunctions>
-      <AdditionalIncludeDirectories>$(SOURCEBASE);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
+      <AdditionalIncludeDirectories>$(SOURCEBASE);$(SOURCEBASE)/include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
       <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;$(CPPFLAGS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
       <FunctionLevelLinking>true</FunctionLevelLinking>
@@ -90,14 +91,19 @@
       <OptimizeReferences>true</OptimizeReferences>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <TargetMachine>MachineX86</TargetMachine>
+      <AdditionalDependencies>Userenv.lib;Iphlpapi.lib;Netapi32.lib;Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>
     </Link>
   </ItemDefinitionGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c" />
+    <ClCompile Include="automatic.c" />
+    <ClCompile Include="common.c" />
+    <ClCompile Include="interactive.c" />
     <ClCompile Include="service.c" />
+    <ClCompile Include="validate.c" />
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="service.h" />
+    <ClInclude Include="validate.h" />
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="openvpnserv_resources.rc" />
@@ -111,4 +117,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
src/openvpnserv/openvpnserv.vcxproj.filters +14 -2
index 0c89b4f..7ccc652 100644
@@ -15,10 +15,19 @@
     </Filter>
   </ItemGroup>
   <ItemGroup>
-    <ClCompile Include="openvpnserv.c">
+    <ClCompile Include="service.c">
       <Filter>Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="service.c">
+    <ClCompile Include="automatic.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="common.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="interactive.c">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="validate.c">
       <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
@@ -26,6 +35,9 @@
     <ClInclude Include="service.h">
       <Filter>Header Files</Filter>
     </ClInclude>
+    <ClInclude Include="validate.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ResourceCompile Include="openvpnserv_resources.rc">
src/openvpnserv/validate.c +2 -0
index b5809b3..019763e 100644
@@ -28,6 +28,8 @@
 #include <shlwapi.h>
 #include <lm.h>
 
+#include "win32.h"
+
 static const WCHAR *white_list[] =
     {
        L"auth-retry",
src/openvpnserv/win32.h new file +32 -0
new file mode 100644
index 0000000..4d1d4f8
@@ -0,0 +1,32 @@
+/*
+*  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) 2013 Heiko Hund <[email protected]...>
+*
+*  This program is free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License version 2
+*  as published by the Free Software Foundation.
+*
+*  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
+*/
+
+#ifndef _WIN32_H
+#define _WIN32_H
+
+#if defined(_MSC_VER)
+#define snwprintf _snwprintf
+#endif
+
+#endif
Signature · 1 line
2.6.4
#6 lore raw

Hi,

src/openvpnserv/win32.h line 32

Quoted 9 lines · Fish
src/openvpnserv/win32.h new file +8 -0
+#ifndef _WIN32_H
+#define _WIN32_H
+
+#if defined(_MSC_VER)
+#define snwprintf _snwprintf
+#endif
+
+#endif

We could've just used _snwprintf directly in the sources and avoided a new header file. mingw has both. Well, may be someone would care to write an openvpn_snwprintf wrapper like the openvpn_sntprintf..

const WCHAR *msg1 = L"You have specified a config file location (%s

Quoted 7 lines

relative to %s)"
- " that requires admin approval. This error may be
avoided"

(quoted diff) +1 -1
-                        " by adding your account to the \"%s\" group";
+                        L" that requires admin approval. This error may

be avoided"
+ L" by adding your account to the \"%s\" group";

Good to know MS has its own standards :-)

By the way, I'm going to submit the rebased patch for block-outside-dns through iservice later tonight. But no idea what is required to make it compile with Visual Studio.

Selva